lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <1343135751-8336-1-git-send-email-yliu.null@gmail.com>
Date:	Tue, 24 Jul 2012 21:15:51 +0800
From:	Yuanhan Liu <yliu.null@...il.com>
To:	x86@...nel.org
Cc:	linux-kernel@...r.kernel.org, Yuanhan Liu <yliu.null@...il.com>,
	Jeremy Fitzhardinge <jeremy@...p.org>,
	Thomas Gleixner <tglx@...utronix.de>,
	Ingo Molnar <mingo@...e.hu>, "H. Peter Anvin" <hpa@...or.com>
Subject: [PATCH] x86/mm: stop allocating pmd page if failed

The old code would call __get_free_page() even though previous
allocation fail met. This is not needed.

Signed-off-by: Yuanhan Liu <yliu.null@...il.com>
Cc: Jeremy Fitzhardinge <jeremy@...p.org>
Cc: Thomas Gleixner <tglx@...utronix.de>
Cc: Ingo Molnar <mingo@...e.hu>
Cc: "H. Peter Anvin" <hpa@...or.com>
---
 arch/x86/mm/pgtable.c |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/arch/x86/mm/pgtable.c b/arch/x86/mm/pgtable.c
index 8573b83..6760348 100644
--- a/arch/x86/mm/pgtable.c
+++ b/arch/x86/mm/pgtable.c
@@ -181,24 +181,24 @@ static void free_pmds(pmd_t *pmds[])
 {
 	int i;
 
-	for(i = 0; i < PREALLOCATED_PMDS; i++)
-		if (pmds[i])
-			free_page((unsigned long)pmds[i]);
+	for(i = 0; i < PREALLOCATED_PMDS; i++) {
+		if (pmds[i] == NULL)
+			break;
+		free_page((unsigned long)pmds[i]);
+	}
 }
 
 static int preallocate_pmds(pmd_t *pmds[])
 {
 	int i;
-	bool failed = false;
 
 	for(i = 0; i < PREALLOCATED_PMDS; i++) {
-		pmd_t *pmd = (pmd_t *)__get_free_page(PGALLOC_GFP);
-		if (pmd == NULL)
-			failed = true;
-		pmds[i] = pmd;
+		pmds[i] = (pmd_t *)__get_free_page(PGALLOC_GFP);
+		if (pmds[i] == NULL)
+			break;
 	}
 
-	if (failed) {
+	if (i < PREALLOCATED_PMDS) {
 		free_pmds(pmds);
 		return -ENOMEM;
 	}
-- 
1.7.4.4

--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Please read the FAQ at  http://www.tux.org/lkml/

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ