summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJes Sorensen <Jes.Sorensen@redhat.com>2011-11-01 16:09:24 +0100
committerNeilBrown <neilb@suse.de>2011-11-02 10:48:53 +1100
commit518a60f3857b3f7db53756a72364c95c28fa3fd2 (patch)
treed5bf033eb4256fb2b83f2af9878f74853011e071
parent730ae51fddab9052fd2b61c8525ba684655e2f7e (diff)
Assemble(): don't dup_super() before we need it.
Avoid resource leak in case we bail loop early Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com> Signed-off-by: NeilBrown <neilb@suse.de>
-rw-r--r--Assemble.c4
1 files changed, 3 insertions, 1 deletions
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)