All of lore.kernel.org
 help / color / mirror / Atom feed
* [libgpiod] [PATCH] gpioinfo: don't crash after EACCESS
@ 2022-04-20 10:26 John Keeping
  0 siblings, 0 replies; only message in thread
From: John Keeping @ 2022-04-20 10:26 UTC (permalink / raw)
  To: linux-gpio; +Cc: John Keeping

If chip_open_by_name() fails then EACCESS is not treated as a fatal
error, but falling through calls list_lines(NULL) which leads to a
segfault.  Move on to the next chip in this instance.

Signed-off-by: John Keeping <john@metanate.com>
---
 tools/gpioinfo.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/tools/gpioinfo.c b/tools/gpioinfo.c
index d50af45..542a881 100644
--- a/tools/gpioinfo.c
+++ b/tools/gpioinfo.c
@@ -226,6 +226,9 @@ int main(int argc, char **argv)
 				else
 					die_perror("unable to open %s",
 						   entries[i]->d_name);
+
+				free(entries[i]);
+				continue;
 			}
 
 			list_lines(chip);
-- 
2.35.3


^ permalink raw reply related	[flat|nested] only message in thread

only message in thread, other threads:[~2022-04-20 10:27 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-20 10:26 [libgpiod] [PATCH] gpioinfo: don't crash after EACCESS John Keeping

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.