Re: uprobes: memory leak in enable/disable loop

From: Johannes Weiner
Date: Tue Aug 16 2016 - 13:40:04 EST


On Tue, Aug 16, 2016 at 04:34:08PM +0200, Oleg Nesterov wrote:
> @@ -172,8 +172,10 @@ static int __replace_page(struct vm_area
> mmu_notifier_invalidate_range_start(mm, mmun_start, mmun_end);
> err = -EAGAIN;
> ptep = page_check_address(page, mm, addr, &ptl, 0);
> - if (!ptep)
> + if (!ptep) {
> + mem_cgroup_cancel_charge(kpage, memcg, false);
> goto unlock;
> + }
>
> get_page(kpage);
> page_add_new_anon_rmap(kpage, vma, addr, false);
> @@ -200,7 +202,6 @@ static int __replace_page(struct vm_area
>
> err = 0;
> unlock:
> - mem_cgroup_cancel_charge(kpage, memcg, false);

Ouch. I must have mistaken this for an exclusive error path.

The patch looks good, thank you.

Reviewed-by: Johannes Weiner <hannes@xxxxxxxxxxx>
Fixes: 00501b531c47 ("mm: memcontrol: rewrite charge API")
Cc: stable@xxxxxxxxxxxxxxx # 3.17+