[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <80516b25-a42d-48e1-bcf9-27efe58f44c6@web.de>
Date: Sun, 3 Nov 2024 14:15:18 +0100
From: Markus Elfring <Markus.Elfring@....de>
To: netdev@...r.kernel.org, "David S. Miller" <davem@...emloft.net>,
Eric Dumazet <edumazet@...gle.com>, Jakub Kicinski <kuba@...nel.org>,
Jiri Pirko <jiri@...nulli.us>, Juntong Deng <juntong.deng@...look.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>,
Nikolay Aleksandrov <razor@...ckwall.org>, Paolo Abeni <pabeni@...hat.com>,
Simon Horman <horms@...nel.org>, Thomas Graf <tgraf@...g.ch>,
Zhengchao Shao <shaozhengchao@...wei.com>
Cc: LKML <linux-kernel@...r.kernel.org>, kernel-janitors@...r.kernel.org,
Jinjie Ruan <ruanjinjie@...wei.com>, Nikolay Aleksandrov <nikolay@...hat.com>
Subject: [PATCH] netlink: Fix off-by-one error in netlink_proto_init()
From: Markus Elfring <elfring@...rs.sourceforge.net>
Date: Sun, 3 Nov 2024 14:01:26 +0100
Hash tables should be properly destroyed after a rhashtable_init() call
failed in this function implementation.
The corresponding exception handling was incomplete because of
a questionable condition check.
Thus use the comparison operator “>=” instead for the affected while loop.
This issue was transformed by using the Coccinelle software.
Fixes: e341694e3eb5 ("netlink: Convert netlink_lookup() to use RCU protected hash table")
Cc: stable@...r.kernel.org
Signed-off-by: Markus Elfring <elfring@...rs.sourceforge.net>
---
net/netlink/af_netlink.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/net/netlink/af_netlink.c b/net/netlink/af_netlink.c
index 0a9287fadb47..9601b85dda95 100644
--- a/net/netlink/af_netlink.c
+++ b/net/netlink/af_netlink.c
@@ -2936,7 +2936,7 @@ static int __init netlink_proto_init(void)
for (i = 0; i < MAX_LINKS; i++) {
if (rhashtable_init(&nl_table[i].hash,
&netlink_rhashtable_params) < 0) {
- while (--i > 0)
+ while (--i >= 0)
rhashtable_destroy(&nl_table[i].hash);
kfree(nl_table);
goto panic;
--
2.47.0
Powered by blists - more mailing lists