linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] staging, media, easycap: Fix mem leak in easycap_usb_probe()
@ 2012-01-29 20:55 Jesper Juhl
  0 siblings, 0 replies; only message in thread
From: Jesper Juhl @ 2012-01-29 20:55 UTC (permalink / raw)
  To: devel
  Cc: linux-kernel, linux-media, R.M. Thomas, Mauro Carvalho Chehab,
	Greg Kroah-Hartman, Tomas Winkler, Dan Carpenter

If allocating 'pdata_urb' fails, the function will return -ENOMEM
without freeing the memory allocated, just a few lines above, for
'purb' and will leak that memory when 'purb' goes out of scope.

This patch resolves the leak by freeing the allocated storage with
usb_free_urb() before the return.

Signed-off-by: Jesper Juhl <jj@chaosbits.net>
---
 drivers/staging/media/easycap/easycap_main.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

  compile tested only

diff --git a/drivers/staging/media/easycap/easycap_main.c b/drivers/staging/media/easycap/easycap_main.c
index 8ff5f38..3d439b7 100644
--- a/drivers/staging/media/easycap/easycap_main.c
+++ b/drivers/staging/media/easycap/easycap_main.c
@@ -3825,6 +3825,7 @@ static int easycap_usb_probe(struct usb_interface *intf,
 /* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
 			pdata_urb = kzalloc(sizeof(struct data_urb), GFP_KERNEL);
 			if (!pdata_urb) {
+				usb_free_urb(purb);
 				SAM("ERROR: Could not allocate struct data_urb.\n");
 				return -ENOMEM;
 			}
-- 
1.7.8.4


-- 
Jesper Juhl <jj@chaosbits.net>       http://www.chaosbits.net/
Don't top-post http://www.catb.org/jargon/html/T/top-post.html
Plain text mails only, please.


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

only message in thread, other threads:[~2012-01-29 20:55 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-01-29 20:55 [PATCH] staging, media, easycap: Fix mem leak in easycap_usb_probe() Jesper Juhl

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).