linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Bartosz Golaszewski <brgl@bgdev.pl>
To: Xiaolei Wang <xiaolei.wang@windriver.com>,
	Linus Walleij <linus.walleij@linaro.org>
Cc: linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
	 Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Subject: Re: [PATCH] gpio: fix memory leak in gpiod_request_commit()
Date: Mon, 19 Feb 2024 08:44:04 +0100	[thread overview]
Message-ID: <CAMRc=MffACd5XyGVv4DQO9AhbeYiVhougS8_SJ23xHd-jpfF2g@mail.gmail.com> (raw)
In-Reply-To: <20240218174853.6492-1-brgl@bgdev.pl>

On Sun, Feb 18, 2024 at 6:49 PM Bartosz Golaszewski <brgl@bgdev.pl> wrote:
>
> From: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
>
> We now copy the label string directly in desc_set_label() so it must not
> be done a second time in gpiod_request_commit().
>
> Fixes: 1f2bcb8c8ccd ("gpio: protect the descriptor label with SRCU")
> Reported-by: Xiaolei Wang <xiaolei.wang@windriver.com>
> Closes: https://lore.kernel.org/all/20240217135255.1128716-1-xiaolei.wang@windriver.com/T/
> Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
> ---
>  drivers/gpio/gpiolib.c | 6 ------
>  1 file changed, 6 deletions(-)
>
> diff --git a/drivers/gpio/gpiolib.c b/drivers/gpio/gpiolib.c
> index e4dd13d81b4d..3c22920bd201 100644
> --- a/drivers/gpio/gpiolib.c
> +++ b/drivers/gpio/gpiolib.c
> @@ -2250,12 +2250,6 @@ static int gpiod_request_commit(struct gpio_desc *desc, const char *label)
>         if (test_and_set_bit(FLAG_REQUESTED, &desc->flags))
>                 return -EBUSY;
>
> -       if (label) {
> -               label = kstrdup_const(label, GFP_KERNEL);
> -               if (!label)
> -                       return -ENOMEM;
> -       }
> -
>         /* NOTE:  gpio_request() can be called in early boot,
>          * before IRQs are enabled, for non-sleeping (SOC) GPIOs.
>          */
> --
> 2.40.1
>

I should probably stop coding while sleep-deprived and in the evening,
I realized now I sent the exact same fix as you. I thought this was
removing the allocation from desc_set_label() and not
gpiod_request_commit().

I'll go ahead and apply your patch and you can disregard this thread.

Thanks!
Bartosz

      reply	other threads:[~2024-02-19  7:44 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-18 17:48 [PATCH] gpio: fix memory leak in gpiod_request_commit() Bartosz Golaszewski
2024-02-19  7:44 ` Bartosz Golaszewski [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='CAMRc=MffACd5XyGVv4DQO9AhbeYiVhougS8_SJ23xHd-jpfF2g@mail.gmail.com' \
    --to=brgl@bgdev.pl \
    --cc=bartosz.golaszewski@linaro.org \
    --cc=linus.walleij@linaro.org \
    --cc=linux-gpio@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=xiaolei.wang@windriver.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;
as well as URLs for NNTP newsgroup(s).