Skip to contentSkip to conversation

master - raid: add free for error path

PATCH Zdenek Kabelac 1 participant 1 message Feb 28, 2018 MD RAID

lore
Share & tools
lore
#0 lore raw
Gitweb:        https://sourceware.org/git/?p=lvm2.git;a=commitdiff;h=261e6c3df69082490a685f0d0599e88139b9a927
Commit:        261e6c3df69082490a685f0d0599e88139b9a927
Parent:        9bfc8881cb712a6b164f08ca3d70ec99745e6c22
Author:        Zdenek Kabelac <[email protected]>
AuthorDate:    Sun Feb 25 16:20:30 2018 +0100
Committer:     Zdenek Kabelac <[email protected]>
CommitterDate: Wed Feb 28 21:05:18 2018 +0100

raid: add free for error path

Recent patch forget to release now allocated 'dso' on error path.

---
 lib/raid/raid.c |   10 +++++++---
 1 files changed, 7 insertions(+), 3 deletions(-)
lib/raid/raid.c +7 -3
index 31a0ac0..269a30c 100644
@@ -655,6 +655,7 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
 	char *dso = NULL;
 	unsigned i;
 	uint64_t monitored = 0;
+	int r = 1;
 
 #ifdef DEVMAPPER_SUPPORT
 #  ifdef DMEVENTD
@@ -667,11 +668,14 @@ int init_multiple_segtypes(struct cmd_context *cmd, struct segtype_library *segl
 
 	for (i = 0; i < DM_ARRAY_SIZE(_raid_types); ++i)
 		if ((segtype = _init_raid_segtype(cmd, &_raid_types[i], dso, monitored)) &&
-		    !lvm_register_segtype(seglib, segtype))
+		    !lvm_register_segtype(seglib, segtype)) {
 			/* segtype is already destroyed */
-			return_0;
+			stack;
+			r = 0;
+			break;
+		}
 
 	dm_free(dso);
 
-	return 1;
+	return r;
 }