Skip to content

Commit

Permalink
parisc: mm: Fix a memory leak related to pmd not attached to the pgd
Browse files Browse the repository at this point in the history
Commit 0e0da48 ("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 <christophe.jaillet@wanadoo.fr>
Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>
Acked-by: Mikulas Patocka <mpatocka@redhat.com>
Acked-by: Helge Deller <deller@gmx.de>
Cc: stable@vger.kernel.org  # v4.0+
Signed-off-by: Helge Deller <deller@gmx.de>
  • Loading branch information
Christophe Jaillet authored and Helge Deller committed Jul 19, 2015
1 parent 9d37e66 commit 4c4ac9a
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion arch/parisc/include/asm/pgalloc.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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);
}

Expand Down

0 comments on commit 4c4ac9a

Please sign in to comment.