Skip to content

Commit

Permalink
USB: mem leak fixes for AMD 5536 UDC high/full speed USB device contr…
Browse files Browse the repository at this point in the history
…oller driver

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.

Signed-off-by: Jesper Juhl <jesper.juhl@gmail.com>
Cc: David Brownell <dbrownell@users.sourceforge.net>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
  • Loading branch information
Jesper Juhl authored and Greg Kroah-Hartman committed Apr 25, 2008
1 parent 148d9fe commit 73d79aa
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions drivers/usb/gadget/amd5536udc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
Expand All @@ -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;
}
Expand All @@ -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;
}
Expand Down

0 comments on commit 73d79aa

Please sign in to comment.