public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] Fix a memory leak in em28xx_usb_probe()
@ 2007-08-09 21:02 Jesper Juhl
  2007-08-15 19:49 ` Markus Rechberger
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2007-08-09 21:02 UTC (permalink / raw)
  To: Linux Kernel Mailing List
  Cc: Luca Risolia, Ludovico Cavedon, Markus Rechberger,
	Mauro Carvalho Chehab, Sascha Sommer, Jesper Juhl,
	Greg Kroah-Hartman

EHLO,

If, in em28xx_usb_probe() the memory allocation
	dev->alt_max_pkt_size = kmalloc(32*
						dev->num_alt,GFP_KERNEL);
fails, then we'll bail out and return -ENOMEM.
The problem is that in that case we don't free the storage allocated 
to 'dev', thus causing a memory leak.

This patch fixes the leak by freeing 'dev' before we return -ENOMEM.
This fixes Coverity bug #647.


Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
---

 drivers/media/video/em28xx/em28xx-video.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/drivers/media/video/em28xx/em28xx-video.c b/drivers/media/video/em28xx/em28xx-video.c
index 2c7b158..40307f3 100644
--- a/drivers/media/video/em28xx/em28xx-video.c
+++ b/drivers/media/video/em28xx/em28xx-video.c
@@ -1772,6 +1772,7 @@ static int em28xx_usb_probe(struct usb_interface *interface,
 	if (dev->alt_max_pkt_size == NULL) {
 		em28xx_errdev("out of memory!\n");
 		em28xx_devused&=~(1<<nr);
+		kfree(dev);
 		return -ENOMEM;
 	}
 




^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-15 19:49 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-09 21:02 [PATCH] Fix a memory leak in em28xx_usb_probe() Jesper Juhl
2007-08-15 19:49 ` Markus Rechberger

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