RE: [Bug Report] Potential Deadlock Bug in drivers/spi/spidev.c, between spidev_ioctl() and spidev_write()
From: Pei Xiao
Date: Thu Apr 23 2026 - 02:23:40 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.
this commit have fix this bug.
commit 40534d19ed2afb880ecf202dab26a8e7a5808d16
Author: Fabian Godehardt <fg@xxxxxxxxx>
Date: Wed Feb 11 08:26:16 2026 +0100
spi: spidev: fix lock inversion between spi_lock and buf_lock
Thanks!
Pei.
> Please check at your convenience. Thank you for your time and consideration.
>
> Best regards,
> Ginger