mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH net] netlink: Fix off-by-one error in netlink_proto_init()
@ 2024-10-28  8:05 Jinjie Ruan
  2024-10-28 15:20 ` Eric Dumazet
  2024-10-28 18:24 ` Kuniyuki Iwashima
  0 siblings, 2 replies; 4+ messages in thread
From: Jinjie Ruan @ 2024-10-28  8:05 UTC (permalink / raw)
  To: davem, edumazet, kuba, pabeni, horms, kuniyu, a.kovaleva,
	ruanjinjie, lirongqing, netdev, linux-kernel

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;
-- 
2.34.1


^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2024-10-29  1:31 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-10-28  8:05 [PATCH net] netlink: Fix off-by-one error in netlink_proto_init() Jinjie Ruan
2024-10-28 15:20 ` Eric Dumazet
2024-10-28 18:24 ` Kuniyuki Iwashima
2024-10-29  1:30   ` Jinjie Ruan

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®