Re: [PATCH] PCI: Handle dev_set_name() failure in pci_setup_device()

From: Rihyeon Kim

Date: Sun Jul 26 2026 - 05:34:02 EST


Hello,

Thanks a lot for the review.

> The kernel-doc for pci_setup_device() will probably need to be updated to
> reflect changes in what the function returns on failure, since now you have
> the -EIO and also -ENOMEM, potentially.

Good point, I missed that. Updated in v2.

> Probably:
>
> Fixes: 1fa5ae857bb1 ("driver core: get rid of struct device's bus_id string array")
>
> The commit you have references a state of the code, a much older code base,
> where the implementation was fundamentally different, per:

You are right, thanks. I had missed that dev_set_name() could not fail at
all back then, and that the commit I picked was only replacing an snprintf()
into the same fixed array. Both patches in v2 use 1fa5ae857bb1 now, and the
commit log says kvasprintf_const().

> The fix there is valid and would be nice to also pick it up. Might use
> a little...
>
> dev->dev.kobj.name = NULL;
>
> After the kfree_const().
>
> Feel free to pick it up, and include here as a second patch, so a small
> series. Don't forget to credit Yang Yingliang, if you do decide to
> follow-up.

Thanks for the suggestion. It is patch 2/2 in v2, with the NULL assignment
as you described, and with Suggested-by: and a Link: to Yang Yingliang's
original posting.

> This one I am not sure. The NULL-assignment move looks awkward there.

Agreed, I left pci_device_add() alone. It also overlaps with the driver
core series that changes when device_add() frees dev->p [1], so I would
rather wait and see how that one settles before proposing anything there.
If it still looks worth doing afterwards, I can revisit it then.

[1] https://lore.kernel.org/all/20260716230411.2767394-2-tarunsahu@xxxxxxxxxx/

Thanks again,
Rihyeon