Commit fa78395d authored by Rob Herring (Arm)'s avatar Rob Herring (Arm) Committed by Greg Kroah-Hartman
Browse files

mfd: syscon: Fix race in device_node_get_regmap()



[ Upstream commit 805f7aaf ]

It is possible for multiple, simultaneous callers calling
device_node_get_regmap() with the same node to fail to find an entry in
the syscon_list. There is a period of time while the first caller is
calling of_syscon_register() that subsequent callers also fail to find
an entry in the syscon_list and then call of_syscon_register() a second
time.

Fix this by keeping the lock held until after of_syscon_register()
completes and adds the node to syscon_list. Convert the spinlock to a
mutex as many of the functions called in of_syscon_register() such as
kzalloc() and of_clk_get() may sleep.

Fixes: bdb0066d ("mfd: syscon: Decouple syscon interface from platform devices")
Signed-off-by: default avatarRob Herring (Arm) <robh@kernel.org>
Reviewed-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: default avatarKrzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: default avatarWill McVicker <willmcvicker@google.com>
Tested-by: default avatarPankaj Dubey <pankaj.dubey@samsung.com>
Reviewed-by: default avatarPankaj Dubey <pankaj.dubey@samsung.com>
Link: https://lore.kernel.org/r/20241217-syscon-fixes-v2-1-4f56d750541d@kernel.org


Signed-off-by: default avatarLee Jones <lee@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
parent 5481df0e
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment