mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Markus Elfring <Markus.Elfring@web.de>
To: netdev@vger.kernel.org, "David S. Miller" <davem@davemloft.net>,
	Eric Dumazet <edumazet@google.com>,
	Jakub Kicinski <kuba@kernel.org>, Jiri Pirko <jiri@resnulli.us>,
	Juntong Deng <juntong.deng@outlook.com>,
	Kuniyuki Iwashima <kuniyu@amazon.com>,
	Nikolay Aleksandrov <razor@blackwall.org>,
	Paolo Abeni <pabeni@redhat.com>, Simon Horman <horms@kernel.org>,
	Thomas Graf <tgraf@suug.ch>,
	Zhengchao Shao <shaozhengchao@huawei.com>
Cc: LKML <linux-kernel@vger.kernel.org>,
	kernel-janitors@vger.kernel.org,
	Jinjie Ruan <ruanjinjie@huawei.com>,
	Nikolay Aleksandrov <nikolay@redhat.com>
Subject: [PATCH] netlink: Fix off-by-one error in netlink_proto_init()
Date: Sun, 3 Nov 2024 14:15:18 +0100	[thread overview]
Message-ID: <80516b25-a42d-48e1-bcf9-27efe58f44c6@web.de> (raw)

From: Markus Elfring <elfring@users.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@vger.kernel.org
Signed-off-by: Markus Elfring <elfring@users.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


             reply	other threads:[~2024-11-03 13:16 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-11-03 13:15 Markus Elfring [this message]
2024-11-03 17:31 ` Kuniyuki Iwashima
2024-11-04  7:38   ` Markus Elfring

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=80516b25-a42d-48e1-bcf9-27efe58f44c6@web.de \
    --to=markus.elfring@web.de \
    --cc=davem@davemloft.net \
    --cc=edumazet@google.com \
    --cc=horms@kernel.org \
    --cc=jiri@resnulli.us \
    --cc=juntong.deng@outlook.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=kuba@kernel.org \
    --cc=kuniyu@amazon.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=netdev@vger.kernel.org \
    --cc=nikolay@redhat.com \
    --cc=pabeni@redhat.com \
    --cc=razor@blackwall.org \
    --cc=ruanjinjie@huawei.com \
    --cc=shaozhengchao@huawei.com \
    --cc=tgraf@suug.ch \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®