From: Lee Jones <lee@kernel.org>
To: lee@kernel.org, Tony Lindgren <tony@atomide.com>,
Haojian Zhuang <haojian.zhuang@linaro.org>,
Linus Walleij <linusw@kernel.org>,
Andy Shevchenko <andy.shevchenko@gmail.com>,
linux-arm-kernel@lists.infradead.org, linux-omap@vger.kernel.org,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org
Cc: stable@vger.kernel.org
Subject: [PATCH 03/12] pinctrl: single: Protect group and function updates with pctldev->mutex
Date: Wed, 2 Dec 2026 09:29:57 +0000 [thread overview]
Message-ID: <e3661508bf5b5be195e5114af378ea4b7c3d0d4e.1796203691.git.lee@kernel.org> (raw)
In-Reply-To: <cover.1796203691.git.lee@kernel.org>
pcs_parse_one_pinctrl_entry() and pcs_parse_bits_in_pinctrl_entry()
mutate pcs->pctl->pin_function_tree and pcs->pctl->pin_group_tree via
pcs_add_function(), pinctrl_generic_add_group(), and their removal
helpers while holding only the driver-private pcs->mutex. However, the
pinctrl core debugfs readers and teardown paths traverse and modify
those radix trees under pctldev->mutex, leaving concurrent readers and
writers racing without a shared lock.
Acquire pcs->pctl->mutex instead of pcs->mutex in both parsing
functions so all generic group and function tree operations are
serialised against the pinctrl core.
Fixes: a4ab10860723 ("pinctrl: single: Fix group and function selector use")
Closes: https://sashiko.dev/#/bug/linux-e32b7426-4575-4354-a2fe-409cde3480ce
Cc: stable@vger.kernel.org
Signed-off-by: Lee Jones <lee@kernel.org>
---
drivers/pinctrl/pinctrl-single.c | 12 ++++++------
1 file changed, 6 insertions(+), 6 deletions(-)
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c
index e351cdf50669..618f8fc6ee6c 100644
--- a/drivers/pinctrl/pinctrl-single.c
+++ b/drivers/pinctrl/pinctrl-single.c
@@ -1059,7 +1059,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
}
pgnames[0] = np->name;
- mutex_lock(&pcs->mutex);
+ mutex_lock(&pcs->pctl->mutex);
fsel = pcs_add_function(pcs, &function, np->name, vals, found,
pgnames, 1);
if (fsel < 0) {
@@ -1102,7 +1102,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
devm_kfree(pcs->dev, function);
devm_kfree(pcs->dev, pgnames);
}
- mutex_unlock(&pcs->mutex);
+ mutex_unlock(&pcs->pctl->mutex);
return 0;
@@ -1118,7 +1118,7 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs,
if (pinmux_generic_get_function(pcs->pctl, fsel)->data == function)
pinmux_generic_remove_function(pcs->pctl, fsel);
free_pins:
- mutex_unlock(&pcs->mutex);
+ mutex_unlock(&pcs->pctl->mutex);
devm_kfree(pcs->dev, pins);
free_vals:
@@ -1229,7 +1229,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
}
pgnames[0] = np->name;
- mutex_lock(&pcs->mutex);
+ mutex_lock(&pcs->pctl->mutex);
fsel = pcs_add_function(pcs, &function, np->name, vals, found,
pgnames, 1);
if (fsel < 0) {
@@ -1254,7 +1254,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
devm_kfree(pcs->dev, function);
devm_kfree(pcs->dev, pgnames);
}
- mutex_unlock(&pcs->mutex);
+ mutex_unlock(&pcs->pctl->mutex);
return 0;
@@ -1263,7 +1263,7 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs,
if (pinmux_generic_get_function(pcs->pctl, fsel)->data == function)
pinmux_generic_remove_function(pcs->pctl, fsel);
free_pins:
- mutex_unlock(&pcs->mutex);
+ mutex_unlock(&pcs->pctl->mutex);
devm_kfree(pcs->dev, pins);
free_vals:
--
2.56.1.911.g883d8bcb20-goog
next prev parent reply other threads:[~2026-12-02 9:31 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-12-02 9:29 [PATCH 00/12] pinctrl: Fix Critical and High issues reported by Sashiko (batch 3) Lee Jones
2026-12-02 9:29 ` [PATCH 01/12] pinctrl: stm32: Validate npins against STM32_GPIO_PINS_PER_BANK Lee Jones
2026-12-02 9:29 ` [PATCH 02/12] pinctrl: imx: Validate pin_id in imx_pinctrl_parse_pin_mmio() Lee Jones
2026-12-02 9:29 ` Lee Jones [this message]
2026-12-02 14:08 ` [PATCH 03/12] pinctrl: single: Protect group and function updates with pctldev->mutex Bartosz Golaszewski
2026-12-02 9:29 ` [PATCH 04/12] pinctrl: imx: Propagate DT parsing errors in imx_pinctrl_probe_dt() Lee Jones
2026-12-02 9:29 ` [PATCH 05/12] pinctrl: tegra: Require at least one register bank in tegra_pinctrl_probe() Lee Jones
2026-12-02 9:30 ` [PATCH 06/12] pinctrl: imx: Serialise MMIO register updates with a spinlock Lee Jones
2026-12-02 9:30 ` [PATCH 07/12] pinctrl: nuvoton: ma35: Avoid double free of shared pin configs Lee Jones
2026-12-02 9:30 ` [PATCH 08/12] pinctrl: keembay: Check src before calling keembay_find_free_slot() Lee Jones
2026-12-02 9:30 ` [PATCH 09/12] pinctrl: ti: iodelay: Protect generic group addition with pctldev->mutex Lee Jones
2026-12-02 9:30 ` [PATCH 10/12] pinctrl: sunxi: Serialise per-bank regulator request and free Lee Jones
2026-12-02 9:30 ` [PATCH 11/12] pinctrl: stm32: Protect irqmux restore with hwspinlock during resume Lee Jones
2026-12-02 9:30 ` [PATCH 12/12] pinctrl: sx150x: Register threaded IRQ after adding GPIO chip Lee Jones
2026-12-02 9:35 ` Neil Armstrong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=e3661508bf5b5be195e5114af378ea4b7c3d0d4e.1796203691.git.lee@kernel.org \
--to=lee@kernel.org \
--cc=andy.shevchenko@gmail.com \
--cc=haojian.zhuang@linaro.org \
--cc=linusw@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-omap@vger.kernel.org \
--cc=stable@vger.kernel.org \
--cc=tony@atomide.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®