Messages in this thread | | | Date | Mon, 9 Jan 2012 14:36:33 -0500 (EST) | From | Alan Stern <> | Subject | Re: 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
| |