[PATCH] staging: r8188eu: Check for null pointer after calling skb_clone

From: Jiasheng Jiang
Date: Fri Jan 07 2022 - 03:01:05 EST


As the possible failure of the allocation, the skb_clone may return NULL
pointer.
Therefore, it may cause the dereference of NULL pointer.
Also, same as rtw_os_recv_indicate_pkt() in
`drivers/staging/rtl8723bs/os_dep/recv_linux.c`, it should be better to
add the check.

Fixes: 2b42bd58b321 ("staging: r8188eu: introduce new os_dep dir for RTL8188eu driver")
Signed-off-by: Jiasheng Jiang <jiasheng@xxxxxxxxxxx>
---
drivers/staging/r8188eu/os_dep/recv_linux.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/staging/r8188eu/os_dep/recv_linux.c b/drivers/staging/r8188eu/os_dep/recv_linux.c
index 917a63e3e94c..cf40f33f3295 100644
--- a/drivers/staging/r8188eu/os_dep/recv_linux.c
+++ b/drivers/staging/r8188eu/os_dep/recv_linux.c
@@ -151,7 +151,7 @@ int rtw_recv_indicatepkt(struct adapter *padapter,

rtw_xmit_entry(skb, pnetdev);

- if (bmcast)
+ if (bmcast && pskb2)
skb = pskb2;
else
goto _recv_indicatepkt_end;
--
2.25.1