Re: [PATCH] driver core: reject devices with unregistered buses

Johan Hovold
2026-04-29T16:00:10Z

On Wed, Apr 29, 2026 at 05:29:02PM +0200, Danilo Krummrich wrote:
> On Wed Apr 29, 2026 at 5:08 PM CEST, Johan Hovold wrote:
> > No, I'm saying that it's a bug in driver core to silently treat a device
> > that is registered before its bus as a bus-less device.
>
> This is an argument that I can buy into, but in the previous discussion (and in
> the commit message) the whole motivation evolved around "reject devices with
> unregistered buses to catch any callers that get the ordering wrong", i.e. catch
> other people's bugs.
>
> What you are raising now is "the driver core is conflating no bus with
> unregistered bus handling". However, the commit message does not reflect that at
> all.

The commit message already explains the issue:

Trying to register a device on a bus which has not yet been
registered used to trigger a NULL-pointer dereference, but since
the const bus structure rework registration instead succeeds
without the device being added to the bus.

namely that

registration [...] succeeds [but] without the device being
added to the bus.

> Can you please adjust the commit message accordingly?

Perhaps I can add "(i.e. as if it were a bus-less device)" to stress it
more but I'm not sure it's needed.

Johan