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] [thread-next>] [day] [month] [year] [list]
Message-ID: <tencent_B7D657EF5135C40D0303A1C3AC90CB0B9507@qq.com>
Date:   Thu, 10 Nov 2022 13:00:42 +0800
From:   Rong Tao <rtoax@...mail.com>
To:     akpm@...ux-foundation.org
Cc:     linux-kernel@...r.kernel.org, linux-mm@...ck.org, rongtao@...tc.cn,
        rtoax@...mail.com, willy@...radead.org, wuchi.zero@...il.com
Subject: [PATCH] lib/radix-tree: Fix uninitialized variable compilation warning

From: Rong Tao <rongtao@...tc.cn>

We need to set an initial value for offset to eliminate compilation
warning. And if the tree is empty, return NULL early.

How to reproduce warning:

$ make -C tools/testing/radix-tree
radix-tree.c: In function ‘radix_tree_tag_clear’:
radix-tree.c:1046:17: warning: ‘offset’ may be used uninitialized in this function [-Wmaybe-uninitialized]
1046 |                 node_tag_clear(root, parent, tag, offset);
     |                 ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

Signed-off-by: Rong Tao <rongtao@...tc.cn>
---
 lib/radix-tree.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/lib/radix-tree.c b/lib/radix-tree.c
index 3c78e1e8b2ad..eee453b856b6 100644
--- a/lib/radix-tree.c
+++ b/lib/radix-tree.c
@@ -1029,10 +1029,10 @@ void *radix_tree_tag_clear(struct radix_tree_root *root,
 {
 	struct radix_tree_node *node, *parent;
 	unsigned long maxindex;
-	int offset;
+	int offset = 0;
 
 	radix_tree_load_root(root, &node, &maxindex);
-	if (index > maxindex)
+	if (index > maxindex || !node)
 		return NULL;
 
 	parent = NULL;
-- 
2.31.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ