summaryrefslogtreecommitdiffstats
path: root/Kill.c
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--Kill.c9
1 files changed, 8 insertions, 1 deletions
diff --git a/Kill.c b/Kill.c
index bfd0efd..43c9abe 100644
--- a/Kill.c
+++ b/Kill.c
@@ -41,6 +41,7 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
* 4 - failed to find a superblock.
*/
+ bool free_super = false;
int fd, rv = 0;
if (force)
@@ -52,8 +53,10 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
dev);
return 2;
}
- if (st == NULL)
+ if (st == NULL) {
st = guess_super(fd);
+ free_super = true;
+ }
if (st == NULL || st->ss->init_super == NULL) {
if (verbose >= 0)
pr_err("Unrecognised md component device - %s\n", dev);
@@ -77,6 +80,10 @@ int Kill(char *dev, struct supertype *st, int force, int verbose, int noexcl)
rv = 0;
}
}
+ if (free_super && st) {
+ st->ss->free_super(st);
+ free(st);
+ }
close(fd);
return rv;
}