Devicetree
 help / color / mirror / Atom feed
From: sashiko-bot@kernel.org
To: "Oleksij Rempel" <o.rempel@pengutronix.de>
Cc: devicetree@vger.kernel.org, linux-hwmon@vger.kernel.org,
	robh@kernel.org, conor+dt@kernel.org
Subject: Re: [PATCH v14 3/6] pinctrl: core: Make pin group callbacks optional for pin-only drivers
Date: Fri, 22 May 2026 05:55:24 +0000	[thread overview]
Message-ID: <20260522055524.C86311F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260522044855.1772639-4-o.rempel@pengutronix.de>

Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:

Pre-existing issues:
- [High] Missing mutex lock in pinconf_groups_show() leading to potential Use-After-Free during debugfs access.
--

commit 3be3569fd20f9c647f76233cee1c7285d9ad8584
Author: Oleksij Rempel <o.rempel@pengutronix.de>

pinctrl: core: Make pin group callbacks optional for pin-only drivers

This patch relaxes the requirement for pin-only drivers to implement
.get_groups_count and .get_group_name callbacks by making them optional
when no muxing or group pin configuration support is provided. The core
and debugfs helpers are updated to check for these callbacks before
invoking them.

> diff --git a/drivers/pinctrl/pinconf.c b/drivers/pinctrl/pinconf.c
> index dca963633b5d1..81686844dfa5f 100644
> --- a/drivers/pinctrl/pinconf.c
> +++ b/drivers/pinctrl/pinconf.c

[ ... ]

> @@ -348,8 +348,13 @@ static int pinconf_groups_show(struct seq_file *s, void *what)
>  {
>  	struct pinctrl_dev *pctldev = s->private;
>  	const struct pinctrl_ops *pctlops = pctldev->desc->pctlops;
> -	unsigned int ngroups = pctlops->get_groups_count(pctldev);
>  	unsigned int selector = 0;
> +	unsigned int ngroups;
> +
> +	if (!pctlops->get_groups_count || !pctlops->get_group_name)
> +		return 0;
> +
> +	ngroups = pctlops->get_groups_count(pctldev);

[Severity: High]
This is a pre-existing issue, but does pinconf_groups_show() need to hold
pctldev->mutex while iterating through pin groups?

Drivers such as pinctrl-lpass-lpi dynamically remove groups via
pinctrl_generic_remove_group() during device unbind (e.g., in
lpi_pinctrl_remove()). This deletes the radix tree node and frees the
group memory via devm_kfree(). Because the controller is registered
with devm_pinctrl_register(), the debugfs entries remain fully accessible
during the driver's remove() callback until devres cleanup runs later.

Could a concurrent read of the pinconf-groups debugfs file race with
this group removal, causing pinctrl_generic_get_group_name() to perform
an unsafe radix_tree_lookup() and dereference the freed group struct?

Also, since pinconf_groups_show() eventually calls pin_config_group_get()
which acquires pctldev->mutex, would wrapping the loop in
mutex_lock(&pctldev->mutex) cause a self-deadlock, thus requiring
unlocked internal accessors to fix properly?

>  
>  	seq_puts(s, "Pin config settings per pin group\n");
>  	seq_puts(s, "Format: group (name): configs\n");

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20260522044855.1772639-1-o.rempel@pengutronix.de?part=3

  reply	other threads:[~2026-05-22  5:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-05-22  4:48 [PATCH v14 0/6] mfd: Add support for NXP MC33978/MC34978 MSDI Oleksij Rempel
2026-05-22  4:48 ` [PATCH v14 1/6] dt-bindings: pinctrl: add " Oleksij Rempel
2026-05-22  4:58   ` sashiko-bot
2026-05-22  4:48 ` [PATCH v14 2/6] mfd: add NXP MC33978/MC34978 core driver Oleksij Rempel
2026-05-22  5:24   ` sashiko-bot
2026-05-22  4:48 ` [PATCH v14 3/6] pinctrl: core: Make pin group callbacks optional for pin-only drivers Oleksij Rempel
2026-05-22  5:55   ` sashiko-bot [this message]
2026-05-22  4:48 ` [PATCH v14 4/6] pinctrl: add NXP MC33978/MC34978 pinctrl driver Oleksij Rempel
2026-05-22  6:22   ` sashiko-bot
2026-05-22  4:48 ` [PATCH v14 5/6] hwmon: add NXP MC33978/MC34978 driver Oleksij Rempel
2026-05-22  6:47   ` sashiko-bot
2026-05-22  4:48 ` [PATCH v14 6/6] mux: add NXP MC33978/MC34978 AMUX driver Oleksij Rempel
2026-05-22  7:09   ` sashiko-bot

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=20260522055524.C86311F000E9@smtp.kernel.org \
    --to=sashiko-bot@kernel.org \
    --cc=conor+dt@kernel.org \
    --cc=devicetree@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=o.rempel@pengutronix.de \
    --cc=robh@kernel.org \
    --cc=sashiko-reviews@lists.linux.dev \
    /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