From: Guoqing Jiang Date: Mon, 31 Oct 2016 02:19:00 +0000 (+0800) Subject: md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns -ENOMEM X-Git-Tag: v4.14-rc1~1897^2^2~60 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=cbb387323610295be9d36c51287b668c1140704f;p=platform%2Fkernel%2Flinux-rpi.git md/bitmap: call bitmap_file_unmap once bitmap_storage_alloc returns -ENOMEM 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 Signed-off-by: Guoqing Jiang Signed-off-by: Shaohua Li --- diff --git a/drivers/md/bitmap.c b/drivers/md/bitmap.c index 2d82692..cd3a065 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);