linux-wireless.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] ath9k: Fix a locking bug in ath9k_add_interface()
@ 2018-10-19 20:08 Dan Carpenter
  2018-10-24  5:50 ` Kalle Valo
  2018-11-06 16:43 ` Kalle Valo
  0 siblings, 2 replies; 5+ messages in thread
From: Dan Carpenter @ 2018-10-19 20:08 UTC (permalink / raw)
  To: QCA ath9k Development, Felix Fietkau
  Cc: Kalle Valo, linux-wireless, kernel-janitors

We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
mode interface") but accidentally missed part of the locking change.

The lock has to be held earlier so that we're holding it when we do
"sc->tx99_vif = vif;" and also there in the current code there is a
stray unlock before we have taken the lock.

Fixes: 6df0580be8bc ("ath9k: add back support for using active monitor interfaces for tx99")
Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
 drivers/net/wireless/ath/ath9k/main.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath9k/main.c b/drivers/net/wireless/ath/ath9k/main.c
index 1e3b5f4a4cf9..f23cb2f3d296 100644
--- a/drivers/net/wireless/ath/ath9k/main.c
+++ b/drivers/net/wireless/ath/ath9k/main.c
@@ -1251,6 +1251,7 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
 	struct ath_vif *avp = (void *)vif->drv_priv;
 	struct ath_node *an = &avp->mcast_node;
 
+	mutex_lock(&sc->mutex);
 	if (IS_ENABLED(CONFIG_ATH9K_TX99)) {
 		if (sc->cur_chan->nvifs >= 1) {
 			mutex_unlock(&sc->mutex);
@@ -1259,8 +1260,6 @@ static int ath9k_add_interface(struct ieee80211_hw *hw,
 		sc->tx99_vif = vif;
 	}
 
-	mutex_lock(&sc->mutex);
-
 	ath_dbg(common, CONFIG, "Attach a VIF of type: %d\n", vif->type);
 	sc->cur_chan->nvifs++;
 
-- 
2.11.0


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

* Re: [PATCH] ath9k: Fix a locking bug in ath9k_add_interface()
  2018-10-19 20:08 [PATCH] ath9k: Fix a locking bug in ath9k_add_interface() Dan Carpenter
@ 2018-10-24  5:50 ` Kalle Valo
  2018-10-24 12:56   ` Dan Carpenter
  2018-11-06 16:43 ` Kalle Valo
  1 sibling, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2018-10-24  5:50 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: QCA ath9k Development, Felix Fietkau, linux-wireless,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
> mode interface") but accidentally missed part of the locking change.
>
> The lock has to be held earlier so that we're holding it when we do
> "sc->tx99_vif = vif;" and also there in the current code there is a
> stray unlock before we have taken the lock.
>
> Fixes: 6df0580be8bc ("ath9k: add back support for using active monitor interfaces for tx99")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

commit 6df0580be8bc is on it's way to v4.20 so should I also queue this
to v4.20?

-- 
Kalle Valo

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

* Re: [PATCH] ath9k: Fix a locking bug in ath9k_add_interface()
  2018-10-24  5:50 ` Kalle Valo
@ 2018-10-24 12:56   ` Dan Carpenter
  2018-10-24 12:58     ` Kalle Valo
  0 siblings, 1 reply; 5+ messages in thread
From: Dan Carpenter @ 2018-10-24 12:56 UTC (permalink / raw)
  To: Kalle Valo
  Cc: QCA ath9k Development, Felix Fietkau, linux-wireless,
	kernel-janitors

On Wed, Oct 24, 2018 at 08:50:52AM +0300, Kalle Valo wrote:
> Dan Carpenter <dan.carpenter@oracle.com> writes:
> 
> > We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
> > mode interface") but accidentally missed part of the locking change.
> >
> > The lock has to be held earlier so that we're holding it when we do
> > "sc->tx99_vif = vif;" and also there in the current code there is a
> > stray unlock before we have taken the lock.
> >
> > Fixes: 6df0580be8bc ("ath9k: add back support for using active monitor interfaces for tx99")
> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
> 
> commit 6df0580be8bc is on it's way to v4.20 so should I also queue this
> to v4.20?

Yeah.  Obviously this is a static checker thing and I haven't tested it.

I don't know if add_interface() is ever called in parallel, but I can
imagine that it might be.  In that case the race condition is something
that would affect real life.

Anyway, it's a small obvious fix.

regards,
dan carpenter


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

* Re: [PATCH] ath9k: Fix a locking bug in ath9k_add_interface()
  2018-10-24 12:56   ` Dan Carpenter
@ 2018-10-24 12:58     ` Kalle Valo
  0 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2018-10-24 12:58 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: QCA ath9k Development, Felix Fietkau, linux-wireless,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> writes:

> On Wed, Oct 24, 2018 at 08:50:52AM +0300, Kalle Valo wrote:
>> Dan Carpenter <dan.carpenter@oracle.com> writes:
>> 
>> > We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
>> > mode interface") but accidentally missed part of the locking change.
>> >
>> > The lock has to be held earlier so that we're holding it when we do
>> > "sc->tx99_vif = vif;" and also there in the current code there is a
>> > stray unlock before we have taken the lock.
>> >
>> > Fixes: 6df0580be8bc ("ath9k: add back support for using active
>> > monitor interfaces for tx99")
>> > Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
>> 
>> commit 6df0580be8bc is on it's way to v4.20 so should I also queue this
>> to v4.20?
>
> Yeah.  Obviously this is a static checker thing and I haven't tested it.
>
> I don't know if add_interface() is ever called in parallel, but I can
> imagine that it might be.  In that case the race condition is something
> that would affect real life.
>
> Anyway, it's a small obvious fix.

Ok, I'll then queue this to v4.20. But I would appreciate if others
could test or review this.

-- 
Kalle Valo

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

* Re: [PATCH] ath9k: Fix a locking bug in ath9k_add_interface()
  2018-10-19 20:08 [PATCH] ath9k: Fix a locking bug in ath9k_add_interface() Dan Carpenter
  2018-10-24  5:50 ` Kalle Valo
@ 2018-11-06 16:43 ` Kalle Valo
  1 sibling, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2018-11-06 16:43 UTC (permalink / raw)
  To: Dan Carpenter
  Cc: QCA ath9k Development, Felix Fietkau, linux-wireless,
	kernel-janitors

Dan Carpenter <dan.carpenter@oracle.com> wrote:

> We tried to revert commit d9c52fd17cb4 ("ath9k: fix tx99 with monitor
> mode interface") but accidentally missed part of the locking change.
> 
> The lock has to be held earlier so that we're holding it when we do
> "sc->tx99_vif = vif;" and also there in the current code there is a
> stray unlock before we have taken the lock.
> 
> Fixes: 6df0580be8bc ("ath9k: add back support for using active monitor interfaces for tx99")
> Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>

Patch applied to wireless-drivers.git, thanks.

461cf0360574 ath9k: Fix a locking bug in ath9k_add_interface()

-- 
https://patchwork.kernel.org/patch/10650123/

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


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

end of thread, other threads:[~2018-11-06 16:43 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2018-10-19 20:08 [PATCH] ath9k: Fix a locking bug in ath9k_add_interface() Dan Carpenter
2018-10-24  5:50 ` Kalle Valo
2018-10-24 12:56   ` Dan Carpenter
2018-10-24 12:58     ` Kalle Valo
2018-11-06 16:43 ` 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).