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

Andrey Ryabinin aryabinin at virtuozzo.com
Thu Oct 8 13:10:55 MSK 2020


__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 53db13f236da..2bd5ca4e7528 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;
 	}
 
-- 
2.26.2



More information about the Devel mailing list