From: Karel Zak <kzak@redhat.com>
Date: Wed, 2 Jul 2025 12:25:45 +0200
Subject: lib/path: avoid double free() for cpusets

Addresses: https://github.com/util-linux/util-linux/issues/3641
Signed-off-by: Karel Zak <kzak@redhat.com>
---
 lib/path.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/lib/path.c b/lib/path.c
index 48324d6..a828aea 100644
--- a/lib/path.c
+++ b/lib/path.c
@@ -1057,8 +1057,10 @@ static int ul_path_cpuparse(struct path_cxt *pc, cpu_set_t **set, int maxcpus, i
 	rc = 0;
 
 out:
-	if (rc)
+	if (rc) {
 		cpuset_free(*set);
+		*set = NULL;
+	}
 	free(buf);
 	return rc;
 }
