]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
wifi: rtw88: Add NULL check for chip->edcca_th in rtw_fw_adaptivity_result()
authorPanagiotis Petrakopoulos <npetrakopoulos2003@gmail.com>
Wed, 15 Apr 2026 05:29:59 +0000 (08:29 +0300)
committerPing-Ke Shih <pkshih@realtek.com>
Wed, 29 Apr 2026 03:04:29 +0000 (11:04 +0800)
It was recently reported that rtw_fw_adaptivity_result()
in fw.c dereferences rtwdev->chip->edcca_th without
a NULL check. The issue is that devices with the
8821CE chip don't define edcca_th in their chip
info. As a result, when rtw_fw_adaptivity_result()
tries to dereference it, the kernel triggers an oops.

Add a NULL check for edcca_th before dereferencing
it in rtw_fw_adaptivity_result() in fw.c. Placing
the check at the function entry avoids logging any
garbage values.

This change does not address the root cause for
this behavior, but it prevents the NULL dereference
and the resulting oops while a more permanent solution
is developed.

Tested on a 8822CE chip which defines edcca_th, so
this issue is not present on it, but it still uses
this driver and I can verify there are no regressions.

Suggested-by: Ping-Ke Shih <pkshih@realtek.com>
Reported-by: Oleksandr Havrylov <goainwo@gmail.com>
Closes: https://bugzilla.kernel.org/show_bug.cgi?id=221286
Signed-off-by: Panagiotis Petrakopoulos <npetrakopoulos2003@gmail.com>
Acked-by: Ping-Ke Shih <pkshih@realtek.com>
Tested-by: Oleksandr Havrylov <goainwo@gmail.com>
Signed-off-by: Ping-Ke Shih <pkshih@realtek.com>
Link: https://patch.msgid.link/20260415052959.14844-1-npetrakopoulos2003@gmail.com
drivers/net/wireless/realtek/rtw88/fw.c

index 48207052e3f82acdf7a268d83340ea7223c52282..945fedcd375b62b4110ab631e87889bb84e2f16b 100644 (file)
@@ -279,6 +279,9 @@ static void rtw_fw_adaptivity_result(struct rtw_dev *rtwdev, u8 *payload,
        const struct rtw_hw_reg_offset *edcca_th = rtwdev->chip->edcca_th;
        struct rtw_c2h_adaptivity *result = (struct rtw_c2h_adaptivity *)payload;
 
+       if (!edcca_th)
+               return;
+
        rtw_dbg(rtwdev, RTW_DBG_ADAPTIVITY,
                "Adaptivity: density %x igi %x l2h_th_init %x l2h %x h2l %x option %x\n",
                result->density, result->igi, result->l2h_th_init, result->l2h,