From: Ping-Ke Shih <pkshih@realtek.com>
To: Abdun Nihaal <nihaal@cse.iitm.ac.in>
Cc: "linux-wireless@vger.kernel.org" <linux-wireless@vger.kernel.org>,
"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
"stable@vger.kernel.org" <stable@vger.kernel.org>
Subject: RE: [PATCH] wifi: rtlwifi: rtl8192du: Fix possible memory leak in rtl92du_init_sw_vars()
Date: Thu, 23 Jul 2026 00:44:01 +0000 [thread overview]
Message-ID: <8e45358b6fd74839a827c25193697ea5@realtek.com> (raw)
In-Reply-To: <20260722121236.136754-1-nihaal@cse.iitm.ac.in>
Abdun Nihaal <nihaal@cse.iitm.ac.in> wrote:
> Sent: Wednesday, July 22, 2026 8:13 PM
> The memory allocated inside rtl92du_init_shared_data() is not freed in
> any of the subsequent error paths in rtl92du_init_sw_vars().
> Fix that by adding a call to rtl92du_deinit_shared_data() in the error
> path.
>
> Fixes: b5dc8873b6ff ("wifi: rtlwifi: Add rtl8192du/sw.c")
> Cc: stable@vger.kernel.org
> Signed-off-by: Abdun Nihaal <nihaal@cse.iitm.ac.in>
> ---
> Compile tested only. Issue found with static analysis.
>
> .../net/wireless/realtek/rtlwifi/rtl8192du/sw.c | 14 ++++++++++----
> 1 file changed, 10 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> index 7bafb051d5ec..c7eab3382b73 100644
> --- a/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> +++ b/drivers/net/wireless/realtek/rtlwifi/rtl8192du/sw.c
> @@ -118,7 +118,7 @@ static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
>
> err = rtl92du_init_shared_data(hw);
> if (err)
> - return err;
> + goto error;
I think here is not necessary to do rtl92du_deinit_shared_data().
>
> rtlpriv->dm.dm_initialgain_enable = true;
> rtlpriv->dm.dm_flag = 0;
> @@ -145,8 +145,10 @@ static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
>
> /* for firmware buf */
> rtlpriv->rtlhal.pfirmware = kmalloc(0x8000, GFP_KERNEL);
> - if (!rtlpriv->rtlhal.pfirmware)
> - return -ENOMEM;
> + if (!rtlpriv->rtlhal.pfirmware) {
> + err = -ENOMEM;
> + goto error;
> + }
>
> rtlpriv->max_fw_size = 0x8000;
> pr_info("Driver for Realtek RTL8192DU WLAN interface\n");
> @@ -160,10 +162,14 @@ static int rtl92du_init_sw_vars(struct ieee80211_hw *hw)
> pr_err("Failed to request firmware!\n");
> kfree(rtlpriv->rtlhal.pfirmware);
> rtlpriv->rtlhal.pfirmware = NULL;
> - return err;
> + goto error;
> }
>
> return 0;
> +
> +error:
> + rtl92du_deinit_shared_data(hw);
> + return err;
> }
>
> static void rtl92du_deinit_sw_vars(struct ieee80211_hw *hw)
> --
> 2.43.0
prev parent reply other threads:[~2026-07-23 0:44 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 12:12 [PATCH] wifi: rtlwifi: rtl8192du: Fix possible memory leak in rtl92du_init_sw_vars() Abdun Nihaal
2026-07-23 0:44 ` Ping-Ke Shih [this message]
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=8e45358b6fd74839a827c25193697ea5@realtek.com \
--to=pkshih@realtek.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-wireless@vger.kernel.org \
--cc=nihaal@cse.iitm.ac.in \
--cc=stable@vger.kernel.org \
/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