[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-Id: <20250410-fix_net-v2-1-d69e7c5739a4@quicinc.com>
Date: Thu, 10 Apr 2025 09:01:27 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Eric Dumazet <edumazet@...gle.com>,
Kuniyuki Iwashima <kuniyu@...zon.com>, Paolo Abeni <pabeni@...hat.com>,
Willem de Bruijn <willemb@...gle.com>,
"David S. Miller" <davem@...emloft.net>, Jakub Kicinski <kuba@...nel.org>,
Simon Horman <horms@...nel.org>, Pavel Emelyanov <xemul@...nvz.org>
Cc: Zijun Hu <zijun_hu@...oud.com>, Eric Dumazet <dada1@...mosbay.com>,
netdev@...r.kernel.org, linux-kernel@...r.kernel.org,
Zijun Hu <quic_zijuhu@...cinc.com>
Subject: [PATCH net-next v2] sock: Correct error checking condition for
(assign|release)_proto_idx()
From: Zijun Hu <quic_zijuhu@...cinc.com>
(assign|release)_proto_idx() wrongly check find_first_zero_bit() failure
by condition '(prot->inuse_idx == PROTO_INUSE_NR - 1)' obviously.
Fix by correcting the condition to '(prot->inuse_idx == PROTO_INUSE_NR)'
Fixes: 13ff3d6fa4e6 ("[SOCK]: Enumerate struct proto-s to facilitate percpu inuse accounting (v2).")
Signed-off-by: Zijun Hu <quic_zijuhu@...cinc.com>
---
Changes in v2:
- Remove @prot->inuse_idx checks in fastpath
- Correct tile and commit message
- Link to v1: https://lore.kernel.org/r/20250408-fix_net-v1-1-375271a79c11@quicinc.com
---
net/core/sock.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/net/core/sock.c b/net/core/sock.c
index 323892066def8ba517ff59f98f2e4ab47edd4e63..e2c3c4bd9cd915706678137d98a15ca8c1a35cb8 100644
--- a/net/core/sock.c
+++ b/net/core/sock.c
@@ -3999,7 +3999,7 @@ static int assign_proto_idx(struct proto *prot)
{
prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR);
- if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) {
+ if (unlikely(prot->inuse_idx == PROTO_INUSE_NR)) {
pr_err("PROTO_INUSE_NR exhausted\n");
return -ENOSPC;
}
@@ -4010,7 +4010,7 @@ static int assign_proto_idx(struct proto *prot)
static void release_proto_idx(struct proto *prot)
{
- if (prot->inuse_idx != PROTO_INUSE_NR - 1)
+ if (prot->inuse_idx != PROTO_INUSE_NR)
clear_bit(prot->inuse_idx, proto_inuse_idx);
}
#else
---
base-commit: 34a07c5b257453b5fcadc2408719c7b075844014
change-id: 20250405-fix_net-3e8364d302ff
Best regards,
--
Zijun Hu <quic_zijuhu@...cinc.com>
Powered by blists - more mailing lists