Message ID | 87h9poxjvs.fsf@kamboji.qca.qualcomm.com (mailing list archive) |
---|---|
State | Accepted |
Headers | show |
On 07/01/2015 03:46 PM, Kalle Valo wrote: > Raja Mani <rmani@qti.qualcomm.com> writes: > >> Due to 512 client support in 10.4 firmware, size of tim ie is going >> to be slightly higher than non 10.4 firmware. So, size of tim_bitmap >> what is carried in swba event from 10.4 firmware is bit higher. >> >> The only bottle neck to reuse existing swba handler >> ath10k_wmi_event_host_swba() for 10.4 is that code designed to deal >> with fixed size tim bitmap(ie, tim_info[].tim_bitmap in wmi_swba_ev_arg). >> This patch removes such size limitation and makes it more suitable >> to handle swba event which has different size tim bitmap. >> >> All existing swba event parsing functions are changed to adapt this >> change. Actual support to handle 10.4 swba event is added in next patch. >> Only preparation is made in this patch. >> >> Signed-off-by: Raja Mani <rmani@qti.qualcomm.com> > [..] >> - BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != >> - sizeof(tim_info->tim_bitmap)); >> + WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > > I'm worried that this WARN_ON() spams too much so I changed it to: > > --- a/drivers/net/wireless/ath/ath10k/wmi.c > +++ b/drivers/net/wireless/ath/ath10k/wmi.c > @@ -2893,7 +2893,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, > if (__le32_to_cpu(tim_info->tim_changed)) { > int i; > > - WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > + WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > > for (i = 0; i < tim_len; i++) { > t = tim_info->tim_bitmap[i / 4]; > > The change looks good to me. -- Raja
Kalle Valo <kvalo@qca.qualcomm.com> writes: >> /* if next SWBA has no tim_changed the tim_bitmap is garbage. >> * we must copy the bitmap upon change and reuse it later */ >> if (__le32_to_cpu(tim_info->tim_changed)) { >> int i; >> >> - BUILD_BUG_ON(sizeof(arvif->u.ap.tim_bitmap) != >> - sizeof(tim_info->tim_bitmap)); >> + WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > > I'm worried that this WARN_ON() spams too much so I changed it to: > > --- a/drivers/net/wireless/ath/ath10k/wmi.c > +++ b/drivers/net/wireless/ath/ath10k/wmi.c > @@ -2893,7 +2893,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, > if (__le32_to_cpu(tim_info->tim_changed)) { > int i; > > - WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > + WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); > > for (i = 0; i < tim_len; i++) { > t = tim_info->tim_bitmap[i / 4]; Actually I got more worried about this. If tim_len > sizeof(arvif->u.ap.tim_bitmap) don't we read out of bounds? So we should actually add return for that case or am I missing something? Full code: WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); for (i = 0; i < tim_len; i++) { t = tim_info->tim_bitmap[i / 4]; v = __le32_to_cpu(t); arvif->u.ap.tim_bitmap[i] = (v >> ((i % 4) * 8)) & 0xFF; }
--- a/drivers/net/wireless/ath/ath10k/wmi.c +++ b/drivers/net/wireless/ath/ath10k/wmi.c @@ -2893,7 +2893,7 @@ static void ath10k_wmi_update_tim(struct ath10k *ar, if (__le32_to_cpu(tim_info->tim_changed)) { int i; - WARN_ON(sizeof(arvif->u.ap.tim_bitmap) < tim_len); + WARN_ON_ONCE(sizeof(arvif->u.ap.tim_bitmap) < tim_len); for (i = 0; i < tim_len; i++) { t = tim_info->tim_bitmap[i / 4];