Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference

From: Sudip Mukherjee
Date: Fri Sep 11 2015 - 10:21:17 EST


On Fri, Sep 11, 2015 at 08:28:34AM -0500, Felipe Balbi wrote:
> Hi,
>
> On Fri, Sep 11, 2015 at 03:32:56PM +0530, Sudip Mukherjee wrote:
> > On Thu, Sep 10, 2015 at 11:03:34AM -0700, David Cohen wrote:
<snip>
> no, the check is pointless. Most of these are. Just look at your probe()
> and you'll see that if dev->virt_addr is NULL (meaning ioremap_nocache()
> failed) you exit from probe() with error. The driver doesn't probe at
> all. So you can be sure that by remove, dev->regs is valid.
>
> BTW, if probe fails, you have a TON of leaked resources!! You don't kfree()
> dev, you don't pci_disable_device(), you don't release_mem_region(), you
> don't iounmap() virt_addr, you don't free_irq().
>
> Also the iounmap() call in remove is wrong. You ioremapped
> dev->virt_addr but iounmap() dev->regs. Are you SURE that's ok ?
>
> Man, what a mess! You gotta fix that up.
:(
Yes, total mess. I am on it.
BTW, while I am fixing it can i also include a patch which will
rearrange the functions and remove the forward declarations?

regards
sudip
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/