mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Nicolas Dufresne <nicolas.dufresne@collabora.com>
To: Dong Chuanjian <chuanjian@nfschina.com>,
	mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
	sebastian.fricke@collabora.com, ezequiel@vanguardiasur.com.ar
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] drivers/media/v4l2-core/v4l2-h264.c : add detection of null pointers
Date: Mon, 09 Jan 2023 16:22:33 -0500	[thread overview]
Message-ID: <31940cd3086bc6e40f3eb9c7b923dd38131d37dd.camel@collabora.com> (raw)
In-Reply-To: <20221226061711.3988-1-chuanjian@nfschina.com>

Hi,

Le lundi 26 décembre 2022 à 14:17 +0800, Dong Chuanjian a écrit :
> Continue the program when the pointer assignment is successful.
> 
> Signed-off-by: Dong Chuanjian <chuanjian@nfschina.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);

Can't this patch be reduced to this ?

+	if (!*out_str)
+		return NULL;

> 
> 
> -
> -	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) {
> +		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;


      parent reply	other threads:[~2023-01-09 21:25 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-26  6:17 Dong Chuanjian
2022-12-26  6:39 ` Chen-Yu Tsai
2023-01-09 21:22 ` Nicolas Dufresne [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=31940cd3086bc6e40f3eb9c7b923dd38131d37dd.camel@collabora.com \
    --to=nicolas.dufresne@collabora.com \
    --cc=chuanjian@nfschina.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=sebastian.fricke@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®