From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Bartosz Golaszewski <brgl@bgdev.pl>
Cc: Kent Gibson <warthog618@gmail.com>,
Linus Walleij <linus.walleij@linaro.org>,
Viresh Kumar <viresh.kumar@linaro.org>,
linux-gpio@vger.kernel.org, linux-kernel@vger.kernel.org,
Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Subject: Re: [PATCH] gpio: sim: fix a memory leak
Date: Thu, 16 Feb 2023 16:42:20 +0200 [thread overview]
Message-ID: <Y+5AzMxlTC7X2UsM@smile.fi.intel.com> (raw)
In-Reply-To: <20230216141555.116219-1-brgl@bgdev.pl>
On Thu, Feb 16, 2023 at 03:15:55PM +0100, Bartosz Golaszewski wrote:
> Fix an inverted logic bug in gpio_sim_remove_hogs() that leads to GPIO
> hog structures never being freed.
Ha-ha, I stared to this code, and in the head I was "okay, this loop is until
chip_label is *not* NULL, so should be fine".
At the same time, "! is hard to process", see for example
2754435d4c82 ("ACPI / battery: get rid of negations in conditions")
which I had suggested.
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
P.S. But my patch I mentioned looks also good to have, no?
> Fixes: cb8c474e79be ("gpio: sim: new testing module")
> Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
> Signed-off-by: Bartosz Golaszewski <brgl@bgdev.pl>
> ---
> drivers/gpio/gpio-sim.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpio/gpio-sim.c b/drivers/gpio/gpio-sim.c
> index 60514bc5454f..9e3893b19e4f 100644
> --- a/drivers/gpio/gpio-sim.c
> +++ b/drivers/gpio/gpio-sim.c
> @@ -736,7 +736,7 @@ static void gpio_sim_remove_hogs(struct gpio_sim_device *dev)
>
> gpiod_remove_hogs(dev->hogs);
>
> - for (hog = dev->hogs; !hog->chip_label; hog++) {
> + for (hog = dev->hogs; hog->chip_label; hog++) {
> kfree(hog->chip_label);
> kfree(hog->line_name);
> }
> --
> 2.37.2
>
--
With Best Regards,
Andy Shevchenko
next prev parent reply other threads:[~2023-02-16 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-02-16 14:15 [PATCH] gpio: sim: fix a memory leak Bartosz Golaszewski
2023-02-16 14:42 ` Andy Shevchenko [this message]
2023-02-16 14:49 ` Bartosz Golaszewski
2023-02-17 11:05 ` Bartosz Golaszewski
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=Y+5AzMxlTC7X2UsM@smile.fi.intel.com \
--to=andriy.shevchenko@linux.intel.com \
--cc=brgl@bgdev.pl \
--cc=linus.walleij@linaro.org \
--cc=linux-gpio@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=mirsad.todorovac@alu.unizg.hr \
--cc=viresh.kumar@linaro.org \
--cc=warthog618@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