[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <057db64d-04de-45fd-b1e6-ede46fa6923a@icloud.com>
Date: Thu, 10 Apr 2025 08:50:49 +0800
From: Zijun Hu <zijun_hu@...oud.com>
To: Kuniyuki Iwashima <kuniyu@...zon.com>
Cc: dada1@...mosbay.com, davem@...emloft.net, edumazet@...gle.com,
horms@...nel.org, kuba@...nel.org, linux-kernel@...r.kernel.org,
netdev@...r.kernel.org, pabeni@...hat.com, quic_zijuhu@...cinc.com,
willemb@...gle.com, xemul@...nvz.org
Subject: Re: [PATCH net-next] sock: Correct error checking condition for
assign|release_proto_idx()
On 2025/4/9 02:21, Kuniyuki Iwashima wrote:
>> diff --git a/include/net/sock.h b/include/net/sock.h
>> index 8daf1b3b12c607d81920682139b53fee935c9bb5..9ece93a3dd044997276b0fa37dddc7b5bbdacc43 100644
>> --- a/include/net/sock.h
>> +++ b/include/net/sock.h
>> @@ -1421,7 +1421,10 @@ struct prot_inuse {
>> static inline void sock_prot_inuse_add(const struct net *net,
>> const struct proto *prot, int val)
>> {
>> - 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);
> How does the else case happen ?
thank you for code review.
provided that @prot->inuse_idx will never be used if @prot fails to be
registered.
will remove this check in v2.
Powered by blists - more mailing lists