From 10cefb33373b0d6808b6754b59a4946e5725c204 Mon Sep 17 00:00:00 2001 From: Eduard Shishkin Date: Wed, 2 Nov 2022 14:26:24 +0100 Subject: [PATCH] zipl/src/zipl_helper.device-mapper: Fix bug in error path MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prevent double free/close that happens in get_multipath_status() when the output of "dmsetup status XXX" is empty Fixes: 599b141 ("zipl: Rewrite helper script in C") Signed-off-by: Eduard Shishkin Reviewed-by: Peter Oberparleiter Reviewed-by: Steffen Eiden Signed-off-by: Jan Höppner --- zipl/src/zipl_helper.device-mapper.c | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/zipl/src/zipl_helper.device-mapper.c b/zipl/src/zipl_helper.device-mapper.c index d60159d6..3a44735f 100644 --- a/zipl/src/zipl_helper.device-mapper.c +++ b/zipl/src/zipl_helper.device-mapper.c @@ -611,9 +611,6 @@ static struct util_list *get_multipath_status(const char *devname) } } - free(line); - pclose(fp); - len = util_list_len(status); if (len == 0) { ERR("No paths found for '%s'\n", devname); @@ -625,15 +622,14 @@ static struct util_list *get_multipath_status(const char *devname) WARN("There are one or more failed paths for device '%s'\n", devname); } - - return status; - -out: + goto success; + out: + status_list_free(status); + status = NULL; + success: free(line); pclose(fp); - status_list_free(status); - - return NULL; + return status; } static struct util_list *get_multipath_data(const char *devname, char *args)