Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752422AbbGMJqc (ORCPT ); Mon, 13 Jul 2015 05:46:32 -0400 Received: from mga01.intel.com ([192.55.52.88]:7743 "EHLO mga01.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751658AbbGMJq3 (ORCPT ); Mon, 13 Jul 2015 05:46:29 -0400 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.15,462,1432623600"; d="scan'208";a="761360677" From: "Kirill A. Shutemov" To: Christophe JAILLET Cc: jejb@parisc-linux.org, deller@gmx.de, mpatocka@redhat.com, kirill.shutemov@linux.intel.com, linux-parisc@vger.kernel.org, linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, Christophe JAILLET In-Reply-To: <1436779963-4286-1-git-send-email-christophe.jaillet@wanadoo.fr> References: <1436779963-4286-1-git-send-email-christophe.jaillet@wanadoo.fr> Subject: RE: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd Content-Transfer-Encoding: 7bit Message-Id: <20150713094625.79B6EA4@black.fi.intel.com> Date: Mon, 13 Jul 2015 12:46:25 +0300 (EEST) Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1746 Lines: 50 Christophe JAILLET wrote: > Commit 0e0da48dee8d ("parisc: mm: don't count preallocated pmds") > introduced a memory leak. > > After this commit, the 'return' statement in pmd_free is executed in all > cases. Even for pmd that are not attached to the pgd. > So 'free_pages' can never be called anymore, leading to a memory leak. > > Signed-off-by: Christophe JAILLET Acked-by: Kirill A. Shutemov > --- > This patch is *untested* as I don't have the hardware to test it. > > This is just a guess based on the indentation, the comment in the code > and the commit log. > --- > arch/parisc/include/asm/pgalloc.h | 3 ++- > 1 file changed, 2 insertions(+), 1 deletion(-) > > diff --git a/arch/parisc/include/asm/pgalloc.h b/arch/parisc/include/asm/pgalloc.h > index 3a08eae..f66d3738 100644 > --- a/arch/parisc/include/asm/pgalloc.h > +++ b/arch/parisc/include/asm/pgalloc.h > @@ -72,7 +72,7 @@ static inline pmd_t *pmd_alloc_one(struct mm_struct *mm, unsigned long address) > > static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) > { > - if(pmd_flag(*pmd) & PxD_FLAG_ATTACHED) > + if (pmd_flag(*pmd) & PxD_FLAG_ATTACHED) { > /* > * This is the permanent pmd attached to the pgd; > * cannot free it. > @@ -81,6 +81,7 @@ static inline void pmd_free(struct mm_struct *mm, pmd_t *pmd) > */ > mm_inc_nr_pmds(mm); > return; > + } > free_pages((unsigned long)pmd, PMD_ORDER); > } > > -- > 2.1.4 > -- 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/