Re: [PATCH net-next] sock: Correct error checking condition for assign|release_proto_idx()

From: Zijun Hu
Date: Wed Apr 09 2025 - 20:53:34 EST


On 2025/4/9 03:06, Eric Dumazet wrote:
>> {
>> - this_cpu_add(net->core.prot_inuse->val[prot->inuse_idx], val);
>> + unsigned int idx = prot->inuse_idx;
>> +
>> + if (likely(idx < PROTO_INUSE_NR))
>> + this_cpu_add(net->core.prot_inuse->val[idx], val);
>> }
> I do not think we are going to add such a test in the fast path, for a
> bug that can not happen.
>

agree.

> Please give us a reproducer ?

will remove that check in v2 provided @prot->inuse_idx will never be
used if @prot fails to be registered.

thank you for code review.