Re: [RFC PATCH] driver core: Don't link the device to the bus until we're ready to probe

From: Greg Kroah-Hartman

Date: Sat Mar 21 2026 - 01:42:14 EST


On Fri, Mar 20, 2026 at 08:06:58PM -0700, Douglas Anderson wrote:
> The moment we link a "struct device" into the list of devices for the
> bus, it's possible probe can happen. This is because another thread
> can load the driver at any time and that can cause the device to
> probe. This has been seen in practice with a stack crawl that looks
> like this [1]:
>
> really_probe()
> __driver_probe_device()
> driver_probe_device()
> __driver_attach()
> bus_for_each_dev()
> driver_attach()
> bus_add_driver()
> driver_register()
> __platform_driver_register()
> init_module() [some module]
> do_one_initcall()
> do_init_module()
> load_module()
> __arm64_sys_finit_module()
> invoke_syscall()

Are you sure this isn't just a platform bus issue? A bus should NOT be
allowing a driver to be added at the same time a device is being added
for that bus, ideally there should be a bus-specific lock somewhere for
this.

When a device is added to the bus, yes, a probe can happen, and is
expected to happen, for that device, so this feels odd.

that being said, your patch does seem sane, and I don't see anything
obviously wrong with it. But it feels odd that this is just now showing
up for something that has been this way for a few decades...

thanks,

greg k-h