Patchwork [2/4] UBUNTU: xen: Check for NULL pointer before using pgd

login
register
mail settings
Submitter Stefan Bader
Date June 22, 2011, 1:42 p.m.
Message ID <1308750171-12578-2-git-send-email-stefan.bader@canonical.com>
Download mbox | patch
Permalink /patch/101470/
State New
Headers show

Comments

Stefan Bader - June 22, 2011, 1:42 p.m.
In pgd_alloc(), the test for the new pgd being NULL is done
after it has already been used for test_and_unpin(). Do that
check before.

BugLink: http://bugs.launchpad.net/bugs/705562

Signed-off-by: Stefan Bader <stefan.bader@canonical.com>
---
 arch/x86/mm/pgtable_32-xen.c |    5 ++++-
 1 files changed, 4 insertions(+), 1 deletions(-)

Patch

diff --git a/arch/x86/mm/pgtable_32-xen.c b/arch/x86/mm/pgtable_32-xen.c
index 74a2e57..48242aa 100644
--- a/arch/x86/mm/pgtable_32-xen.c
+++ b/arch/x86/mm/pgtable_32-xen.c
@@ -345,9 +345,12 @@  pgd_t *pgd_alloc(struct mm_struct *mm)
 	pmd_t **pmds = NULL;
 	unsigned long flags;
 
+	if (!pgd)
+		return NULL;
+
 	pgd_test_and_unpin(pgd);
 
-	if (PTRS_PER_PMD == 1 || !pgd)
+	if (PTRS_PER_PMD == 1)
 		return pgd;
 
 #ifdef CONFIG_XEN