]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
bitmap_fd_read(): fix memory leak
authorJes Sorensen <Jes.Sorensen@redhat.com>
Tue, 1 Nov 2011 15:09:33 +0000 (16:09 +0100)
committerNeilBrown <neilb@suse.de>
Tue, 1 Nov 2011 23:48:53 +0000 (10:48 +1100)
Signed-off-by: Jes Sorensen <Jes.Sorensen@redhat.com>
Signed-off-by: NeilBrown <neilb@suse.de>
bitmap.c

index 2e1ecdac2e6be666bc8063ee812414c4b7e73eb4..d02f16e64604cb74490e17fc6ad0a58fb5db57ef 100644 (file)
--- a/bitmap.c
+++ b/bitmap.c
@@ -147,6 +147,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
                fprintf(stderr, Name ": failed to allocate %zd bytes\n",
                                sizeof(*info));
 #endif
+               free(buf);
                return NULL;
        }
 
@@ -154,6 +155,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
                fprintf(stderr, Name ": failed to read superblock of bitmap "
                        "file: %s\n", strerror(errno));
                free(info);
+               free(buf);
                return NULL;
        }
        memcpy(&info->sb, buf, sizeof(info->sb));
@@ -198,6 +200,7 @@ bitmap_info_t *bitmap_fd_read(int fd, int brief)
                total_bits = read_bits;
        }
 out:
+       free(buf);
        info->total_bits = total_bits;
        info->dirty_bits = dirty_bits;
        return info;