Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752380AbZDTXg7 (ORCPT ); Mon, 20 Apr 2009 19:36:59 -0400 Received: (majordomo@vger.kernel.org) by vger.kernel.org id S1752156AbZDTXgt (ORCPT ); Mon, 20 Apr 2009 19:36:49 -0400 Received: from ti-out-0910.google.com ([209.85.142.187]:24485 "EHLO ti-out-0910.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752152AbZDTXgs (ORCPT ); Mon, 20 Apr 2009 19:36:48 -0400 DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:x-mailer :mime-version:content-type:content-transfer-encoding; b=weOrfvIZsrYQt1+9oczeF3u3kmmi1V4LqxbbZ73hJBCrePgUspkzJVWsAkMgy0RgPX WzO+L23QdfRxy4Q6J8vDdVRlOH9e1v2NhCWeQmdToICUvrS88BciBGsG4DlUvzq1ksWI d/3pNgn1qNO6j1VFXO5UsZuIuM6+2PnqE/Grk= Date: Tue, 21 Apr 2009 08:36:39 +0900 From: Minchan Kim To: Johannes Weiner Cc: Andrew Morton , linux-mm@kvack.org, linux-kernel@vger.kernel.org, Balbir Singh Subject: Re: [patch 1/3] mm: fix pageref leak in do_swap_page() Message-Id: <20090421083639.97ae549c.minchan.kim@barrios-desktop> In-Reply-To: <1240259085-25872-1-git-send-email-hannes@cmpxchg.org> References: <1240259085-25872-1-git-send-email-hannes@cmpxchg.org> X-Mailer: Sylpheed 2.4.8 (GTK+ 2.12.9; i486-pc-linux-gnu) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1683 Lines: 58 On Mon, 20 Apr 2009 22:24:43 +0200 Johannes Weiner wrote: Nice catch!! Reviewed-by: Minchan Kim > By the time the memory cgroup code is notified about a swapin we > already hold a reference on the fault page. > > If the cgroup callback fails make sure to unlock AND release the page > or we leak the reference. > > Signed-off-by: Johannes Weiner > Cc: Balbir Singh > --- > mm/memory.c | 4 ++-- > 1 files changed, 2 insertions(+), 2 deletions(-) > > diff --git a/mm/memory.c b/mm/memory.c > index 366dab5..db126b6 100644 > --- a/mm/memory.c > +++ b/mm/memory.c > @@ -2536,8 +2536,7 @@ static int do_swap_page(struct mm_struct *mm, struct vm_area_struct *vma, > > if (mem_cgroup_try_charge_swapin(mm, page, GFP_KERNEL, &ptr)) { > ret = VM_FAULT_OOM; > - unlock_page(page); > - goto out; > + goto out_page; > } > > /* > @@ -2599,6 +2598,7 @@ out: > out_nomap: > mem_cgroup_cancel_charge_swapin(ptr); > pte_unmap_unlock(page_table, ptl); > +out_page: > unlock_page(page); > page_cache_release(page); > return ret; > -- > 1.6.2.1.135.gde769 > > -- > To unsubscribe, send a message with 'unsubscribe linux-mm' in > the body to majordomo@kvack.org. For more info on Linux MM, > see: http://www.linux-mm.org/ . > Don't email: email@kvack.org -- Kinds Regards Minchan Kim -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/