public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] [media] dib0700: unlock mutexes on error paths
@ 2012-03-07 19:21 Alexey Khoroshilov
  2012-03-19 17:47 ` Mauro Carvalho Chehab
  0 siblings, 1 reply; 3+ messages in thread
From: Alexey Khoroshilov @ 2012-03-07 19:21 UTC (permalink / raw)
  To: Mauro Carvalho Chehab, Olivier Grenie
  Cc: Alexey Khoroshilov, Patrick Boettcher, linux-media, linux-kernel,
	ldv-project

dib0700_i2c_xfer [_new and _legacy] leave i2c_mutex locked on error paths.
The patch adds appropriate unlocks.

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

Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru>
---
 drivers/media/dvb/dvb-usb/dib0700_core.c |    9 ++++++---
 1 files changed, 6 insertions(+), 3 deletions(-)

diff --git a/drivers/media/dvb/dvb-usb/dib0700_core.c b/drivers/media/dvb/dvb-usb/dib0700_core.c
index 070e82a..8ec22c4 100644
--- a/drivers/media/dvb/dvb-usb/dib0700_core.c
+++ b/drivers/media/dvb/dvb-usb/dib0700_core.c
@@ -228,7 +228,7 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, struct i2c_msg *msg,
 			/* Write request */
 			if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
 				err("could not acquire lock");
-				return 0;
+				break;
 			}
 			st->buf[0] = REQUEST_NEW_I2C_WRITE;
 			st->buf[1] = msg[i].addr << 1;
@@ -270,11 +270,14 @@ static int dib0700_i2c_xfer_legacy(struct i2c_adapter *adap,
 	struct dib0700_state *st = d->priv;
 	int i,len;
 
-	if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
+	if (mutex_lock_interruptible(&d->i2c_mutex) < 0) {
+		err("could not acquire lock");
 		return -EAGAIN;
+	}
 	if (mutex_lock_interruptible(&d->usb_mutex) < 0) {
+		mutex_unlock(&d->i2c_mutex);
 		err("could not acquire lock");
-		return 0;
+		return -EAGAIN;
 	}
 
 	for (i = 0; i < num; i++) {
-- 
1.7.4.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2012-03-19 20:30 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-07 19:21 [PATCH] [media] dib0700: unlock mutexes on error paths Alexey Khoroshilov
2012-03-19 17:47 ` Mauro Carvalho Chehab
2012-03-19 19:56   ` Alexey Khoroshilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox