[Bug Report] Potential Deadlock Bug in drivers/spi/spidev.c, between spidev_ioctl() and spidev_write()

From: Ginger

Date: Thu Apr 23 2026 - 00:42:26 EST


Dear Linux kernel maintainers,

Sorry that my previous emails were not sent in plain text modes. I
sincerely apologize for any inconvenience caused.

My research-based static analyzer found a potential deadlock bug
within the 'drivers/spi' subsystem.

Kernel version: long-term kernel v6.18.9
git commit: adb851edb70783e3ded28044491f5a3ed065b7b2 of branch 6.18.y

The potential concurrent triggering executions:
T0:
spidev_ioctl
--> mutex_lock(&spidev->spi_lock); [t0]
--> mutex_lock(&spidev->buf_lock); [t2]
T1:
spidev_write
--> mutex_lock(&spidev->buf_lock); [t1]
--> spidev_sync_write
--> spidev_sync
--> mutex_lock(&spidev->spi_lock); [t3]

The circular dependency may occur between 'spidev->spi_lock' and
'spidev->buf_lock' via t0 -> t1 -> t2 -> t3, causing system hang.

Please check at your convenience. Thank you for your time and consideration.

Best regards,
Ginger