diff --git a/drivers/md/md.c b/drivers/md/md.c index 8c1e1900893db355510366d564ee8879de95f8b6..ea6837d45fc8c09ad2ba3fbf74accb4b0ff11031 100644 --- a/drivers/md/md.c +++ b/drivers/md/md.c @@ -3601,10 +3601,13 @@ static int set_bitmap_file(mddev_t *mddev, int fd) mddev->pers->quiesce(mddev, 1); if (fd >= 0) err = bitmap_create(mddev); - if (fd < 0 || err) + if (fd < 0 || err) { bitmap_destroy(mddev); + fd = -1; /* make sure to put the file */ + } mddev->pers->quiesce(mddev, 0); - } else if (fd < 0) { + } + if (fd < 0) { if (mddev->bitmap_file) fput(mddev->bitmap_file); mddev->bitmap_file = NULL;