From: Baochen Qiang <baochen.qiang@oss.qualcomm.com>
To: Linkai Gong <gonglinkai@kylinos.cn>, Jeff Johnson <jjohnson@kernel.org>
Cc: Vasanthakumar Thiagarajan
<vasanthakumar.thiagarajan@oss.qualcomm.com>,
Rameshkumar Sundaram <rameshkumar.sundaram@oss.qualcomm.com>,
linux-wireless@vger.kernel.org, ath12k@lists.infradead.org,
linux-kernel@vger.kernel.org
Subject: Re: [PATCH] wifi: ath12k: fix channel list double-free on error paths
Date: Mon, 10 Aug 2026 17:37:16 +0800 [thread overview]
Message-ID: <bd5db1a2-90f3-4cc9-8cd8-c18499c56a2b@oss.qualcomm.com> (raw)
In-Reply-To: <20260731093816.1771338-1-gonglinkai@kylinos.cn>
On 7/31/2026 5:38 PM, Linkai Gong wrote:
> ath12k_mac_setup_channels_rates() frees band channel arrays on failure
> but either leaves the pointers non-NULL or clears the wrong band. Later
> ath12k_mac_cleanup_unregister() frees the same pointers again.
The radio that frees its sbands[].channels inside setup_channels_rates() is precisely the
one excluded from cleanup_unregister() — the loop is for (j = 0; j < i; j++) and the
failing radio is index i. The earlier radios (0..i-1) all fully succeeded, so their
channel arrays are valid and freed exactly once. So this is actually a dangling pointer
issue, not a reachable double-free — nothing frees the failing radio's pointers a second
time. Please reword the message to something like "error paths leave dangling pointers + a
copy-paste typo; harden by consistently nulling after kfree()."
>
> Clear the correct sbands[].channels pointers after kfree(), including
> a copy-paste bug that nulled 2 GHz after freeing 6 GHz channels.
>
> Fixes: acc152f9be20 ("wifi: ath12k: combine channel list for split-phy devices in single-wiphy")
> Signed-off-by: Linkai Gong <gonglinkai@kylinos.cn>
> ---
> drivers/net/wireless/ath/ath12k/mac.c | 5 ++++-
> 1 file changed, 4 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/wireless/ath/ath12k/mac.c b/drivers/net/wireless/ath/ath12k/mac.c
> index a0928890671a..5468a8d2d5d5 100644
> --- a/drivers/net/wireless/ath/ath12k/mac.c
> +++ b/drivers/net/wireless/ath/ath12k/mac.c
> @@ -14275,6 +14275,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
> sizeof(ath12k_6ghz_channels), GFP_KERNEL);
> if (!channels) {
> kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels);
> + ar->mac.sbands[NL80211_BAND_2GHZ].channels = NULL;
> return -ENOMEM;
> }
>
> @@ -14325,7 +14326,9 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
> GFP_KERNEL);
> if (!channels) {
> kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels);
> + ar->mac.sbands[NL80211_BAND_2GHZ].channels = NULL;
> kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
> + ar->mac.sbands[NL80211_BAND_6GHZ].channels = NULL;
> return -ENOMEM;
> }
>
> @@ -14365,7 +14368,7 @@ static int ath12k_mac_setup_channels_rates(struct ath12k *ar,
> kfree(ar->mac.sbands[NL80211_BAND_2GHZ].channels);
> ar->mac.sbands[NL80211_BAND_2GHZ].channels = NULL;
> kfree(ar->mac.sbands[NL80211_BAND_6GHZ].channels);
> - ar->mac.sbands[NL80211_BAND_2GHZ].channels = NULL;
> + ar->mac.sbands[NL80211_BAND_6GHZ].channels = NULL;
> kfree(channels);
> band->channels = NULL;
> return ret;
actual code change looks good
next prev parent reply other threads:[~2026-08-10 9:37 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-31 9:38 Linkai Gong
2026-08-07 1:47 ` Jeff Johnson
2026-08-07 2:56 ` Linkai Gong
2026-08-07 15:48 ` Jeff Johnson
2026-08-10 9:37 ` Baochen Qiang [this message]
2026-08-11 2:05 ` Linkai Gong
2026-08-10 10:14 ` Rameshkumar Sundaram
2026-08-11 2:06 ` Linkai Gong
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=bd5db1a2-90f3-4cc9-8cd8-c18499c56a2b@oss.qualcomm.com \
--to=baochen.qiang@oss.qualcomm.com \
--cc=ath12k@lists.infradead.org \
--cc=gonglinkai@kylinos.cn \
--cc=jjohnson@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=rameshkumar.sundaram@oss.qualcomm.com \
--cc=vasanthakumar.thiagarajan@oss.qualcomm.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®