summaryrefslogtreecommitdiff
path: root/drivers/dma/qcom
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/qcom
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/qcom')
-rw-r--r--drivers/dma/qcom/bam_dma.c3
-rw-r--r--drivers/dma/qcom/gpi.c2
-rw-r--r--drivers/dma/qcom/hidma.c2
-rw-r--r--drivers/dma/qcom/qcom_adm.c2
4 files changed, 4 insertions, 5 deletions
diff --git a/drivers/dma/qcom/bam_dma.c b/drivers/dma/qcom/bam_dma.c
index e184cebbface..19116295f832 100644
--- a/drivers/dma/qcom/bam_dma.c
+++ b/drivers/dma/qcom/bam_dma.c
@@ -662,8 +662,7 @@ static struct dma_async_tx_descriptor *bam_prep_slave_sg(struct dma_chan *chan,
/* allocate enough room to accommodate the number of entries */
num_alloc = sg_nents_for_dma(sgl, sg_len, BAM_FIFO_SIZE);
- async_desc = kzalloc(struct_size(async_desc, desc, num_alloc),
- GFP_NOWAIT);
+ async_desc = kzalloc_flex(*async_desc, desc, num_alloc, GFP_NOWAIT);
if (!async_desc)
return NULL;
diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c
index 6e30f3aa401e..c9a6f610ffd9 100644
--- a/drivers/dma/qcom/gpi.c
+++ b/drivers/dma/qcom/gpi.c
@@ -1836,7 +1836,7 @@ gpi_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
if (!(flags & DMA_PREP_INTERRUPT) && (nr - nr_tre < 2))
return NULL;
- gpi_desc = kzalloc(sizeof(*gpi_desc), GFP_NOWAIT);
+ gpi_desc = kzalloc_obj(*gpi_desc, GFP_NOWAIT);
if (!gpi_desc)
return NULL;
diff --git a/drivers/dma/qcom/hidma.c b/drivers/dma/qcom/hidma.c
index c2b3e4452e71..5a8dca8db5ce 100644
--- a/drivers/dma/qcom/hidma.c
+++ b/drivers/dma/qcom/hidma.c
@@ -352,7 +352,7 @@ static int hidma_alloc_chan_resources(struct dma_chan *dmach)
/* Alloc descriptors for this channel */
for (i = 0; i < dmadev->nr_descriptors; i++) {
- mdesc = kzalloc(sizeof(struct hidma_desc), GFP_NOWAIT);
+ mdesc = kzalloc_obj(struct hidma_desc, GFP_NOWAIT);
if (!mdesc) {
rc = -ENOMEM;
break;
diff --git a/drivers/dma/qcom/qcom_adm.c b/drivers/dma/qcom/qcom_adm.c
index 490edad20ae6..07fbe32d31fa 100644
--- a/drivers/dma/qcom/qcom_adm.c
+++ b/drivers/dma/qcom/qcom_adm.c
@@ -401,7 +401,7 @@ static struct dma_async_tx_descriptor *adm_prep_slave_sg(struct dma_chan *chan,
single_count = sg_nents_for_dma(sgl, sg_len, ADM_MAX_XFER);
}
- async_desc = kzalloc(sizeof(*async_desc), GFP_NOWAIT);
+ async_desc = kzalloc_obj(*async_desc, GFP_NOWAIT);
if (!async_desc) {
dev_err(adev->dev, "not enough memory for async_desc struct\n");
return NULL;