[PATCH 1/2] mtd: spi-nor: Fix deadlock in spi_nor_rww_start_exclusive()
NG, TZE YEE
tze.yee.ng at altera.com
Mon Oct 5 19:13:43 PDT 2026
On 21/9/2026 2:58 pm, Michael Walle wrote:
> On Thu Sep 3, 2026 at 5:14 AM CEST, tze.yee.ng wrote:
>> From: Tze Yee Ng <tze.yee.ng at altera.com>
>>
>> spi_nor_rww_start_exclusive() takes nor->lock with a bare mutex_lock()
>> and returns with it held, while its counterpart
>> spi_nor_rww_end_exclusive() re-acquires nor->lock via guard(mutex). Any
>> exclusive operation on a read-while-write (SNOR_F_RWW) part thus
>> deadlocks against itself.
>>
>> The exclusive section is serialized by the rww ongoing_io/rd/pe flags,
>> so take nor->lock with guard(mutex) like the sibling start helpers.
>>
>> Fixes: 03e7bb864d9a9 ("mtd: spi-nor: use scope-based mutex cleanup helpers")
>> Cc: stable at vger.kernel.org
>> Signed-off-by: Tze Yee Ng <tze.yee.ng at altera.com>
>
> This was already fixed in:
> https://git.kernel.org/pub/scm/linux/kernel/git/mtd/linux.git/commit/?id=44b8a0bf5f96e8393312fc34b956766882341f16
>
> -michael
Thanks Michael, you're right. I missed that commit. I'll drop this patch
and resend the use-after-free fix (patch 2/2) standalone as v2.
Thanks,
Tze Yee
More information about the linux-mtd
mailing list