X-Git-Url: http://git.ipfire.org/?a=blobdiff_plain;f=super0.c;h=0b95dac214c73c34bf64d6bcf704a51395cd50f7;hb=1cc7f4feb9a979fdf7ac4bb06e5632b065d4f4d9;hp=d69d0c049ad81d5337a1432158c91e4d0cf08e66;hpb=446d2a5ad48671be2e23676d9ea93af1b8dddf0b;p=thirdparty%2Fmdadm.git diff --git a/super0.c b/super0.c index d69d0c04..0b95dac2 100644 --- 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; }