diff options
author | Jesper Juhl <jesper.juhl@gmail.com> | 2008-03-28 17:50:27 -0400 |
---|---|---|
committer | Greg Kroah-Hartman <gregkh@suse.de> | 2008-04-25 00:16:47 -0400 |
commit | 73d79aaba9ee21aaa1a6676f568ef7b3bdf993ea (patch) | |
tree | 13ac17bdca5816cc7b7c5124823905be1139f35f /drivers/usb/gadget | |
parent | 148d9fe4c91a6356dae1b05b76b8133586c26be4 (diff) |
USB: mem leak fixes for AMD 5536 UDC high/full speed USB device controller 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>
Diffstat (limited to 'drivers/usb/gadget')
-rw-r--r-- | drivers/usb/gadget/amd5536udc.c | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/drivers/usb/gadget/amd5536udc.c b/drivers/usb/gadget/amd5536udc.c index b663f23f2642..fc6f3483be44 100644 --- a/drivers/usb/gadget/amd5536udc.c +++ b/drivers/usb/gadget/amd5536udc.c | |||
@@ -3248,6 +3248,8 @@ static int udc_pci_probe( | |||
3248 | 3248 | ||
3249 | /* pci setup */ | 3249 | /* pci setup */ |
3250 | if (pci_enable_device(pdev) < 0) { | 3250 | if (pci_enable_device(pdev) < 0) { |
3251 | kfree(dev); | ||
3252 | dev = 0; | ||
3251 | retval = -ENODEV; | 3253 | retval = -ENODEV; |
3252 | goto finished; | 3254 | goto finished; |
3253 | } | 3255 | } |
@@ -3259,6 +3261,8 @@ static int udc_pci_probe( | |||
3259 | 3261 | ||
3260 | if (!request_mem_region(resource, len, name)) { | 3262 | if (!request_mem_region(resource, len, name)) { |
3261 | dev_dbg(&pdev->dev, "pci device used already\n"); | 3263 | dev_dbg(&pdev->dev, "pci device used already\n"); |
3264 | kfree(dev); | ||
3265 | dev = 0; | ||
3262 | retval = -EBUSY; | 3266 | retval = -EBUSY; |
3263 | goto finished; | 3267 | goto finished; |
3264 | } | 3268 | } |
@@ -3267,18 +3271,24 @@ static int udc_pci_probe( | |||
3267 | dev->virt_addr = ioremap_nocache(resource, len); | 3271 | dev->virt_addr = ioremap_nocache(resource, len); |
3268 | if (dev->virt_addr == NULL) { | 3272 | if (dev->virt_addr == NULL) { |
3269 | dev_dbg(&pdev->dev, "start address cannot be mapped\n"); | 3273 | dev_dbg(&pdev->dev, "start address cannot be mapped\n"); |
3274 | kfree(dev); | ||
3275 | dev = 0; | ||
3270 | retval = -EFAULT; | 3276 | retval = -EFAULT; |
3271 | goto finished; | 3277 | goto finished; |
3272 | } | 3278 | } |
3273 | 3279 | ||
3274 | if (!pdev->irq) { | 3280 | if (!pdev->irq) { |
3275 | dev_err(&dev->pdev->dev, "irq not set\n"); | 3281 | dev_err(&dev->pdev->dev, "irq not set\n"); |
3282 | kfree(dev); | ||
3283 | dev = 0; | ||
3276 | retval = -ENODEV; | 3284 | retval = -ENODEV; |
3277 | goto finished; | 3285 | goto finished; |
3278 | } | 3286 | } |
3279 | 3287 | ||
3280 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { | 3288 | if (request_irq(pdev->irq, udc_irq, IRQF_SHARED, name, dev) != 0) { |
3281 | dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); | 3289 | dev_dbg(&dev->pdev->dev, "request_irq(%d) fail\n", pdev->irq); |
3290 | kfree(dev); | ||
3291 | dev = 0; | ||
3282 | retval = -EBUSY; | 3292 | retval = -EBUSY; |
3283 | goto finished; | 3293 | goto finished; |
3284 | } | 3294 | } |