Skip to contentSkip to conversation

rtw88: fix potential NULL pointer access for firmware

PATCH In review [email protected] 3 participants 3 messages Nov 5, 2019 – Nov 6, 2019 Realtek wireless driver (rtw88)

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 rtw88: fix potential NULL pointer access for firmware

From: Yan-Hsuan Chuang <[email protected]>

Driver could access a NULL firmware pointer if we don't return here.

Fixes 5195b90426409 ("rtw88: avoid FW info flood")
---
 drivers/net/wireless/realtek/rtw88/main.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/net/wireless/realtek/rtw88/main.c +3 -1
index 021668f1b74f..de82d08ea29e 100644
@@ -1024,8 +1024,10 @@ static void rtw_load_firmware_cb(const struct firmware *firmware, void *context)
 	struct rtw_fw_state *fw = &rtwdev->fw;
 	const struct rtw_fw_hdr *fw_hdr;
 
-	if (!firmware)
+	if (!firmware || !firmware->data) {
 		rtw_err(rtwdev, "failed to request firmware\n");
+		return;
+	}
 
 	fw_hdr = (const struct rtw_fw_hdr *)firmware->data;
 	fw->h2c_version = le16_to_cpu(fw_hdr->h2c_fmt_ver);
Signature · 1 line
2.17.1
#1 lore raw
Quoted 9 lines · <[email protected]> wrote:

From: Yan-Hsuan Chuang <[email protected]>

Driver could access a NULL firmware pointer if we don't return here.

Fixes 5195b90426409 ("rtw88: avoid FW info flood")

Patch applied to wireless-drivers-next.git, thanks.

f530c1961af2 rtw88: fix potential NULL pointer access for firmware

Signature · 3 lines
https://patchwork.kernel.org/patch/11227185/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
#2 lore raw
In reply to [email protected]

On Tue, Nov 5, 2019 at 1:06 AM <[email protected]> wrote:
...

Quoted 1 line
Fixes 5195b90426409 ("rtw88: avoid FW info flood")

...

drivers/net/wireless/realtek/rtw88/main.c static void rtw_load_firmware_cb(const struct firmware *firmware, void *context) · line 1028

Quoted 9 lines
drivers/net/wireless/realtek/rtw88/main.c +1 -1
@@ -1024,8 +1024,10 @@ static void rtw_load_firmware_cb(const struct firmware *firmware, void *context)
        struct rtw_fw_state *fw = &rtwdev->fw;
        const struct rtw_fw_hdr *fw_hdr;
 
-       if (!firmware)
+       if (!firmware || !firmware->data) {
                rtw_err(rtwdev, "failed to request firmware\n");

I think you still wanted 'complete_all()' here, otherwise your waiters will hang forever. (They correctly check whether the firmware is NULL, so that's not a problem there.)

I'll send a follow-up to the follow-up :)

Brian

Quoted 2 lines
drivers/net/wireless/realtek/rtw88/main.c +2 -0
+               return;
+       }