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]
Message-Id: <1629885588-10590-1-git-send-email-lirongqing@baidu.com>
Date:   Wed, 25 Aug 2021 17:59:48 +0800
From:   Li RongQing <lirongqing@...du.com>
To:     peterz@...radead.org, dbueso@...e.de, mingo@...nel.org,
        michel@...pinasse.org, linux-kernel@...r.kernel.org,
        lirongqing@...du.com
Subject: [PATCH] rbtree: stop iteration early in rb_find_first

stop iteration if match is not NULL and result of cmp is
not zero, this means the matched node has been found, and
the node with same key has been passed

Signed-off-by: Li RongQing <lirongqing@...du.com>
---
 include/linux/rbtree.h | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/include/linux/rbtree.h b/include/linux/rbtree.h
index d31ecaf4fdd3..2689771df9bb 100644
--- a/include/linux/rbtree.h
+++ b/include/linux/rbtree.h
@@ -324,6 +324,9 @@ rb_find_first(const void *key, const struct rb_root *tree,
 		} else if (c > 0) {
 			node = node->rb_right;
 		}
+
+		if (match && c)
+			break;
 	}
 
 	return match;
-- 
2.33.0.69.gc420321.dirty

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ