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:   Thu, 25 Feb 2021 16:59:41 +0800
From:   Yang Li <yang.lee@...ux.alibaba.com>
To:     viro@...iv.linux.org.uk
Cc:     linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org,
        Yang Li <yang.lee@...ux.alibaba.com>
Subject: [PATCH] direct-io: Using kmem_cache_zalloc() instead of kmem_cache_alloc() and memset()

Fix the following coccicheck warning:
./fs/direct-io.c:1155:7-23: WARNING: kmem_cache_zalloc should be used
for dio, instead of kmem_cache_alloc/memset

Reported-by: Abaci Robot <abaci@...ux.alibaba.com>
Signed-off-by: Yang Li <yang.lee@...ux.alibaba.com>
---
 fs/direct-io.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/fs/direct-io.c b/fs/direct-io.c
index 0957e1b..6ec2935 100644
--- a/fs/direct-io.c
+++ b/fs/direct-io.c
@@ -1152,7 +1152,7 @@ static inline int drop_refcount(struct dio *dio)
 	if (iov_iter_rw(iter) == READ && !count)
 		return 0;
 
-	dio = kmem_cache_alloc(dio_cache, GFP_KERNEL);
+	dio = kmem_cache_zalloc(dio_cache, GFP_KERNEL);
 	if (!dio)
 		return -ENOMEM;
 	/*
@@ -1160,8 +1160,6 @@ static inline int drop_refcount(struct dio *dio)
 	 * performance regression in a database benchmark.  So, we take
 	 * care to only zero out what's needed.
 	 */
-	memset(dio, 0, offsetof(struct dio, pages));
-
 	dio->flags = flags;
 	if (dio->flags & DIO_LOCKING && iov_iter_rw(iter) == READ) {
 		/* will be released by direct_io_worker */
-- 
1.8.3.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ