linux-gpio.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [libgpiod PATCH] gpioinfo: Clean up scandir allocations
@ 2022-02-02 12:01 Joel Stanley
  2022-02-18 18:37 ` Bartosz Golaszewski
  0 siblings, 1 reply; 2+ messages in thread
From: Joel Stanley @ 2022-02-02 12:01 UTC (permalink / raw)
  To: linux-gpio

==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 <joel@jms.id.au>
---
 tools/gpioinfo.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index 3d8911176281..d50af45dbf35 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]);
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2022-02-18 18:37 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2022-02-02 12:01 [libgpiod PATCH] gpioinfo: Clean up scandir allocations Joel Stanley
2022-02-18 18:37 ` Bartosz Golaszewski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).