Commit 560febde authored by Dan Carpenter's avatar Dan Carpenter Committed by Jiri Slaby

media: dw2102: some missing unlocks on error

commit 324ed533 upstream.

We recently introduced some new error paths but the unlocks are missing.
Fixes: 0065a79a ('[media] dw2102: Don't use dynamic static allocation')
Signed-off-by: default avatarDan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: default avatarMauro Carvalho Chehab <m.chehab@samsung.com>
Signed-off-by: default avatarJiri Slaby <jslaby@suse.cz>
parent fc3200dc
...@@ -301,6 +301,7 @@ static int dw2102_serit_i2c_transfer(struct i2c_adapter *adap, ...@@ -301,6 +301,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) 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); struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret;
if (!d) if (!d)
return -ENODEV; return -ENODEV;
...@@ -316,7 +317,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms ...@@ -316,7 +317,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
if (2 + msg[1].len > sizeof(ibuf)) { if (2 + msg[1].len > sizeof(ibuf)) {
warn("i2c rd: len=%d is too big!\n", warn("i2c rd: len=%d is too big!\n",
msg[1].len); msg[1].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[0].addr << 1; obuf[0] = msg[0].addr << 1;
...@@ -340,7 +342,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms ...@@ -340,7 +342,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
if (2 + msg[0].len > sizeof(obuf)) { if (2 + msg[0].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[1].len); msg[1].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[0].addr << 1; obuf[0] = msg[0].addr << 1;
...@@ -357,7 +360,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms ...@@ -357,7 +360,8 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
if (2 + msg[0].len > sizeof(obuf)) { if (2 + msg[0].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[1].len); msg[1].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[0].addr << 1; obuf[0] = msg[0].addr << 1;
...@@ -386,15 +390,17 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms ...@@ -386,15 +390,17 @@ static int dw2102_earda_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg ms
break; break;
} }
ret = num;
unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
return num; return ret;
} }
static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num) static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], int num)
{ {
struct dvb_usb_device *d = i2c_get_adapdata(adap); struct dvb_usb_device *d = i2c_get_adapdata(adap);
int len, i, j; int len, i, j, ret;
if (!d) if (!d)
return -ENODEV; return -ENODEV;
...@@ -430,7 +436,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i ...@@ -430,7 +436,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
if (2 + msg[j].len > sizeof(ibuf)) { if (2 + msg[j].len > sizeof(ibuf)) {
warn("i2c rd: len=%d is too big!\n", warn("i2c rd: len=%d is too big!\n",
msg[j].len); msg[j].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
dw210x_op_rw(d->udev, 0xc3, dw210x_op_rw(d->udev, 0xc3,
...@@ -466,7 +473,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i ...@@ -466,7 +473,8 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
if (2 + msg[j].len > sizeof(obuf)) { if (2 + msg[j].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[j].len); msg[j].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[j].addr << 1; obuf[0] = msg[j].addr << 1;
...@@ -481,15 +489,18 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i ...@@ -481,15 +489,18 @@ static int dw2104_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], i
} }
} }
ret = num;
unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
return num; return ret;
} }
static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
int num) int num)
{ {
struct dvb_usb_device *d = i2c_get_adapdata(adap); struct dvb_usb_device *d = i2c_get_adapdata(adap);
int ret;
int i; int i;
if (!d) if (!d)
...@@ -506,7 +517,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -506,7 +517,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (2 + msg[1].len > sizeof(ibuf)) { if (2 + msg[1].len > sizeof(ibuf)) {
warn("i2c rd: len=%d is too big!\n", warn("i2c rd: len=%d is too big!\n",
msg[1].len); msg[1].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[0].addr << 1; obuf[0] = msg[0].addr << 1;
obuf[1] = msg[0].len; obuf[1] = msg[0].len;
...@@ -530,7 +542,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -530,7 +542,8 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (2 + msg[0].len > sizeof(obuf)) { if (2 + msg[0].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[0].len); msg[0].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[0].addr << 1; obuf[0] = msg[0].addr << 1;
obuf[1] = msg[0].len; obuf[1] = msg[0].len;
...@@ -556,9 +569,11 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -556,9 +569,11 @@ static int dw3101_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
msg[i].flags == 0 ? ">>>" : "<<<"); msg[i].flags == 0 ? ">>>" : "<<<");
debug_dump(msg[i].buf, msg[i].len, deb_xfer); debug_dump(msg[i].buf, msg[i].len, deb_xfer);
} }
ret = num;
unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
return num; return ret;
} }
static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
...@@ -566,7 +581,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -566,7 +581,7 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
{ {
struct dvb_usb_device *d = i2c_get_adapdata(adap); struct dvb_usb_device *d = i2c_get_adapdata(adap);
struct usb_device *udev; struct usb_device *udev;
int len, i, j; int len, i, j, ret;
if (!d) if (!d)
return -ENODEV; return -ENODEV;
...@@ -618,7 +633,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -618,7 +633,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (msg[j].len > sizeof(ibuf)) { if (msg[j].len > sizeof(ibuf)) {
warn("i2c rd: len=%d is too big!\n", warn("i2c rd: len=%d is too big!\n",
msg[j].len); msg[j].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
dw210x_op_rw(d->udev, 0x91, 0, 0, dw210x_op_rw(d->udev, 0x91, 0, 0,
...@@ -652,7 +668,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -652,7 +668,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (2 + msg[j].len > sizeof(obuf)) { if (2 + msg[j].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[j].len); msg[j].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[j + 1].len; obuf[0] = msg[j + 1].len;
...@@ -671,7 +688,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -671,7 +688,8 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
if (2 + msg[j].len > sizeof(obuf)) { if (2 + msg[j].len > sizeof(obuf)) {
warn("i2c wr: len=%d is too big!\n", warn("i2c wr: len=%d is too big!\n",
msg[j].len); msg[j].len);
return -EOPNOTSUPP; ret = -EOPNOTSUPP;
goto unlock;
} }
obuf[0] = msg[j].len + 1; obuf[0] = msg[j].len + 1;
obuf[1] = (msg[j].addr << 1); obuf[1] = (msg[j].addr << 1);
...@@ -685,9 +703,11 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], ...@@ -685,9 +703,11 @@ static int s6x0_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
} }
} }
} }
ret = num;
unlock:
mutex_unlock(&d->i2c_mutex); mutex_unlock(&d->i2c_mutex);
return num; return ret;
} }
static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[], static int su3000_i2c_transfer(struct i2c_adapter *adap, struct i2c_msg msg[],
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment