From 518a60f3857b3f7db53756a72364c95c28fa3fd2 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 1 Nov 2011 16:09:24 +0100 Subject: [PATCH] Assemble(): don't dup_super() before we need it. Avoid resource leak in case we bail loop early Signed-off-by: Jes Sorensen Signed-off-by: NeilBrown --- Assemble.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Assemble.c b/Assemble.c index 05710f5..3c8e74d 100644 --- a/Assemble.c +++ b/Assemble.c @@ -293,7 +293,7 @@ int Assemble(struct supertype *st, char *mddev, char *devname = tmpdev->devname; int dfd; struct stat stb; - struct supertype *tst = dup_super(st); + struct supertype *tst; struct dev_policy *pol = NULL; int found_container = 0; @@ -306,6 +306,8 @@ int Assemble(struct supertype *st, char *mddev, continue; } + tst = dup_super(st); + dfd = dev_open(devname, O_RDONLY|O_EXCL); if (dfd < 0) { if (report_missmatch)