From: Qianfeng Rong Date: Mon, 25 Aug 2025 14:27:52 +0000 (+0800) Subject: net: hns3: use kcalloc() instead of kzalloc() X-Git-Tag: v6.18-rc1~132^2~332 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=7e484a97f6d5f9cfc524294917555cf87e765d9b;p=thirdparty%2Fkernel%2Flinux.git 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 Reviewed-by: Jijie Shao Link: https://patch.msgid.link/20250825142753.534509-1-rongqianfeng@vivo.com Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c index 0255c8acb7444..4cce4f4ba6b01 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c @@ -843,7 +843,7 @@ static int hns3_dbg_bd_file_init(struct hnae3_handle *handle, u32 cmd) entry_dir = hns3_dbg_dentry[hns3_dbg_cmd[cmd].dentry].dentry; max_queue_num = hns3_get_max_available_channels(handle); - data = devm_kzalloc(&handle->pdev->dev, max_queue_num * sizeof(*data), + data = devm_kcalloc(&handle->pdev->dev, max_queue_num, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM;