[PATCH] md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns -ENOMEM

From
Guoqing Jiang <hidden>
Date
2016-10-31 02:19:00
It is possible that bitmap_storage_alloc could return -ENOMEM,
and some member inside store could be allocated such as filemap.

To avoid memory leak, we need to call bitmap_file_unmap to free
those members in the bitmap_resize.

Reviewed-by: NeilBrown <redacted>
Signed-off-by: Guoqing Jiang <redacted>
---
 drivers/md/bitmap.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c
index 2d826927a3bf..cd3a0659cc07 100644
--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -2029,8 +2029,10 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks,
 					   !bitmap->mddev->bitmap_info.external,
 					   mddev_is_clustered(bitmap->mddev)
 					   ? bitmap->cluster_slot : 0);
-	if (ret)
+	if (ret) {
+		bitmap_file_unmap(&store);
 		goto err;
+	}
 
 	pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
 
-- 
2.6.2
Thread (2 messages) 2 messages, 2 authors, last reply 2016-11-04
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