Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

sock: Correct error checking condition for (assign|release)_proto_idx()

(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)'

Signed-off-by: Zijun Hu <quic_zijuhu@quicinc.com>
Reviewed-by: Kuniyuki Iwashima <kuniyu@amazon.com>
Link: https://patch.msgid.link/20250410-fix_net-v2-1-d69e7c5739a4@quicinc.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Zijun Hu and committed by
Jakub Kicinski
faeefc17 61499764

+2 -2
+2 -2
net/core/sock.c
··· 4004 4004 { 4005 4005 prot->inuse_idx = find_first_zero_bit(proto_inuse_idx, PROTO_INUSE_NR); 4006 4006 4007 - if (unlikely(prot->inuse_idx == PROTO_INUSE_NR - 1)) { 4007 + if (unlikely(prot->inuse_idx == PROTO_INUSE_NR)) { 4008 4008 pr_err("PROTO_INUSE_NR exhausted\n"); 4009 4009 return -ENOSPC; 4010 4010 } ··· 4015 4015 4016 4016 static void release_proto_idx(struct proto *prot) 4017 4017 { 4018 - if (prot->inuse_idx != PROTO_INUSE_NR - 1) 4018 + if (prot->inuse_idx != PROTO_INUSE_NR) 4019 4019 clear_bit(prot->inuse_idx, proto_inuse_idx); 4020 4020 } 4021 4021 #else