Skip to content

Commit f31b2cb

Browse files
author
Hans Verkuil
committed
media: dvb-usb-v2: af9035: fix missing unlock
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 <[email protected]> Fixes: 7bf744f ("media: dvb-usb-v2: af9035: Fix null-ptr-deref in af9035_i2c_master_xfer") Signed-off-by: Hans Verkuil <[email protected]>
1 parent 51b74c0 commit f31b2cb

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

drivers/media/usb/dvb-usb-v2/af9035.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -322,8 +322,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
322322
ret = -EOPNOTSUPP;
323323
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
324324
(msg[0].addr == state->af9033_i2c_addr[1])) {
325-
if (msg[0].len < 3 || msg[1].len < 1)
326-
return -EOPNOTSUPP;
325+
if (msg[0].len < 3 || msg[1].len < 1) {
326+
ret = -EOPNOTSUPP;
327+
goto unlock;
328+
}
327329
/* demod access via firmware interface */
328330
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
329331
msg[0].buf[2];
@@ -383,8 +385,10 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
383385
ret = -EOPNOTSUPP;
384386
} else if ((msg[0].addr == state->af9033_i2c_addr[0]) ||
385387
(msg[0].addr == state->af9033_i2c_addr[1])) {
386-
if (msg[0].len < 3)
387-
return -EOPNOTSUPP;
388+
if (msg[0].len < 3) {
389+
ret = -EOPNOTSUPP;
390+
goto unlock;
391+
}
388392
/* demod access via firmware interface */
389393
u32 reg = msg[0].buf[0] << 16 | msg[0].buf[1] << 8 |
390394
msg[0].buf[2];
@@ -459,6 +463,7 @@ static int af9035_i2c_master_xfer(struct i2c_adapter *adap,
459463
ret = -EOPNOTSUPP;
460464
}
461465

466+
unlock:
462467
mutex_unlock(&d->i2c_mutex);
463468

464469
if (ret < 0)

0 commit comments

Comments
 (0)