Re: [PATCH] kobject: fix kobj and fmt are both null

From: Andy Shevchenko
Date: Mon Sep 04 2023 - 05:45:09 EST


On Sun, Sep 03, 2023 at 02:54:53PM +0200, Greg KH wrote:
> On Sun, Sep 03, 2023 at 08:42:31PM +0800, Edward AD wrote:
> > If kobj and fmt are both NULL, it will cause an exception in kvasprintf_const,
> > then when this situation occurs, -EINVAL is directly returned.
>
> How can this happen? Are there any in-kernel users that cause this to
> occur?

Theoretically anything which uses

dev_set_name(dev, dev_name(dev));

is affected, but practically it happens only when _previous_ dev_set_name()
fails, which _only_ may happen due to fault injection.

> If so, which ones, why not fix that?

In any case the real fix is here:
https://lore.kernel.org/all/20230828145824.3895288-1-andriy.shevchenko@xxxxxxxxxxxxxxx/

> And your description isn't quite correct here, you are not checking for
> kobj, but rather kobj->name.

--
With Best Regards,
Andy Shevchenko