Skip to contentSkip to conversation

v4l2-core: v4l2-h264: check after increasing memory allocation

PATCH In review Li zeming 2 participants 2 messages Dec 19, 2022 Media (V4L/DVB)

lore
Share & tools
lore

Li zeming

author
#0 lore raw

PATCH 1/1 v4l2-core: v4l2-h264: check after increasing memory allocation

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

---
 drivers/media/v4l2-core/v4l2-h264.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/media/v4l2-core/v4l2-h264.c +2 -0
index 72bd64f65198..934aba539332 100644
@@ -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, "|");
 
Signature · 1 line
2.18.2
#1 lore raw
Quoted 2 lines · Li zeming

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

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

drivers/media/v4l2-core/v4l2-h264.c static const char *format_ref_list_p(const struct v4l2_h264_reflist_builder *bui · line 309

Quoted 10 lines
drivers/media/v4l2-core/v4l2-h264.c +2 -0
index 72bd64f65198..934aba539332 100644
@@ -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.

Signature · 1 line
An old man doll... just what I always wanted! - Clara