Thread (15 messages) 15 messages, 2 authors, 2011-11-03
STALE5364d

[PATCH 12/12] match_metadata_desc(): Fix memory leak

From: <hidden>
Date: 2011-11-02 14:42:17
Subsystem: the rest · Maintainer: Linus Torvalds

From: Jes Sorensen <redacted>

Signed-off-by: Jes Sorensen <redacted>
---
 super-mbr.c |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/super-mbr.c b/super-mbr.c
index 5eefdf6..6499963 100644
--- a/super-mbr.c
+++ b/super-mbr.c
@@ -169,13 +169,14 @@ static void getinfo_mbr(struct supertype *st, struct mdinfo *info, char *map)
 
 static struct supertype *match_metadata_desc(char *arg)
 {
-	struct supertype *st = malloc(sizeof(*st));
+	struct supertype *st;
 
-	if (!st)
-		return st;
 	if (strcmp(arg, "mbr") != 0)
 		return NULL;
 
+	st = malloc(sizeof(*st));
+	if (!st)
+		return st;
 	st->ss = &mbr;
 	st->info = NULL;
 	st->minor_version = 0;
-- 
1.7.6.4
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help