From nobody Sun Feb 8 08:48:42 2026 Received: from rtits2.realtek.com.tw (rtits2.realtek.com [211.75.126.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0FF9226AC3 for ; Tue, 6 Jan 2026 02:15:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=211.75.126.72 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767665721; cv=none; b=Q58y10ODduEyCCCP4YIXWtc5llG0Q3adA23/eC9DHs9thxbE6RSEvh/38iGQnecDaM5o/3A2J4/kVuBssdYncc9cyD2P026pn/VXq7k1uxEehTwupG4M0Je67HfS+WA0/7vMwFwP/mDXMUlmyLxCKwd4GnaZVqQ5sKKK9uZa9Eo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1767665721; c=relaxed/simple; bh=qiLT+4pgWqjxGSnj3a6VAKP7fWGTa8Kbg24Y1nAdTwM=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version:Content-Type; b=QOwwxh3ch7dk61/WN7qRrQ1qT81VoePaIVMQlBdE0/HCZoN4r89aW3Psop3Z0VYdZEKTyIdi6YEBxBAsinHFNzc0GW0yncdzPu01zkeMaiIBJViP9xzVtGOoe5VjpimeYfHsvzE/kVMIVmqrcEtNkKLCw5Rtwinc/Ngkx+WScG0= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com; spf=pass smtp.mailfrom=realtek.com; dkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com header.b=HkBlMCmz; arc=none smtp.client-ip=211.75.126.72 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=realtek.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=realtek.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=realtek.com header.i=@realtek.com header.b="HkBlMCmz" X-SpamFilter-By: ArmorX SpamTrap 5.80 with qID 6062F1US04067113, This message is accepted by code: ctloc85258 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=realtek.com; s=dkim; t=1767665702; bh=HaAw4MM82keio2eCC2fGdmqheihsPpuEhBSKRVuhePk=; h=From:To:CC:Subject:Date:Message-ID:MIME-Version: Content-Transfer-Encoding:Content-Type; b=HkBlMCmz08YYYBJVPWsVile+VpmoAUkarNY9ra638cbAKM5kJz650dpk0lsDfgQxV QkrXqtREvu4ksZPZLWNav+UUcwNtRRHyJFjWKRTxGWxOW7M/ifJ3Sr+y7cbiy9x7Qs Oi9hEKfyHPFtX8BYhBBQqtqRxv4Hr3MnLw7MeoWnWB3Zddoa6swPUbfB2umnxJvfsG /5WoyppJT6mr88jJrPIme7gH5RF5lk8EQ0tNa1XWdfrGo85L1tr58pnSUfofUPckQO X6xGtPhc/DkrR2W0uGi5UH4HmUEWBsip7uWjaY6RoDXHcm/r3ME3UIdYn4YR1uyvdL UZDo5kV6vgffg== Received: from mail.realtek.com (rtkexhmbs02.realtek.com.tw[172.21.6.41]) by rtits2.realtek.com.tw (8.15.2/3.21/5.94) with ESMTPS id 6062F1US04067113 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 6 Jan 2026 10:15:01 +0800 Received: from RTKEXHMBS05.realtek.com.tw (10.21.1.55) by RTKEXHMBS02.realtek.com.tw (172.21.6.41) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 6 Jan 2026 10:15:02 +0800 Received: from RTKEXHMBS04.realtek.com.tw (10.21.1.54) by RTKEXHMBS05.realtek.com.tw (10.21.1.55) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.2.1748.10; Tue, 6 Jan 2026 10:15:01 +0800 Received: from cn1dhc-k02 (172.21.252.101) by RTKEXHMBS04.realtek.com.tw (10.21.1.54) with Microsoft SMTP Server id 15.2.1748.10 via Frontend Transport; Tue, 6 Jan 2026 10:15:01 +0800 From: Yu-Chun Lin To: , , , , , CC: , , , , Subject: [PATCH] regmap: Fix race condition in hwspinlock irqsave routine Date: Tue, 6 Jan 2026 10:15:01 +0800 Message-ID: <20260106021501.30682-1-eleanor.lin@realtek.com> X-Mailer: git-send-email 2.50.1 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" From: Cheng-Yu Lee 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 Signed-off-by: Yu-Chun Lin --- drivers/base/regmap/regmap.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/drivers/base/regmap/regmap.c b/drivers/base/regmap/regmap.c index ce9be3989a21..8d889372517f 100644 --- a/drivers/base/regmap/regmap.c +++ b/drivers/base/regmap/regmap.c @@ -408,9 +408,11 @@ static void regmap_lock_hwlock_irq(void *__map) static void regmap_lock_hwlock_irqsave(void *__map) { struct regmap *map =3D __map; + unsigned long flags; =20 hwspin_lock_timeout_irqsave(map->hwlock, UINT_MAX, - &map->spinlock_flags); + &flags); + map->spinlock_flags =3D flags; } =20 static void regmap_unlock_hwlock(void *__map) --=20 2.34.1