Skip to content

Commit

Permalink
[media] lmedm04: Do not unlock mutex if mutex_lock_interruptible failed
Browse files Browse the repository at this point in the history
There are a couple of places where mutex_unlock() is called even
if mutex_lock_interruptible() failed. The patch fixes the issue.

Found by Linux Driver Verification project (linuxtesting.org).

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
  • Loading branch information
Alexey Khoroshilov authored and Mauro Carvalho Chehab committed May 20, 2011
1 parent eeaaf81 commit 6f030ab
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions drivers/media/dvb/dvb-usb/lmedm04.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,9 +666,10 @@ static int lme2510_streaming_ctrl(struct dvb_usb_adapter *adap, int onoff)
else {
deb_info(1, "STM Steam Off");
/* mutex is here only to avoid collision with I2C */
ret = mutex_lock_interruptible(&adap->dev->i2c_mutex);
if (mutex_lock_interruptible(&adap->dev->i2c_mutex) < 0)
return -EAGAIN;

ret |= lme2510_usb_talk(adap->dev, clear_reg_3,
ret = lme2510_usb_talk(adap->dev, clear_reg_3,
sizeof(clear_reg_3), rbuf, rlen);
st->stream_on = 0;
st->i2c_talk_onoff = 1;
Expand Down Expand Up @@ -1099,12 +1100,13 @@ static int lme2510_powerup(struct dvb_usb_device *d, int onoff)
static u8 rbuf[1];
int ret, len = 3, rlen = 1;

ret = mutex_lock_interruptible(&d->i2c_mutex);
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
return -EAGAIN;

if (onoff)
ret |= lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
ret = lme2510_usb_talk(d, lnb_on, len, rbuf, rlen);
else
ret |= lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);
ret = lme2510_usb_talk(d, lnb_off, len, rbuf, rlen);

st->i2c_talk_onoff = 1;

Expand Down

0 comments on commit 6f030ab

Please sign in to comment.