public inbox for linux-staging@lists.linux.dev
 help / color / mirror / Atom feed
* [PATCH] staging: r8188eu: add a null check of kzalloc in go_add_group_info_attr
@ 2023-02-26 13:25 Kang Chen
  2023-02-27  4:47 ` Dan Carpenter
  0 siblings, 1 reply; 5+ messages in thread
From: Kang Chen @ 2023-02-26 13:25 UTC (permalink / raw)
  To: paskripkin
  Cc: Larry.Finger, phil, gregkh, linux-staging, linux-kernel,
	Kang Chen

kzalloc may fails, pdata_attr might be null and will cause
illegal address access later.

Signed-off-by: Kang Chen <void0red@gmail.com>
---
 drivers/staging/r8188eu/core/rtw_p2p.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/drivers/staging/r8188eu/core/rtw_p2p.c b/drivers/staging/r8188eu/core/rtw_p2p.c
index 93d3c9c43..802e1170a 100644
--- a/drivers/staging/r8188eu/core/rtw_p2p.c
+++ b/drivers/staging/r8188eu/core/rtw_p2p.c
@@ -31,6 +31,8 @@ static u32 go_add_group_info_attr(struct wifidirect_info *pwdinfo, u8 *pbuf)
 	struct sta_priv *pstapriv = &padapter->stapriv;
 
 	pdata_attr = kzalloc(MAX_P2P_IE_LEN, GFP_KERNEL);
+	if (!pdata_attr)
+		return 0;
 
 	pstart = pdata_attr;
 	pcur = pdata_attr;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2023-02-27  7:23 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-26 13:25 [PATCH] staging: r8188eu: add a null check of kzalloc in go_add_group_info_attr Kang Chen
2023-02-27  4:47 ` Dan Carpenter
2023-02-27  7:11   ` Kang Chen
2023-02-27  7:18     ` Dan Carpenter
2023-02-27  7:23     ` Dan Carpenter

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox