[media] staging/media: lirc_imon: fix leaks in imon_probe()
Error handling of usb_submit_urb() is not as all others in imon_probe(). It just unlocks mutexes and returns nonzero leaving all already allocated resources unfreed. The patch makes sure all the resources are deallocated. Found by Linux Driver Verification project (linuxtesting.org). Signed-off-by: Alexey Khoroshilov <khoroshilov@ispras.ru> Signed-off-by: Mauro Carvalho Chehab <mchehab@redhat.com>
This commit is contained in:
parent
07342664d3
commit
e049ca5e85
|
@ -911,8 +911,8 @@ static int imon_probe(struct usb_interface *interface,
|
||||||
if (retval) {
|
if (retval) {
|
||||||
dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n",
|
dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n",
|
||||||
__func__, retval);
|
__func__, retval);
|
||||||
mutex_unlock(&context->ctx_lock);
|
alloc_status = 8;
|
||||||
goto exit;
|
goto unlock;
|
||||||
}
|
}
|
||||||
|
|
||||||
usb_set_intfdata(interface, context);
|
usb_set_intfdata(interface, context);
|
||||||
|
@ -937,6 +937,8 @@ unlock:
|
||||||
alloc_status_switch:
|
alloc_status_switch:
|
||||||
|
|
||||||
switch (alloc_status) {
|
switch (alloc_status) {
|
||||||
|
case 8:
|
||||||
|
lirc_unregister_driver(driver->minor);
|
||||||
case 7:
|
case 7:
|
||||||
usb_free_urb(tx_urb);
|
usb_free_urb(tx_urb);
|
||||||
case 6:
|
case 6:
|
||||||
|
@ -959,7 +961,6 @@ alloc_status_switch:
|
||||||
retval = 0;
|
retval = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
exit:
|
|
||||||
mutex_unlock(&driver_lock);
|
mutex_unlock(&driver_lock);
|
||||||
|
|
||||||
return retval;
|
return retval;
|
||||||
|
|
Loading…
Reference in New Issue