wifi: brcmfmac: pcie: handle randbuf allocation failure
authorDuoming Zhou <duoming@zju.edu.cn>
Wed, 6 Mar 2024 14:04:37 +0000 (22:04 +0800)
committerKalle Valo <kvalo@kernel.org>
Tue, 12 Mar 2024 15:32:25 +0000 (17:32 +0200)
commit316f790ebcf94bdf59f794b7cdea4068dc676d4c
tree26e017c9ab6dc1ae5eff5af37270cc48b1a9f965
parent789c17185fb0f39560496c2beab9b57ce1d0cbe7
wifi: brcmfmac: pcie: handle randbuf allocation failure

The kzalloc() in brcmf_pcie_download_fw_nvram() will return null
if the physical memory has run out. As a result, if we use
get_random_bytes() to generate random bytes in the randbuf, the
null pointer dereference bug will happen.

In order to prevent allocation failure, this patch adds a separate
function using buffer on kernel stack to generate random bytes in
the randbuf, which could prevent the kernel stack from overflow.

Fixes: 91918ce88d9f ("wifi: brcmfmac: pcie: Provide a buffer of random bytes to the device")
Suggested-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Duoming Zhou <duoming@zju.edu.cn>
Signed-off-by: Kalle Valo <kvalo@kernel.org>
Link: https://msgid.link/20240306140437.18177-1-duoming@zju.edu.cn
drivers/net/wireless/broadcom/brcm80211/brcmfmac/pcie.c