linux/drivers/pci
Samiullah Khawaja f45a49a238 PCI: Initialize temporary device in new_id_store()
When setting new_id of a PCI device driver using sysfs a lockdep splat
occurs. This is because new_id_store() builds a temporary pci_dev for
pci_match_device(), which calls device_match_driver_override().  That
depends on the driver_override.lock added by cb3d1049f4 ("driver core:
generalize driver_override in struct device").

The new driver_override.lock was not initialized in the temporary pci_dev,
resulting in this lockdep splat.

Initialize the temporary pci_dev to fix this.

Repro:

  Build with CONFIG_LOCKDEP=y, boot with QEMU, and add a new ID:

  # echo "8086 10f5" > /sys/bus/pci/drivers/e1000e/new_id

  INFO: trying to register non-static key.
  The code is fine but needs lockdep annotation, or maybe
  you didn't initialize this object before use?
  turning off the locking correctness validator.
  CPU: 2 UID: 0 PID: 177 Comm: liveupdate-iomm Not tainted 7.0.0+ #9 PREEMPT(full)
  Hardware name: QEMU Standard PC (Q35 + ICH9, 2009), BIOS rel-1.16.3-0-ga6ed6b701f0a-prebuilt.qemu.org 04/01/2014
  Call Trace:
   <TASK>
   dump_stack_lvl+0x5d/0x80
   register_lock_class+0x77e/0x790
   lock_acquire+0xbf/0x2e0
   pci_match_device+0x24/0x180
   new_id_store+0x189/0x1d0
   kernfs_fop_write_iter+0x14f/0x210
   vfs_write+0x263/0x5e0
   ksys_write+0x79/0xf0
   do_syscall_64+0x117/0xf80

Fixes: 10a4206a24 ("PCI: use generic driver_override infrastructure")
Fixes: 8895d3bcb8 ("PCI: Fail new_id for vendor/device values already built into driver")
Signed-off-by: Samiullah Khawaja <skhawaja@google.com>
[bhelgaas: add commit log details and repro, trim backtrace]
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
Reviewed-by: Danilo Krummrich <dakr@kernel.org>
Link: https://patch.msgid.link/20260505234327.716630-1-skhawaja@google.com
2026-05-08 15:50:06 -05:00
..
controller LoongArch changes for v7.1 2026-04-24 09:54:45 -07:00
endpoint pci-v7.1-changes 2026-04-15 14:41:21 -07:00
hotplug Merge branch 'pci/reset' 2026-04-13 12:50:05 -05:00
msi PCI/MSI: Add TODO comment about legacy pcim_enable_device() side-effect 2026-02-23 09:01:20 -06:00
pcie Merge branch 'pci/ptm' 2026-04-13 12:50:04 -05:00
pwrctrl pci-v7.1-changes 2026-04-15 14:41:21 -07:00
switch Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
access.c PCI: Revert the cfg_access_lock lockdep mechanism 2024-06-04 12:10:05 -05:00
ats.c iommufd: Extend IOMMU_GET_HW_INFO to report PASID capability 2025-03-28 10:07:23 -03:00
bus.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
devres.c PCI: Remove useless WARN_ON() from devres 2026-01-14 11:00:00 -06:00
doe.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
ecam.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
host-bridge.c PCI: Export pci_get_host_bridge_device() for use by pci-keystone 2025-11-13 12:20:46 -06:00
ide.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
iomap.c PCI: Remove hybrid-devres usage warnings from kernel-doc 2025-05-20 07:39:16 +00:00
iov.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
irq.c
Kconfig PCI: Clean up dead code in Kconfig 2026-03-30 17:21:46 -05:00
Makefile Merge branch 'pci/trace' 2026-02-06 17:09:26 -06:00
mmap.c
npem.c PCI/NPEM: Set LED_HW_PLUGGABLE for hotplug-capable ports 2026-04-06 12:34:28 -05:00
of_property.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
of.c Merge branch 'pci/misc' 2026-04-13 12:50:54 -05:00
p2pdma.c PCI/P2PDMA: Add Google SoCs to the P2P DMA host bridge list 2026-04-10 17:27:39 -05:00
pci-acpi.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
pci-bridge-emul.c PCI: Rename CRS Completion Status to RRS 2024-09-10 19:52:30 -05:00
pci-bridge-emul.h
pci-driver.c PCI: Initialize temporary device in new_id_store() 2026-05-08 15:50:06 -05:00
pci-label.c
pci-mid.c PCI/PM: Switch to new Intel CPU model defines 2024-06-11 17:08:14 -05:00
pci-pf-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-stub.c PCI: Add missing MODULE_DESCRIPTION() macros 2024-07-08 08:35:35 +00:00
pci-sysfs.c pci-v7.1-changes 2026-04-15 14:41:21 -07:00
pci.c PCI: Don't fallback to bus reset after failed slot reset 2026-04-27 17:26:59 -05:00
pci.h Merge branch 'pci/controller/max-link-speed' 2026-04-13 12:50:07 -05:00
probe.c pci-v7.1-changes 2026-04-15 14:41:21 -07:00
proc.c Convert 'alloc_obj' family to use the new default GFP_KERNEL argument 2026-02-21 17:09:51 -08:00
quirks.c PCMCIA fixes and cleanups for v7.1 2026-04-23 11:22:16 -07:00
rebar.c PCI: Fix Resizable BAR restore order 2026-01-22 10:29:55 -06:00
remove.c PCI/pwrctrl: Switch to pwrctrl create, power on/off, destroy APIs 2026-01-16 13:23:38 -06:00
rom.c
search.c PCI: Add PCI_BRIDGE_NO_ALIAS quirk for ASPEED AST1150 2026-01-13 11:46:33 -06:00
setup-bus.c PCI: Fix alignment calculation for resource size larger than align 2026-03-27 10:19:08 -05:00
setup-cardbus.c PCI: Move CardBus bridge scanning to setup-cardbus.c 2026-01-27 16:36:53 -06:00
setup-res.c PCI: Update saved_config_space upon resource assignment 2026-05-08 15:50:06 -05:00
slot.c s390 updates for 7.1 merge window 2026-04-22 11:13:45 -07:00
syscall.c
tph.c pci-v7.1-changes 2026-04-15 14:41:21 -07:00
trace.c PCI: trace: Add PCI controller tracepoint feature 2026-04-07 20:12:16 +05:30
tsm.c PCI/TSM: Add 'dsm' and 'bound' attributes for dependent functions 2025-11-14 15:06:57 -08:00
vc.c
vgaarb.c PCI/VGA: Pass errors from pci_set_vga_state() up 2026-03-25 13:28:49 -05:00
vpd.c sysfs: treewide: switch back to attribute_group::bin_attrs 2025-06-17 10:44:15 +02:00
xen-pcifront.c xen: branch for v7.0-rc3 2026-03-07 07:44:32 -08:00