diff mbox series

[ndctl] libdaxctl: free resource allocated with asprintf()

Message ID 20220304000133.1053883-1-alison.schofield@intel.com (mailing list archive)
State Accepted
Commit 057ca6fc2ce63625236bf00e795e0847e6508ed8
Headers show
Series [ndctl] libdaxctl: free resource allocated with asprintf() | expand

Commit Message

Alison Schofield March 4, 2022, 12:01 a.m. UTC
From: Alison Schofield <alison.schofield@intel.com>

Static analysis reported this resource leak.

Fixes: d07508a0cc3c ("libdaxctl: add daxctl_region_create_dev()")
Signed-off-by: Alison Schofield <alison.schofield@intel.com>
---
 daxctl/lib/libdaxctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)


base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4
diff mbox series

Patch

diff --git a/daxctl/lib/libdaxctl.c b/daxctl/lib/libdaxctl.c
index f173bbb7c514..5703992f5b88 100644
--- a/daxctl/lib/libdaxctl.c
+++ b/daxctl/lib/libdaxctl.c
@@ -624,10 +624,9 @@  DAXCTL_EXPORT int daxctl_region_create_dev(struct daxctl_region *region)
 	}
 
 	rc = sysfs_write_attr(ctx, path, num_devices);
-	if (rc)
-		return rc;
+	free(num_devices);
 
-	return 0;
+	return rc;
 }
 
 DAXCTL_EXPORT int daxctl_region_destroy_dev(struct daxctl_region *region,