* [PATCH] wifi: ath9k: add a defensive NULL check to prevent null-pointer dereference in ath9k_beacon_remove_slot()
@ 2026-01-07 3:12 Tuo Li
2026-01-07 10:03 ` Toke Høiland-Jørgensen
0 siblings, 1 reply; 3+ messages in thread
From: Tuo Li @ 2026-01-07 3:12 UTC (permalink / raw)
To: toke; +Cc: linux-wireless, linux-kernel, Tuo Li
In this function, bf is guarded by an if statement, indicating that it may
be NULL:
if (bf && bf->bf_mpdu) {...}
If bf is NULL, calling list_add_tail() may result in a null-pointer
dereference:
list_add_tail(&bf->list, &sc->beacon.bbuf);
Therefore, add a defensive NULL check before invoking list_add_tail() to
prevent this issue.
Signed-off-by: Tuo Li <islituo@gmail.com>
---
drivers/net/wireless/ath/ath9k/beacon.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/drivers/net/wireless/ath/ath9k/beacon.c b/drivers/net/wireless/ath/ath9k/beacon.c
index 4a27e3753c03..e39e2738ba1a 100644
--- a/drivers/net/wireless/ath/ath9k/beacon.c
+++ b/drivers/net/wireless/ath/ath9k/beacon.c
@@ -236,7 +236,8 @@ void ath9k_beacon_remove_slot(struct ath_softc *sc, struct ieee80211_vif *vif)
avp->av_bcbuf = NULL;
sc->beacon.bslot[avp->av_bslot] = NULL;
- list_add_tail(&bf->list, &sc->beacon.bbuf);
+ if (bf)
+ list_add_tail(&bf->list, &sc->beacon.bbuf);
tasklet_enable(&sc->bcon_tasklet);
}
--
2.43.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: ath9k: add a defensive NULL check to prevent null-pointer dereference in ath9k_beacon_remove_slot()
2026-01-07 3:12 [PATCH] wifi: ath9k: add a defensive NULL check to prevent null-pointer dereference in ath9k_beacon_remove_slot() Tuo Li
@ 2026-01-07 10:03 ` Toke Høiland-Jørgensen
2026-01-08 13:41 ` Tuo Li
0 siblings, 1 reply; 3+ messages in thread
From: Toke Høiland-Jørgensen @ 2026-01-07 10:03 UTC (permalink / raw)
To: Tuo Li; +Cc: linux-wireless, linux-kernel, Tuo Li
Tuo Li <islituo@gmail.com> writes:
> In this function, bf is guarded by an if statement, indicating that it may
> be NULL:
>
> if (bf && bf->bf_mpdu) {...}
>
> If bf is NULL, calling list_add_tail() may result in a null-pointer
> dereference:
>
> list_add_tail(&bf->list, &sc->beacon.bbuf);
>
> Therefore, add a defensive NULL check before invoking list_add_tail() to
> prevent this issue.
>
> Signed-off-by: Tuo Li <islituo@gmail.com>
Are you fixing an actual bug here? Otherwise, this is not worth the
churn...
-Toke
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH] wifi: ath9k: add a defensive NULL check to prevent null-pointer dereference in ath9k_beacon_remove_slot()
2026-01-07 10:03 ` Toke Høiland-Jørgensen
@ 2026-01-08 13:41 ` Tuo Li
0 siblings, 0 replies; 3+ messages in thread
From: Tuo Li @ 2026-01-08 13:41 UTC (permalink / raw)
To: Toke Høiland-Jørgensen; +Cc: linux-wireless, linux-kernel
On Wed, Jan 7, 2026 at 6:03 PM Toke Høiland-Jørgensen <toke@toke.dk> wrote:
>
> Tuo Li <islituo@gmail.com> writes:
>
> > In this function, bf is guarded by an if statement, indicating that it may
> > be NULL:
> >
> > if (bf && bf->bf_mpdu) {...}
> >
> > If bf is NULL, calling list_add_tail() may result in a null-pointer
> > dereference:
> >
> > list_add_tail(&bf->list, &sc->beacon.bbuf);
> >
> > Therefore, add a defensive NULL check before invoking list_add_tail() to
> > prevent this issue.
> >
> > Signed-off-by: Tuo Li <islituo@gmail.com>
>
> Are you fixing an actual bug here? Otherwise, this is not worth the
> churn...
>
> -Toke
Thanks for pointing this out.
This issue was reported by a static analysis tool. After reviewing the
code, I noticed that bf is guarded by an if statement, which indicates
that it may be NULL, so I added a defensive check before the other
dereference.
However, I have not been able to identify a concrete execution path in
which bf would actually be NULL at that point. I'm fine with dropping
this change if it is considered unnecessary.
Best regards,
Tuo
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-01-08 13:41 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-01-07 3:12 [PATCH] wifi: ath9k: add a defensive NULL check to prevent null-pointer dereference in ath9k_beacon_remove_slot() Tuo Li
2026-01-07 10:03 ` Toke Høiland-Jørgensen
2026-01-08 13:41 ` Tuo Li
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox