Skip to content

Commit 4198a9b

Browse files
Maria YuLinus Walleij
authored andcommitted
pinctrl: avoid reload of p state in list iteration
When in the list_for_each_entry iteration, reload of p->state->settings with a local setting from old_state will turn the list iteration into an infinite loop. The typical symptom when the issue happens, will be a printk message like: "not freeing pin xx (xxx) as part of deactivating group xxx - it is already used for some other setting". This is a compiler-dependent problem, one instance occurred using Clang version 10.0 on the arm64 architecture with linux version 4.19. Fixes: 6e5e959 ("pinctrl: API changes to support multiple states per device") Signed-off-by: Maria Yu <quic_aiquny@quicinc.com> Cc: <stable@vger.kernel.org> Link: https://lore.kernel.org/r/20231115102824.23727-1-quic_aiquny@quicinc.com Signed-off-by: Linus Walleij <linus.walleij@linaro.org>
1 parent df572eb commit 4198a9b

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

drivers/pinctrl/core.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1262,17 +1262,17 @@ static void pinctrl_link_add(struct pinctrl_dev *pctldev,
12621262
static int pinctrl_commit_state(struct pinctrl *p, struct pinctrl_state *state)
12631263
{
12641264
struct pinctrl_setting *setting, *setting2;
1265-
struct pinctrl_state *old_state = p->state;
1265+
struct pinctrl_state *old_state = READ_ONCE(p->state);
12661266
int ret;
12671267

1268-
if (p->state) {
1268+
if (old_state) {
12691269
/*
12701270
* For each pinmux setting in the old state, forget SW's record
12711271
* of mux owner for that pingroup. Any pingroups which are
12721272
* still owned by the new state will be re-acquired by the call
12731273
* to pinmux_enable_setting() in the loop below.
12741274
*/
1275-
list_for_each_entry(setting, &p->state->settings, node) {
1275+
list_for_each_entry(setting, &old_state->settings, node) {
12761276
if (setting->type != PIN_MAP_TYPE_MUX_GROUP)
12771277
continue;
12781278
pinmux_disable_setting(setting);

0 commit comments

Comments
 (0)