Conceptual bug on SoundWire probe/remove?

Takashi Iwai tiwai at suse.de
Thu Mar 24 11:17:21 CET 2022


On Thu, 24 Mar 2022 11:12:34 +0100,
Srinivas Kandagatla wrote:
> 
> 
> 
> On 23/03/2022 19:45, Pierre-Louis Bossart wrote:
> > Hi,
> > I could use feedback/guidance on a possible conceptual bug in the
> > SoundWire probe and bus handling.
> >
> > When we probe a driver, the code does this:
> >
> > static int sdw_drv_probe(struct device *dev)
> > {
> >      struct sdw_slave *slave = dev_to_sdw_dev(dev);
> >      struct sdw_driver *drv = drv_to_sdw_driver(dev->driver);
> >      const struct sdw_device_id *id;
> >      const char *name;
> >      int ret;
> >
> >      /*
> >       * fw description is mandatory to bind
> >       */
> >      if (!dev->fwnode)
> >          return -ENODEV;
> >
> >      if (!IS_ENABLED(CONFIG_ACPI) && !dev->of_node)
> >          return -ENODEV;
> >
> >      id = sdw_get_device_id(slave, drv);
> >      if (!id)
> >          return -ENODEV;
> >
> >      slave->ops = drv->ops;
> 
> may be add try_module_get(dev->driver->owner) here, which should
> prevent the module from unloading in the first place.

The module refcount helps only partially, unfortunately.
The unbindig via sysfs is still allowed and it hits the very same
problem.


Takashi


More information about the Alsa-devel mailing list