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

wifi: mac80211_hwsim: use 32-bit skb cookie

We won't really have enough skbs to need a 64-bit cookie,
and on 32-bit platforms storing the 64-bit cookie into the
void *rate_driver_data doesn't work anyway. Switch back to
using just a 32-bit cookie and uintptr_t for the type to
avoid compiler warnings about all this.

Fixes: 4ee186fa7e40 ("wifi: mac80211_hwsim: fix race condition in pending packet")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>

+5 -5
+5 -5
drivers/net/wireless/mac80211_hwsim.c
··· 687 687 bool ps_poll_pending; 688 688 struct dentry *debugfs; 689 689 690 - atomic64_t pending_cookie; 690 + atomic_t pending_cookie; 691 691 struct sk_buff_head pending; /* packets pending */ 692 692 /* 693 693 * Only radios in the same group can communicate together (the ··· 1358 1358 int i; 1359 1359 struct hwsim_tx_rate tx_attempts[IEEE80211_TX_MAX_RATES]; 1360 1360 struct hwsim_tx_rate_flag tx_attempts_flags[IEEE80211_TX_MAX_RATES]; 1361 - u64 cookie; 1361 + uintptr_t cookie; 1362 1362 1363 1363 if (data->ps != PS_DISABLED) 1364 1364 hdr->frame_control |= cpu_to_le16(IEEE80211_FCTL_PM); ··· 1427 1427 goto nla_put_failure; 1428 1428 1429 1429 /* We create a cookie to identify this skb */ 1430 - cookie = (u64)atomic64_inc_return(&data->pending_cookie); 1430 + cookie = atomic_inc_return(&data->pending_cookie); 1431 1431 info->rate_driver_data[0] = (void *)cookie; 1432 1432 if (nla_put_u64_64bit(skb, HWSIM_ATTR_COOKIE, cookie, HWSIM_ATTR_PAD)) 1433 1433 goto nla_put_failure; ··· 4207 4207 /* look for the skb matching the cookie passed back from user */ 4208 4208 spin_lock_irqsave(&data2->pending.lock, flags); 4209 4209 skb_queue_walk_safe(&data2->pending, skb, tmp) { 4210 - u64 skb_cookie; 4210 + uintptr_t skb_cookie; 4211 4211 4212 4212 txi = IEEE80211_SKB_CB(skb); 4213 - skb_cookie = (u64)(uintptr_t)txi->rate_driver_data[0]; 4213 + skb_cookie = (uintptr_t)txi->rate_driver_data[0]; 4214 4214 4215 4215 if (skb_cookie == ret_skb_cookie) { 4216 4216 __skb_unlink(skb, &data2->pending);