Re: [PATCH] PCI: Init driver override spinlock in new_id_store()
From: Danilo Krummrich
Date: Mon Apr 27 2026 - 15:46:34 EST
On Mon Apr 27, 2026 at 9:31 PM CEST, Samiullah Khawaja wrote:
> Fixes: cb3d1049f4ea ("driver core: generalize driver_override in struct device")
I don't think anything is wrong with this commit, and it seems unrelated.
> Fixes: 10a4206a2401 ("PCI: use generic driver_override infrastructure")
I'm also not sure that this one contains the root cause, despite revealing the
actual issue, more below.
> Signed-off-by: Samiullah Khawaja <skhawaja@xxxxxxxxxx>
> ---
> drivers/pci/pci-driver.c | 5 +++++
> 1 file changed, 5 insertions(+)
>
> diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
> index d10ece0889f0..5f453213b8c5 100644
> --- a/drivers/pci/pci-driver.c
> +++ b/drivers/pci/pci-driver.c
> @@ -215,6 +215,11 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf,
> pdev->subsystem_device = subdevice;
> pdev->class = class;
>
> + /*
> + * Initialize the embedded struct device driver_override lock to
> + * avoid the lockdep errors.
> + */
> + spin_lock_init(&pdev->dev.driver_override.lock);
Can't we just call device_initialize() and set pdev->dev.release to a new
function that just calls kfree()?
This way nothing of that kind can ever happen again; it is hard to predict that
a device is used without ever being initialized.
> if (pci_match_device(pdrv, pdev))
> retval = -EEXIST;
>
>
> base-commit: 254f49634ee16a731174d2ae34bc50bd5f45e731
> --
> 2.54.0.545.g6539524ca2-goog