public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* Stable request: wifi: mt76: do not run mt76_unregister_device() on unregistered hw
@ 2024-10-02  9:55 Georg Müller
  2024-10-02 10:16 ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Georg Müller @ 2024-10-02  9:55 UTC (permalink / raw)
  To: stable; +Cc: Lorenzo Bianconi

commit 41130c32f3a18fcc930316da17f3a5f3bc326aa1 upstream

This was not marked as stable (but has a Fixes: tag), but causes the USB stack
to crash with 6.1.x kernels.

The patch does not apply when cherry-picking because of the context.
Should I send the patch again with updated context so that it applies without
conflicts?

Best regards,
Georg


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

* Re: Stable request: wifi: mt76: do not run mt76_unregister_device() on unregistered hw
  2024-10-02  9:55 Stable request: wifi: mt76: do not run mt76_unregister_device() on unregistered hw Georg Müller
@ 2024-10-02 10:16 ` Greg KH
  2024-10-02 12:06   ` [PATCH] " Georg Müller
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2024-10-02 10:16 UTC (permalink / raw)
  To: Georg Müller; +Cc: stable, Lorenzo Bianconi

On Wed, Oct 02, 2024 at 11:55:52AM +0200, Georg Müller wrote:
> commit 41130c32f3a18fcc930316da17f3a5f3bc326aa1 upstream
> 
> This was not marked as stable (but has a Fixes: tag), but causes the USB stack
> to crash with 6.1.x kernels.
> 
> The patch does not apply when cherry-picking because of the context.
> Should I send the patch again with updated context so that it applies without
> conflicts?

Yes, please submit a working, tested, patch and we will be glad to apply
it.

thanks,

greg k-h

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

* [PATCH] wifi: mt76: do not run mt76_unregister_device() on unregistered hw
  2024-10-02 10:16 ` Greg KH
@ 2024-10-02 12:06   ` Georg Müller
  2024-10-02 12:39     ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Georg Müller @ 2024-10-02 12:06 UTC (permalink / raw)
  To: stable
  Cc: gregkh, Lorenzo Bianconi, Stuart Hayhurst, Helmut Grohne,
	Kalle Valo, Georg Müller

From: Lorenzo Bianconi <lorenzo@kernel.org>

commit 41130c32f3a18fcc930316da17f3a5f3bc326aa1 upstream.

Trying to probe a mt7921e pci card without firmware results in a
successful probe where ieee80211_register_hw hasn't been called. When
removing the driver, ieee802111_unregister_hw is called unconditionally
leading to a kernel NULL pointer dereference.
Fix the issue running mt76_unregister_device routine just for registered
hw.

Link: https://bugs.debian.org/1029116
Link: https://bugs.kali.org/view.php?id=8140
Reported-by: Stuart Hayhurst <stuart.a.hayhurst@gmail.com>
Fixes: 1c71e03afe4b ("mt76: mt7921: move mt7921_init_hw in a dedicated work")
Tested-by: Helmut Grohne <helmut@freexian.com>
Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Signed-off-by: Georg Müller <georgmueller@gmx.net>
Link: https://lore.kernel.org/r/be3457d82f4e44bb71a22b2b5db27b644a37b1e1.1677107277.git.lorenzo@kernel.org
---
 drivers/net/wireless/mediatek/mt76/mac80211.c | 8 ++++++++
 drivers/net/wireless/mediatek/mt76/mt76.h     | 1 +
 2 files changed, 9 insertions(+)

diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c
index 6de13d641438..82fce4b1d581 100644
--- a/drivers/net/wireless/mediatek/mt76/mac80211.c
+++ b/drivers/net/wireless/mediatek/mt76/mac80211.c
@@ -522,6 +522,7 @@ int mt76_register_phy(struct mt76_phy *phy, bool vht,
 	if (ret)
 		return ret;

+	set_bit(MT76_STATE_REGISTERED, &phy->state);
 	phy->dev->phys[phy->band_idx] = phy;

 	return 0;
@@ -532,6 +533,9 @@ void mt76_unregister_phy(struct mt76_phy *phy)
 {
 	struct mt76_dev *dev = phy->dev;

+	if (!test_bit(MT76_STATE_REGISTERED, &phy->state))
+		return;
+
 	mt76_tx_status_check(dev, true);
 	ieee80211_unregister_hw(phy->hw);
 	dev->phys[phy->band_idx] = NULL;
@@ -654,6 +658,7 @@ int mt76_register_device(struct mt76_dev *dev, bool vht,
 		return ret;

 	WARN_ON(mt76_worker_setup(hw, &dev->tx_worker, NULL, "tx"));
+	set_bit(MT76_STATE_REGISTERED, &phy->state);
 	sched_set_fifo_low(dev->tx_worker.task);

 	return 0;
@@ -664,6 +669,9 @@ void mt76_unregister_device(struct mt76_dev *dev)
 {
 	struct ieee80211_hw *hw = dev->hw;

+	if (!test_bit(MT76_STATE_REGISTERED, &dev->phy.state))
+		return;
+
 	if (IS_ENABLED(CONFIG_MT76_LEDS))
 		mt76_led_cleanup(dev);
 	mt76_tx_status_check(dev, true);
diff --git a/drivers/net/wireless/mediatek/mt76/mt76.h b/drivers/net/wireless/mediatek/mt76/mt76.h
index 60c9f9c56a4f..5b03e3b33d54 100644
--- a/drivers/net/wireless/mediatek/mt76/mt76.h
+++ b/drivers/net/wireless/mediatek/mt76/mt76.h
@@ -388,6 +388,7 @@ struct mt76_tx_cb {

 enum {
 	MT76_STATE_INITIALIZED,
+	MT76_STATE_REGISTERED,
 	MT76_STATE_RUNNING,
 	MT76_STATE_MCU_RUNNING,
 	MT76_SCANNING,
--
2.46.2


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

* Re: [PATCH] wifi: mt76: do not run mt76_unregister_device() on unregistered hw
  2024-10-02 12:06   ` [PATCH] " Georg Müller
@ 2024-10-02 12:39     ` Greg KH
  2024-10-02 12:41       ` Georg Müller
  0 siblings, 1 reply; 6+ messages in thread
From: Greg KH @ 2024-10-02 12:39 UTC (permalink / raw)
  To: Georg Müller
  Cc: stable, Lorenzo Bianconi, Stuart Hayhurst, Helmut Grohne,
	Kalle Valo

On Wed, Oct 02, 2024 at 02:06:24PM +0200, Georg Müller wrote:
> From: Lorenzo Bianconi <lorenzo@kernel.org>
> 
> commit 41130c32f3a18fcc930316da17f3a5f3bc326aa1 upstream.
> 
> Trying to probe a mt7921e pci card without firmware results in a
> successful probe where ieee80211_register_hw hasn't been called. When
> removing the driver, ieee802111_unregister_hw is called unconditionally
> leading to a kernel NULL pointer dereference.
> Fix the issue running mt76_unregister_device routine just for registered
> hw.
> 
> Link: https://bugs.debian.org/1029116
> Link: https://bugs.kali.org/view.php?id=8140
> Reported-by: Stuart Hayhurst <stuart.a.hayhurst@gmail.com>
> Fixes: 1c71e03afe4b ("mt76: mt7921: move mt7921_init_hw in a dedicated work")
> Tested-by: Helmut Grohne <helmut@freexian.com>
> Signed-off-by: Lorenzo Bianconi <lorenzo@kernel.org>
> Signed-off-by: Kalle Valo <kvalo@kernel.org>
> Signed-off-by: Georg Müller <georgmueller@gmx.net>
> Link: https://lore.kernel.org/r/be3457d82f4e44bb71a22b2b5db27b644a37b1e1.1677107277.git.lorenzo@kernel.org
> ---
>  drivers/net/wireless/mediatek/mt76/mac80211.c | 8 ++++++++
>  drivers/net/wireless/mediatek/mt76/mt76.h     | 1 +
>  2 files changed, 9 insertions(+)

What kernel tree(s) do you want this applied to?

thanks,

greg k-h

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

* Re: [PATCH] wifi: mt76: do not run mt76_unregister_device() on unregistered hw
  2024-10-02 12:39     ` Greg KH
@ 2024-10-02 12:41       ` Georg Müller
  2024-10-02 12:55         ` Greg KH
  0 siblings, 1 reply; 6+ messages in thread
From: Georg Müller @ 2024-10-02 12:41 UTC (permalink / raw)
  To: Greg KH
  Cc: stable, Lorenzo Bianconi, Stuart Hayhurst, Helmut Grohne,
	Kalle Valo

> What kernel tree(s) do you want this applied to?

linux-6.1.y, please.

Thank you,
Best regards,
Georg


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

* Re: [PATCH] wifi: mt76: do not run mt76_unregister_device() on unregistered hw
  2024-10-02 12:41       ` Georg Müller
@ 2024-10-02 12:55         ` Greg KH
  0 siblings, 0 replies; 6+ messages in thread
From: Greg KH @ 2024-10-02 12:55 UTC (permalink / raw)
  To: Georg Müller
  Cc: stable, Lorenzo Bianconi, Stuart Hayhurst, Helmut Grohne,
	Kalle Valo

On Wed, Oct 02, 2024 at 02:41:21PM +0200, Georg Müller wrote:
> > What kernel tree(s) do you want this applied to?
> 
> linux-6.1.y, please.

Now queued up, thanks.

greg k-h

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

end of thread, other threads:[~2024-10-02 12:55 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-02  9:55 Stable request: wifi: mt76: do not run mt76_unregister_device() on unregistered hw Georg Müller
2024-10-02 10:16 ` Greg KH
2024-10-02 12:06   ` [PATCH] " Georg Müller
2024-10-02 12:39     ` Greg KH
2024-10-02 12:41       ` Georg Müller
2024-10-02 12:55         ` Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox