* [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
@ 2024-10-29 9:12 Pei Xiao
2024-10-29 10:33 ` Kalle Valo
2024-10-29 20:37 ` Markus Elfring
0 siblings, 2 replies; 6+ messages in thread
From: Pei Xiao @ 2024-10-29 9:12 UTC (permalink / raw)
To: pkshih, linux-wireless, kvalo, linux-kernel
Cc: xiaopeitux, xiongxin, Pei Xiao
kmalloc may fail, return might be NULL and will cause
NULL pointer dereference later.
Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
---
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] 6+ messages in thread* Re: [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
2024-10-29 9:12 [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc Pei Xiao
@ 2024-10-29 10:33 ` Kalle Valo
2024-10-30 0:35 ` Ping-Ke Shih
2024-10-29 20:37 ` Markus Elfring
1 sibling, 1 reply; 6+ messages in thread
From: Kalle Valo @ 2024-10-29 10:33 UTC (permalink / raw)
To: Pei Xiao; +Cc: pkshih, linux-wireless, linux-kernel, xiaopeitux, xiongxin
Pei Xiao <xiaopei01@kylinos.cn> writes:
> kmalloc may fail, return might be NULL and will cause
> NULL pointer dereference later.
>
> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
We use 'wifi: rtw89:' in the title, please check the documentation below
for more.
--
https://patchwork.kernel.org/project/linux-wireless/list/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 6+ messages in thread
* RE: [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
2024-10-29 10:33 ` Kalle Valo
@ 2024-10-30 0:35 ` Ping-Ke Shih
2024-10-30 3:12 ` Pei Xiao
0 siblings, 1 reply; 6+ messages in thread
From: Ping-Ke Shih @ 2024-10-30 0:35 UTC (permalink / raw)
To: Kalle Valo, Pei Xiao
Cc: linux-wireless@vger.kernel.org, linux-kernel@vger.kernel.org,
xiaopeitux@foxmail.com, xiongxin@kylinos.cn
Kalle Valo <kvalo@kernel.org> wrote:
> Pei Xiao <xiaopei01@kylinos.cn> writes:
>
> > kmalloc may fail, return might be NULL and will cause
> > NULL pointer dereference later.
> >
> > Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
>
> We use 'wifi: rtw89:' in the title, please check the documentation below
> for more.
>
A way to known subject prefix is to use git log with the files touched by
this patch:
git log --oneline drivers/net/wireless/realtek/rtw89/coex.c
Also subject can point out specific function. Then my opinion is
"wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()"
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
2024-10-30 0:35 ` Ping-Ke Shih
@ 2024-10-30 3:12 ` Pei Xiao
2024-10-30 3:13 ` Pei Xiao
0 siblings, 1 reply; 6+ messages in thread
From: Pei Xiao @ 2024-10-30 3:12 UTC (permalink / raw)
To: 425562414, Ping-Ke Shih, Kalle Valo
Cc: Pei Xiao, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, xiaopeitux@foxmail.com,
xiongxin@kylinos.cn
On 2024/10/30 08:35, Ping-Ke Shih wrote:
> Kalle Valo <kvalo@kernel.org> wrote:
>> Pei Xiao <xiaopei01@kylinos.cn> writes:
>>
>>> kmalloc may fail, return might be NULL and will cause
>>> NULL pointer dereference later.
>>>
>>> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
>>
>> We use 'wifi: rtw89:' in the title, please check the documentation below
>> for more.
>>
>
> A way to known subject prefix is to use git log with the files touched by
> this patch:
> git log --oneline drivers/net/wireless/realtek/rtw89/coex.c
>
> Also subject can point out specific function. Then my opinion is
> "wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()"
>
hi Kalle Valo and Ping-Ke Shih,
Thanks,I will modify the commit information and add Fixes.Thanks for help.
Pei Xiao.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
2024-10-30 3:12 ` Pei Xiao
@ 2024-10-30 3:13 ` Pei Xiao
0 siblings, 0 replies; 6+ messages in thread
From: Pei Xiao @ 2024-10-30 3:13 UTC (permalink / raw)
To: Ping-Ke Shih, Kalle Valo
Cc: Pei Xiao, linux-wireless@vger.kernel.org,
linux-kernel@vger.kernel.org, xiaopeitux@foxmail.com,
xiongxin@kylinos.cn
On 2024/10/30 08:35, Ping-Ke Shih wrote:
> Kalle Valo <kvalo@kernel.org> wrote:
>> Pei Xiao <xiaopei01@kylinos.cn> writes:
>>
>>> kmalloc may fail, return might be NULL and will cause
>>> NULL pointer dereference later.
>>>
>>> Signed-off-by: Pei Xiao <xiaopei01@kylinos.cn>
>>
>> We use 'wifi: rtw89:' in the title, please check the documentation below
>> for more.
>>
>
> A way to known subject prefix is to use git log with the files touched by
> this patch:
> git log --oneline drivers/net/wireless/realtek/rtw89/coex.c
>
> Also subject can point out specific function. Then my opinion is
> "wifi: rtw89: coex: check NULL return of kmalloc in btc_fw_set_monreg()"
>
hi Kalle Valo and Ping-Ke Shih,
Thanks,I will modify the commit information and add Fixes.Thanks for help.
Pei Xiao.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc
2024-10-29 9:12 [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc Pei Xiao
2024-10-29 10:33 ` Kalle Valo
@ 2024-10-29 20:37 ` Markus Elfring
1 sibling, 0 replies; 6+ messages in thread
From: Markus Elfring @ 2024-10-29 20:37 UTC (permalink / raw)
To: Pei Xiao, linux-wireless, Kalle Valo, Ping-Ke Shih
Cc: LKML, xiaopeitux, xiongxin
> kmalloc may fail, return might be NULL and will cause
value?
> NULL pointer dereference later.
* An imperative wording is more desirable for such a change description,
isn't it?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc5#n94
* Would you like to add any tags (like “Fixes” and “Cc”) accordingly?
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/tree/Documentation/process/submitting-patches.rst?h=v6.12-rc5#n145
Regards,
Markus
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2024-10-30 3:13 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-10-29 9:12 [PATCH] net: wireless: realtek/rtw89: Add check null return of kmalloc Pei Xiao
2024-10-29 10:33 ` Kalle Valo
2024-10-30 0:35 ` Ping-Ke Shih
2024-10-30 3:12 ` Pei Xiao
2024-10-30 3:13 ` Pei Xiao
2024-10-29 20:37 ` Markus Elfring
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox