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

Vasily Averin vvs at virtuozzo.com
Thu Oct 8 21:35:14 MSK 2020


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 at 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 at virtuozzo.com>
---
 mm/filemap.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

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;
 	}
 


More information about the Devel mailing list