ath11k.lists.infradead.org archive mirror
 help / color / mirror / Atom feed
* [bug report] wifi: ath11k: fix peer addition/deletion error on sta band migration
@ 2023-02-09  9:35 Dan Carpenter
  2023-02-09 23:55 ` Christian Marangi
  0 siblings, 1 reply; 3+ messages in thread
From: Dan Carpenter @ 2023-02-09  9:35 UTC (permalink / raw)
  To: ansuelsmth; +Cc: ath11k

Hello Christian Marangi,

The patch d673cb6fe6c0: "wifi: ath11k: fix peer addition/deletion
error on sta band migration" from Sep 22, 2022, leads to the
following Smatch static checker warning:

	drivers/net/wireless/ath/ath11k/peer.c:396 ath11k_peer_create()
	warn: sleeping in atomic context

drivers/net/wireless/ath/ath11k/peer.c
    370 int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,
    371                        struct ieee80211_sta *sta, struct peer_create_params *param)
    372 {
    373         struct ath11k_peer *peer;
    374         struct ath11k_sta *arsta;
    375         int ret, fbret;
    376 
    377         lockdep_assert_held(&ar->conf_mutex);
    378 
    379         if (ar->num_peers > (ar->max_num_peers - 1)) {
    380                 ath11k_warn(ar->ab,
    381                             "failed to create peer due to insufficient peer entry resource in firmware\n");
    382                 return -ENOBUFS;
    383         }
    384 
    385         spin_lock_bh(&ar->ab->base_lock);
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Holding a spin lock.

    386         peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr);
    387         if (peer) {
    388                 if (peer->vdev_id == param->vdev_id) {
    389                         spin_unlock_bh(&ar->ab->base_lock);
    390                         return -EINVAL;
    391                 }
    392 
    393                 /* Assume sta is transitioning to another band.
    394                  * Remove here the peer from rhash.
    395                  */
--> 396                 mutex_lock(&ar->ab->tbl_mtx_lock);
                        ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
So we can't take a mutex.

    397                 ath11k_peer_rhash_delete(ar->ab, peer);
    398                 mutex_unlock(&ar->ab->tbl_mtx_lock);
    399         }
    400         spin_unlock_bh(&ar->ab->base_lock);
    401 
    402         ret = ath11k_wmi_send_peer_create_cmd(ar, param);

regards,
dan carpenter

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] wifi: ath11k: fix peer addition/deletion error on sta band migration
  2023-02-09  9:35 [bug report] wifi: ath11k: fix peer addition/deletion error on sta band migration Dan Carpenter
@ 2023-02-09 23:55 ` Christian Marangi
  2023-02-13 12:26   ` Kalle Valo
  0 siblings, 1 reply; 3+ messages in thread
From: Christian Marangi @ 2023-02-09 23:55 UTC (permalink / raw)
  To: Dan Carpenter; +Cc: ath11k

On Thu, Feb 09, 2023 at 12:35:20PM +0300, Dan Carpenter wrote:
> Hello Christian Marangi,
> 
> The patch d673cb6fe6c0: "wifi: ath11k: fix peer addition/deletion
> error on sta band migration" from Sep 22, 2022, leads to the
> following Smatch static checker warning:
> 
> 	drivers/net/wireless/ath/ath11k/peer.c:396 ath11k_peer_create()
> 	warn: sleeping in atomic context
> 
> drivers/net/wireless/ath/ath11k/peer.c
>     370 int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,
>     371                        struct ieee80211_sta *sta, struct peer_create_params *param)
>     372 {
>     373         struct ath11k_peer *peer;
>     374         struct ath11k_sta *arsta;
>     375         int ret, fbret;
>     376 
>     377         lockdep_assert_held(&ar->conf_mutex);
>     378 
>     379         if (ar->num_peers > (ar->max_num_peers - 1)) {
>     380                 ath11k_warn(ar->ab,
>     381                             "failed to create peer due to insufficient peer entry resource in firmware\n");
>     382                 return -ENOBUFS;
>     383         }
>     384 
>     385         spin_lock_bh(&ar->ab->base_lock);
>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> Holding a spin lock.
> 
>     386         peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr);
>     387         if (peer) {
>     388                 if (peer->vdev_id == param->vdev_id) {
>     389                         spin_unlock_bh(&ar->ab->base_lock);
>     390                         return -EINVAL;
>     391                 }
>     392 
>     393                 /* Assume sta is transitioning to another band.
>     394                  * Remove here the peer from rhash.
>     395                  */
> --> 396                 mutex_lock(&ar->ab->tbl_mtx_lock);
>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
> So we can't take a mutex.
> 
>     397                 ath11k_peer_rhash_delete(ar->ab, peer);
>     398                 mutex_unlock(&ar->ab->tbl_mtx_lock);
>     399         }
>     400         spin_unlock_bh(&ar->ab->base_lock);
>     401 
>     402         ret = ath11k_wmi_send_peer_create_cmd(ar, param);

Hi,
thanks for the report. I send a patch to ath mailing list that should
fix this bug!

-- 
	Ansuel

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [bug report] wifi: ath11k: fix peer addition/deletion error on sta band migration
  2023-02-09 23:55 ` Christian Marangi
@ 2023-02-13 12:26   ` Kalle Valo
  0 siblings, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2023-02-13 12:26 UTC (permalink / raw)
  To: Christian Marangi; +Cc: Dan Carpenter, ath11k

Christian Marangi <ansuelsmth@gmail.com> writes:

> On Thu, Feb 09, 2023 at 12:35:20PM +0300, Dan Carpenter wrote:
>
>> Hello Christian Marangi,
>> 
>> The patch d673cb6fe6c0: "wifi: ath11k: fix peer addition/deletion
>> error on sta band migration" from Sep 22, 2022, leads to the
>> following Smatch static checker warning:
>> 
>> 	drivers/net/wireless/ath/ath11k/peer.c:396 ath11k_peer_create()
>> 	warn: sleeping in atomic context
>> 
>> drivers/net/wireless/ath/ath11k/peer.c
>>     370 int ath11k_peer_create(struct ath11k *ar, struct ath11k_vif *arvif,
>>     371                        struct ieee80211_sta *sta, struct peer_create_params *param)
>>     372 {
>>     373         struct ath11k_peer *peer;
>>     374         struct ath11k_sta *arsta;
>>     375         int ret, fbret;
>>     376 
>>     377         lockdep_assert_held(&ar->conf_mutex);
>>     378 
>>     379         if (ar->num_peers > (ar->max_num_peers - 1)) {
>>     380                 ath11k_warn(ar->ab,
>>     381                             "failed to create peer due to insufficient peer entry resource in firmware\n");
>>     382                 return -ENOBUFS;
>>     383         }
>>     384 
>>     385         spin_lock_bh(&ar->ab->base_lock);
>>                 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> Holding a spin lock.
>> 
>>     386         peer = ath11k_peer_find_by_addr(ar->ab, param->peer_addr);
>>     387         if (peer) {
>>     388                 if (peer->vdev_id == param->vdev_id) {
>>     389                         spin_unlock_bh(&ar->ab->base_lock);
>>     390                         return -EINVAL;
>>     391                 }
>>     392 
>>     393                 /* Assume sta is transitioning to another band.
>>     394                  * Remove here the peer from rhash.
>>     395                  */
>> --> 396                 mutex_lock(&ar->ab->tbl_mtx_lock);
>>                         ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
>> So we can't take a mutex.
>> 
>>     397                 ath11k_peer_rhash_delete(ar->ab, peer);
>>     398                 mutex_unlock(&ar->ab->tbl_mtx_lock);
>>     399         }
>>     400         spin_unlock_bh(&ar->ab->base_lock);
>>     401 
>>     402         ret = ath11k_wmi_send_peer_create_cmd(ar, param);
>
> thanks for the report. I send a patch to ath mailing list that should
> fix this bug!

Christian, thanks for the patch. For reference here's the patch:

https://patchwork.kernel.org/project/linux-wireless/patch/20230209222622.1751-1-ansuelsmth@gmail.com/

-- 
https://patchwork.kernel.org/project/linux-wireless/list/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches

-- 
ath11k mailing list
ath11k@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/ath11k

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2023-02-13 12:27 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-02-09  9:35 [bug report] wifi: ath11k: fix peer addition/deletion error on sta band migration Dan Carpenter
2023-02-09 23:55 ` Christian Marangi
2023-02-13 12:26   ` Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).