[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <Pine.LNX.4.44L0.1201091202090.1541-100000@iolanthe.rowland.org>
Date: Mon, 9 Jan 2012 12:35:09 -0500 (EST)
From: Alan Stern <stern@...land.harvard.edu>
To: Joerg Roedel <joerg.roedel@....com>,
Konrad Rzeszutek Wilk <konrad.wilk@...cle.com>,
Martin Schwidefsky <schwidefsky@...ibm.com>,
Michael Buesch <m@...s.ch>
cc: Dmitry Torokhov <dmitry.torokhov@...il.com>,
Kernel development list <linux-kernel@...r.kernel.org>
Subject: Incorrect uses of get_driver()/put_driver()
The get_driver() and put_driver() routines in the device core are not
documented well, and what they really do is quite different from what
people might think they do. In particular, get_driver() does not
prevent a driver from being unregistered or unloaded -- the API which
comes closest to doing that is try_module_get().
In fact, get_driver() and put_driver() are pretty much useless for
normal purposes, and Dmitry and I have been discussing getting rid of
them entirely. But first we need to make sure that doing so won't mess
anything up.
The purpose of this email is to check with the maintainers of the
various drivers that seem to be using these routines in questionable
ways, to make sure nothing will go wrong. Here are the places we have
identified:
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.
drivers/s390/cio/device.c:1681: drv = get_driver(&cdrv->driver);
drivers/s390/cio/device.c:1687: put_driver(drv);
Martin, these calls seem to be useless. The calls in ccwgroup.c are
definitely useless; there's no reason to take a reference to a driver
while it's being unregistered, since it can't go away until the
unregistration is finished.
drivers/ssb/main.c:146: get_driver(&drv->drv);
drivers/ssb/main.c:153: put_driver(&drv->drv);
Michael, these are part of ssb_driver_get() and ssb_driver_put(), used
in ssb_devices_freeze() and ssb_devices_thaw(). They don't currently
do anything, but it looks as if they are meant to prevent the driver
from being unloaded. Should they be replaced with try_module_get()?
Or would it be good enough to call device_attach() in
ssb_devices_thaw()?
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