This is an automatic generated email to let you know that the following patch 
were queued:

Subject: media: dib0700: fix locking in dib0700_i2c_xfer_new()
Author:  Dan Carpenter <dan.carpen...@oracle.com>
Date:    Fri Apr 28 09:52:07 2017 -0300

This patch mostly adds unlocks to error paths.  But one additional small
change is that I made the first "break;" a "goto unlock;" which means
that now we return failure instead of success on that path.

Signed-off-by: Dan Carpenter <dan.carpen...@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <mche...@s-opensource.com>

 drivers/media/usb/dvb-usb/dib0700_core.c | 18 ++++++++++++------
 1 file changed, 12 insertions(+), 6 deletions(-)

---

diff --git a/drivers/media/usb/dvb-usb/dib0700_core.c 
b/drivers/media/usb/dvb-usb/dib0700_core.c
index 08acdd32e412..4dea79718827 100644
--- a/drivers/media/usb/dvb-usb/dib0700_core.c
+++ b/drivers/media/usb/dvb-usb/dib0700_core.c
@@ -215,13 +215,14 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, 
struct i2c_msg *msg,
                                                 USB_CTRL_GET_TIMEOUT);
                        if (result < 0) {
                                deb_info("i2c read error (status = %d)\n", 
result);
-                               break;
+                               goto unlock;
                        }
 
                        if (msg[i].len > sizeof(st->buf)) {
                                deb_info("buffer too small to fit %d bytes\n",
                                         msg[i].len);
-                               return -EIO;
+                               result = -EIO;
+                               goto unlock;
                        }
 
                        memcpy(msg[i].buf, st->buf, msg[i].len);
@@ -233,8 +234,8 @@ 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");
-                               mutex_unlock(&d->i2c_mutex);
-                               return -EINTR;
+                               result = -EINTR;
+                               goto unlock;
                        }
                        st->buf[0] = REQUEST_NEW_I2C_WRITE;
                        st->buf[1] = msg[i].addr << 1;
@@ -247,7 +248,9 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, 
struct i2c_msg *msg,
                        if (msg[i].len > sizeof(st->buf) - 4) {
                                deb_info("i2c message to big: %d\n",
                                         msg[i].len);
-                               return -EIO;
+                               mutex_unlock(&d->usb_mutex);
+                               result = -EIO;
+                               goto unlock;
                        }
 
                        /* The Actual i2c payload */
@@ -269,8 +272,11 @@ static int dib0700_i2c_xfer_new(struct i2c_adapter *adap, 
struct i2c_msg *msg,
                        }
                }
        }
+       result = i;
+
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return i;
+       return result;
 }
 
 /*

_______________________________________________
linuxtv-commits mailing list
linuxtv-commits@linuxtv.org
https://www.linuxtv.org/cgi-bin/mailman/listinfo/linuxtv-commits

Reply via email to