From 39c74d5e25208e70ac7cc9e63932ff04125e0817 Mon Sep 17 00:00:00 2001 From: Jes Sorensen Date: Tue, 1 Nov 2011 16:09:33 +0100 Subject: [PATCH] bitmap_fd_read(): fix memory leak Signed-off-by: Jes Sorensen Signed-off-by: NeilBrown --- bitmap.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/bitmap.c b/bitmap.c index 2e1ecda..d02f16e 100644 --- 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;