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, 23 Mar 2023 17:37:52 +0800
From:   gouhao@...ontech.com
To:     viro@...iv.linux.org.uk, brauner@...nel.org
Cc:     linux-fsdevel@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] fs/buffer: adjust the order of might_sleep() in __getblk_gfp()

From: Gou Hao <gouhao@...ontech.com>

If 'bh' is found in cache, just return directly.
might_sleep() is only required on slow paths.

Signed-off-by: Gou Hao <gouhao@...ontech.com>
---
 fs/buffer.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/fs/buffer.c b/fs/buffer.c
index 9e1e2add541e..e13eff504fb5 100644
--- a/fs/buffer.c
+++ b/fs/buffer.c
@@ -1371,10 +1371,11 @@ __getblk_gfp(struct block_device *bdev, sector_t block,
 {
 	struct buffer_head *bh = __find_get_block(bdev, block, size);
 
+	if (bh)
+		return bh;
+
 	might_sleep();
-	if (bh == NULL)
-		bh = __getblk_slow(bdev, block, size, gfp);
-	return bh;
+	return __getblk_slow(bdev, block, size, gfp);
 }
 EXPORT_SYMBOL(__getblk_gfp);
 
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ