From 866bd1ef85a3ed09dc73826521cc16493285ec12 Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Thu, 13 Feb 2020 15:13:42 +0100 Subject: [PATCH] core: reuse the err_close_fd label in gpiod_chip_open() Remove redundant resource cleanup in error path after is_gpiochip_cdev() and reuse the already existing label. Signed-off-by: Bartosz Golaszewski --- lib/core.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/lib/core.c b/lib/core.c index ed63012..f704b44 100644 --- a/lib/core.c +++ b/lib/core.c @@ -179,10 +179,8 @@ struct gpiod_chip *gpiod_chip_open(const char *path) * We were able to open the file but is it really a gpiochip character * device? */ - if (!is_gpiochip_cdev(path)) { - close(fd); - return NULL; - } + if (!is_gpiochip_cdev(path)) + goto err_close_fd; chip = malloc(sizeof(*chip)); if (!chip) -- 2.30.2