Skip to content

Commit adec57f

Browse files
hagarhemlinusw
authored andcommitted
pinctrl: fix deadlock in create_pinctrl() when handling -EPROBE_DEFER
In create_pinctrl(), pinctrl_maps_mutex is acquired before calling add_setting(). If add_setting() returns -EPROBE_DEFER, create_pinctrl() calls pinctrl_free(). However, pinctrl_free() attempts to acquire pinctrl_maps_mutex, which is already held by create_pinctrl(), leading to a potential deadlock. This patch resolves the issue by releasing pinctrl_maps_mutex before calling pinctrl_free(), preventing the deadlock. This bug was discovered and resolved using Coverity Static Analysis Security Testing (SAST) by Synopsys, Inc. Fixes: 42fed7b ("pinctrl: move subsystem mutex to pinctrl_dev struct") Suggested-by: Maximilian Heyne <[email protected]> Signed-off-by: Hagar Hemdan <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Linus Walleij <[email protected]>
1 parent 61fef29 commit adec57f

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/pinctrl/core.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1106,8 +1106,8 @@ static struct pinctrl *create_pinctrl(struct device *dev,
11061106
* an -EPROBE_DEFER later, as that is the worst case.
11071107
*/
11081108
if (ret == -EPROBE_DEFER) {
1109-
pinctrl_free(p, false);
11101109
mutex_unlock(&pinctrl_maps_mutex);
1110+
pinctrl_free(p, false);
11111111
return ERR_PTR(ret);
11121112
}
11131113
}

0 commit comments

Comments
 (0)