* [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()
@ 2024-10-30 3:20 Pei Xiao
2024-10-30 10:37 ` Kalle Valo
2024-11-06 6:21 ` Ping-Ke Shih
0 siblings, 2 replies; 3+ messages in thread
From: Pei Xiao @ 2024-10-30 3:20 UTC (permalink / raw)
To: xiaopei01; +Cc: kvalo, linux-wireless, pkshih, xiaopeitux
kmalloc may fail, return value might be NULL and will cause
NULL pointer dereference. Add check NULL return of kmalloc in
btc_fw_set_monreg().
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
Fixes: b952cb0a6e2d ("wifi: rtw89: coex: Add register monitor report v7 format")
---
drivers/net/wireless/realtek/rtw89/coex.c | 4 ++++
1 file changed, 4 insertions(+)
diff --git a/drivers/net/wireless/realtek/rtw89/coex.c b/drivers/net/wireless/realtek/rtw89/coex.c
index b60c8bd4537b..092f882147cd 100644
--- a/drivers/net/wireless/realtek/rtw89/coex.c
+++ b/drivers/net/wireless/realtek/rtw89/coex.c
@@ -2507,6 +2507,8 @@ static void btc_fw_set_monreg(struct rtw89_dev *rtwdev)
if (ver->fcxmreg == 7) {
sz = struct_size(v7, regs, n);
v7 = kmalloc(sz, GFP_KERNEL);
+ if (!v7)
+ return;
v7->type = RPT_EN_MREG;
v7->fver = ver->fcxmreg;
v7->len = n;
@@ -2521,6 +2523,8 @@ static void btc_fw_set_monreg(struct rtw89_dev *rtwdev)
} else {
sz = struct_size(v1, regs, n);
v1 = kmalloc(sz, GFP_KERNEL);
+ if (!v1)
+ return;
v1->fver = ver->fcxmreg;
v1->reg_num = n;
memcpy(v1->regs, chip->mon_reg, flex_array_size(v1, regs, n));
--
2.34.1
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()
2024-10-30 3:20 [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg() Pei Xiao
@ 2024-10-30 10:37 ` Kalle Valo
2024-11-06 6:21 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Kalle Valo @ 2024-10-30 10:37 UTC (permalink / raw)
To: Pei Xiao; +Cc: linux-wireless, pkshih, xiaopeitux
Pei Xiao <xiaopei01@kylinos.cn> writes:
> kmalloc may fail, return value might be NULL and will cause
> NULL pointer dereference. Add check NULL return of kmalloc in
> btc_fw_set_monreg().
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> Fixes: b952cb0a6e2d ("wifi: rtw89: coex: Add register monitor report v7 format")
When you submit v2 please include a list of changes from v1. No need to
resend because of this but please read the documentation below.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()
2024-10-30 3:20 [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg() Pei Xiao
2024-10-30 10:37 ` Kalle Valo
@ 2024-11-06 6:21 ` Ping-Ke Shih
1 sibling, 0 replies; 3+ messages in thread
From: Ping-Ke Shih @ 2024-11-06 6:21 UTC (permalink / raw)
To: Pei Xiao, xiaopei01; +Cc: kvalo, linux-wireless, pkshih, xiaopeitux
Pei Xiao <xiaopei01@kylinos.cn> wrote:
> kmalloc may fail, return value might be NULL and will cause
> NULL pointer dereference. Add check NULL return of kmalloc in
> btc_fw_set_monreg().
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
> Fixes: b952cb0a6e2d ("wifi: rtw89: coex: Add register monitor report v7 format")
1 patch(es) applied to rtw-next branch of rtw.git, thanks.
81df5ed446b4 wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()
---
https://github.com/pkshih/rtw.git
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2024-11-06 6:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-30 3:20 [PATCH V2] wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg() Pei Xiao
2024-10-30 10:37 ` Kalle Valo
2024-11-06 6:21 ` Ping-Ke Shih
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).