diff options
author | Guoqing Jiang <gqjiang@suse.com> | 2016-10-31 10:19:00 +0800 |
---|---|---|
committer | Shaohua Li <shli@fb.com> | 2016-11-07 15:08:21 -0800 |
commit | cbb387323610295be9d36c51287b668c1140704f (patch) | |
tree | b697134a5e51559f4ab83d440825f10316f4dfb4 /drivers/md/bitmap.c | |
parent | 7adb072ca83d71103ecc8578bee5f73c4f1eba89 (diff) | |
download | linux-cbb387323610295be9d36c51287b668c1140704f.tar.bz2 |
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 <neilb@suse.com>
Signed-off-by: Guoqing Jiang <gqjiang@suse.com>
Signed-off-by: Shaohua Li <shli@fb.com>
Diffstat (limited to 'drivers/md/bitmap.c')
-rw-r--r-- | drivers/md/bitmap.c | 4 |
1 files changed, 3 insertions, 1 deletions
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); |