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 for Android: free password hash cracker in your pocket
[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Date: Wed,  5 Jun 2024 21:52:45 +0800
From: cuitao <cuitao@...inos.cn>
To: mst@...hat.com,
	jasowang@...hat.com,
	virtualization@...ts.linux.dev
Cc: xuanzhuo@...ux.alibaba.com,
	eperezma@...hat.com,
	linux-kernel@...r.kernel.org,
	cuitao <cuitao@...inos.cn>
Subject: [PATCH] tools/virtio: Use the __GFP_ZERO flag of kmalloc to complete the memory initialization.

Use the __GFP_ZERO flag of kmalloc to initialize memory while allocating it,
without the need for an additional memset call.

Signed-off-by: cuitao <cuitao@...inos.cn>
---
 tools/virtio/linux/kernel.h | 5 +----
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/tools/virtio/linux/kernel.h b/tools/virtio/linux/kernel.h
index 6702008f7f5c..9e401fb7c215 100644
--- a/tools/virtio/linux/kernel.h
+++ b/tools/virtio/linux/kernel.h
@@ -66,10 +66,7 @@ static inline void *kmalloc_array(unsigned n, size_t s, gfp_t gfp)
 
 static inline void *kzalloc(size_t s, gfp_t gfp)
 {
-	void *p = kmalloc(s, gfp);
-
-	memset(p, 0, s);
-	return p;
+	return kmalloc(s, gfp | __GFP_ZERO);
 }
 
 static inline void *alloc_pages_exact(size_t s, gfp_t gfp)
-- 
2.25.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ