From: Jes Sorensen Date: Mon, 7 Mar 2016 18:48:19 +0000 (-0500) Subject: bitmap: Fix resource leak in bitmap_file_open() X-Git-Tag: mdadm-4.0~119 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=de12cdc7eb528d76017365a23ff38bd863afddda;p=thirdparty%2Fmdadm.git 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 --- diff --git a/bitmap.c b/bitmap.c index 5ad7401b..51dda8be 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; } }