Re: [PATCH v3 1/3] jump_label: Prevent key->enabled int overflow

From: Dmitry Safonov
Date: Mon Nov 14 2022 - 12:14:05 EST


On 11/14/22 16:24, Jason Baron wrote:
>
[..]
>> @@ -148,16 +167,23 @@ void static_key_slow_inc_cpuslocked(struct static_key *key)
>> */
>> atomic_set_release(&key->enabled, 1);
>> } else {
>> - atomic_inc(&key->enabled);
>> + if (WARN_ON_ONCE(static_key_fast_inc(key))) {
>
> Shouldn't that be negated to catch the overflow:
>
> if (WARN_ON_ONCE(!static_key_fast_inc(key)))

Oh, that's just embarrassing!
I wonder how did I miss it during tests..

Thanks for spotting this, will fix in v4,
Dmitry