* [PATCH] md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns -ENOMEM
@ 2016-10-31 2:19 Guoqing Jiang
2016-11-04 20:19 ` Shaohua Li
0 siblings, 1 reply; 2+ messages in thread
From: Guoqing Jiang @ 2016-10-31 2:19 UTC (permalink / raw)
To: shli; +Cc: linux-raid, Guoqing Jiang
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 <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
---
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
^ permalink raw reply related [flat|nested] 2+ messages in thread
end of thread, other threads:[~2016-11-04 20:19 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-10-31 2:19 [PATCH] md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns -ENOMEM Guoqing Jiang
2016-11-04 20:19 ` Shaohua Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).