gpio: sim: fix a memory leak
authorBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 17 Feb 2023 11:02:26 +0000 (12:02 +0100)
committerBartosz Golaszewski <bartosz.golaszewski@linaro.org>
Fri, 17 Feb 2023 11:02:26 +0000 (12:02 +0100)
Fix an inverted logic bug in gpio_sim_remove_hogs() that leads to GPIO
hog structures never being freed.

Fixes: cb8c474e79be ("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>
drivers/gpio/gpio-sim.c

index 60514bc5454f8ceb258e0647910b91fd1642cd8e..9e3893b19e4f24200d69893410ff3099c7b8bbe3 100644 (file)
@@ -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);
        }