Re: PCI driver module unload race?

Patrick Mochel
2003-03-11T15:21:01Z

> > > I think it's not easy. I haven't studied the code completely yet, but
> > > e.g. when you attach a device to a driver you also have to get a
> > > reference to the driver.
> >
> > You get a link to the driver, but you can't increment the module count
> > of the driver at that time, as we have to be able to remove a module
> > somehow :)
>
> That is simple. Export a generic way to disconnect a driver from a device.

It's not that easy - Linux has always supported the operation of being
able to remove a module while it is attached to devices. The reference
count only goes up if a device is opened.

This means the module refcount must remain at 0, even after it's bound to
devices. Changing this would require a change in visible behavior, and
require an extra step by a user to disconnect the driver before they
unload the module.

-pat