All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Verkuil <hverkuil-cisco@xs4all.nl>
To: linux-media@vger.kernel.org
Cc: Hans Verkuil <hverkuil-cisco@xs4all.nl>,
	Sakari Ailus <sakari.ailus@linux.intel.com>
Subject: [PATCH 7/9] media: i2c: tc358746: check fmt validity
Date: Fri,  6 Oct 2023 12:08:48 +0200	[thread overview]
Message-ID: <b4a9369bf923c0a3b90cf0e8ccee8ee2178403fc.1696586632.git.hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <cover.1696586632.git.hverkuil-cisco@xs4all.nl>

Check if the format was really found.

Fixes smatch warning:

drivers/media/i2c/tc358746.c:790 tc358746_set_fmt() error: 'fmt' dereferencing possible ERR_PTR()

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
CC: Sakari Ailus <sakari.ailus@linux.intel.com>
---
 drivers/media/i2c/tc358746.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/media/i2c/tc358746.c b/drivers/media/i2c/tc358746.c
index 566f5eaddd57..ce612a47ba84 100644
--- a/drivers/media/i2c/tc358746.c
+++ b/drivers/media/i2c/tc358746.c
@@ -784,8 +784,12 @@ static int tc358746_set_fmt(struct v4l2_subdev *sd,
 	sink_fmt = v4l2_subdev_get_pad_format(sd, sd_state, TC358746_SINK);
 
 	fmt = tc358746_get_format_by_code(format->pad, format->format.code);
-	if (IS_ERR(fmt))
+	if (IS_ERR(fmt)) {
 		fmt = tc358746_get_format_by_code(format->pad, tc358746_def_fmt.code);
+		// Can't happen, but just in case...
+		if (WARN_ON(IS_ERR(fmt)))
+			return -EINVAL;
+	}
 
 	format->format.code = fmt->code;
 	format->format.field = V4L2_FIELD_NONE;
-- 
2.40.1


  parent reply	other threads:[~2023-10-06 10:09 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-10-06 10:08 [PATCH 0/9] media: fix smatch warnings Hans Verkuil
2023-10-06 10:08 ` [PATCH 1/9] staging: media: atomisp: drop check for reentrant .s_stream() Hans Verkuil
2023-10-09 14:48   ` Hans de Goede
2023-10-06 10:08 ` [PATCH 2/9] media: i2c: adp1653: don't reuse the same node pointer Hans Verkuil
2023-10-10  6:40   ` Sakari Ailus
2023-10-06 10:08 ` [PATCH 3/9] staging: media: atomisp: improve unwinding Hans Verkuil
2023-10-09 14:52   ` Hans de Goede
2023-10-06 10:08 ` [PATCH 4/9] media: dvb-usb-v2: af9035: fix missing unlock Hans Verkuil
2023-10-13  8:32   ` Hans Verkuil
2023-10-06 10:08 ` [PATCH 5/9] media: nxp: imx-jpeg: use goto instead of return Hans Verkuil
2023-10-06 10:08 ` [PATCH 6/9] media: qcom: venus: fix incorrect return value Hans Verkuil
2023-10-06 10:13   ` Bryan O'Donoghue
2023-10-06 10:08 ` Hans Verkuil [this message]
2023-10-10  6:39   ` [PATCH 7/9] media: i2c: tc358746: check fmt validity Sakari Ailus
2023-10-06 10:08 ` [PATCH 8/9] media: i2c: mt9m114: goto proper error path Hans Verkuil
2023-10-06 15:18   ` Laurent Pinchart
2023-10-10  7:24     ` Hans Verkuil
2023-10-10  7:58       ` Laurent Pinchart
2023-10-10  7:59       ` Sakari Ailus
2023-10-10  8:06         ` Hans Verkuil
2023-10-10 15:03           ` Sakari Ailus
2023-10-06 10:08 ` [PATCH 9/9] media: pci: mgb4: fix potential spectre vulnerability Hans Verkuil
2023-10-10 10:31   ` Martin Tůma
2023-10-11  0:35     ` Pawan Gupta
2023-10-11 16:36       ` Hans Verkuil
2023-10-12  9:09       ` Martin Tůma
2023-10-12  9:08   ` Martin Tůma

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=b4a9369bf923c0a3b90cf0e8ccee8ee2178403fc.1696586632.git.hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=sakari.ailus@linux.intel.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.