Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > linux.kernel > #1182637 > unrolled thread

[PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd

Started byChristophe JAILLET <christophe.jaillet@wanadoo.fr>
First post2015-07-13 11:40 +0200
Last post2015-07-13 14:50 +0200
Articles 3 — 3 participants

Back to article view | Back to linux.kernel


Contents

  [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd Christophe JAILLET <christophe.jaillet@wanadoo.fr> - 2015-07-13 11:40 +0200
    RE: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached  to the pgd "Kirill A. Shutemov" <kirill.shutemov@linux.intel.com> - 2015-07-13 11:50 +0200
    Re: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached  to the pgd Mikulas Patocka <mpatocka@redhat.com> - 2015-07-13 14:50 +0200

#1182637 — [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd

FromChristophe JAILLET <christophe.jaillet@wanadoo.fr>
Date2015-07-13 11:40 +0200
Subject[PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd
Message-ID<pLInp-3kU-3@gated-at.bofh.it>
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 <christophe.jaillet@wanadoo.fr>
---
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/

[toc] | [next] | [standalone]


#1182653 — RE: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd

From"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>
Date2015-07-13 11:50 +0200
SubjectRE: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd
Message-ID<pLIx3-3o4-1@gated-at.bofh.it>
In reply to#1182637
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 <christophe.jaillet@wanadoo.fr>

Acked-by: Kirill A. Shutemov <kirill.shutemov@linux.intel.com>

> ---
> 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/

[toc] | [prev] | [next] | [standalone]


#1182778 — Re: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd

FromMikulas Patocka <mpatocka@redhat.com>
Date2015-07-13 14:50 +0200
SubjectRe: [PATCH] parisc: mm: Fix a memory leak related to pmd not attached to the pgd
Message-ID<pLLlg-53X-1@gated-at.bofh.it>
In reply to#1182637

On Mon, 13 Jul 2015, 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 <christophe.jaillet@wanadoo.fr>

Acked-by: Mikulas Patocka <mpatocka@redhat.com>

also add this, so that it is backported to 4.0 and 4.2:
Cc: stable@vger.kernel.org	# 4.0+
Fixes: 0e0da48dee8d

> ---
> 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/

[toc] | [prev] | [standalone]


Back to top | Article view | linux.kernel


csiph-web