Patchwork [2/3] lib: fwts_oops: fix fwts_oops_check dereference checks on oopses and warn_ons

login
register
mail settings
Submitter Colin King
Date Nov. 16, 2012, 8:32 a.m.
Message ID <1353054776-4856-3-git-send-email-colin.king@canonical.com>
Download mbox | patch
Permalink /patch/199517/
State Accepted
Headers show

Comments

Colin King - Nov. 16, 2012, 8:32 a.m.
From: Colin Ian King <colin.king@canonical.com>

fwts_oops_check() dereferences oopses and warn_ons before we check
if they are NULL.  Fix this by checking if they are NULL before
assiging zero to them.

Signed-off-by: Colin Ian King <colin.king@canonical.com>
---
 src/lib/src/fwts_oops.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
Alex Hung - Nov. 22, 2012, 3:01 a.m.
On 11/16/2012 04:32 PM, Colin King wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> fwts_oops_check() dereferences oopses and warn_ons before we check
> if they are NULL.  Fix this by checking if they are NULL before
> assiging zero to them.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>   src/lib/src/fwts_oops.c |    5 +++--
>   1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
> index 4eaad1f..18a14ee 100644
> --- a/src/lib/src/fwts_oops.c
> +++ b/src/lib/src/fwts_oops.c
> @@ -117,14 +117,15 @@ static void fwts_klog_stack_dump(
>   int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
>   {
>   	fwts_list_link *item;
> -	*oopses = 0;
> -	*warn_ons = 0;
>
>   	/* Sanity check */
>   	if ((fw == NULL) || (oopses == NULL) ||
>   	    (warn_ons == NULL) || (klog == NULL))
>   		return FWTS_ERROR;
>
> +	*oopses = 0;
> +	*warn_ons = 0;
> +
>   	fwts_list_foreach(item, klog) {
>   		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
>   		if ((strncmp("BUG:", line, 4) == 0) ||
>
Acked-by: Alex Hung <alex.hung@canonical.com>
Keng-Yu Lin - Nov. 22, 2012, 6:09 a.m.
On Fri, Nov 16, 2012 at 4:32 PM, Colin King <colin.king@canonical.com> wrote:
> From: Colin Ian King <colin.king@canonical.com>
>
> fwts_oops_check() dereferences oopses and warn_ons before we check
> if they are NULL.  Fix this by checking if they are NULL before
> assiging zero to them.
>
> Signed-off-by: Colin Ian King <colin.king@canonical.com>
> ---
>  src/lib/src/fwts_oops.c |    5 +++--
>  1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
> index 4eaad1f..18a14ee 100644
> --- a/src/lib/src/fwts_oops.c
> +++ b/src/lib/src/fwts_oops.c
> @@ -117,14 +117,15 @@ static void fwts_klog_stack_dump(
>  int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
>  {
>         fwts_list_link *item;
> -       *oopses = 0;
> -       *warn_ons = 0;
>
>         /* Sanity check */
>         if ((fw == NULL) || (oopses == NULL) ||
>             (warn_ons == NULL) || (klog == NULL))
>                 return FWTS_ERROR;
>
> +       *oopses = 0;
> +       *warn_ons = 0;
> +
>         fwts_list_foreach(item, klog) {
>                 char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
>                 if ((strncmp("BUG:", line, 4) == 0) ||
> --
> 1.7.10.4
>
Acked-by: Keng-Yu Lin <kengyu@canonical.com>

Patch

diff --git a/src/lib/src/fwts_oops.c b/src/lib/src/fwts_oops.c
index 4eaad1f..18a14ee 100644
--- a/src/lib/src/fwts_oops.c
+++ b/src/lib/src/fwts_oops.c
@@ -117,14 +117,15 @@  static void fwts_klog_stack_dump(
 int fwts_oops_check(fwts_framework *fw, fwts_list *klog, int *oopses, int *warn_ons)
 {
 	fwts_list_link *item;
-	*oopses = 0;
-	*warn_ons = 0;
 
 	/* Sanity check */
 	if ((fw == NULL) || (oopses == NULL) ||
 	    (warn_ons == NULL) || (klog == NULL))
 		return FWTS_ERROR;
 
+	*oopses = 0;
+	*warn_ons = 0;
+
 	fwts_list_foreach(item, klog) {
 		char *line = fwts_klog_remove_timestamp(fwts_list_data(char *, item));
 		if ((strncmp("BUG:", line, 4) == 0) ||