]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
regulator: core: Protect regulator_supply_alias_list with regulator_list_mutex
authorsparkhuang <huangshaobo3@xiaomi.com>
Thu, 27 Nov 2025 02:57:16 +0000 (10:57 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:25 +0000 (14:03 +0100)
commit64099b5c0aeb70bc7cd5556eb7f59c5b4a5010bf
treea99e213f1b9791d76c09122c8b48676582ddbf08
parented3cc640b4f1662e7b4a8941bead6779f2d48cb3
regulator: core: Protect regulator_supply_alias_list with regulator_list_mutex

[ Upstream commit 0cc15a10c3b4ab14cd71b779fd5c9ca0cb2bc30d ]

regulator_supply_alias_list was accessed without any locking in
regulator_supply_alias(), regulator_register_supply_alias(), and
regulator_unregister_supply_alias(). Concurrent registration,
unregistration and lookups can race, leading to:

1 use-after-free if an alias entry is removed while being read,
2 duplicate entries when two threads register the same alias,
3 inconsistent alias mappings observed by consumers.

Protect all traversals, insertions and deletions on
regulator_supply_alias_list with the existing regulator_list_mutex.

Fixes: a06ccd9c3785f ("regulator: core: Add ability to create a lookup alias for supply")
Signed-off-by: sparkhuang <huangshaobo3@xiaomi.com>
Reviewed-by: Charles Keepax <ckeepax@opensource.cirrus.com>
Link: https://patch.msgid.link/20251127025716.5440-1-huangshaobo3@xiaomi.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/regulator/core.c