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

From: Felipe Balbi
Date: Fri Sep 11 2015 - 11:05:54 EST


On Fri, Sep 11, 2015 at 07:51:01PM +0530, Sudip Mukherjee wrote:
> 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?

sure, just make sure fixes and cleanups are separate. First all fixes,
then cleanups and reorderings.

cheers

--
balbi

Attachment: signature.asc
Description: Digital signature