Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

net: hns3: use kcalloc() instead of kzalloc()

As noted in the kernel documentation, open-coded multiplication in
allocator arguments is discouraged because it can lead to integer overflow.

Use devm_kcalloc() to gain built-in overflow protection, making memory
allocation safer when calculating allocation size compared to explicit
multiplication.

Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
Reviewed-by: Jijie Shao <shaojijie@huawei.com>
Link: https://patch.msgid.link/20250825142753.534509-1-rongqianfeng@vivo.com
Signed-off-by: Jakub Kicinski <kuba@kernel.org>

authored by

Qianfeng Rong and committed by
Jakub Kicinski
7e484a97 b4d5cd20

+1 -1
+1 -1
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
··· 843 843 844 844 entry_dir = hns3_dbg_dentry[hns3_dbg_cmd[cmd].dentry].dentry; 845 845 max_queue_num = hns3_get_max_available_channels(handle); 846 - data = devm_kzalloc(&handle->pdev->dev, max_queue_num * sizeof(*data), 846 + data = devm_kcalloc(&handle->pdev->dev, max_queue_num, sizeof(*data), 847 847 GFP_KERNEL); 848 848 if (!data) 849 849 return -ENOMEM;