Commit 6699291f authored by Alexey Khoroshilov's avatar Alexey Khoroshilov Committed by Greg Kroah-Hartman

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: default avatarAlexey Khoroshilov <khoroshilov@ispras.ru>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@suse.de>
parent 93916157
...@@ -727,6 +727,9 @@ static int imon_probe(struct usb_interface *interface, ...@@ -727,6 +727,9 @@ static int imon_probe(struct usb_interface *interface,
int i; int i;
u16 vendor, product; u16 vendor, product;
/* prevent races probing devices w/multiple interfaces */
mutex_lock(&driver_lock);
context = kzalloc(sizeof(struct imon_context), GFP_KERNEL); context = kzalloc(sizeof(struct imon_context), GFP_KERNEL);
if (!context) { if (!context) {
err("%s: kzalloc failed for context", __func__); err("%s: kzalloc failed for context", __func__);
...@@ -753,9 +756,6 @@ static int imon_probe(struct usb_interface *interface, ...@@ -753,9 +756,6 @@ static int imon_probe(struct usb_interface *interface,
dev_dbg(dev, "%s: found iMON device (%04x:%04x, intf%d)\n", dev_dbg(dev, "%s: found iMON device (%04x:%04x, intf%d)\n",
__func__, vendor, product, ifnum); __func__, vendor, product, ifnum);
/* prevent races probing devices w/multiple interfaces */
mutex_lock(&driver_lock);
/* /*
* Scan the endpoint list and set: * Scan the endpoint list and set:
* first input endpoint = IR endpoint * first input endpoint = IR endpoint
......
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