]> www.infradead.org Git - users/jedix/linux-maple.git/commit
mfd: syscon: Fix race in device_node_get_regmap()
authorRob Herring (Arm) <robh@kernel.org>
Tue, 17 Dec 2024 18:11:40 +0000 (12:11 -0600)
committerLee Jones <lee@kernel.org>
Thu, 9 Jan 2025 11:11:36 +0000 (11:11 +0000)
commit805f7aaf7fee14a57b56af01d270edf6c10765e8
tree2e3a3fc2ac72502adb4c68cdb160530a825f43c1
parentb55689c0a9b14ba873de662408b0ee298c307a35
mfd: syscon: Fix race in device_node_get_regmap()

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: bdb0066df96e ("mfd: syscon: Decouple syscon interface from platform devices")
Signed-off-by: Rob Herring (Arm) <robh@kernel.org>
Reviewed-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Krzysztof Kozlowski <krzysztof.kozlowski@linaro.org>
Tested-by: Will McVicker <willmcvicker@google.com>
Tested-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Reviewed-by: Pankaj Dubey <pankaj.dubey@samsung.com>
Link: https://lore.kernel.org/r/20241217-syscon-fixes-v2-1-4f56d750541d@kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
drivers/mfd/syscon.c