aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/media/rc
diff options
context:
space:
mode:
authorJames Hogan <james.hogan@imgtec.com>2014-03-01 17:52:25 -0500
committerMauro Carvalho Chehab <m.chehab@samsung.com>2014-03-11 14:56:32 -0400
commit262912335c823a2bbcc87003ee55d62cc27f4e48 (patch)
tree90ad93d575245b05bd1f9b479848995d09aada45 /drivers/media/rc
parentcdcb12e78a4559c1842fbf8fb82e770b9f7362d6 (diff)
[media] rc-main: fix missing unlock if no devno left
While playing with make coccicheck I noticed this message: drivers/media/rc/rc-main.c:1245:3-9: preceding lock on line 1238 It was introduced by commit 587d1b06e07b ([media] rc-core: reuse device numbers) which returns -ENOMEM after a mutex_lock without first unlocking it when there are no more device numbers left. The added code doesn't depend on the device lock, so move it before the lock is taken. Signed-off-by: James Hogan <james.hogan@imgtec.com> Signed-off-by: Mauro Carvalho Chehab <m.chehab@samsung.com>
Diffstat (limited to 'drivers/media/rc')
-rw-r--r--drivers/media/rc/rc-main.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/media/rc/rc-main.c b/drivers/media/rc/rc-main.c
index b1a690054834..f87e0f0ee597 100644
--- a/drivers/media/rc/rc-main.c
+++ b/drivers/media/rc/rc-main.c
@@ -1286,14 +1286,6 @@ int rc_register_device(struct rc_dev *dev)
1286 if (dev->close) 1286 if (dev->close)
1287 dev->input_dev->close = ir_close; 1287 dev->input_dev->close = ir_close;
1288 1288
1289 /*
1290 * Take the lock here, as the device sysfs node will appear
1291 * when device_add() is called, which may trigger an ir-keytable udev
1292 * rule, which will in turn call show_protocols and access
1293 * dev->enabled_protocols before it has been initialized.
1294 */
1295 mutex_lock(&dev->lock);
1296
1297 do { 1289 do {
1298 devno = find_first_zero_bit(ir_core_dev_number, 1290 devno = find_first_zero_bit(ir_core_dev_number,
1299 IRRCV_NUM_DEVICES); 1291 IRRCV_NUM_DEVICES);
@@ -1302,6 +1294,14 @@ int rc_register_device(struct rc_dev *dev)
1302 return -ENOMEM; 1294 return -ENOMEM;
1303 } while (test_and_set_bit(devno, ir_core_dev_number)); 1295 } while (test_and_set_bit(devno, ir_core_dev_number));
1304 1296
1297 /*
1298 * Take the lock here, as the device sysfs node will appear
1299 * when device_add() is called, which may trigger an ir-keytable udev
1300 * rule, which will in turn call show_protocols and access
1301 * dev->enabled_protocols before it has been initialized.
1302 */
1303 mutex_lock(&dev->lock);
1304
1305 dev->devno = devno; 1305 dev->devno = devno;
1306 dev_set_name(&dev->dev, "rc%ld", dev->devno); 1306 dev_set_name(&dev->dev, "rc%ld", dev->devno);
1307 dev_set_drvdata(&dev->dev, dev); 1307 dev_set_drvdata(&dev->dev, dev);