summaryrefslogtreecommitdiff
path: root/drivers/staging/lirc
diff options
context:
space:
mode:
authorAlexey Khoroshilov <khoroshilov@ispras.ru>2011-08-30 00:17:56 +0400
committerGreg Kroah-Hartman <gregkh@suse.de>2011-09-06 11:46:20 -0700
commit6699291f89aa3e22490c9c93620350f92015b699 (patch)
treef5e4dc3e05af2b3d4449c1ebd1e88cadbba3f47a /drivers/staging/lirc
parent939161571c01670ecc7e33a6b880ed812a17bbc6 (diff)
staging: lirc: fix mismatch in mutex lock-unlock in imon_probe
If kzalloc failed for allocation of context, goto alloc_status_switch leads to unlock of unacquired driver_lock. The patch moves mutex_lock(&driver_lock) before allocation of context. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
Diffstat (limited to 'drivers/staging/lirc')
-rw-r--r--drivers/staging/lirc/lirc_imon.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/staging/lirc/lirc_imon.c b/drivers/staging/lirc/lirc_imon.c
index 4a9e563f40fa..f5308d5929c6 100644
--- a/drivers/staging/lirc/lirc_imon.c
+++ b/drivers/staging/lirc/lirc_imon.c
@@ -727,6 +727,9 @@ static int imon_probe(struct usb_interface *interface,
int i;
u16 vendor, product;
+ /* prevent races probing devices w/multiple interfaces */
+ mutex_lock(&driver_lock);
+
context = kzalloc(sizeof(struct imon_context), GFP_KERNEL);
if (!context) {
err("%s: kzalloc failed for context", __func__);
@@ -753,9 +756,6 @@ static int imon_probe(struct usb_interface *interface,
dev_dbg(dev, "%s: found iMON device (%04x:%04x, intf%d)\n",
__func__, vendor, product, ifnum);
- /* prevent races probing devices w/multiple interfaces */
- mutex_lock(&driver_lock);
-
/*
* Scan the endpoint list and set:
* first input endpoint = IR endpoint