pcistub_init_device() resets the device through pcistub_reset_device_state(), which calls __pci_reset_function_locked(). That function requires the device lock, and since commit f06e0ad226fd ("PCI: Use device_lock_assert() to verify device lock is held") it asserts it. When the driver is probed for a device after initialization, as for a device bound through sysfs, pcistub_seize() runs pcistub_init_device() from ->probe(), so the driver core holds the lock. Devices that are seized while the driver registers, such as those listed in xen-pciback.hide=, are initialized later by pcistub_init_devices_late(), which does not take the lock. A dom0 kernel with lockdep warns once for each such device at boot, and the reset is not serialized against other users of the device lock. Take the device lock around pcistub_init_device() in pcistub_init_devices_late(), so it runs in the same context as on the probe path. The missing lock was found by a static check that turns the locking rule in a function's comment into a Clang context-analysis requirement on its callers. Compile tested only. Fixes: cd9db80e5257 ("xen/pciback: Support pci_reset_function, aka FLR or D3 support.") Cc: stable@vger.kernel.org Signed-off-by: Praneeth Balasubramanian --- Notes: This was found by a compiler-based check, part of research at UCSB SecLab. The locking rule stated in the kernel-doc comment of the called function was turned into a Clang context-analysis requirement (__must_hold) on that function, and Clang 23 with CONFIG_WARN_CONTEXT_ANALYSIS then checked every caller. An LLM was used only to turn the comment into a machine-readable rule; the report itself comes from the compiler. The patch and changelog were drafted with Claude Opus 5.5. I reviewed the patch and take responsibility for it. Testing: builds without new warnings with W=1 (x86_64, clang 23, allmodconfig). Not runtime-tested, and I have not observed the race myself. drivers/xen/xen-pciback/pci_stub.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/xen/xen-pciback/pci_stub.c b/drivers/xen/xen-pciback/pci_stub.c index d1a335233aab..9eba7a982300 100644 --- a/drivers/xen/xen-pciback/pci_stub.c +++ b/drivers/xen/xen-pciback/pci_stub.c @@ -508,7 +508,9 @@ static int __init pcistub_init_devices_late(void) spin_unlock_irqrestore(&pcistub_devices_lock, flags); + device_lock(&psdev->dev->dev); err = pcistub_init_device(psdev); + device_unlock(&psdev->dev->dev); if (err) { dev_err(&psdev->dev->dev, "error %d initializing device\n", err); -- 2.25.1