| From 324ed533bf0b23c309b805272c4ffcc5d51493a6 Mon Sep 17 00:00:00 2001 |
| From: Dan Carpenter <dan.carpenter@oracle.com> |
| Date: Fri, 22 Nov 2013 04:56:33 -0300 |
| Subject: media: dw2102: some missing unlocks on error |
| |
| From: Dan Carpenter <dan.carpenter@oracle.com> |
| |
| commit 324ed533bf0b23c309b805272c4ffcc5d51493a6 upstream. |
| |
| 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> |
| Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org> |
| |
| --- |
| drivers/media/usb/dvb-usb/dw2102.c | 52 +++++++++++++++++++++++++------------ |
| 1 file changed, 36 insertions(+), 16 deletions(-) |
| |
| --- a/drivers/media/usb/dvb-usb/dw2102.c |
| +++ b/drivers/media/usb/dvb-usb/dw2102.c |
| @@ -301,6 +301,7 @@ static int dw2102_serit_i2c_transfer(str |
| 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; |
| @@ -316,7 +317,8 @@ static int dw2102_earda_i2c_transfer(str |
| 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; |
| @@ -340,7 +342,8 @@ static int dw2102_earda_i2c_transfer(str |
| 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; |
| @@ -357,7 +360,8 @@ static int dw2102_earda_i2c_transfer(str |
| 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; |
| @@ -386,15 +390,17 @@ static int dw2102_earda_i2c_transfer(str |
| |
| 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; |
| @@ -430,7 +436,8 @@ static int dw2104_i2c_transfer(struct i2 |
| 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, |
| @@ -466,7 +473,8 @@ static int dw2104_i2c_transfer(struct i2 |
| 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; |
| @@ -481,15 +489,18 @@ static int dw2104_i2c_transfer(struct i2 |
| } |
| |
| } |
| + 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) |
| @@ -506,7 +517,8 @@ static int dw3101_i2c_transfer(struct i2 |
| 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; |
| @@ -530,7 +542,8 @@ static int dw3101_i2c_transfer(struct i2 |
| 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; |
| @@ -556,9 +569,11 @@ static int dw3101_i2c_transfer(struct i2 |
| 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[], |
| @@ -566,7 +581,7 @@ static int s6x0_i2c_transfer(struct i2c_ |
| { |
| 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; |
| @@ -618,7 +633,8 @@ static int s6x0_i2c_transfer(struct i2c_ |
| 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, |
| @@ -652,7 +668,8 @@ static int s6x0_i2c_transfer(struct i2c_ |
| 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; |
| @@ -671,7 +688,8 @@ static int s6x0_i2c_transfer(struct i2c_ |
| 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); |
| @@ -685,9 +703,11 @@ static int s6x0_i2c_transfer(struct i2c_ |
| } |
| } |
| } |
| + 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[], |