diff mbox series

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

Message ID 20221226070236.4450-1-chuanjian@nfschina.com
State New
Headers show
Series [v2] drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers | expand

Commit Message

Dong Chuanjian Dec. 26, 2022, 7:02 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.
diff mbox series

Patch

diff --git a/drivers/media/v4l2-core/v4l2-h264.c b/drivers/media/v4l2-core/v4l2-h264.c
index 72bd64f65198..0e7b35ae3e94 100644
--- a/drivers/media/v4l2-core/v4l2-h264.c
+++ b/drivers/media/v4l2-core/v4l2-h264.c
@@ -343,6 +343,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, "|");
 
@@ -356,7 +358,6 @@  static const char *format_ref_list_b(const struct v4l2_h264_reflist_builder *bui
 			       longterm ? 'l' : 's',
 			       ref_type_to_char(reflist[i].fields));
 	}
-
 	return *out_str;
 }