Re: [PATCH] Memory leak once alloc superblock page failed

From
Xiao Ni <hidden>
Date
2014-08-25 07:45:57
Sorry for this patch. I find the memory will be released in the function bitmap_free
which is called in error path of bitmap_create.

The patch is wrong.

Best Regards
Xiao

----- Original Message -----
quoted hunk
From: "Xiao Ni" <redacted>
To: <redacted>
Cc: "jes sorensen" <redacted>, "Xiao Ni" <redacted>
Sent: Wednesday, August 20, 2014 10:08:00 AM
Subject: [PATCH] Memory leak once alloc superblock page failed

[PATCH] Fix memory leak if alloc superblock page fails

Signed-off-by: Xiao Ni <redacted>
---
 drivers/md/bitmap.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 67f8b31..5997c34 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -698,8 +698,11 @@ static int bitmap_storage_alloc(struct bitmap_storage
*store,
 
 	if (with_super && !store->sb_page) {
 		store->sb_page = alloc_page(GFP_KERNEL|__GFP_ZERO);
-		if (store->sb_page == NULL)
+		if (store->sb_page == NULL) {
+			kfree(store->filemap);
+			store->filemap = NULL;
 			return -ENOMEM;
+		}
 		store->sb_page->index = 0;
 	}
 	pnum = 0;
--
1.7.1
Thread (1 message) 1 message, 1 author, last reply 2014-08-25
Keyboard shortcuts
hback out one level
jnext message in thread / next series-diff position
kprevious message in thread / previous series-diff position
ldrill in
Escclose help / fold thread tree
?toggle this help