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

Keng-Yu Lin kengyu at canonical.com
Thu Nov 22 06:09:08 UTC 2012


On Fri, Nov 16, 2012 at 4:32 PM, Colin King <colin.king at canonical.com> wrote:
> From: Colin Ian King <colin.king at 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 at 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 at canonical.com>



More information about the fwts-devel mailing list