Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > linux.kernel > #1222676
| From | Sudip Mukherjee <sudipm.mukherjee@gmail.com> |
|---|---|
| Newsgroups | linux.kernel |
| Subject | Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference |
| Date | 2015-09-11 12:10 +0200 |
| Message-ID | <q7trj-6Qv-9@gated-at.bofh.it> (permalink) |
| References | <q4XFg-Zz-5@gated-at.bofh.it> <q7esi-Fm-5@gated-at.bofh.it> |
| Organization | linux.* mail to news gateway |
On Thu, Sep 10, 2015 at 11:03:34AM -0700, David Cohen wrote: > Hi Sudip, > > On Fri, Sep 04, 2015 at 05:12:23PM +0530, Sudip Mukherjee wrote: > > We were checking if dev->regs is NULL but it was done after > > dereferencing it. Lets reset the controller and iounmap dev->regs only > > if it is not NULL. > > free_irq() does not need dev->regs, so unmaping it before freeing the > > irq should not matter. > > > > Signed-off-by: Sudip Mukherjee <sudip@vectorindia.org> > > --- > > drivers/usb/gadget/udc/amd5536udc.c | 7 ++++--- > > 1 file changed, 4 insertions(+), 3 deletions(-) > > > > diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c > > index fdacddb..26066d3 100644 > > --- a/drivers/usb/gadget/udc/amd5536udc.c > > +++ b/drivers/usb/gadget/udc/amd5536udc.c > > @@ -3135,11 +3135,12 @@ static void udc_pci_remove(struct pci_dev *pdev) <snip> > > I'm not familiar with the driver, but you're iounmap'ing before freeing > irq. Looks fishy to me. Well, I thought you will be able to give me some idea about how fix it. :) Then I guess we should be on the safe side and what about the following: diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index fdacddb..82f36f6 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -3134,8 +3134,9 @@ static void udc_pci_remove(struct pci_dev *pdev) pci_pool_destroy(dev->stp_requests); } - /* reset controller */ - writel(AMD_BIT(UDC_DEVCFG_SOFTRESET), &dev->regs->cfg); + if (dev->regs) + /* reset controller */ + writel(AMD_BIT(UDC_DEVCFG_SOFTRESET), &dev->regs->cfg); if (dev->irq_registered) free_irq(pdev->irq, dev); if (dev->regs) And just for my information: for a device what might happen if I iounmap before I free the irq? One thing I can think of is that after iounmap just at that moment one interrupt comes and the driver tries to access the io memory while servicing the irq. regards sudip -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/
Back to linux.kernel | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference David Cohen <david.a.cohen@linux.intel.com> - 2015-09-10 20:10 +0200
Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-11 12:10 +0200
Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference Felipe Balbi <balbi@ti.com> - 2015-09-11 15:30 +0200
Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference Sudip Mukherjee <sudipm.mukherjee@gmail.com> - 2015-09-11 16:30 +0200
Re: [PATCH] usb: gadget: amd5536udc: fix NULL pointer dereference Felipe Balbi <balbi@ti.com> - 2015-09-11 17:10 +0200
csiph-web