linux-media.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging/media: lirc_imon: fix leaks in imon_probe()
@ 2013-06-03  2:58 Alexey Khoroshilov
  0 siblings, 0 replies; only message in thread
From: Alexey Khoroshilov @ 2013-06-03  2:58 UTC (permalink / raw)
  To: Jarod Wilson
  Cc: Alexey Khoroshilov, Mauro Carvalho Chehab, Greg Kroah-Hartman,
	linux-media, devel, linux-kernel, ldv-project

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>
---
 drivers/staging/media/lirc/lirc_imon.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/staging/media/lirc/lirc_imon.c b/drivers/staging/media/lirc/lirc_imon.c
index 0a2c45d..4afa7da 100644
--- a/drivers/staging/media/lirc/lirc_imon.c
+++ b/drivers/staging/media/lirc/lirc_imon.c
@@ -911,8 +911,8 @@ static int imon_probe(struct usb_interface *interface,
 	if (retval) {
 		dev_err(dev, "%s: usb_submit_urb failed for intf0 (%d)\n",
 			__func__, retval);
-		mutex_unlock(&context->ctx_lock);
-		goto exit;
+		alloc_status = 8;
+		goto unlock;
 	}
 
 	usb_set_intfdata(interface, context);
@@ -937,6 +937,8 @@ unlock:
 alloc_status_switch:
 
 	switch (alloc_status) {
+	case 8:
+		lirc_unregister_driver(driver->minor);
 	case 7:
 		usb_free_urb(tx_urb);
 	case 6:
@@ -959,7 +961,6 @@ alloc_status_switch:
 		retval = 0;
 	}
 
-exit:
 	mutex_unlock(&driver_lock);
 
 	return retval;
-- 
1.8.1.2

^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2013-06-03  2:59 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-06-03  2:58 [PATCH] staging/media: lirc_imon: fix leaks in imon_probe() Alexey Khoroshilov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).