linux-mm.kvack.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] rmap: validate pointer in anon_vma_clone
@ 2014-05-07  2:32 Leon Ma
  2014-05-07  2:58 ` Ma, Xindong
  2014-05-07  4:28 ` Jianyu Zhan
  0 siblings, 2 replies; 3+ messages in thread
From: Leon Ma @ 2014-05-07  2:32 UTC (permalink / raw)
  To: akpm, iamjoonsoo.kim, n-horiguchi, kirill.shutemov, gorcunov,
	linux-mm, linux-kernel
  Cc: Leon Ma

If memory allocation failed in first loop, root will be NULL and
will lead to kernel panic.

Signed-off-by: Leon Ma <xindong.ma@intel.com>
---
 mm/rmap.c |    6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/mm/rmap.c b/mm/rmap.c
index 9c3e773..6e53aed 100644
--- a/mm/rmap.c
+++ b/mm/rmap.c
@@ -246,8 +246,10 @@ int anon_vma_clone(struct vm_area_struct *dst, struct vm_area_struct *src)
 
 		avc = anon_vma_chain_alloc(GFP_NOWAIT | __GFP_NOWARN);
 		if (unlikely(!avc)) {
-			unlock_anon_vma_root(root);
-			root = NULL;
+			if (!root) {
+				unlock_anon_vma_root(root);
+				root = NULL;
+			}
 			avc = anon_vma_chain_alloc(GFP_KERNEL);
 			if (!avc)
 				goto enomem_failure;
-- 
1.7.9.5

--
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: <a href=mailto:"dont@kvack.org"> email@kvack.org </a>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2014-05-07  4:28 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-05-07  2:32 [PATCH] rmap: validate pointer in anon_vma_clone Leon Ma
2014-05-07  2:58 ` Ma, Xindong
2014-05-07  4:28 ` Jianyu Zhan

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox