lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <CAGXv+5HT4CD5eRYCuAdwrdAPRbNcd9SPEdDCnPfLpAAQbooBYQ@mail.gmail.com>
Date:   Mon, 26 Dec 2022 14:39:45 +0800
From:   Chen-Yu Tsai <wenst@...omium.org>
To:     Dong Chuanjian <chuanjian@...china.com>
Cc:     mchehab@...nel.org, hverkuil-cisco@...all.nl,
        nicolas.dufresne@...labora.com, sebastian.fricke@...labora.com,
        ezequiel@...guardiasur.com.ar, linux-media@...r.kernel.org,
        linux-kernel@...r.kernel.org
Subject: Re: [PATCH] drivers/media/v4l2-core/v4l2-h264.c : add detection of
 null pointers

On Mon, Dec 26, 2022 at 2:17 PM Dong Chuanjian <chuanjian@...china.com> wrote:
>
> Continue the program when the pointer assignment is successful.
>
> Signed-off-by: Dong Chuanjian <chuanjian@...china.com>
>
> diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
> index 72bd64f65198..1163cd48ff33 100644
> --- a/drivers/media/v4l2-core/v4l2-h264.c
> +++ b/drivers/media/v4l2-core/v4l2-h264.c
> @@ -343,18 +343,19 @@ static const char *format_ref_list_b(const struct v4l2_h264_reflist_builder *bui
>         int n = 0, i;
>
>         *out_str = kmalloc(tmp_str_size, GFP_KERNEL);
> -
> -       n += snprintf(*out_str + n, tmp_str_size - n, "|");
> -
> -       for (i = 0; i < builder->num_valid; i++) {
> -               int frame_num = builder->refs[reflist[i].index].frame_num;
> -               u32 poc = v4l2_h264_get_poc(builder, reflist + i);
> -               bool longterm = builder->refs[reflist[i].index].longterm;
> -
> -               n += scnprintf(*out_str + n, tmp_str_size - n, "%i%c%c|",
> -                              longterm ? frame_num : poc,
> -                              longterm ? 'l' : 's',
> -                              ref_type_to_char(reflist[i].fields));
> +       if (*out_str != NULL) {

I would suggest returning early if it's NULL. The change would be cleaner
as you wouldn't need to reindent the whole code block.

ChenYu

> +               n += snprintf(*out_str + n, tmp_str_size - n, "|");
> +
> +               for (i = 0; i < builder->num_valid; i++) {
> +                       int frame_num = builder->refs[reflist[i].index].frame_num;
> +                       u32 poc = v4l2_h264_get_poc(builder, reflist + i);
> +                       bool longterm = builder->refs[reflist[i].index].longterm;
> +
> +                       n += scnprintf(*out_str + n, tmp_str_size - n, "%i%c%c|",
> +                                      longterm ? frame_num : poc,
> +                                      longterm ? 'l' : 's',
> +                                      ref_type_to_char(reflist[i].fields));
> +               }
>         }
>
>         return *out_str;
> --
> 2.18.2
>

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ