WSL2-Linux-Kernel/drivers/staging/rtl8192u
Len Baker 07e7f36da8 staging/rtl8192u: Prefer kcalloc over open coded arithmetic
As noted in the "Deprecated Interfaces, Language Features, Attributes,
and Conventions" documentation [1], size calculations (especially
multiplication) should not be performed in memory allocator (or similar)
function arguments due to the risk of them overflowing. This could lead
to values wrapping around and a smaller allocation being made than the
caller was expecting. Using those allocations could lead to linear
overflows of heap memory and other misbehaviors.

In this case these aren't actually dynamic sizes: both sides of the
multiplication are constant values. However it is best to refactor these
anyway, just to keep the open-coded math idiom out of code.

So, use the purpose specific kcalloc() function instead of the argument
size * count in the kzalloc() function.

[1] https://www.kernel.org/doc/html/latest/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments

Reviewed-by: Kees Cook <keescook@chromium.org>
Signed-off-by: Len Baker <len.baker@gmx.com>
Link: https://lore.kernel.org/r/20210824090039.GA7999@titan
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2021-08-26 12:14:27 +02:00
..
ieee80211 staging: rtl8192u: Avoid field-overflowing memcpy() 2021-08-10 12:09:35 +02:00
Kconfig staging: rtl819x: select CONFIG_CRC32 2021-01-05 15:27:22 +01:00
Makefile staging: rtl8192u: remove unneeded compiler flags 2020-01-10 13:28:15 +01:00
authors
changes
r819xU_cmdpkt.c staging: r819xU_cmdpkt: Remove functionless method 'cmpk_handle_query_config_rx' 2021-05-10 11:19:23 +02:00
r819xU_cmdpkt.h
r819xU_firmware.c staging: rtl8192u: clean up blank line style issues 2020-09-22 09:51:11 +02:00
r819xU_firmware.h
r819xU_firmware_img.c
r819xU_firmware_img.h staging: rtl8192u: clean up blank line style issues 2020-09-22 09:51:11 +02:00
r819xU_phy.c staging/rtl8192u: Prefer kcalloc over open coded arithmetic 2021-08-26 12:14:27 +02:00
r819xU_phy.h
r819xU_phyreg.h staging: rtl8192u: clean up blank line style issues 2020-09-22 09:51:11 +02:00
r8180_93cx6.c staging: rtl8192u: Add space around binary operators 2019-08-25 10:27:39 +02:00
r8180_93cx6.h
r8190_rtl8256.c staging: rtl8192u: remove unnecessary return in r8190_rtl8256.c 2021-03-10 09:25:26 +01:00
r8190_rtl8256.h
r8192U.h staging/rtl8192u: avoid Wempty-body warning 2021-03-22 17:05:15 +01:00
r8192U_core.c staging: rtl8192u: Fix bitwise vs logical operator in TranslateRxSignalStuff819xUsb() 2021-08-16 09:09:59 +02:00
r8192U_dm.c staging: rtl8192u: Fixed warnings of coding style 2021-05-27 13:01:04 +02:00
r8192U_dm.h staging: rtl8192u: Remove function dm_backup_dynamic_mechanism_state() 2019-07-01 09:11:23 +02:00
r8192U_hw.h staging: rtl8192u: fix spaces in r8192U_hw.h 2021-06-03 15:59:18 +02:00
r8192U_wx.c r8192U_wx.c: style: avoid multiple blank lines 2021-03-26 15:01:16 +01:00
r8192U_wx.h