Re: [PATCH] driver core: faux: fix root device registration
From: Johan Hovold
Date: Fri Apr 24 2026 - 10:03:59 EST
On Fri, Apr 24, 2026 at 01:42:12PM +0200, Danilo Krummrich wrote:
> On Fri Apr 24, 2026 at 12:22 PM CEST, Johan Hovold wrote:
> > diff --git a/drivers/base/faux.c b/drivers/base/faux.c
> > index fb3e42f21362..402ed119dfdf 100644
> > --- a/drivers/base/faux.c
> > +++ b/drivers/base/faux.c
> > @@ -133,6 +133,9 @@ struct faux_device *faux_device_create_with_groups(const char *name,
> > struct device *dev;
> > int ret;
> >
> > + if (IS_ERR_OR_NULL(faux_bus_root))
> > + return NULL;
>
> As Greg mentioned, if this happens we already have a much bigger fundamental
> problem earlier in the boot process.
>
> Anyway, I think this check only catches when root_device_register() fails, but
> everything that comes after root_device_register() in faux_bus_init() still
> leaves us with a dangling pointer.
Indeed. I cleared the pointer in an earlier draft for this reason, but
got side tracked and later found the change too invasive for something
that would never happen in practise and somehow convinced myself that
this check would do.
I'll respin.
Johan