public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation
@ 2022-12-19  3:37 Li zeming
  2022-12-19  7:41 ` Bagas Sanjaya
  0 siblings, 1 reply; 2+ messages in thread
From: Li zeming @ 2022-12-19  3:37 UTC (permalink / raw)
  To: mchehab, hverkuil-cisco, nicolas.dufresne
  Cc: linux-media, linux-kernel, Li zeming

The pointer *out_str adds judgment and should help with program robustness.

Signed-off-by: Li zeming <zeming@nfschina.com>
---
 drivers/media/v4l2-core/v4l2-h264.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
index 72bd64f65198..934aba539332 100644
--- a/drivers/media/v4l2-core/v4l2-h264.c
+++ b/drivers/media/v4l2-core/v4l2-h264.c
@@ -305,6 +305,8 @@ static const char *format_ref_list_p(const struct v4l2_h264_reflist_builder *bui
 	int n = 0, i;
 
 	*out_str = kmalloc(tmp_str_size, GFP_KERNEL);
+	if (!*out_str)
+		return NULL;
 
 	n += snprintf(*out_str + n, tmp_str_size - n, "|");
 
-- 
2.18.2


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation
  2022-12-19  3:37 [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation Li zeming
@ 2022-12-19  7:41 ` Bagas Sanjaya
  0 siblings, 0 replies; 2+ messages in thread
From: Bagas Sanjaya @ 2022-12-19  7:41 UTC (permalink / raw)
  To: Li zeming, mchehab, hverkuil-cisco, nicolas.dufresne
  Cc: linux-media, linux-kernel

[-- Attachment #1: Type: text/plain, Size: 775 bytes --]

On Mon, Dec 19, 2022 at 11:37:12AM +0800, Li zeming wrote:
> The pointer *out_str adds judgment and should help with program robustness.
> 

Terminology: if[-else] blocks are conditionals, not judgements.

> diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
> index 72bd64f65198..934aba539332 100644
> --- a/drivers/media/v4l2-core/v4l2-h264.c
> +++ b/drivers/media/v4l2-core/v4l2-h264.c
> @@ -305,6 +305,8 @@ static const char *format_ref_list_p(const struct v4l2_h264_reflist_builder *bui
>  	int n = 0, i;
>  
>  	*out_str = kmalloc(tmp_str_size, GFP_KERNEL);
> +	if (!*out_str)
> +		return NULL;

Why did you add the check beside robustness?

Thanks. 

-- 
An old man doll... just what I always wanted! - Clara

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-12-19  7:41 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-12-19  3:37 [PATCH] v4l2-core: v4l2-h264: check after increasing memory allocation Li zeming
2022-12-19  7:41 ` Bagas Sanjaya

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox