diff mbox series

ath10k: add cleanup in ath10k_sta_state()

Message ID 1565903072-3948-1-git-send-email-wenwen@cs.uga.edu (mailing list archive)
State New, archived
Headers show
Series ath10k: add cleanup in ath10k_sta_state() | expand

Commit Message

Wenwen Wang Aug. 15, 2019, 9:04 p.m. UTC
If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
go to the 'exit' label.

Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
---
 drivers/net/wireless/ath/ath10k/mac.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

Comments

Sebastian Gottschall Aug. 16, 2019, 10:31 a.m. UTC | #1
this patch will kick our any peer each time you call for statistics.so 
it will not solve anything. it creates a massive bug. usually just kfree 
is enough here but even this will maybe just kill existing stats

Am 15.08.2019 um 23:04 schrieb Wenwen Wang:
> If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
> leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
> go to the 'exit' label.
>
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
>   drivers/net/wireless/ath/ath10k/mac.c | 6 +++++-
>   1 file changed, 5 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
> index 0606416..f99e6d2 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -6548,8 +6548,12 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
>   
>   		spin_unlock_bh(&ar->data_lock);
>   
> -		if (!sta->tdls)
> +		if (!sta->tdls) {
> +			ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
> +			ath10k_mac_dec_num_stations(arvif, sta);
> +			kfree(arsta->tx_stats);
>   			goto exit;
> +		}
>   
>   		ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
>   						      WMI_TDLS_ENABLE_ACTIVE);
Kalle Valo Sept. 17, 2019, 2:11 p.m. UTC | #2
Wenwen Wang <wenwen@cs.uga.edu> wrote:

> If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
> leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
> go to the 'exit' label.
> 
> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

Patch applied to ath-next branch of ath.git, thanks.

334f5b61a6f2 ath10k: add cleanup in ath10k_sta_state()
Bjorn Andersson Nov. 13, 2019, 7:28 p.m. UTC | #3
On Thu 15 Aug 14:04 PDT 2019, Wenwen Wang wrote:

> If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
> leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
> go to the 'exit' label.
> 

Unfortunately this patch consistently crashes all my msm8998, sdm845 and
qcs404 devices (running ath10k_snoc).  Upon trying to join a network the
WiFi firmware crashes with the following:

[  124.315286] wlan0: authenticate with 70:3a:cb:4d:34:f3
[  124.334051] wlan0: send auth to 70:3a:cb:4d:34:f3 (try 1/3)
[  124.338828] wlan0: authenticated
[  124.342470] wlan0: associate with 70:3a:cb:4d:34:f3 (try 1/3)
[  124.347223] wlan0: RX AssocResp from 70:3a:cb:4d:34:f3 (capab=0x1011 status=0 aid=2)
[  124.402535] qcom-q6v5-mss 4080000.remoteproc: fatal error received: err_qdi.c:456:EF:wlan_process:1:cmnos_thread.c:3900:Asserted in wlan_vdev.c:_wlan_vdev_up:3219

Can we please revert it for v5.5?

Regards,
Bjorn

> Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> ---
>  drivers/net/wireless/ath/ath10k/mac.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
> index 0606416..f99e6d2 100644
> --- a/drivers/net/wireless/ath/ath10k/mac.c
> +++ b/drivers/net/wireless/ath/ath10k/mac.c
> @@ -6548,8 +6548,12 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
>  
>  		spin_unlock_bh(&ar->data_lock);
>  
> -		if (!sta->tdls)
> +		if (!sta->tdls) {
> +			ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
> +			ath10k_mac_dec_num_stations(arvif, sta);
> +			kfree(arsta->tx_stats);
>  			goto exit;
> +		}
>  
>  		ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
>  						      WMI_TDLS_ENABLE_ACTIVE);
> -- 
> 2.7.4
>
Jeffrey Hugo Nov. 13, 2019, 7:37 p.m. UTC | #4
On Wed, Nov 13, 2019 at 12:28 PM Bjorn Andersson
<bjorn.andersson@linaro.org> wrote:
>
> On Thu 15 Aug 14:04 PDT 2019, Wenwen Wang wrote:
>
> > If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
> > leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
> > go to the 'exit' label.
> >
>
> Unfortunately this patch consistently crashes all my msm8998, sdm845 and
> qcs404 devices (running ath10k_snoc).  Upon trying to join a network the
> WiFi firmware crashes with the following:
>
> [  124.315286] wlan0: authenticate with 70:3a:cb:4d:34:f3
> [  124.334051] wlan0: send auth to 70:3a:cb:4d:34:f3 (try 1/3)
> [  124.338828] wlan0: authenticated
> [  124.342470] wlan0: associate with 70:3a:cb:4d:34:f3 (try 1/3)
> [  124.347223] wlan0: RX AssocResp from 70:3a:cb:4d:34:f3 (capab=0x1011 status=0 aid=2)
> [  124.402535] qcom-q6v5-mss 4080000.remoteproc: fatal error received: err_qdi.c:456:EF:wlan_process:1:cmnos_thread.c:3900:Asserted in wlan_vdev.c:_wlan_vdev_up:3219
>
> Can we please revert it for v5.5?

I observe the same, and concur with this request.

>
> Regards,
> Bjorn
>
> > Signed-off-by: Wenwen Wang <wenwen@cs.uga.edu>
> > ---
> >  drivers/net/wireless/ath/ath10k/mac.c | 6 +++++-
> >  1 file changed, 5 insertions(+), 1 deletion(-)
> >
> > diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
> > index 0606416..f99e6d2 100644
> > --- a/drivers/net/wireless/ath/ath10k/mac.c
> > +++ b/drivers/net/wireless/ath/ath10k/mac.c
> > @@ -6548,8 +6548,12 @@ static int ath10k_sta_state(struct ieee80211_hw *hw,
> >
> >               spin_unlock_bh(&ar->data_lock);
> >
> > -             if (!sta->tdls)
> > +             if (!sta->tdls) {
> > +                     ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
> > +                     ath10k_mac_dec_num_stations(arvif, sta);
> > +                     kfree(arsta->tx_stats);
> >                       goto exit;
> > +             }
> >
> >               ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
> >                                                     WMI_TDLS_ENABLE_ACTIVE);
> > --
> > 2.7.4
> >
Kalle Valo Nov. 14, 2019, 7:42 a.m. UTC | #5
Bjorn Andersson <bjorn.andersson@linaro.org> writes:

> On Thu 15 Aug 14:04 PDT 2019, Wenwen Wang wrote:
>
>> If 'sta->tdls' is false, no cleanup is executed, leading to memory/resource
>> leaks, e.g., 'arsta->tx_stats'. To fix this issue, perform cleanup before
>> go to the 'exit' label.
>> 
>
> Unfortunately this patch consistently crashes all my msm8998, sdm845 and
> qcs404 devices (running ath10k_snoc).  Upon trying to join a network the
> WiFi firmware crashes with the following:
>
> [  124.315286] wlan0: authenticate with 70:3a:cb:4d:34:f3
> [  124.334051] wlan0: send auth to 70:3a:cb:4d:34:f3 (try 1/3)
> [  124.338828] wlan0: authenticated
> [  124.342470] wlan0: associate with 70:3a:cb:4d:34:f3 (try 1/3)
> [  124.347223] wlan0: RX AssocResp from 70:3a:cb:4d:34:f3 (capab=0x1011 status=0 aid=2)
> [ 124.402535] qcom-q6v5-mss 4080000.remoteproc: fatal error received:
> err_qdi.c:456:EF:wlan_process:1:cmnos_thread.c:3900:Asserted in
> wlan_vdev.c:_wlan_vdev_up:3219
>
> Can we please revert it for v5.5?

Yes, let's revert it. And thanks for sending the patch to do that:

https://patchwork.kernel.org/patch/11242743/
diff mbox series

Patch

diff --git a/drivers/net/wireless/ath/ath10k/mac.c b/drivers/net/wireless/ath/ath10k/mac.c
index 0606416..f99e6d2 100644
--- a/drivers/net/wireless/ath/ath10k/mac.c
+++ b/drivers/net/wireless/ath/ath10k/mac.c
@@ -6548,8 +6548,12 @@  static int ath10k_sta_state(struct ieee80211_hw *hw,
 
 		spin_unlock_bh(&ar->data_lock);
 
-		if (!sta->tdls)
+		if (!sta->tdls) {
+			ath10k_peer_delete(ar, arvif->vdev_id, sta->addr);
+			ath10k_mac_dec_num_stations(arvif, sta);
+			kfree(arsta->tx_stats);
 			goto exit;
+		}
 
 		ret = ath10k_wmi_update_fw_tdls_state(ar, arvif->vdev_id,
 						      WMI_TDLS_ENABLE_ACTIVE);