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

wifi: mac80211_hwsim: use hrtimer_active()

Instead of hrtimer_is_queued(), use hrtimer_active() since
it might be running concurrently, and then it's not queued
at that point in time, as suggested by Thomas Gleixner in
https://lore.kernel.org/87plqn5psu.ffs@tglx, I just never
got to this for ages.

I think the concurrency is otherwise fine since we'll get
to cancel if we're actually removing things, and otherwise
we just send a beacon at slightly the wrong time or so.

Reported-by: syzbot+41e4341f493f1155aa3d@syzkaller.appspotmail.com
Link: https://patch.msgid.link/20241011145230.5a4d38d4ff9b.Iac0ec316a0c9a7b2619abe52ddc8e04c25d8c7e1@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+2 -2
+2 -2
drivers/net/wireless/virtual/mac80211_hwsim.c
··· 2442 2442 2443 2443 if (!data->started || !link_data->beacon_int) { 2444 2444 hrtimer_cancel(&link_data->beacon_timer); 2445 - } else if (!hrtimer_is_queued(&link_data->beacon_timer)) { 2445 + } else if (!hrtimer_active(&link_data->beacon_timer)) { 2446 2446 u64 tsf = mac80211_hwsim_get_tsf(hw, NULL); 2447 2447 u32 bcn_int = link_data->beacon_int; 2448 2448 u64 until_tbtt = bcn_int - do_div(tsf, bcn_int); ··· 2537 2537 info->enable_beacon, info->beacon_int); 2538 2538 vp->bcn_en = info->enable_beacon; 2539 2539 if (data->started && 2540 - !hrtimer_is_queued(&link_data->beacon_timer) && 2540 + !hrtimer_active(&link_data->beacon_timer) && 2541 2541 info->enable_beacon) { 2542 2542 u64 tsf, until_tbtt; 2543 2543 u32 bcn_int;