public inbox for linux-media@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH 2/2 v2] [media] dib0700: Fix memory leak during initialization
@ 2012-03-13 17:52 Jean Delvare
  0 siblings, 0 replies; only message in thread
From: Jean Delvare @ 2012-03-13 17:52 UTC (permalink / raw)
  To: LMML; +Cc: Mauro Carvalho Chehab, Devin Heitmueller

Reported by kmemleak.

Signed-off-by: Jean Delvare <khali@linux-fr.org>
Cc: Mauro Carvalho Chehab <mchehab@infradead.org>
Cc: Devin Heitmueller <dheitmueller@kernellabs.com>
---
Changes since v1:
* Don't free the URB when it is still in use.
* Fix a second leak (transfer_buffer).

 drivers/media/dvb/dvb-usb/dib0700_core.c |    7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- linux-3.3-rc7.orig/drivers/media/dvb/dvb-usb/dib0700_core.c	2012-03-13 11:20:33.748864483 +0100
+++ linux-3.3-rc7/drivers/media/dvb/dvb-usb/dib0700_core.c	2012-03-13 17:42:20.316570058 +0100
@@ -679,6 +679,7 @@ static void dib0700_rc_urb_completion(st
 	deb_info("%s()\n", __func__);
 	if (d->rc_dev == NULL) {
 		/* This will occur if disable_rc_polling=1 */
+		kfree(purb->transfer_buffer);
 		usb_free_urb(purb);
 		return;
 	}
@@ -687,6 +688,7 @@ static void dib0700_rc_urb_completion(st
 
 	if (purb->status < 0) {
 		deb_info("discontinuing polling\n");
+		kfree(purb->transfer_buffer);
 		usb_free_urb(purb);
 		return;
 	}
@@ -781,8 +783,11 @@ int dib0700_rc_setup(struct dvb_usb_devi
 			  dib0700_rc_urb_completion, d);
 
 	ret = usb_submit_urb(purb, GFP_ATOMIC);
-	if (ret)
+	if (ret) {
 		err("rc submit urb failed\n");
+		kfree(purb->transfer_buffer);
+		usb_free_urb(purb);
+	}
 
 	return ret;
 }


-- 
Jean Delvare

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

only message in thread, other threads:[~2012-03-13 17:52 UTC | newest]

Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-03-13 17:52 [PATCH 2/2 v2] [media] dib0700: Fix memory leak during initialization Jean Delvare

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox