Skip to contentSkip to conversation

main - cov: memleak on error path

PATCH Zdenek Kabelac 1 participant 1 message Mar 10, 2021

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=a6075fe2f259c4b2abd946cf06f9b507f9a7a49e
Commit:        a6075fe2f259c4b2abd946cf06f9b507f9a7a49e
Parent:        241c63f7a72cecad085c8983b8a294d8d9985119
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Tue Mar 9 15:38:54 2021 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed Mar 10 01:29:44 2021 +0100

cov: memleak on error path

---
 lib/device/dev-cache.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
lib/device/dev-cache.c +3 -1
index 6cf798858..05b2b9bff 100644
@@ -1713,8 +1713,10 @@ static int _setup_devices_list(struct cmd_context *cmd)
 		if (!(du = zalloc(sizeof(struct dev_use))))
 			return_0;
 
-		if (!(du->devname = strdup(strl->str)))
+		if (!(du->devname = strdup(strl->str))) {
+			free(du);
 			return_0;
+		}
 
 		dm_list_add(&cmd->use_devices, &du->list);
 	}