All of lore.kernel.org
 help / color / mirror / Atom feed
From: Dong Chuanjian <chuanjian@nfschina.com>
To: mchehab@kernel.org, hverkuil-cisco@xs4all.nl,
	nicolas.dufresne@collabora.com, sebastian.fricke@collabora.com,
	ezequiel@vanguardiasur.com.ar
Cc: linux-media@vger.kernel.org, linux-kernel@vger.kernel.org,
	Dong Chuanjian <chuanjian@nfschina.com>
Subject: [PATCH] drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers
Date: Tue, 27 Dec 2022 10:36:25 +0800	[thread overview]
Message-ID: <20221227023625.7261-1-chuanjian@nfschina.com> (raw)

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

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, "|");
 
-- 
2.18.2


             reply	other threads:[~2022-12-27  2:36 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-12-27  2:36 Dong Chuanjian [this message]
2023-01-09 21:27 ` [PATCH] drivers/media/v4l2-core/v4l2-h264 : add detection of null pointers Nicolas Dufresne

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20221227023625.7261-1-chuanjian@nfschina.com \
    --to=chuanjian@nfschina.com \
    --cc=ezequiel@vanguardiasur.com.ar \
    --cc=hverkuil-cisco@xs4all.nl \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    --cc=nicolas.dufresne@collabora.com \
    --cc=sebastian.fricke@collabora.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.