[media] dw2102: some missing unlocks on error
authorDan Carpenter <dan.carpenter@oracle.com>
Fri, 22 Nov 2013 07:56:33 +0000 (04:56 -0300)
committerMauro Carvalho Chehab <m.chehab@samsung.com>
Tue, 10 Dec 2013 17:37:31 +0000 (15:37 -0200)
We recently introduced some new error paths but the unlocks are missing.
Fixes: 0065a79a8698 ('[media] dw2102: Don't use dynamic static allocation')
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
drivers/media/usb/dvb-usb/dw2102.c

index 172a8554bc94cf67b4df71e4e63c7a4021c27105..ae0f56a32e4d0ba888b09a214492cb2b2f14b244 100644 (file)
@@ -292,6 +292,7 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap,
 static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
+       int ret;
 
        if (!d)
                return -ENODEV;
@@ -307,7 +308,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                if (2 + msg[1].len > sizeof(ibuf)) {
                        warn("i2c rd: len=%d is too big!\n",
                             msg[1].len);
-                       return -EOPNOTSUPP;
+                       ret = -EOPNOTSUPP;
+                       goto unlock;
                }
 
                obuf[0] = msg[0].addr << 1;
@@ -331,7 +333,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                        if (2 + msg[0].len > sizeof(obuf)) {
                                warn("i2c wr: len=%d is too big!\n",
                                     msg[1].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
 
                        obuf[0] = msg[0].addr << 1;
@@ -348,7 +351,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
                        if (2 + msg[0].len > sizeof(obuf)) {
                                warn("i2c wr: len=%d is too big!\n",
                                     msg[1].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
 
                        obuf[0] = msg[0].addr << 1;
@@ -377,15 +381,17 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
 
                break;
        }
+       ret = num;
 
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return num;
+       return ret;
 }
 
 static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
-       int len, i, j;
+       int len, i, j, ret;
 
        if (!d)
                return -ENODEV;
@@ -421,7 +427,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
                                if (2 + msg[j].len > sizeof(ibuf)) {
                                        warn("i2c rd: len=%d is too big!\n",
                                             msg[j].len);
-                                       return -EOPNOTSUPP;
+                                       ret = -EOPNOTSUPP;
+                                       goto unlock;
                                }
 
                                dw210x_op_rw(d->udev, 0xc3,
@@ -457,7 +464,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
                                if (2 + msg[j].len > sizeof(obuf)) {
                                        warn("i2c wr: len=%d is too big!\n",
                                             msg[j].len);
-                                       return -EOPNOTSUPP;
+                                       ret = -EOPNOTSUPP;
+                                       goto unlock;
                                }
 
                                obuf[0] = msg[j].addr << 1;
@@ -472,15 +480,18 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
                }
 
        }
+       ret = num;
 
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return num;
+       return ret;
 }
 
 static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                                                int num)
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
+       int ret;
        int i;
 
        if (!d)
@@ -497,7 +508,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                if (2 + msg[1].len > sizeof(ibuf)) {
                        warn("i2c rd: len=%d is too big!\n",
                             msg[1].len);
-                       return -EOPNOTSUPP;
+                       ret = -EOPNOTSUPP;
+                       goto unlock;
                }
                obuf[0] = msg[0].addr << 1;
                obuf[1] = msg[0].len;
@@ -521,7 +533,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                        if (2 + msg[0].len > sizeof(obuf)) {
                                warn("i2c wr: len=%d is too big!\n",
                                     msg[0].len);
-                               return -EOPNOTSUPP;
+                               ret = -EOPNOTSUPP;
+                               goto unlock;
                        }
                        obuf[0] = msg[0].addr << 1;
                        obuf[1] = msg[0].len;
@@ -547,9 +560,11 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                msg[i].flags == 0 ? ">>>" : "<<<");
                debug_dump(msg[i].buf, msg[i].len, deb_xfer);
        }
+       ret = num;
 
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return num;
+       return ret;
 }
 
 static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
@@ -557,7 +572,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
 {
        struct dvb_usb_device *d = i2c_get_adapdata(adap);
        struct usb_device *udev;
-       int len, i, j;
+       int len, i, j, ret;
 
        if (!d)
                return -ENODEV;
@@ -609,7 +624,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                if (msg[j].len > sizeof(ibuf)) {
                                        warn("i2c rd: len=%d is too big!\n",
                                             msg[j].len);
-                                       return -EOPNOTSUPP;
+                                       ret = -EOPNOTSUPP;
+                                       goto unlock;
                                }
 
                                dw210x_op_rw(d->udev, 0x91, 0, 0,
@@ -643,7 +659,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                if (2 + msg[j].len > sizeof(obuf)) {
                                        warn("i2c wr: len=%d is too big!\n",
                                             msg[j].len);
-                                       return -EOPNOTSUPP;
+                                       ret = -EOPNOTSUPP;
+                                       goto unlock;
                                }
 
                                obuf[0] = msg[j + 1].len;
@@ -662,7 +679,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                                if (2 + msg[j].len > sizeof(obuf)) {
                                        warn("i2c wr: len=%d is too big!\n",
                                             msg[j].len);
-                                       return -EOPNOTSUPP;
+                                       ret = -EOPNOTSUPP;
+                                       goto unlock;
                                }
                                obuf[0] = msg[j].len + 1;
                                obuf[1] = (msg[j].addr << 1);
@@ -676,9 +694,11 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
                }
                }
        }
+       ret = num;
 
+unlock:
        mutex_unlock(&d->i2c_mutex);
-       return num;
+       return ret;
 }
 
 static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],