From: Jes Sorensen Date: Tue, 1 Nov 2011 15:09:24 +0000 (+0100) Subject: Assemble(): don't dup_super() before we need it. X-Git-Tag: mdadm-3.2.3~88 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=518a60f3857b3f7db53756a72364c95c28fa3fd2;p=thirdparty%2Fmdadm.git 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 --- diff --git a/Assemble.c b/Assemble.c index 05710f53..3c8e74dc 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)