mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Frank Li <Frank.li@oss.nxp.com>
To: kr494167@gmail.com
Cc: linusw@kernel.org, Frank.Li@nxp.com, linux-gpio@vger.kernel.org,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH] pinctrl: generic-mux: free maps on pinctrl_generic_to_map() failure
Date: Fri, 24 Jul 2026 14:46:47 -0400	[thread overview]
Message-ID: <amOzF3h0ujw8x5ST@lizhi-Precision-Tower-5810> (raw)
In-Reply-To: <20260723063011.27145-1-kr494167@gmail.com>

On Thu, Jul 23, 2026 at 12:00:11PM +0530, kr494167@gmail.com wrote:
> From: Surendra Singh Chouhan <kr494167@gmail.com>
>
> mux_pinmux_dt_node_to_map() calls pinctrl_generic_to_map() to parse DT
> configuration and allocate pinctrl maps.
>
> If pinctrl_generic_to_map() returns an error, *maps may contain partial
> map entries allocated by pinctrl_utils_reserve_map(). Returning the error
> directly without calling pinctrl_utils_free_map() leaks the allocated
> mapping memory.

Fix pinctrl_generic_to_map(), which should cleanup memory before return
failure.

Frank

>
> Fix this by calling pinctrl_utils_free_map() when pinctrl_generic_to_map()
> fails.
>
> Fixes: 34acc5a8adfb ("pinctrl: add generic board-level pinctrl driver using mux framework")
> Signed-off-by: Surendra Singh Chouhan <kr494167@gmail.com>
> ---
>  drivers/pinctrl/pinctrl-generic-mux.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/pinctrl/pinctrl-generic-mux.c b/drivers/pinctrl/pinctrl-generic-mux.c
> index da5a5ec01583..927c7aa616f5 100644
> --- a/drivers/pinctrl/pinctrl-generic-mux.c
> +++ b/drivers/pinctrl/pinctrl-generic-mux.c
> @@ -58,8 +58,10 @@ mux_pinmux_dt_node_to_map(struct pinctrl_dev *pctldev,
>  				     num_maps, &num_reserved_maps, group_names,
>  				     0, &np_config->name, NULL, 0);
>
> -	if (ret)
> +	if (ret) {
> +		pinctrl_utils_free_map(pctldev, *maps, *num_maps);
>  		return ret;
> +	}
>
>  	ret = pinmux_generic_add_function(pctldev, np_config->name, group_names,
>  					  1, function);
> --
> 2.55.0
>

      reply	other threads:[~2026-07-24 18:46 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-23  6:30 kr494167
2026-07-24 18:46 ` Frank Li [this message]

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=amOzF3h0ujw8x5ST@lizhi-Precision-Tower-5810 \
    --to=frank.li@oss.nxp.com \
    --cc=Frank.Li@nxp.com \
    --cc=kr494167@gmail.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    /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®