summaryrefslogtreecommitdiff
path: root/drivers/infiniband/hw/ionic/ionic_admin.c
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/infiniband/hw/ionic/ionic_admin.c
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/infiniband/hw/ionic/ionic_admin.c')
-rw-r--r--drivers/infiniband/hw/ionic/ionic_admin.c16
1 files changed, 8 insertions, 8 deletions
diff --git a/drivers/infiniband/hw/ionic/ionic_admin.c b/drivers/infiniband/hw/ionic/ionic_admin.c
index 2537aa55d12d..850bd40ae3cc 100644
--- a/drivers/infiniband/hw/ionic/ionic_admin.c
+++ b/drivers/infiniband/hw/ionic/ionic_admin.c
@@ -520,7 +520,7 @@ static struct ionic_vcq *ionic_create_rdma_admincq(struct ionic_ibdev *dev,
struct ionic_cq *cq;
int rc;
- vcq = kzalloc(sizeof(*vcq), GFP_KERNEL);
+ vcq = kzalloc_obj(*vcq, GFP_KERNEL);
if (!vcq)
return ERR_PTR(-ENOMEM);
@@ -558,7 +558,7 @@ static struct ionic_aq *__ionic_create_rdma_adminq(struct ionic_ibdev *dev,
struct ionic_aq *aq;
int rc;
- aq = kzalloc(sizeof(*aq), GFP_KERNEL);
+ aq = kzalloc_obj(*aq, GFP_KERNEL);
if (!aq)
return ERR_PTR(-ENOMEM);
@@ -575,7 +575,7 @@ static struct ionic_aq *__ionic_create_rdma_adminq(struct ionic_ibdev *dev,
ionic_queue_dbell_init(&aq->q, aq->aqid);
- aq->q_wr = kcalloc((u32)aq->q.mask + 1, sizeof(*aq->q_wr), GFP_KERNEL);
+ aq->q_wr = kzalloc_objs(*aq->q_wr, (u32)aq->q.mask + 1, GFP_KERNEL);
if (!aq->q_wr) {
rc = -ENOMEM;
goto err_wr;
@@ -983,7 +983,7 @@ static struct ionic_eq *ionic_create_eq(struct ionic_ibdev *dev, int eqid)
struct ionic_eq *eq;
int rc;
- eq = kzalloc(sizeof(*eq), GFP_KERNEL);
+ eq = kzalloc_obj(*eq, GFP_KERNEL);
if (!eq)
return ERR_PTR(-ENOMEM);
@@ -1095,8 +1095,8 @@ int ionic_create_rdma_admin(struct ionic_ibdev *dev)
goto out;
}
- dev->eq_vec = kmalloc_array(dev->lif_cfg.eq_count, sizeof(*dev->eq_vec),
- GFP_KERNEL);
+ dev->eq_vec = kmalloc_objs(*dev->eq_vec, dev->lif_cfg.eq_count,
+ GFP_KERNEL);
if (!dev->eq_vec) {
rc = -ENOMEM;
goto out;
@@ -1126,8 +1126,8 @@ int ionic_create_rdma_admin(struct ionic_ibdev *dev)
dev->lif_cfg.eq_count = eq_i;
- dev->aq_vec = kmalloc_array(dev->lif_cfg.aq_count, sizeof(*dev->aq_vec),
- GFP_KERNEL);
+ dev->aq_vec = kmalloc_objs(*dev->aq_vec, dev->lif_cfg.aq_count,
+ GFP_KERNEL);
if (!dev->aq_vec) {
rc = -ENOMEM;
goto out;