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

[ Upstream commit be3ae7cf43 ]

When the pointer variable is judged to be null, null is returned
directly.

[hverkuil: fix two checkpatch warnings]

Signed-off-by: Dong Chuanjian <chuanjian@nfschina.com>
Acked-by: Nicolas Dufresne <nicolas.dufresne@collabora.com>
Fixes: d3f756ad62 ("media: v4l2: Trace calculated p/b0/b1 initial reflist")
Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
Signed-off-by: Mauro Carvalho Chehab <mchehab@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
This commit is contained in:
Dong Chuanjian 2022-12-27 03:36:25 +01:00 committed by Greg Kroah-Hartman
parent 80f98dc3eb
commit ece8818968
1 changed files with 4 additions and 0 deletions

View File

@ -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, "|");
@ -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))
return NULL;
n += snprintf(*out_str + n, tmp_str_size - n, "|");