[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1201091426460.1541-100000@iolanthe.rowland.org>
Date: Mon, 9 Jan 2012 14:36:33 -0500 (EST)
From: Alan Stern <stern@...land.harvard.edu>
To: Dmitry Torokhov <dmitry.torokhov@...il.com>
cc: Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Joerg Roedel <joerg.roedel@....com>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Michael Buesch <m@...s.ch>,
Kernel development list <linux-kernel@...r.kernel.org>
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
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists