Message ID | 82dd45fe7faed8f558841643a0593202b2da90c5.1730192926.git.xiaopei01@kylinos.cn |
---|---|
State | New |
Headers | show |
Series | net: wireless: realtek/rtw89: Add check null return of kmalloc | expand |
> 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
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.
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));
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(+)