Blame SOURCES/0006-gpt_disk_get_partition_info-free-our-allocations-on-.patch

ac385c
From 939e4a8524821ccc30b34fec97416bc1b97b5455 Mon Sep 17 00:00:00 2001
ac385c
From: Peter Jones <pjones@redhat.com>
ac385c
Date: Mon, 1 May 2017 14:44:43 -0400
ac385c
Subject: [PATCH 06/22] gpt_disk_get_partition_info(): free our allocations on
ac385c
 the error path.
ac385c
ac385c
When gpt_disk_get_partition_info() discovers that a partition is
ac385c
invalid, it returns error, but it forgets to free its allocations.
ac385c
ac385c
Found by covscan.
ac385c
ac385c
Signed-off-by: Peter Jones <pjones@redhat.com>
ac385c
---
ac385c
 src/gpt.c | 10 ++++------
ac385c
 1 file changed, 4 insertions(+), 6 deletions(-)
ac385c
ac385c
diff --git a/src/gpt.c b/src/gpt.c
ac385c
index 30cbdfd..e9c713b 100644
ac385c
--- a/src/gpt.c
ac385c
+++ b/src/gpt.c
ac385c
@@ -640,7 +640,7 @@ gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
ac385c
 	gpt_entry *ptes = NULL, *p;
ac385c
 	int rc = 0;
ac385c
 
ac385c
-	char *report=getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
ac385c
+	char *report = getenv("LIBEFIBOOT_REPORT_GPT_ERRORS");
ac385c
 	if (report)
ac385c
 		report_errors = 1;
ac385c
 
ac385c
@@ -662,12 +662,10 @@ gpt_disk_get_partition_info(int fd, uint32_t num, uint64_t * start,
ac385c
 		if (report_errors)
ac385c
 			fprintf(stderr, "partition %d is not valid\n", num);
ac385c
 		errno = EINVAL;
ac385c
-		return -1;
ac385c
+		rc = -1;
ac385c
 	}
ac385c
-	if (ptes)
ac385c
-		free(ptes);
ac385c
-	if (gpt)
ac385c
-		free(gpt);
ac385c
+	free(ptes);
ac385c
+	free(gpt);
ac385c
 
ac385c
 	return rc;
ac385c
 }
ac385c
-- 
ac385c
2.12.2
ac385c