bitmap: Fix resource leak in bitmap_file_open()

The code would leak 'fd' if locate_bitmap() failed.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
This commit is contained in:
Jes Sorensen 2016-03-07 13:48:19 -05:00
parent b913501173
commit de12cdc7eb
1 changed files with 2 additions and 0 deletions

View File

@ -220,10 +220,12 @@ int bitmap_file_open(char *filename, struct supertype **stp, int node_num)
} else if (!st->ss->locate_bitmap) {
pr_err("No bitmap possible with %s metadata\n",
st->ss->name);
close(fd);
return -1;
} else {
if (st->ss->locate_bitmap(st, fd, node_num)) {
pr_err("%s doesn't have bitmap\n", filename);
close(fd);
fd = -1;
}
}