[media] cxusb: unlock on error in cxusb_i2c_xfer()
We recently introduced some new error paths which are missing their
unlocks.
Fixes: 64f7ef8afb
('[media] cxusb: 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>
This commit is contained in:
parent
e351bf25fa
commit
1cdbcc5db4
1 changed files with 16 additions and 5 deletions
|
@ -149,6 +149,7 @@ static int cxusb_i2c_xfer(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 (mutex_lock_interruptible(&d->i2c_mutex) < 0)
|
if (mutex_lock_interruptible(&d->i2c_mutex) < 0)
|
||||||
|
@ -173,7 +174,8 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
|
||||||
if (1 + msg[i].len > sizeof(ibuf)) {
|
if (1 + msg[i].len > sizeof(ibuf)) {
|
||||||
warn("i2c rd: len=%d is too big!\n",
|
warn("i2c rd: len=%d is too big!\n",
|
||||||
msg[i].len);
|
msg[i].len);
|
||||||
return -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
|
goto unlock;
|
||||||
}
|
}
|
||||||
obuf[0] = 0;
|
obuf[0] = 0;
|
||||||
obuf[1] = msg[i].len;
|
obuf[1] = msg[i].len;
|
||||||
|
@ -193,12 +195,14 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
|
||||||
if (3 + msg[i].len > sizeof(obuf)) {
|
if (3 + msg[i].len > sizeof(obuf)) {
|
||||||
warn("i2c wr: len=%d is too big!\n",
|
warn("i2c wr: len=%d is too big!\n",
|
||||||
msg[i].len);
|
msg[i].len);
|
||||||
return -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
|
goto unlock;
|
||||||
}
|
}
|
||||||
if (1 + msg[i + 1].len > sizeof(ibuf)) {
|
if (1 + msg[i + 1].len > sizeof(ibuf)) {
|
||||||
warn("i2c rd: len=%d is too big!\n",
|
warn("i2c rd: len=%d is too big!\n",
|
||||||
msg[i + 1].len);
|
msg[i + 1].len);
|
||||||
return -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
|
goto unlock;
|
||||||
}
|
}
|
||||||
obuf[0] = msg[i].len;
|
obuf[0] = msg[i].len;
|
||||||
obuf[1] = msg[i+1].len;
|
obuf[1] = msg[i+1].len;
|
||||||
|
@ -223,7 +227,8 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
|
||||||
if (2 + msg[i].len > sizeof(obuf)) {
|
if (2 + msg[i].len > sizeof(obuf)) {
|
||||||
warn("i2c wr: len=%d is too big!\n",
|
warn("i2c wr: len=%d is too big!\n",
|
||||||
msg[i].len);
|
msg[i].len);
|
||||||
return -EOPNOTSUPP;
|
ret = -EOPNOTSUPP;
|
||||||
|
goto unlock;
|
||||||
}
|
}
|
||||||
obuf[0] = msg[i].addr;
|
obuf[0] = msg[i].addr;
|
||||||
obuf[1] = msg[i].len;
|
obuf[1] = msg[i].len;
|
||||||
|
@ -237,8 +242,14 @@ static int cxusb_i2c_xfer(struct i2c_adapter *adap, struct i2c_msg msg[],
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (i == num)
|
||||||
|
ret = num;
|
||||||
|
else
|
||||||
|
ret = -EREMOTEIO;
|
||||||
|
|
||||||
|
unlock:
|
||||||
mutex_unlock(&d->i2c_mutex);
|
mutex_unlock(&d->i2c_mutex);
|
||||||
return i == num ? num : -EREMOTEIO;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
|
static u32 cxusb_i2c_func(struct i2c_adapter *adapter)
|
||||||
|
|
Loading…
Add table
Reference in a new issue