From c721ba435fc7d2fb61a6e586c5cc11c27f67b480 Mon Sep 17 00:00:00 2001 From: Tobin Harding Date: Wed, 18 Oct 2017 03:37:50 +1100 Subject: Fix coverity defects: CID 161388 CID 161388: Resource Leak (REASOURCE_LEAK) Jump to errout so that file descriptor gets closed before returning from function. Reviewed-by: Brian Behlendorf Signed-off-by: Tobin C. Harding Closes #6755 --- cmd/zpool/zpool_main.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'cmd/zpool/zpool_main.c') diff --git a/cmd/zpool/zpool_main.c b/cmd/zpool/zpool_main.c index c61639cc2..db2486aee 100644 --- a/cmd/zpool/zpool_main.c +++ b/cmd/zpool/zpool_main.c @@ -897,7 +897,8 @@ zpool_do_labelclear(int argc, char **argv) if (zpool_read_label(fd, &config, NULL) != 0 || config == NULL) { (void) fprintf(stderr, gettext("failed to check state for %s\n"), vdev); - return (1); + ret = 1; + goto errout; } nvlist_free(config); @@ -905,7 +906,8 @@ zpool_do_labelclear(int argc, char **argv) if (ret != 0) { (void) fprintf(stderr, gettext("failed to check state for %s\n"), vdev); - return (1); + ret = 1; + goto errout; } if (!inuse) -- cgit v1.2.3