Skip to contentSkip to conversation

libdaxctl: free resource allocated with asprintf()

PATCH New [email protected] 1 participant 1 message Mar 3, 2022 libnvdimm: non-volatile memory device

lore
Share & tools
lore

[email protected]

author maintainer
#0 lore raw

PATCH 1/1 libdaxctl: free resource allocated with asprintf()

From: Alison Schofield <[email protected]>

Static analysis reported this resource leak.

Fixes d07508a0cc3c ("libdaxctl: add daxctl_region_create_dev()")
---
 daxctl/lib/libdaxctl.c | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)
daxctl/lib/libdaxctl.c +2 -3
index f173bbb7c514..5703992f5b88 100644
@@ -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,

base-commit: 3b5fb8b6428dfaab39bab58d67412427f514c1f4

Signature · 1 line
2.31.1