Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

[media] cxusb: unlock on error in cxusb_i2c_xfer()

We recently introduced some new error paths which are missing their
unlocks.
Fixes: 64f7ef8afbf8 ('[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>

authored by

Dan Carpenter and committed by
Mauro Carvalho Chehab
1cdbcc5d e351bf25

+16 -5
+16 -5
drivers/media/usb/dvb-usb/cxusb.c
··· 149 149 int num) 150 150 { 151 151 struct dvb_usb_device *d = i2c_get_adapdata(adap); 152 + int ret; 152 153 int i; 153 154 154 155 if (mutex_lock_interruptible(&d->i2c_mutex) < 0) ··· 174 173 if (1 + msg[i].len > sizeof(ibuf)) { 175 174 warn("i2c rd: len=%d is too big!\n", 176 175 msg[i].len); 177 - return -EOPNOTSUPP; 176 + ret = -EOPNOTSUPP; 177 + goto unlock; 178 178 } 179 179 obuf[0] = 0; 180 180 obuf[1] = msg[i].len; ··· 195 193 if (3 + msg[i].len > sizeof(obuf)) { 196 194 warn("i2c wr: len=%d is too big!\n", 197 195 msg[i].len); 198 - return -EOPNOTSUPP; 196 + ret = -EOPNOTSUPP; 197 + goto unlock; 199 198 } 200 199 if (1 + msg[i + 1].len > sizeof(ibuf)) { 201 200 warn("i2c rd: len=%d is too big!\n", 202 201 msg[i + 1].len); 203 - return -EOPNOTSUPP; 202 + ret = -EOPNOTSUPP; 203 + goto unlock; 204 204 } 205 205 obuf[0] = msg[i].len; 206 206 obuf[1] = msg[i+1].len; ··· 227 223 if (2 + msg[i].len > sizeof(obuf)) { 228 224 warn("i2c wr: len=%d is too big!\n", 229 225 msg[i].len); 230 - return -EOPNOTSUPP; 226 + ret = -EOPNOTSUPP; 227 + goto unlock; 231 228 } 232 229 obuf[0] = msg[i].addr; 233 230 obuf[1] = msg[i].len; ··· 242 237 } 243 238 } 244 239 240 + if (i == num) 241 + ret = num; 242 + else 243 + ret = -EREMOTEIO; 244 + 245 + unlock: 245 246 mutex_unlock(&d->i2c_mutex); 246 - return i == num ? num : -EREMOTEIO; 247 + return ret; 247 248 } 248 249 249 250 static u32 cxusb_i2c_func(struct i2c_adapter *adapter)