tests: iter: free non-mockup GPIO chips
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 11 Jul 2019 15:24:28 +0000 (17:24 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Thu, 11 Jul 2019 15:24:28 +0000 (17:24 +0200)
When using gpiod_foreach_chip_noclose() we need to close any non-mockup
GPIO chip that may be present in the system. Otherwise we'll be leaking
memory.

Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
tests/tests-iter.c

index f4aff42b481d73a98d263c8c7d3757662ed84d7e..de71efdb874b2540873df741ef4188228eaedcc2 100644 (file)
@@ -64,6 +64,8 @@ static void chip_iter_noclose(void)
                                  "gpio-mockup-C") == 0) {
                        C = true;
                        chipC = chip;
+               } else {
+                       gpiod_chip_close(chip);
                }
        }