[RHEL7,COMMIT] mm/filemap: fix potential memcg->cache charge leak

Submitted by Vasily Averin on Oct. 8, 2020, 6:35 p.m.

Details

Message ID 202010081835.098IZEHH010399@vz7build.vvs.sw.ru
State New
Series "mm/filemap: fix potential memcg->cache charge leak"
Headers show

Commit Message

Vasily Averin Oct. 8, 2020, 6:35 p.m.
The commit is pushed to "branch-rh7-3.10.0-1127.18.2.vz7.163.x-ovz" and will appear at https://src.openvz.org/scm/ovz/vzkernel.git
after rh7-3.10.0-1127.18.2.vz7.163.35
------>
commit 79a5642e9d9a6bdbb56d9e0ee990fd96b7c8625c
Author: Andrey Ryabinin <aryabinin@virtuozzo.com>
Date:   Thu Oct 8 21:35:13 2020 +0300

    mm/filemap: fix potential memcg->cache charge leak
    
    __add_to_page_cache_locked() after mem_cgroup_try_charge_cache()
    uses mem_cgroup_cancel_charge() in one of the error paths.
    This may lead to leaking a few memcg->cache charges.
    
    Use mem_cgroup_cancel_cache_charge() to fix this.
    
    https://jira.sw.ru/browse/PSBM-121046
    Signed-off-by: Andrey Ryabinin <aryabinin@virtuozzo.com>
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Patch hide | download patch | download mbox

diff --git a/mm/filemap.c b/mm/filemap.c
index 53db13f..2bd5ca4 100644
--- a/mm/filemap.c
+++ b/mm/filemap.c
@@ -732,7 +732,7 @@  static int __add_to_page_cache_locked(struct page *page,
 	error = radix_tree_maybe_preload(gfp_mask & GFP_RECLAIM_MASK);
 	if (error) {
 		if (!huge)
-			mem_cgroup_cancel_charge(page, memcg);
+			mem_cgroup_cancel_cache_charge(page, memcg);
 		return error;
 	}