diff mbox series

[2/2] wifi: ath12k: fix undefined behavior with __fls in dp

Message ID 20230809042738.13394-3-quic_hprem@quicinc.com (mailing list archive)
State Changes Requested
Delegated to: Johannes Berg
Headers show
Series wifi: ath12k: Ignore fragments from uninitialized peer in dp | expand

Commit Message

Harshitha Prem Aug. 9, 2023, 4:27 a.m. UTC
When max virtual ap interfaces are configured in all the bands
with ACS and hostapd restart is done every 60s,
a crash is observed at random times because of handling the
uninitialized peer fragments.

During the crash, the fragment id of that packet was 0 and
__fls returned a junk value. Hence, it was identified that "__fls"
would have an undefined behavior if the argument is passed as "0".
Therefore, add changes to handle the same.

Tested-on: QCN9274 hw2.0 PCI WLAN.WBE.1.0.1-00029-QCAHKSWPL_SILICONZ-1

Signed-off-by: Harshitha Prem <quic_hprem@quicinc.com>
---
 drivers/net/wireless/ath/ath12k/dp_rx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Comments

Johannes Berg Aug. 9, 2023, 12:17 p.m. UTC | #1
On Wed, 2023-08-09 at 09:57 +0530, Harshitha Prem wrote:
> 
> During the crash, the fragment id of that packet was 0 and
> __fls returned a junk value. Hence, it was identified that "__fls"
> would have an undefined behavior if the argument is passed as "0".
> Therefore, add changes to handle the same.

Umm. That makes it sound like you are surprised by this behaviour of
__fls() and expected something else?! Please go read the documentation,
and then rewrite the commit message. You really shouldn't be surprised
by this.

johannes
Johannes Berg Aug. 9, 2023, 12:18 p.m. UTC | #2
On Wed, 2023-08-09 at 14:17 +0200, Johannes Berg wrote:
> On Wed, 2023-08-09 at 09:57 +0530, Harshitha Prem wrote:
> > 
> > During the crash, the fragment id of that packet was 0 and
> > __fls returned a junk value. Hence, it was identified that "__fls"
> > would have an undefined behavior if the argument is passed as "0".
> > Therefore, add changes to handle the same.
> 
> Umm. That makes it sound like you are surprised by this behaviour of
> __fls() and expected something else?! Please go read the documentation,
> and then rewrite the commit message. You really shouldn't be surprised
> by this.
> 

Also, btw, "Fixes:" tags would be nice for fixes. I'm sure Kalle has
brought that up a million times before ;)

johannes
Harshitha Prem Aug. 11, 2023, 9:16 a.m. UTC | #3
On 8/9/2023 5:47 PM, Johannes Berg wrote:
> On Wed, 2023-08-09 at 09:57 +0530, Harshitha Prem wrote:
>>
>> During the crash, the fragment id of that packet was 0 and
>> __fls returned a junk value. Hence, it was identified that "__fls"
>> would have an undefined behavior if the argument is passed as "0".
>> Therefore, add changes to handle the same.
> 
> Umm. That makes it sound like you are surprised by this behaviour of
> __fls() and expected something else?! Please go read the documentation,
> and then rewrite the commit message. You really shouldn't be surprised
> by this.
> 
> johannes

Thanks Johannes for reviewing the changes. Sure, I will update the 
commit message in next patch version.

Thanks,
Harshitha
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath12k/dp_rx.c b/drivers/net/wireless/ath/ath12k/dp_rx.c
index 5923c7c9eaff..ea8dfea22be6 100644
--- a/drivers/net/wireless/ath/ath12k/dp_rx.c
+++ b/drivers/net/wireless/ath/ath12k/dp_rx.c
@@ -3238,7 +3238,7 @@  static int ath12k_dp_rx_frag_h_mpdu(struct ath12k *ar,
 		goto out_unlock;
 	}
 
-	if (frag_no > __fls(rx_tid->rx_frag_bitmap))
+	if ((!rx_tid->rx_frag_bitmap || frag_no > __fls(rx_tid->rx_frag_bitmap)))
 		__skb_queue_tail(&rx_tid->rx_frags, msdu);
 	else
 		ath12k_dp_rx_h_sort_frags(ab, &rx_tid->rx_frags, msdu);