Skip to content

Commit

Permalink
staging: lirc: fix mismatch in mutex lock-unlock in imon_probe
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
Alexey Khoroshilov authored and Greg Kroah-Hartman committed Sep 6, 2011
1 parent 9391615 commit 6699291
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions drivers/staging/lirc/lirc_imon.c
Original file line number Diff line number Diff line change
Expand Up @@ -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__);
Expand All @@ -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
Expand Down

0 comments on commit 6699291

Please sign in to comment.