]> git.baikalelectronics.ru Git - kernel.git/commitdiff
gpio: sim: fix a memory leak
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 17 Feb 2023 11:02:26 +0000 (12:02 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Wed, 22 Feb 2023 11:59:50 +0000 (12:59 +0100)
commit 67961b6d86a4ce917f3e4ad378327c67bb8572d4 upstream.

Fix an inverted logic bug in gpio_sim_remove_hogs() that leads to GPIO
hog structures never being freed.

Fixes: eee5b4460bf3 ("gpio: sim: new testing module")
Reported-by: Mirsad Goran Todorovac <mirsad.todorovac@alu.unizg.hr>
Signed-off-by: Bartosz Golaszewski <bartosz.golaszewski@linaro.org>
Reviewed-by: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
drivers/gpio/gpio-sim.c

index 1020c2feb24964303c279fa352af7839991a8775..cff68f31a09fdfaed8bda6151a23917e620abba1 100644 (file)
@@ -732,7 +732,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);
        }