public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] ath9k: fix null-ptr-deref in ath_chanctx_event
@ 2023-09-01  8:07 Dongliang Mu
  2023-09-01 10:41 ` Toke Høiland-Jørgensen
  0 siblings, 1 reply; 7+ messages in thread
From: Dongliang Mu @ 2023-09-01  8:07 UTC (permalink / raw)
  To: Toke Høiland-Jørgensen, Kalle Valo, Sujith Manoharan,
	John W. Linville
  Cc: hust-os-kernel-patches, Dongliang Mu, linux-wireless,
	linux-kernel

Smatch reports:

ath_chanctx_event() error: we previously assumed 'vif' could be null

The function ath_chanctx_event can be called with vif argument as NULL.
If vif is NULL, ath_dbg can trigger a null pointer dereference.

Fix this by adding a null pointer check.

Fixes: 878066e745b5 ("ath9k: Add more debug statements for channel context")
Signed-off-by: Dongliang Mu <dzm91@hust.edu.cn>
---
 drivers/net/wireless/ath/ath9k/channel.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath9k/channel.c b/drivers/net/wireless/ath/ath9k/channel.c
index 571062f2e82a..e343c8962d14 100644
--- a/drivers/net/wireless/ath/ath9k/channel.c
+++ b/drivers/net/wireless/ath/ath9k/channel.c
@@ -576,7 +576,9 @@ void ath_chanctx_event(struct ath_softc *sc, struct ieee80211_vif *vif,
 		if (sc->sched.state != ATH_CHANCTX_STATE_WAIT_FOR_BEACON)
 			break;
 
-		ath_dbg(common, CHAN_CTX, "Preparing beacon for vif: %pM\n", vif->addr);
+		if (vif)
+			ath_dbg(common, CHAN_CTX,
+				"Preparing beacon for vif: %pM\n", vif->addr);
 
 		sc->sched.beacon_pending = true;
 		sc->sched.next_tbtt = REG_READ(ah, AR_NEXT_TBTT_TIMER);
-- 
2.39.2


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

end of thread, other threads:[~2023-09-07 15:41 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-09-01  8:07 [PATCH] ath9k: fix null-ptr-deref in ath_chanctx_event Dongliang Mu
2023-09-01 10:41 ` Toke Høiland-Jørgensen
2023-09-01 10:59   ` Dongliang Mu
2023-09-01 11:16     ` Toke Høiland-Jørgensen
2023-09-01 11:21       ` Dongliang Mu
2023-09-01 12:24         ` Toke Høiland-Jørgensen
2023-09-07 11:02       ` Dan Carpenter

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