summaryrefslogtreecommitdiffstats
path: root/super1.c
diff options
context:
space:
mode:
Diffstat (limited to 'super1.c')
-rw-r--r--super1.c9
1 files changed, 7 insertions, 2 deletions
diff --git a/super1.c b/super1.c
index 8678765..736ed7d 100644
--- a/super1.c
+++ b/super1.c
@@ -478,11 +478,15 @@ static int write_init_super1(struct supertype *st, void *sbv, mdu_disk_info_t *d
*(__u32*)(sb->device_uuid+12) = random();
- if (ioctl(fd, BLKGETSIZE, &size))
+ if (ioctl(fd, BLKGETSIZE, &size)) {
+ close(fd);
return 1;
+ }
- if (size < 24)
+ if (size < 24) {
+ close(fd);
return 2;
+ }
/*
@@ -522,6 +526,7 @@ static int write_init_super1(struct supertype *st, void *sbv, mdu_disk_info_t *d
rv = store_super1(fd, sb);
if (rv)
fprintf(stderr, Name ": failed to write superblock to %s\n", devname);
+ close(fd);
return rv;
}