Re: [Bug Report] Potential Deadlock Bug in drivers/spi/spidev.c, between spidev_ioctl() and spidev_write()
From: Ginger
Date: Thu Apr 23 2026 - 02:49:03 EST
On Thu, Apr 23, 2026 at 2:23 PM Pei Xiao <xiaopei01@xxxxxxxxxx> wrote:
>
> > 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.
Oops, thank you for pointing it out! Sorry I missed the commit before
and filed a fixed bug report. Again, thank you for your time!
> > Please check at your convenience. Thank you for your time and consideration.
> >
> > Best regards,
> > Ginger