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-prev] [day] [month] [year] [list]
Date: Sun, 14 Apr 2024 00:15:27 +0800
From: Chin-Chun Chen <chinchunchen2001@...il.com>
To: yury.norov@...il.com
Cc: linux@...musvillemoes.dk,
	linux-kernel@...r.kernel.org,
	Chin-Chun Chen <chinchunchen2001@...il.com>
Subject: [PATCH v2] include/linux/bitops.h: Fix function fns

Modified the function fns to resolve a calculation error by reducing n first to correctly determine the n-th set bit instead of n+1.

This commit improves the accuracy and reliability of the code.
---
Changes since v1:
* Clarified the commit message.
* Fixed the incorrect operation.

Signed-off-by: Chin-Chun Chen <chinchunchen2001@...il.com>
---
 include/linux/bitops.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/include/linux/bitops.h b/include/linux/bitops.h
index 2ba557e067fe..5842d7d03f19 100644
--- a/include/linux/bitops.h
+++ b/include/linux/bitops.h
@@ -258,7 +258,7 @@ static inline unsigned long fns(unsigned long word, unsigned int n)
 
 	while (word) {
 		bit = __ffs(word);
-		if (n-- == 0)
+		if (--n == 0)
 			return bit;
 		__clear_bit(bit, &word);
 	}

base-commit: 8f2c057754b25075aa3da132cd4fd4478cdab854
-- 
2.40.1


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ