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

Submitted by Andrey Ryabinin on Oct. 8, 2020, 10:10 a.m.

Details

Message ID 20201008101055.5831-1-aryabinin@virtuozzo.com
State New
Series "mm/filemap: fix potential memcg->cache charge leak"
Headers show

Commit Message

Andrey Ryabinin Oct. 8, 2020, 10:10 a.m.
__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 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;
 	}
 

Comments

Andrey Ryabinin Oct. 9, 2020, 8:05 a.m.
On 10/9/20 10:14 AM, Vasily Averin wrote:
> vz8 is affected too, please cherry-pick 
> vz7 commit 79a5642e9d9a6bdbb56d9e0ee990fd96b7c8625c
> 

vz8 is not affected