lkml.org 
[lkml]   [2012]   [Jan]   [9]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: Incorrect uses of get_driver()/put_driver()
On Mon, 9 Jan 2012, Dmitry Torokhov wrote:

> > > > > lib/dma-debug.c:173: drv = get_driver(dev->driver);
> > > > > lib/dma-debug.c:188: put_driver(drv);
> > > > >
> > > > > Joerg, these calls don't seem to do anything, as far as I can tell.
> > > > > Is there any reason to keep them?
> > > > >
> > > > > drivers/pci/xen-pcifront.c:596: if (get_driver(&pdrv->driver)) {
> > > > > drivers/pci/xen-pcifront.c:626: put_driver(&pdrv->driver);
> > > > >
> > > > > Konrad, these calls don't seem to do anything either.
> > > > >
> > > >
> > > > Looks like they should be replaced with the try_module_get() equivalant
> > > > for the 'struct pci_driver'? Is there such one?
> > >
> > > You seem to need stronger guarantees that the driver simply present in
> > > memory. You need to make sure that the driver you fetched is kept being
> > > bound to the device for entire duration of pcifront_common_process().
> >
> > OK, any suggestions?
>
> Nothing canned I'm afraid...

device_lock(&pcidev->dev) will block unbinding. If you take the lock
before looking at pcidev->driver, it should be okay.

The drawback is that pdrv->error_handler may end up doing something
that takes the same lock. If you can verify that won't happen, there
won't be any problem.

Alan Stern



\
 
 \ /
  Last update: 2012-01-09 20:39    [W:0.333 / U:0.136 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site