Re: [PATCH] usb: roles: try to get/put all relevant modules

Greg KH
2024-01-12T08:24:13Z

On Fri, Jan 12, 2024 at 04:01:08PM +0800, Xu Yang wrote:
> +void usb_role_switch_get_modules(struct device *dev)
> +{
> + while (dev) {
> + if (dev->driver)
> + WARN_ON(!try_module_get(dev->driver->owner));

You just crashed all systems that have panic-on-warn enabled, which is
by far (i.e. in the billions) the huge majority of Linux systems in the
world.

If this is something that can fail, then properly handle the issue,
don't just give up and say "let's fill the kernel log with a mess and
reboot the box!".

Also, are you SURE that module owners are what you want to track here?
That's not usually the real solution for things like this, remember
module reference counts deal with code, but the driver model deals with
data...

thanks,

greg k-h