From ef3c61a082c86a20cc1a4382142d480655b3c5a1 Mon Sep 17 00:00:00 2001 From: Kent Gibson Date: Wed, 8 Jul 2020 12:15:58 +0800 Subject: tools: gpio: fix spurious close warning in lsgpio Fix bogus close warning that occurs when opening the character device fails. Signed-off-by: Kent Gibson Signed-off-by: Bartosz Golaszewski --- tools/gpio/lsgpio.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/gpio/lsgpio.c b/tools/gpio/lsgpio.c index 8a71ad36f83b..b08d7a5e779b 100644 --- a/tools/gpio/lsgpio.c +++ b/tools/gpio/lsgpio.c @@ -94,7 +94,7 @@ int list_device(const char *device_name) if (fd == -1) { ret = -errno; fprintf(stderr, "Failed to open %s\n", chrdev_name); - goto exit_close_error; + goto exit_free_name; } /* Inspect this GPIO chip */ @@ -141,6 +141,7 @@ int list_device(const char *device_name) exit_close_error: if (close(fd) == -1) perror("Failed to close GPIO character device file"); +exit_free_name: free(chrdev_name); return ret; } -- cgit v1.2.3 From e890678f6949e848720c66620c390d5e876149a6 Mon Sep 17 00:00:00 2001 From: Kent Gibson Date: Wed, 8 Jul 2020 12:15:59 +0800 Subject: tools: gpio: fix spurious close warning in gpio-utils Fix bogus close warning that occurs when opening the character device fails. Signed-off-by: Kent Gibson Signed-off-by: Bartosz Golaszewski --- tools/gpio/gpio-utils.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'tools') diff --git a/tools/gpio/gpio-utils.c b/tools/gpio/gpio-utils.c index 06003789e7c7..16a5d9cb9da2 100644 --- a/tools/gpio/gpio-utils.c +++ b/tools/gpio/gpio-utils.c @@ -75,7 +75,7 @@ int gpiotools_request_linehandle(const char *device_name, unsigned int *lines, ret = -errno; fprintf(stderr, "Failed to open %s, %s\n", chrdev_name, strerror(errno)); - goto exit_close_error; + goto exit_free_name; } for (i = 0; i < nlines; i++) @@ -94,9 +94,9 @@ int gpiotools_request_linehandle(const char *device_name, unsigned int *lines, "GPIO_GET_LINEHANDLE_IOCTL", ret, strerror(errno)); } -exit_close_error: if (close(fd) == -1) perror("Failed to close GPIO character device file"); +exit_free_name: free(chrdev_name); return ret < 0 ? ret : req.fd; } -- cgit v1.2.3 From df51f402e3b15b00284309bd3016bb4536d2260c Mon Sep 17 00:00:00 2001 From: Kent Gibson Date: Wed, 8 Jul 2020 12:16:00 +0800 Subject: tools: gpio: fix spurious close warning in gpio-event-mon Fix bogus close warning that occurs when opening the character device fails. Signed-off-by: Kent Gibson Signed-off-by: Bartosz Golaszewski --- tools/gpio/gpio-event-mon.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'tools') diff --git a/tools/gpio/gpio-event-mon.c b/tools/gpio/gpio-event-mon.c index 30ed0e06f52a..1a303a81aeef 100644 --- a/tools/gpio/gpio-event-mon.c +++ b/tools/gpio/gpio-event-mon.c @@ -45,7 +45,7 @@ int monitor_device(const char *device_name, if (fd == -1) { ret = -errno; fprintf(stderr, "Failed to open %s\n", chrdev_name); - goto exit_close_error; + goto exit_free_name; } req.lineoffset = line; @@ -117,6 +117,7 @@ int monitor_device(const char *device_name, exit_close_error: if (close(fd) == -1) perror("Failed to close GPIO character device file"); +exit_free_name: free(chrdev_name); return ret; } -- cgit v1.2.3