From: Joel Stanley Date: Wed, 2 Feb 2022 12:01:23 +0000 (+1030) Subject: gpioinfo: Clean up scandir allocations X-Git-Url: http://git.maquefel.me/?a=commitdiff_plain;h=7bd9e62fc29040ccad6a8363416c9dd0da0bc145;p=qemu-gpiodev%2Flibgpiod.git gpioinfo: Clean up scandir allocations ==3017== 176 (80 direct, 96 indirect) bytes in 1 blocks are definitely lost in loss record 2 of 2 ==3017== at 0x483F6C7: malloc (in /usr/libexec/valgrind/vgpreload_memcheck-amd64-linux.so) ==3017== by 0x491CE92: ??? (in /lib/libc.so.6) ==3017== by 0x10AAAC: main (gpioinfo.c:215) The entires must be freed, and then the array itself. Signed-off-by: Joel Stanley Signed-off-by: Bartosz Golaszewski --- diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c index 3d89111..d50af45 100644 --- a/tools/gpioinfo.c +++ b/tools/gpioinfo.c @@ -231,7 +231,9 @@ int main(int argc, char **argv) list_lines(chip); gpiod_chip_unref(chip); + free(entries[i]); } + free(entries); } else { for (i = 0; i < argc; i++) { chip = chip_open_lookup(argv[i]);