]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regmap: Fix race condition in hwspinlock irqsave routine
authorCheng-Yu Lee <cylee12@realtek.com>
Fri, 9 Jan 2026 03:26:33 +0000 (11:26 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Fri, 30 Jan 2026 09:27:35 +0000 (10:27 +0100)
commit24f31be6ad70537fd7706269d99c92cade465a09
tree3b0c44308152887cdca343d804cc6614e8768b2f
parent417cdfd9b9f986e95bfcb1d68eb443e6e0a15f8c
regmap: Fix race condition in hwspinlock irqsave routine

[ Upstream commit 4b58aac989c1e3fafb1c68a733811859df388250 ]

Previously, the address of the shared member '&map->spinlock_flags' was
passed directly to 'hwspin_lock_timeout_irqsave'. This creates a race
condition where multiple contexts contending for the lock could overwrite
the shared flags variable, potentially corrupting the state for the
current lock owner.

Fix this by using a local stack variable 'flags' to store the IRQ state
temporarily.

Fixes: 8698b9364710 ("regmap: Add hardware spinlock support")
Signed-off-by: Cheng-Yu Lee <cylee12@realtek.com>
Co-developed-by: Yu-Chun Lin <eleanor.lin@realtek.com>
Signed-off-by: Yu-Chun Lin <eleanor.lin@realtek.com>
Link: https://patch.msgid.link/20260109032633.8732-1-eleanor.lin@realtek.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/base/regmap/regmap.c