mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Antonio Borneo <antonio.borneo@foss.st.com>
To: Felix Gu <ustc.gu@gmail.com>, Linus Walleij <linusw@kernel.org>
Cc: <linux-gpio@vger.kernel.org>, <linux-kernel@vger.kernel.org>
Subject: Re: [PATCH] pinctrl: pinconf-generic: Fix memory leak in pinconf_generic_parse_dt_config()
Date: Sun, 15 Feb 2026 17:24:39 +0100	[thread overview]
Message-ID: <57cdc887db63f34c7058836c4d806bba6068a2ee.camel@foss.st.com> (raw)
In-Reply-To: <20260214-pinconf-v1-1-e515d35a153b@gmail.com>

On Sat, 2026-02-14 at 23:14 +0800, Felix Gu wrote:
> In pinconf_generic_parse_dt_config(), if parse_dt_cfg() fails, it returns
> directly. This bypasses the cleanup logic and results in a memory leak of
> the cfg buffer.
> 
> Fix this by jumping to the out label on failure, ensuring kfree(cfg) is
> called before returning.
> 
> Fixes: 90a18c512884 ("pinctrl: pinconf-generic: Handle string values for generic properties")
> Signed-off-by: Felix Gu <ustc.gu@gmail.com>
> ---
>  drivers/pinctrl/pinconf-generic.c | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pinctrl/pinconf-generic.c b/drivers/pinctrl/pinconf-generic.c
> index 94b1d057197c..2b030bd0e6ad 100644
> --- a/drivers/pinctrl/pinconf-generic.c
> +++ b/drivers/pinctrl/pinconf-generic.c
> @@ -351,13 +351,13 @@ int pinconf_generic_parse_dt_config(struct device_node *np,
>  
>         ret = parse_dt_cfg(np, dt_params, ARRAY_SIZE(dt_params), cfg, &ncfg);
>         if (ret)
> -               return ret;
> +               goto out;
>         if (pctldev && pctldev->desc->num_custom_params &&
>                 pctldev->desc->custom_params) {
>                 ret = parse_dt_cfg(np, pctldev->desc->custom_params,
>                                    pctldev->desc->num_custom_params, cfg, &ncfg);
>                 if (ret)
> -                       return ret;
> +                       goto out;
>         }
>  
>         /* no configs found at all */
> 
> ---
> base-commit: 635c467cc14ebdffab3f77610217c1dacaf88e8c
> change-id: 20260214-pinconf-cbc1e31088ff
> 
> Best regards,

Reviewed-by: Antonio Borneo <antonio.borneo@foss.st.com>

Thanks!
Antonio


  reply	other threads:[~2026-02-15 16:24 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-02-14 15:14 Felix Gu
2026-02-15 16:24 ` Antonio Borneo [this message]
2026-02-24  8:51 ` Linus Walleij

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=57cdc887db63f34c7058836c4d806bba6068a2ee.camel@foss.st.com \
    --to=antonio.borneo@foss.st.com \
    --cc=linusw@kernel.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=ustc.gu@gmail.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®