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>,
	Mauro Carvalho Chehab <mchehab@kernel.org>
Subject: [PATCH 4/9] media: dvb-usb-v2: af9035: fix missing unlock
Date: Fri,  6 Oct 2023 12:08:45 +0200	[thread overview]
Message-ID: <cae6602b2c8789239a3d302b3ffc21f5e09d1189.1696586632.git.hverkuil-cisco@xs4all.nl> (raw)
In-Reply-To: <cover.1696586632.git.hverkuil-cisco@xs4all.nl>

Instead of returning an error, goto the mutex unlock at
the end of the function.

Fixes smatch warning:

drivers/media/usb/dvb-usb-v2/af9035.c:467 af9035_i2c_master_xfer() warn: inconsistent returns '&d->i2c_mutex'.
  Locked on  : 326,387
  Unlocked on: 465,467

Signed-off-by: Hans Verkuil <hverkuil-cisco@xs4all.nl>
CC: Mauro Carvalho Chehab <mchehab@kernel.org>
---
 drivers/media/usb/dvb-usb-v2/af9035.c | 13 +++++++++----
 1 file changed, 9 insertions(+), 4 deletions(-)

diff --git a/drivers/media/usb/dvb-usb-v2/af9035.c b/drivers/media/usb/dvb-usb-v2/af9035.c
index 33a2aa8907e6..4eb7dd4599b7 100644
--- a/drivers/media/usb/dvb-usb-v2/af9035.c
+++ b/drivers/media/usb/dvb-usb-v2/af9035.c
@@ -322,8 +322,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 			ret = -EOPNOTSUPP;
 		} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
 			   (msg[0].addr == state->af9033_i2c_addr[1])) {
-			if (msg[0].len < 3 || msg[1].len < 1)
-				return -EOPNOTSUPP;
+			if (msg[0].len < 3 || msg[1].len < 1) {
+				ret = -EOPNOTSUPP;
+				goto unlock;
+			}
 			/* demod access via firmware interface */
 			u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
 					msg[0].buf[2];
@@ -383,8 +385,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 			ret = -EOPNOTSUPP;
 		} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
 			   (msg[0].addr == state->af9033_i2c_addr[1])) {
-			if (msg[0].len < 3)
-				return -EOPNOTSUPP;
+			if (msg[0].len < 3) {
+				ret = -EOPNOTSUPP;
+				goto unlock;
+			}
 			/* demod access via firmware interface */
 			u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
 					msg[0].buf[2];
@@ -459,6 +463,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
 		ret = -EOPNOTSUPP;
 	}
 
+unlock:
 	mutex_unlock(&d->i2c_mutex);
 
 	if (ret < 0)
-- 
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 ` Hans Verkuil [this message]
2023-10-13  8:32   ` [PATCH 4/9] media: dvb-usb-v2: af9035: fix missing unlock 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 ` [PATCH 7/9] media: i2c: tc358746: check fmt validity Hans Verkuil
2023-10-10  6:39   ` 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=cae6602b2c8789239a3d302b3ffc21f5e09d1189.1696586632.git.hverkuil-cisco@xs4all.nl \
    --to=hverkuil-cisco@xs4all.nl \
    --cc=linux-media@vger.kernel.org \
    --cc=mchehab@kernel.org \
    /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.