drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
As noted in the kernel documentation [1], 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.
Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments #1
Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com>
---
drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c
index 0255c8acb744..4cce4f4ba6b0 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;
--
2.34.1
on 2025/8/25 22:27, Qianfeng Rong wrote: > As noted in the kernel documentation [1], 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. > > Link: https://www.kernel.org/doc/html/next/process/deprecated.html#open-coded-arithmetic-in-allocator-arguments #1 > Signed-off-by: Qianfeng Rong <rongqianfeng@vivo.com> > --- Thanks, Reviewed-by: Jijie Shao <shaojijie@huawei.com> > drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) > > diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c b/drivers/net/ethernet/hisilicon/hns3/hns3_debugfs.c > index 0255c8acb744..4cce4f4ba6b0 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;
© 2016 - 2025 Red Hat, Inc.