public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] mem leak fixes for AMD 5536 UDC high/full speed USB device controller driver
@ 2008-03-21 22:38 Jesper Juhl
  2008-03-26 12:59 ` Thomas Dahlmann
  0 siblings, 1 reply; 2+ messages in thread
From: Jesper Juhl @ 2008-03-21 22:38 UTC (permalink / raw)
  To: Thomas Dahlmann; +Cc: LKML, linux-usb, Jesper Juhl


In drivers/usb/gadget/amd5536udc.c::udc_pci_probe(),
sizeof(struct udc) storage is allocated for 'dev'.

There are many exit points from the function where
'dev' is not free'd but has also not yet been used
for anything. The following patch free's 'dev' at the
return points where it has not yet been used.

Please consider applying.


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

 amd5536udc.c |   10 ++++++++++
 1 file changed, 10 insertions(+)

diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c
index b663f23..fc6f348 100644
--- a/drivers/usb/gadget/amd5536udc.c
+++ b/drivers/usb/gadget/amd5536udc.c
@@ -3248,6 +3248,8 @@ static int udc_pci_probe(
 
 	/* pci setup */
 	if (pci_enable_device(pdev) < 0) {
+		kfree(dev);
+		dev = 0;
 		retval = -ENODEV;
 		goto finished;
 	}
@@ -3259,6 +3261,8 @@ static int udc_pci_probe(
 
 	if (!request_mem_region(resource, len, name)) {
 		dev_dbg(&pdev->dev, "pci device used already\n");
+		kfree(dev);
+		dev = 0;
 		retval = -EBUSY;
 		goto finished;
 	}
@@ -3267,18 +3271,24 @@ static int udc_pci_probe(
 	dev->virt_addr = ioremap_nocache(resource, len);
 	if (dev->virt_addr == NULL) {
 		dev_dbg(&pdev->dev, "start address cannot be mapped\n");
+		kfree(dev);
+		dev = 0;
 		retval = -EFAULT;
 		goto finished;
 	}
 
 	if (!pdev->irq) {
 		dev_err(&dev->pdev->dev, "irq not set\n");
+		kfree(dev);
+		dev = 0;
 		retval = -ENODEV;
 		goto finished;
 	}
 
 	if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) {
 		dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq);
+		kfree(dev);
+		dev = 0;
 		retval = -EBUSY;
 		goto finished;
 	}




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

end of thread, other threads:[~2008-03-26 13:04 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2008-03-21 22:38 [PATCH] mem leak fixes for AMD 5536 UDC high/full speed USB device controller driver Jesper Juhl
2008-03-26 12:59 ` Thomas Dahlmann

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