]> git.ipfire.org Git - thirdparty/mdadm.git/blobdiff - super0.c
Don't close fds in write_init_super
[thirdparty/mdadm.git] / super0.c
index d69d0c049ad81d5337a1432158c91e4d0cf08e66..0b95dac214c73c34bf64d6bcf704a51395cd50f7 100644 (file)
--- a/super0.c
+++ b/super0.c
@@ -752,8 +752,6 @@ static int write_init_super0(struct supertype *st)
                        fprintf(stderr,
                                Name ": failed to write superblock to %s\n",
                                di->devname);
-               close(di->fd);
-               di->fd = -1;
        }
        return rv;
 }
@@ -1079,6 +1077,13 @@ static void free_super0(struct supertype *st)
 {
        if (st->sb)
                free(st->sb);
+       while (st->info) {
+               struct devinfo *di = st->info;
+               st->info = di->next;
+               if (di->fd >= 0)
+                       close(di->fd);
+               free(di);
+       }
        st->sb = NULL;
 }