anitazha / rpms / ndctl

Forked from rpms/ndctl 2 years ago
Clone

Blame SOURCES/0144-libdaxctl-free-resource-allocated-with-asprintf.patch

e0018b
From 057ca6fc2ce63625236bf00e795e0847e6508ed8 Mon Sep 17 00:00:00 2001
e0018b
From: Alison Schofield <alison.schofield@intel.com>
e0018b
Date: Thu, 3 Mar 2022 16:01:33 -0800
e0018b
Subject: [PATCH 144/217] libdaxctl: free resource allocated with asprintf()
e0018b
e0018b
Static analysis reported this resource leak.
e0018b
e0018b
Link: https://lore.kernel.org/r/20220304000133.1053883-1-alison.schofield@intel.com
e0018b
Fixes: d07508a0cc3c ("libdaxctl: add daxctl_region_create_dev()")
e0018b
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
e0018b
Signed-off-by: Vishal Verma <vishal.l.verma@intel.com>
e0018b
---
e0018b
 daxctl/lib/libdaxctl.c | 5 ++---
e0018b
 1 file changed, 2 insertions(+), 3 deletions(-)
e0018b
e0018b
diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
e0018b
index f173bbb..5703992 100644
e0018b
--- a/daxctl/lib/libdaxctl.c
e0018b
+++ b/daxctl/lib/libdaxctl.c
e0018b
@@ -624,10 +624,9 @@ DAXCTL_EXPORT int daxctl_region_create_dev(struct daxctl_region *region)
e0018b
 	}
e0018b
 
e0018b
 	rc = sysfs_write_attr(ctx, path, num_devices);
e0018b
-	if (rc)
e0018b
-		return rc;
e0018b
+	free(num_devices);
e0018b
 
e0018b
-	return 0;
e0018b
+	return rc;
e0018b
 }
e0018b
 
e0018b
 DAXCTL_EXPORT int daxctl_region_destroy_dev(struct daxctl_region *region,
e0018b
-- 
e0018b
2.27.0
e0018b