From: Jinjie Ruan <ruanjinjie@huawei.com>
To: Kuniyuki Iwashima <kuniyu@amazon.com>
Cc: <a.kovaleva@yadro.com>, <davem@davemloft.net>,
<edumazet@google.com>, <horms@kernel.org>, <kuba@kernel.org>,
<linux-kernel@vger.kernel.org>, <lirongqing@baidu.com>,
<netdev@vger.kernel.org>, <pabeni@redhat.com>
Subject: Re: [PATCH net] netlink: Fix off-by-one error in netlink_proto_init()
Date: Tue, 29 Oct 2024 09:30:58 +0800 [thread overview]
Message-ID: <a88119f3-3968-e072-6caa-8229e2e470bf@huawei.com> (raw)
In-Reply-To: <20241028182421.6692-1-kuniyu@amazon.com>
On 2024/10/29 2:24, Kuniyuki Iwashima wrote:
> From: Jinjie Ruan <ruanjinjie@huawei.com>
> Date: Mon, 28 Oct 2024 16:05:15 +0800
>> In the error path of netlink_proto_init(), frees the already allocated
>> bucket table for new hash tables in a loop, but the loop condition
>> terminates when the index reaches zero, which fails to free the first
>> bucket table at index zero.
>>
>> Check for >= 0 so that nl_table[0].hash is freed as well.
>>
>> Fixes: 1da177e4c3f4 ("Linux-2.6.12-rc2")
>> Signed-off-by: Jinjie Ruan <ruanjinjie@huawei.com>
>> ---
>> 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;
>
> I remember the same question was posted in the past.
> https://lore.kernel.org/netdev/ZfOalln%2FmyRNOkH6@cy-server/
>
> As Eric alreday pointed out (and as mentioned in the thread above too),
> it's going to panic, and we need not clean up resources here, so let's
> remove rhashtable_destroy() and kfree() instead of adjusting the loop
> condition.
Thank you very much, remove it is fine.
>
prev parent reply other threads:[~2024-10-29 1:31 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-10-28 8:05 Jinjie Ruan
2024-10-28 15:20 ` Eric Dumazet
2024-10-28 18:24 ` Kuniyuki Iwashima
2024-10-29 1:30 ` Jinjie Ruan [this message]
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=a88119f3-3968-e072-6caa-8229e2e470bf@huawei.com \
--to=ruanjinjie@huawei.com \
--cc=a.kovaleva@yadro.com \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=kuniyu@amazon.com \
--cc=linux-kernel@vger.kernel.org \
--cc=lirongqing@baidu.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/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®