summaryrefslogtreecommitdiff
path: root/drivers/dma/ti
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/dma/ti
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
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/dma/ti')
-rw-r--r--drivers/dma/ti/dma-crossbar.c6
-rw-r--r--drivers/dma/ti/edma.c8
-rw-r--r--drivers/dma/ti/k3-udma.c10
-rw-r--r--drivers/dma/ti/omap-dma.c4
4 files changed, 14 insertions, 14 deletions
diff --git a/drivers/dma/ti/dma-crossbar.c b/drivers/dma/ti/dma-crossbar.c
index e04077d542d2..cf1ceab10f14 100644
--- a/drivers/dma/ti/dma-crossbar.c
+++ b/drivers/dma/ti/dma-crossbar.c
@@ -103,7 +103,7 @@ static void *ti_am335x_xbar_route_allocate(struct of_phandle_args *dma_spec,
goto out_put_pdev;
}
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map) {
of_node_put(dma_spec->np);
map = ERR_PTR(-ENOMEM);
@@ -260,7 +260,7 @@ static void *ti_dra7_xbar_route_allocate(struct of_phandle_args *dma_spec,
goto out_put_pdev;
}
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map) {
of_node_put(dma_spec->np);
map = ERR_PTR(-ENOMEM);
@@ -393,7 +393,7 @@ static int ti_dra7_xbar_probe(struct platform_device *pdev)
if (!nelm)
return -EINVAL;
- rsv_events = kcalloc(nelm, sizeof(*rsv_events), GFP_KERNEL);
+ rsv_events = kzalloc_objs(*rsv_events, nelm, GFP_KERNEL);
if (!rsv_events)
return -ENOMEM;
diff --git a/drivers/dma/ti/edma.c b/drivers/dma/ti/edma.c
index 552be71db6c4..d97db5af3555 100644
--- a/drivers/dma/ti/edma.c
+++ b/drivers/dma/ti/edma.c
@@ -1041,7 +1041,7 @@ static struct dma_async_tx_descriptor *edma_prep_slave_sg(
return NULL;
}
- edesc = kzalloc(struct_size(edesc, pset, sg_len), GFP_ATOMIC);
+ edesc = kzalloc_flex(*edesc, pset, sg_len, GFP_ATOMIC);
if (!edesc)
return NULL;
@@ -1158,7 +1158,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_memcpy(
nslots = 2;
}
- edesc = kzalloc(struct_size(edesc, pset, nslots), GFP_ATOMIC);
+ edesc = kzalloc_flex(*edesc, pset, nslots, GFP_ATOMIC);
if (!edesc)
return NULL;
@@ -1265,7 +1265,7 @@ edma_prep_dma_interleaved(struct dma_chan *chan,
if (src_bidx > SZ_64K || dst_bidx > SZ_64K)
return NULL;
- edesc = kzalloc(struct_size(edesc, pset, 1), GFP_ATOMIC);
+ edesc = kzalloc_flex(*edesc, pset, 1, GFP_ATOMIC);
if (!edesc)
return NULL;
@@ -1361,7 +1361,7 @@ static struct dma_async_tx_descriptor *edma_prep_dma_cyclic(
}
}
- edesc = kzalloc(struct_size(edesc, pset, nslots), GFP_ATOMIC);
+ edesc = kzalloc_flex(*edesc, pset, nslots, GFP_ATOMIC);
if (!edesc)
return NULL;
diff --git a/drivers/dma/ti/k3-udma.c b/drivers/dma/ti/k3-udma.c
index aa2dc762140f..b547b19bc9d8 100644
--- a/drivers/dma/ti/k3-udma.c
+++ b/drivers/dma/ti/k3-udma.c
@@ -3241,7 +3241,7 @@ udma_prep_slave_sg_pkt(struct udma_chan *uc, struct scatterlist *sgl,
unsigned int i;
u64 asel;
- d = kzalloc(struct_size(d, hwdesc, sglen), GFP_NOWAIT);
+ d = kzalloc_flex(*d, hwdesc, sglen, GFP_NOWAIT);
if (!d)
return NULL;
@@ -3588,7 +3588,7 @@ udma_prep_dma_cyclic_pkt(struct udma_chan *uc, dma_addr_t buf_addr,
if (period_len >= SZ_4M)
return NULL;
- d = kzalloc(struct_size(d, hwdesc, periods), GFP_NOWAIT);
+ d = kzalloc_flex(*d, hwdesc, periods, GFP_NOWAIT);
if (!d)
return NULL;
@@ -4686,7 +4686,7 @@ static int udma_setup_resources(struct udma_dev *ud)
irq_res.sets += rm_res->sets;
}
- irq_res.desc = kcalloc(irq_res.sets, sizeof(*irq_res.desc), GFP_KERNEL);
+ irq_res.desc = kzalloc_objs(*irq_res.desc, irq_res.sets, GFP_KERNEL);
if (!irq_res.desc)
return -ENOMEM;
rm_res = tisci_rm->rm_ranges[RM_RANGE_TCHAN];
@@ -4878,7 +4878,7 @@ static int bcdma_setup_resources(struct udma_dev *ud)
}
}
- irq_res.desc = kcalloc(irq_res.sets, sizeof(*irq_res.desc), GFP_KERNEL);
+ irq_res.desc = kzalloc_objs(*irq_res.desc, irq_res.sets, GFP_KERNEL);
if (!irq_res.desc)
return -ENOMEM;
if (ud->bchan_cnt) {
@@ -5080,7 +5080,7 @@ static int pktdma_setup_resources(struct udma_dev *ud)
irq_res.sets += rm_res->sets;
}
- irq_res.desc = kcalloc(irq_res.sets, sizeof(*irq_res.desc), GFP_KERNEL);
+ irq_res.desc = kzalloc_objs(*irq_res.desc, irq_res.sets, GFP_KERNEL);
if (!irq_res.desc)
return -ENOMEM;
rm_res = tisci_rm->rm_ranges[RM_RANGE_TFLOW];
diff --git a/drivers/dma/ti/omap-dma.c b/drivers/dma/ti/omap-dma.c
index 73ed4b794630..70591c2bf92a 100644
--- a/drivers/dma/ti/omap-dma.c
+++ b/drivers/dma/ti/omap-dma.c
@@ -1002,7 +1002,7 @@ static struct dma_async_tx_descriptor *omap_dma_prep_slave_sg(
}
/* Now allocate and setup the descriptor. */
- d = kzalloc(struct_size(d, sg, sglen), GFP_ATOMIC);
+ d = kzalloc_flex(*d, sg, sglen, GFP_ATOMIC);
if (!d)
return NULL;
d->sglen = sglen;
@@ -1503,7 +1503,7 @@ static int omap_dma_chan_init(struct omap_dmadev *od)
{
struct omap_chan *c;
- c = kzalloc(sizeof(*c), GFP_KERNEL);
+ c = kzalloc_obj(*c, GFP_KERNEL);
if (!c)
return -ENOMEM;