From 9ae0289e8142097f4d3cf91bd4d1f2a5621914c7 Mon Sep 17 00:00:00 2001
From: Karel Zak <kzak@redhat.com>
Date: Thu, 17 Mar 2022 11:22:29 +0100
Subject: [PATCH] partx: remove memory leak to make scanners happy  [coverity
 scan]

Signed-off-by: Karel Zak <kzak@redhat.com>
---
 disk-utils/partx.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/disk-utils/partx.c b/disk-utils/partx.c
index 07b3e28b9e..76872907fe 100644
--- a/disk-utils/partx.c
+++ b/disk-utils/partx.c
@@ -1013,6 +1013,7 @@ int main(int argc, char **argv)
 				errx(EXIT_FAILURE, _("%s: partitioned loop devices unsupported"),
 				     wholedisk);
 			assoc_loopdev(wholedisk);
+			free(wholedisk);
 			wholedisk = xstrdup(lc.device);
 		} else if (!S_ISBLK(x.st_mode))
 			errx(EXIT_FAILURE, _("%s: not a block device"), wholedisk);
@@ -1061,6 +1062,8 @@ int main(int argc, char **argv)
 		blkid_free_probe(pr);
 	}
 
+	free(wholedisk);
+
 	if (loopdev)
 		loopcxt_deinit(&lc);
 
