rtw88: fix potential NULL pointer access for firmware

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

Fixes: 5195b90426 ("rtw88: avoid FW info flood")
Reported-by: kbuild test robot <lkp@intel.com>
Reported-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yan-Hsuan Chuang <yhchuang@realtek.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
This commit is contained in:
Yan-Hsuan Chuang 2019-11-05 17:04:42 +08:00 committed by Kalle Valo
parent 5174f1e410
commit f530c1961a

View File

@ -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);