File 0018-bitmap-Fix-resource-leak-in-bitmap_file_open.patch of Package mdadm.7129
From de12cdc7eb528d76017365a23ff38bd863afddda Mon Sep 17 00:00:00 2001
From: Jes Sorensen <Jes.Sorensen@redhat.com>
Date: Mon, 7 Mar 2016 13:48:19 -0500
Subject: [PATCH 240/359] bitmap: Fix resource leak in bitmap_file_open()
References: bsc#1081910
The code would leak 'fd' if locate_bitmap() failed.
Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: Coly Li <colyli@suse.de>
---
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;
}
}
--
2.16.1