Re: Problems with get_driver() and driver_attach() (and new_id too)

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, 9 Jan 2012, Dmitry Torokhov wrote:

> > I don't think any of those calls actually accomplish anything, but it's
> > hard to be certain.  Some of them appear to be futile attempts to
> > prevent the driver from being unregistered or unloaded, others are
> > there simply to drop the reference taken by driver_find().
> > 
> > In a few of them it's obvious that the driver can't be unregistered 
> > while the critical section runs, but in the others I can't tell.  On 
> > the other hand, if a critical section can race with unregistration 
> > then the code is buggy now.
> > 
> > What do you think?
> 
> I think we need to audit them and decide on case-by-case basis. For
> example drivers/s390/cio/device.c is completely nonsensical: it takes a
> reference on a driver that is passed as argument before calling
> driver_find_device(). But if passed driver was valid before we called
> get_driver it won't become any more valid afterwards and it should not
> disappear either.
> 
> drivers/s390/cio/ccwgroup.c - calls are useless;
> 
> Authors of drivers/net/phy/phy_device.c had their reservations:
> 
>         /* Make sure the driver is held.
>          * XXX -- Is this correct? */
>         drv = get_driver(phydev->dev.driver);
> 
> However it is in phydev_probe() and I hope our device core takes care of
> not destroying drivers in the middle of binding to a device.

Yes, it does.  That one looks like a misunderstanding.  It calls
get_driver during phy_probe and put_driver during phy_remove, which
accomplishes nothing.

> drivers/ssb/main.c seems like needs some protection but does it
> incorrectly as we do not wait for drivers to drop all references before
> unloading modules.

Possibly it needs to be replaced with try_module_get.  I'll send out an 
email to the maintainers of these drivers to see what they think.

Alan Stern

--
To unsubscribe from this list: send the line "unsubscribe linux-usb" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Media]     [Linux Input]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Old Linux USB Devel Archive]

  Powered by Linux