summaryrefslogtreecommitdiff
path: root/drivers/net/ethernet/huawei
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/net/ethernet/huawei
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.zip
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/net/ethernet/huawei')
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_debugfs.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_devlink.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_ethtool.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c6
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic/hinic_port.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c8
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_filter.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c5
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c2
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_lld.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_main.c5
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c17
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c6
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c4
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_rx.c6
-rw-r--r--drivers/net/ethernet/huawei/hinic3/hinic3_tx.c12
21 files changed, 51 insertions, 54 deletions
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c b/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
index 061952c6c21a..39ceba2820bf 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_debugfs.c
@@ -88,7 +88,7 @@ static int hinic_dbg_get_func_table(struct hinic_dev *nic_dev, int idx)
int ret = ~0;
int err;
- read_data = kzalloc(sizeof(*read_data), GFP_KERNEL);
+ read_data = kzalloc_obj(*read_data, GFP_KERNEL);
if (!read_data)
return ~0;
@@ -182,7 +182,7 @@ static int create_dbg_files(struct hinic_dev *dev, enum hinic_dbg_type type, voi
struct hinic_debug_priv *tmp;
int i;
- tmp = kzalloc(sizeof(*tmp), GFP_KERNEL);
+ tmp = kzalloc_obj(*tmp, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
index 300bc267a259..f4d34fdbc014 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_devlink.c
@@ -130,7 +130,7 @@ static int hinic_flash_fw(struct hinic_devlink_priv *priv, const u8 *data,
int total_len_flag = 0;
int err;
- fw_update_msg = kzalloc(sizeof(*fw_update_msg), GFP_KERNEL);
+ fw_update_msg = kzalloc_obj(*fw_update_msg, GFP_KERNEL);
if (!fw_update_msg)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
index f28528df5aac..d4787347d0c5 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_ethtool.c
@@ -1392,7 +1392,7 @@ static void hinic_get_ethtool_stats(struct net_device *netdev,
sizeof(u64)) ? *(u64 *)p : *(u32 *)p;
}
- port_stats = kzalloc(sizeof(*port_stats), GFP_KERNEL);
+ port_stats = kzalloc_obj(*port_stats, GFP_KERNEL);
if (!port_stats) {
memset(&data[i], 0,
ARRAY_SIZE(hinic_port_stats) * sizeof(*data));
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
index 97c1584dc05b..f8aef328f8c0 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_mbox.c
@@ -487,7 +487,7 @@ static void recv_mbox_handler(struct hinic_mbox_func_to_func *func_to_func,
if (!rcv_mbox_temp->buf_out)
goto err_alloc_rcv_mbox_buf;
- mbox_work = kzalloc(sizeof(*mbox_work), GFP_KERNEL);
+ mbox_work = kzalloc_obj(*mbox_work, GFP_KERNEL);
if (!mbox_work)
goto err_alloc_mbox_work;
@@ -603,7 +603,7 @@ static bool check_vf_mbox_random_id(struct hinic_mbox_func_to_func *func_to_func
"The mailbox random id(0x%x) of func_id(0x%x) doesn't match with pf reservation(0x%x)\n",
random_id, src, func_to_func->vf_mbx_rand_id[src]);
- mbox_work = kzalloc(sizeof(*mbox_work), GFP_KERNEL);
+ mbox_work = kzalloc_obj(*mbox_work, GFP_KERNEL);
if (!mbox_work)
return false;
@@ -1402,7 +1402,7 @@ int hinic_func_to_func_init(struct hinic_hwdev *hwdev)
int err;
pfhwdev = container_of(hwdev, struct hinic_pfhwdev, hwdev);
- func_to_func = kzalloc(sizeof(*func_to_func), GFP_KERNEL);
+ func_to_func = kzalloc_obj(*func_to_func, GFP_KERNEL);
if (!func_to_func)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
index 4aa1f433ed24..8bda0a26a345 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_mgmt.c
@@ -441,7 +441,7 @@ static void mgmt_recv_msg_handler(struct hinic_pf_to_mgmt *pf_to_mgmt,
{
struct hinic_mgmt_msg_handle_work *mgmt_work = NULL;
- mgmt_work = kzalloc(sizeof(*mgmt_work), GFP_KERNEL);
+ mgmt_work = kzalloc_obj(*mgmt_work, GFP_KERNEL);
if (!mgmt_work)
return;
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_port.c b/drivers/net/ethernet/huawei/hinic/hinic_port.c
index 486fb0e20bef..868e666cc392 100644
--- a/drivers/net/ethernet/huawei/hinic/hinic_port.c
+++ b/drivers/net/ethernet/huawei/hinic/hinic_port.c
@@ -1032,7 +1032,7 @@ int hinic_get_phy_port_stats(struct hinic_dev *nic_dev,
struct pci_dev *pdev = hwif->pdev;
int err;
- port_stats = kzalloc(sizeof(*port_stats), GFP_KERNEL);
+ port_stats = kzalloc_obj(*port_stats, GFP_KERNEL);
if (!port_stats)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
index 86720bb119e9..ab38da085ae5 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_cmdq.c
@@ -123,7 +123,7 @@ struct hinic3_cmd_buf *hinic3_alloc_cmd_buf(struct hinic3_hwdev *hwdev)
cmdqs = hwdev->cmdqs;
- cmd_buf = kmalloc(sizeof(*cmd_buf), GFP_ATOMIC);
+ cmd_buf = kmalloc_obj(*cmd_buf, GFP_ATOMIC);
if (!cmd_buf)
return NULL;
@@ -614,8 +614,8 @@ static int init_cmdq(struct hinic3_cmdq *cmdq, struct hinic3_hwdev *hwdev,
spin_lock_init(&cmdq->cmdq_lock);
- cmdq->cmd_infos = kcalloc(cmdq->wq.q_depth, sizeof(*cmdq->cmd_infos),
- GFP_KERNEL);
+ cmdq->cmd_infos = kzalloc_objs(*cmdq->cmd_infos, cmdq->wq.q_depth,
+ GFP_KERNEL);
if (!cmdq->cmd_infos) {
err = -ENOMEM;
return err;
@@ -738,7 +738,7 @@ static int init_cmdqs(struct hinic3_hwdev *hwdev)
{
struct hinic3_cmdqs *cmdqs;
- cmdqs = kzalloc(sizeof(*cmdqs), GFP_KERNEL);
+ cmdqs = kzalloc_obj(*cmdqs, GFP_KERNEL);
if (!cmdqs)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
index a2c3962116d5..78f50dc6513a 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_eqs.c
@@ -648,7 +648,7 @@ int hinic3_aeqs_init(struct hinic3_hwdev *hwdev, u16 num_aeqs,
u16 q_id;
int err;
- aeqs = kzalloc(sizeof(*aeqs), GFP_KERNEL);
+ aeqs = kzalloc_obj(*aeqs, GFP_KERNEL);
if (!aeqs)
return -ENOMEM;
@@ -720,7 +720,7 @@ int hinic3_ceqs_init(struct hinic3_hwdev *hwdev, u16 num_ceqs,
u16 q_id;
int err;
- ceqs = kzalloc(sizeof(*ceqs), GFP_KERNEL);
+ ceqs = kzalloc_obj(*ceqs, GFP_KERNEL);
if (!ceqs)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_filter.c b/drivers/net/ethernet/huawei/hinic3/hinic3_filter.c
index 6349d71f574b..6d378c86aabd 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_filter.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_filter.c
@@ -75,7 +75,7 @@ static void hinic3_add_filter(struct net_device *netdev,
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
struct hinic3_mac_filter *f;
- f = kzalloc(sizeof(*f), GFP_ATOMIC);
+ f = kzalloc_obj(*f, GFP_ATOMIC);
if (!f)
return;
@@ -110,7 +110,7 @@ hinic3_mac_filter_entry_clone(const struct hinic3_mac_filter *src)
{
struct hinic3_mac_filter *f;
- f = kzalloc(sizeof(*f), GFP_ATOMIC);
+ f = kzalloc_obj(*f, GFP_ATOMIC);
if (!f)
return NULL;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c b/drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c
index 7827c1f626db..c65dec383535 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_hw_cfg.c
@@ -86,8 +86,7 @@ static int hinic3_init_irq_info(struct hinic3_hwdev *hwdev)
}
irq_info = &cfg_mgmt->irq_info;
- irq_info->irq = kcalloc(intr_num, sizeof(struct hinic3_irq),
- GFP_KERNEL);
+ irq_info->irq = kzalloc_objs(struct hinic3_irq, intr_num, GFP_KERNEL);
if (!irq_info->irq)
return -ENOMEM;
@@ -130,7 +129,7 @@ int hinic3_init_cfg_mgmt(struct hinic3_hwdev *hwdev)
struct hinic3_cfg_mgmt_info *cfg_mgmt;
int err;
- cfg_mgmt = kzalloc(sizeof(*cfg_mgmt), GFP_KERNEL);
+ cfg_mgmt = kzalloc_obj(*cfg_mgmt, GFP_KERNEL);
if (!cfg_mgmt)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c b/drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c
index 7906d4057cf2..f0b402b792b9 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_hwdev.c
@@ -528,7 +528,7 @@ int hinic3_init_hwdev(struct pci_dev *pdev)
struct hinic3_hwdev *hwdev;
int err;
- hwdev = kzalloc(sizeof(*hwdev), GFP_KERNEL);
+ hwdev = kzalloc_obj(*hwdev, GFP_KERNEL);
if (!hwdev)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c b/drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c
index 801f48e241f8..c1eeedbe0c15 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_hwif.c
@@ -432,7 +432,7 @@ int hinic3_init_hwif(struct hinic3_hwdev *hwdev)
u32 attr1, attr4, attr5;
int err;
- hwif = kzalloc(sizeof(*hwif), GFP_KERNEL);
+ hwif = kzalloc_obj(*hwif, GFP_KERNEL);
if (!hwif)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
index 87413e192f10..b5d026c95d39 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_lld.c
@@ -60,7 +60,7 @@ static struct hinic3_adev *hinic3_add_one_adev(struct hinic3_hwdev *hwdev,
const char *svc_name;
int ret;
- hadev = kzalloc(sizeof(*hadev), GFP_KERNEL);
+ hadev = kzalloc_obj(*hadev, GFP_KERNEL);
if (!hadev)
return NULL;
@@ -250,7 +250,7 @@ static int hinic3_pci_init(struct pci_dev *pdev)
struct hinic3_pcidev *pci_adapter;
int err;
- pci_adapter = kzalloc(sizeof(*pci_adapter), GFP_KERNEL);
+ pci_adapter = kzalloc_obj(*pci_adapter, GFP_KERNEL);
if (!pci_adapter)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
index 6275d94dfefd..3c9efe037793 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_main.c
@@ -57,9 +57,8 @@ static int hinic3_init_intr_coalesce(struct net_device *netdev)
{
struct hinic3_nic_dev *nic_dev = netdev_priv(netdev);
- nic_dev->intr_coalesce = kcalloc(nic_dev->max_qps,
- sizeof(*nic_dev->intr_coalesce),
- GFP_KERNEL);
+ nic_dev->intr_coalesce = kzalloc_objs(*nic_dev->intr_coalesce,
+ nic_dev->max_qps, GFP_KERNEL);
if (!nic_dev->intr_coalesce)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
index c871fd0fb109..8c7bb38cc57d 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mbox.c
@@ -320,7 +320,7 @@ static int hinic3_init_func_mbox_msg_channel(struct hinic3_hwdev *hwdev)
int err;
mbox = hwdev->mbox;
- mbox->func_msg = kzalloc(sizeof(*mbox->func_msg), GFP_KERNEL);
+ mbox->func_msg = kzalloc_obj(*mbox->func_msg, GFP_KERNEL);
if (!mbox->func_msg)
return -ENOMEM;
@@ -412,7 +412,7 @@ int hinic3_init_mbox(struct hinic3_hwdev *hwdev)
struct hinic3_mbox *mbox;
int err;
- mbox = kzalloc(sizeof(*mbox), GFP_KERNEL);
+ mbox = kzalloc_obj(*mbox, GFP_KERNEL);
if (!mbox)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c b/drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c
index be2a2ae75fc0..29422ac14bb8 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_mgmt.c
@@ -120,7 +120,7 @@ static void hinic3_init_mgmt_msg_work(struct hinic3_msg_pf_to_mgmt *pf_to_mgmt,
{
struct mgmt_msg_handle_work *mgmt_work;
- mgmt_work = kmalloc(sizeof(*mgmt_work), GFP_KERNEL);
+ mgmt_work = kmalloc_obj(*mgmt_work, GFP_KERNEL);
if (!mgmt_work)
return;
@@ -252,7 +252,7 @@ int hinic3_pf_to_mgmt_init(struct hinic3_hwdev *hwdev)
struct hinic3_msg_pf_to_mgmt *pf_to_mgmt;
int err;
- pf_to_mgmt = kzalloc(sizeof(*pf_to_mgmt), GFP_KERNEL);
+ pf_to_mgmt = kzalloc_obj(*pf_to_mgmt, GFP_KERNEL);
if (!pf_to_mgmt)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
index 75adfe897e81..7830bff30859 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_netdev_ops.c
@@ -99,9 +99,8 @@ static int hinic3_setup_num_qps(struct net_device *netdev)
nic_dev->num_qp_irq = 0;
- nic_dev->qps_msix_entries = kcalloc(nic_dev->max_qps,
- sizeof(struct msix_entry),
- GFP_KERNEL);
+ nic_dev->qps_msix_entries = kzalloc_objs(struct msix_entry,
+ nic_dev->max_qps, GFP_KERNEL);
if (!nic_dev->qps_msix_entries)
return -ENOMEM;
@@ -127,20 +126,20 @@ static int hinic3_alloc_txrxq_resources(struct net_device *netdev,
{
int err;
- q_params->txqs_res = kcalloc(q_params->num_qps,
- sizeof(*q_params->txqs_res), GFP_KERNEL);
+ q_params->txqs_res = kzalloc_objs(*q_params->txqs_res,
+ q_params->num_qps, GFP_KERNEL);
if (!q_params->txqs_res)
return -ENOMEM;
- q_params->rxqs_res = kcalloc(q_params->num_qps,
- sizeof(*q_params->rxqs_res), GFP_KERNEL);
+ q_params->rxqs_res = kzalloc_objs(*q_params->rxqs_res,
+ q_params->num_qps, GFP_KERNEL);
if (!q_params->rxqs_res) {
err = -ENOMEM;
goto err_free_txqs_res_arr;
}
- q_params->irq_cfg = kcalloc(q_params->num_qps,
- sizeof(*q_params->irq_cfg), GFP_KERNEL);
+ q_params->irq_cfg = kzalloc_objs(*q_params->irq_cfg, q_params->num_qps,
+ GFP_KERNEL);
if (!q_params->irq_cfg) {
err = -ENOMEM;
goto err_free_rxqs_res_arr;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
index 90887d2bb127..0ded1000b369 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_nic_io.c
@@ -212,7 +212,7 @@ int hinic3_init_nic_io(struct hinic3_nic_dev *nic_dev)
struct hinic3_nic_io *nic_io;
int err;
- nic_io = kzalloc(sizeof(*nic_io), GFP_KERNEL);
+ nic_io = kzalloc_obj(*nic_io, GFP_KERNEL);
if (!nic_io)
return -ENOMEM;
@@ -408,13 +408,13 @@ int hinic3_alloc_qps(struct hinic3_nic_dev *nic_dev,
if (qp_params->num_qps > nic_io->max_qps || !qp_params->num_qps)
return -EINVAL;
- sqs = kcalloc(qp_params->num_qps, sizeof(*sqs), GFP_KERNEL);
+ sqs = kzalloc_objs(*sqs, qp_params->num_qps, GFP_KERNEL);
if (!sqs) {
err = -ENOMEM;
goto err_out;
}
- rqs = kcalloc(qp_params->num_qps, sizeof(*rqs), GFP_KERNEL);
+ rqs = kzalloc_objs(*rqs, qp_params->num_qps, GFP_KERNEL);
if (!rqs) {
err = -ENOMEM;
goto err_free_sqs;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c b/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c
index fab9011de9ad..9c00d1ed825a 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_queue_common.c
@@ -44,8 +44,8 @@ int hinic3_queue_pages_alloc(struct hinic3_hwdev *hwdev,
u32 pg_idx;
int err;
- qpages->pages = kcalloc(qpages->num_pages, sizeof(qpages->pages[0]),
- GFP_KERNEL);
+ qpages->pages = kzalloc_objs(qpages->pages[0], qpages->num_pages,
+ GFP_KERNEL);
if (!qpages->pages)
return -ENOMEM;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
index 159c291fa293..f2d43beab444 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_rx.c
@@ -66,7 +66,7 @@ int hinic3_alloc_rxqs(struct net_device *netdev)
struct hinic3_rxq *rxq;
u16 q_id;
- nic_dev->rxqs = kcalloc(num_rxqs, sizeof(*nic_dev->rxqs), GFP_KERNEL);
+ nic_dev->rxqs = kzalloc_objs(*nic_dev->rxqs, num_rxqs, GFP_KERNEL);
if (!nic_dev->rxqs)
return -ENOMEM;
@@ -419,8 +419,8 @@ int hinic3_alloc_rxqs_res(struct net_device *netdev, u16 num_rq,
for (idx = 0; idx < num_rq; idx++) {
rqres = &rxqs_res[idx];
- rqres->rx_info = kcalloc(rq_depth, sizeof(*rqres->rx_info),
- GFP_KERNEL);
+ rqres->rx_info = kzalloc_objs(*rqres->rx_info, rq_depth,
+ GFP_KERNEL);
if (!rqres->rx_info)
goto err_free_rqres;
diff --git a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
index 6d3dc930ca97..8c988df8963e 100644
--- a/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
+++ b/drivers/net/ethernet/huawei/hinic3/hinic3_tx.c
@@ -48,7 +48,7 @@ int hinic3_alloc_txqs(struct net_device *netdev)
struct pci_dev *pdev = nic_dev->pdev;
struct hinic3_txq *txq;
- nic_dev->txqs = kcalloc(num_txqs, sizeof(*nic_dev->txqs), GFP_KERNEL);
+ nic_dev->txqs = kzalloc_objs(*nic_dev->txqs, num_txqs, GFP_KERNEL);
if (!nic_dev->txqs)
return -ENOMEM;
@@ -681,14 +681,14 @@ int hinic3_alloc_txqs_res(struct net_device *netdev, u16 num_sq,
for (idx = 0; idx < num_sq; idx++) {
tqres = &txqs_res[idx];
- tqres->tx_info = kcalloc(sq_depth, sizeof(*tqres->tx_info),
- GFP_KERNEL);
+ tqres->tx_info = kzalloc_objs(*tqres->tx_info, sq_depth,
+ GFP_KERNEL);
if (!tqres->tx_info)
goto err_free_tqres;
- tqres->bds = kcalloc(sq_depth * HINIC3_BDS_PER_SQ_WQEBB +
- HINIC3_MAX_SQ_SGE, sizeof(*tqres->bds),
- GFP_KERNEL);
+ tqres->bds = kzalloc_objs(*tqres->bds,
+ sq_depth * HINIC3_BDS_PER_SQ_WQEBB + HINIC3_MAX_SQ_SGE,
+ GFP_KERNEL);
if (!tqres->bds) {
kfree(tqres->tx_info);
goto err_free_tqres;