]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
bitmap: Fix resource leak in bitmap_file_open()
authorJes Sorensen <Jes.Sorensen@redhat.com>
Mon, 7 Mar 2016 18:48:19 +0000 (13:48 -0500)
committerJes Sorensen <Jes.Sorensen@redhat.com>
Wed, 9 Mar 2016 16:35:34 +0000 (11:35 -0500)
The code would leak 'fd' if locate_bitmap() failed.

Reviewed-by: NeilBrown <neilb@suse.com>
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
bitmap.c

index 5ad7401bed0735d2763e697dc508396cba303c03..51dda8bea4dc82e45bd3c7bb043e3d44e77b3d69 100644 (file)
--- 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;
                        }
                }