Blame SOURCES/0005-nvme-topology-fix-memory-leaks-in-nvme_logical_block.patch

955b2d
From b580886dbc322b2a71d6c0c1b71f9fca7b750b02 Mon Sep 17 00:00:00 2001
955b2d
From: Maurizio Lombardi <mlombard@redhat.com>
955b2d
Date: Tue, 14 Dec 2021 09:58:09 +0100
955b2d
Subject: [PATCH 4/6] nvme-topology: fix memory leaks in
955b2d
 nvme_logical_block_size_from_ns_char()
955b2d
955b2d
Free the allocated strings before returning from the function
955b2d
955b2d
Signed-off-by: Maurizio Lombardi <mlombard@redhat.com>
955b2d
---
955b2d
 nvme-topology.c | 5 ++++-
955b2d
 1 file changed, 4 insertions(+), 1 deletion(-)
955b2d
955b2d
diff --git a/nvme-topology.c b/nvme-topology.c
955b2d
index 0a22f6b..6be2b09 100644
955b2d
--- a/nvme-topology.c
955b2d
+++ b/nvme-topology.c
955b2d
@@ -686,10 +686,13 @@ int nvme_logical_block_size_from_ns_char(const char *dev)
955b2d
 		return -EINVAL;
955b2d
 
955b2d
 	s = nvme_get_ctrl_attr(path, "logical_block_size");
955b2d
+	free(path);
955b2d
 	if (!s)
955b2d
 		return -EINVAL;
955b2d
 
955b2d
-	return atoi(s);
955b2d
+	ret = atoi(s);
955b2d
+	free(s);
955b2d
+	return ret;
955b2d
 }
955b2d
 
955b2d
 void *mmap_registers(const char *dev)
955b2d
-- 
955b2d
2.27.0
955b2d