diff mbox series

drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers

Message ID 20221227023625.7261-1-chuanjian@nfschina.com
State Accepted
Commit be3ae7cf4326e95bb1d5413b63baabc26f4a1324
Headers show
Series drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers | expand

Commit Message

Dong Chuanjian Dec. 27, 2022, 2:36 a.m. UTC
When the pointer variable is judged to be null, null is returned
directly.

Signed-off-by: Dong Chuanjian <chuanjian@nfschina.com>
---
v2: Directly return when pointer allocation fails.
v3: problems in synchronous repair format_ref_list_p

Comments

Nicolas Dufresne Jan. 9, 2023, 9:27 p.m. UTC | #1
Le mardi 27 décembre 2022 à 10:36 +0800, Dong Chuanjian a écrit :
> When the pointer variable is judged to be null, null is returned
> directly.
> 
> Signed-off-by: Dong Chuanjian <chuanjian@nfschina.com>

Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>

Please add the missing Fixes tag.

Fixes: d3f756ad629b39 ("media: v4l2: Trace calculated p/b0/b1 initial reflist")

If someone have time, the pr_debug should be ported to v4l2_debug according to
some other reviews.

> ---
> v2: Directly return when pointer allocation fails.
> v3: problems in synchronous repair format_ref_list_p
> 
> diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
> index 72bd64f65198..f6684c1d7319 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 == NULL)
> +		return NULL;
>  
>  	n += snprintf(*out_str + n, tmp_str_size - n, "|");
>  
> @@ -343,6 +345,8 @@ 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);
> +	if (*out_str == NULL)
> +		return NULL;
>  
>  	n += snprintf(*out_str + n, tmp_str_size - n, "|");
>
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
index 72bd64f65198..f6684c1d7319 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 == NULL)
+		return NULL;
 
 	n += snprintf(*out_str + n, tmp_str_size - n, "|");
 
@@ -343,6 +345,8 @@  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);
+	if (*out_str == NULL)
+		return NULL;
 
 	n += snprintf(*out_str + n, tmp_str_size - n, "|");