From de12cdc7eb528d76017365a23ff38bd863afddda Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Mon, 7 Mar 2016 13:48:19 -0500 Subject: [PATCH] bitmap: Fix resource leak in bitmap_file_open() The code would leak 'fd' if locate_bitmap() failed. Reviewed-by: NeilBrown Signed-off-by: Jes Sorensen --- bitmap.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/bitmap.c b/bitmap.c index 5ad7401..51dda8b 100644 --- a/bitmap.c +++ b/bitmap.c @@ -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; } }