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]
Date:   Mon, 28 Sep 2020 00:33:37 +0800
From:   Hui Su <sh_def@....com>
To:     akpm@...ux-foundation.org, linux-mm@...ck.org,
        linux-kernel@...r.kernel.org
Subject: [PATCH] mm/vmalloc.c: check the addr first

As the comments said, if @addr is NULL, no operation
is performed, check the addr first in vfree() and
vfree_atomic() maybe a better choice.

Signed-off-by: Hui Su <sh_def@....com>
---
 mm/vmalloc.c | 11 ++++++-----
 1 file changed, 6 insertions(+), 5 deletions(-)

diff --git a/mm/vmalloc.c b/mm/vmalloc.c
index be4724b916b3..1cf50749a209 100644
--- a/mm/vmalloc.c
+++ b/mm/vmalloc.c
@@ -2305,10 +2305,11 @@ void vfree_atomic(const void *addr)
 {
 	BUG_ON(in_nmi());
 
-	kmemleak_free(addr);
-
 	if (!addr)
 		return;
+
+	kmemleak_free(addr);
+
 	__vfree_deferred(addr);
 }
 
@@ -2340,13 +2341,13 @@ void vfree(const void *addr)
 {
 	BUG_ON(in_nmi());
 
+	if (!addr)
+		return;
+
 	kmemleak_free(addr);
 
 	might_sleep_if(!in_interrupt());
 
-	if (!addr)
-		return;
-
 	__vfree(addr);
 }
 EXPORT_SYMBOL(vfree);
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ