summaryrefslogtreecommitdiff
path: root/drivers/dma
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
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')
-rw-r--r--drivers/dma/acpi-dma.c2
-rw-r--r--drivers/dma/altera-msgdma.c2
-rw-r--r--drivers/dma/amba-pl08x.c16
-rw-r--r--drivers/dma/amd/qdma/qdma.c2
-rw-r--r--drivers/dma/apple-admac.c2
-rw-r--r--drivers/dma/arm-dma350.c4
-rw-r--r--drivers/dma/at_hdmac.c14
-rw-r--r--drivers/dma/bcm2835-dma.c2
-rw-r--r--drivers/dma/bestcomm/bestcomm.c2
-rw-r--r--drivers/dma/bestcomm/sram.c2
-rw-r--r--drivers/dma/dma-axi-dmac.c2
-rw-r--r--drivers/dma/dma-jz4780.c2
-rw-r--r--drivers/dma/dmaengine.c2
-rw-r--r--drivers/dma/dmatest.c8
-rw-r--r--drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c4
-rw-r--r--drivers/dma/dw-edma/dw-edma-core.c6
-rw-r--r--drivers/dma/dw-edma/dw-edma-pcie.c2
-rw-r--r--drivers/dma/dw/rzn1-dmamux.c2
-rw-r--r--drivers/dma/ep93xx_dma.c2
-rw-r--r--drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c8
-rw-r--r--drivers/dma/fsl-edma-common.c2
-rw-r--r--drivers/dma/fsl-qdma.c2
-rw-r--r--drivers/dma/fsl_raid.c4
-rw-r--r--drivers/dma/fsldma.c4
-rw-r--r--drivers/dma/hisi_dma.c2
-rw-r--r--drivers/dma/hsu/hsu.c4
-rw-r--r--drivers/dma/idma64.c4
-rw-r--r--drivers/dma/idxd/cdev.c4
-rw-r--r--drivers/dma/idxd/irq.c4
-rw-r--r--drivers/dma/idxd/perfmon.c4
-rw-r--r--drivers/dma/img-mdc-dma.c6
-rw-r--r--drivers/dma/imx-dma.c6
-rw-r--r--drivers/dma/imx-sdma.c4
-rw-r--r--drivers/dma/ioat/dma.c2
-rw-r--r--drivers/dma/ioat/init.c4
-rw-r--r--drivers/dma/k3dma.c2
-rw-r--r--drivers/dma/lgm/lgm-dma.c4
-rw-r--r--drivers/dma/loongson1-apb-dma.c4
-rw-r--r--drivers/dma/loongson2-apb-dma.c4
-rw-r--r--drivers/dma/mediatek/mtk-cqdma.c4
-rw-r--r--drivers/dma/mediatek/mtk-hsdma.c4
-rw-r--r--drivers/dma/mediatek/mtk-uart-apdma.c2
-rw-r--r--drivers/dma/milbeaut-hdmac.c4
-rw-r--r--drivers/dma/milbeaut-xdmac.c2
-rw-r--r--drivers/dma/moxart-dma.c2
-rw-r--r--drivers/dma/mpc512x_dma.c2
-rw-r--r--drivers/dma/mv_xor.c2
-rw-r--r--drivers/dma/of-dma.c4
-rw-r--r--drivers/dma/owl-dma.c6
-rw-r--r--drivers/dma/pch_dma.c2
-rw-r--r--drivers/dma/pl330.c7
-rw-r--r--drivers/dma/plx_dma.c8
-rw-r--r--drivers/dma/ppc4xx/adma.c9
-rw-r--r--drivers/dma/pxa_dma.c6
-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
-rw-r--r--drivers/dma/sa11x0-dma.c8
-rw-r--r--drivers/dma/sf-pdma/sf-pdma.c2
-rw-r--r--drivers/dma/sh/rcar-dmac.c2
-rw-r--r--drivers/dma/sh/rz-dmac.c2
-rw-r--r--drivers/dma/sh/shdma-base.c4
-rw-r--r--drivers/dma/sh/usb-dmac.c2
-rw-r--r--drivers/dma/sprd-dma.c4
-rw-r--r--drivers/dma/st_fdma.c2
-rw-r--r--drivers/dma/ste_dma40.c2
-rw-r--r--drivers/dma/stm32/stm32-dma.c6
-rw-r--r--drivers/dma/stm32/stm32-dma3.c2
-rw-r--r--drivers/dma/stm32/stm32-dmamux.c2
-rw-r--r--drivers/dma/stm32/stm32-mdma.c2
-rw-r--r--drivers/dma/sun4i-dma.c6
-rw-r--r--drivers/dma/sun6i-dma.c6
-rw-r--r--drivers/dma/tegra186-gpc-dma.c9
-rw-r--r--drivers/dma/tegra20-apb-dma.c4
-rw-r--r--drivers/dma/tegra210-adma.c2
-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
-rw-r--r--drivers/dma/timb_dma.c5
-rw-r--r--drivers/dma/txx9dmac.c2
-rw-r--r--drivers/dma/uniphier-mdmac.c2
-rw-r--r--drivers/dma/uniphier-xdmac.c4
-rw-r--r--drivers/dma/xilinx/xdma.c6
-rw-r--r--drivers/dma/xilinx/xilinx_dma.c2
-rw-r--r--drivers/dma/xilinx/xilinx_dpdma.c2
-rw-r--r--drivers/dma/xilinx/zynqmp_dma.c4
88 files changed, 172 insertions, 179 deletions
diff --git a/drivers/dma/acpi-dma.c b/drivers/dma/acpi-dma.c
index 2abbe11e797e..d7a033822045 100644
--- a/drivers/dma/acpi-dma.c
+++ b/drivers/dma/acpi-dma.c
@@ -189,7 +189,7 @@ int acpi_dma_controller_register(struct device *dev,
if (!adev)
return -EINVAL;
- adma = kzalloc(sizeof(*adma), GFP_KERNEL);
+ adma = kzalloc_obj(*adma, GFP_KERNEL);
if (!adma)
return -ENOMEM;
diff --git a/drivers/dma/altera-msgdma.c b/drivers/dma/altera-msgdma.c
index 50534a6045a0..b46999c81df0 100644
--- a/drivers/dma/altera-msgdma.c
+++ b/drivers/dma/altera-msgdma.c
@@ -657,7 +657,7 @@ static int msgdma_alloc_chan_resources(struct dma_chan *dchan)
struct msgdma_sw_desc *desc;
int i;
- mdev->sw_desq = kcalloc(MSGDMA_DESC_NUM, sizeof(*desc), GFP_NOWAIT);
+ mdev->sw_desq = kzalloc_objs(*desc, MSGDMA_DESC_NUM, GFP_NOWAIT);
if (!mdev->sw_desq)
return -ENOMEM;
diff --git a/drivers/dma/amba-pl08x.c b/drivers/dma/amba-pl08x.c
index f16a70937200..fb9dad69c314 100644
--- a/drivers/dma/amba-pl08x.c
+++ b/drivers/dma/amba-pl08x.c
@@ -1743,7 +1743,7 @@ static void pl08x_issue_pending(struct dma_chan *chan)
static struct pl08x_txd *pl08x_get_txd(struct pl08x_dma_chan *plchan)
{
- struct pl08x_txd *txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ struct pl08x_txd *txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (txd)
INIT_LIST_HEAD(&txd->dsg_list);
@@ -1895,7 +1895,7 @@ static struct dma_async_tx_descriptor *pl08x_prep_dma_memcpy(
return NULL;
}
- dsg = kzalloc(sizeof(struct pl08x_sg), GFP_NOWAIT);
+ dsg = kzalloc_obj(struct pl08x_sg, GFP_NOWAIT);
if (!dsg) {
pl08x_free_txd(pl08x, txd);
return NULL;
@@ -2020,7 +2020,7 @@ static int pl08x_tx_add_sg(struct pl08x_txd *txd,
{
struct pl08x_sg *dsg;
- dsg = kzalloc(sizeof(struct pl08x_sg), GFP_NOWAIT);
+ dsg = kzalloc_obj(struct pl08x_sg, GFP_NOWAIT);
if (!dsg)
return -ENOMEM;
@@ -2372,7 +2372,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,
* to cope with that situation.
*/
for (i = 0; i < channels; i++) {
- chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+ chan = kzalloc_obj(*chan, GFP_KERNEL);
if (!chan)
return -ENOMEM;
@@ -2390,7 +2390,7 @@ static int pl08x_dma_init_virtual_channels(struct pl08x_driver_data *pl08x,
chan->signal = i;
pl08x_dma_slave_init(chan);
} else {
- chan->cd = kzalloc(sizeof(*chan->cd), GFP_KERNEL);
+ chan->cd = kzalloc_obj(*chan->cd, GFP_KERNEL);
if (!chan->cd) {
kfree(chan);
return -ENOMEM;
@@ -2709,7 +2709,7 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
goto out_no_pl08x;
/* Create the driver state holder */
- pl08x = kzalloc(sizeof(*pl08x), GFP_KERNEL);
+ pl08x = kzalloc_obj(*pl08x, GFP_KERNEL);
if (!pl08x) {
ret = -ENOMEM;
goto out_no_pl08x;
@@ -2855,8 +2855,8 @@ static int pl08x_probe(struct amba_device *adev, const struct amba_id *id)
}
/* Initialize physical channels */
- pl08x->phy_chans = kcalloc(vd->channels, sizeof(*pl08x->phy_chans),
- GFP_KERNEL);
+ pl08x->phy_chans = kzalloc_objs(*pl08x->phy_chans, vd->channels,
+ GFP_KERNEL);
if (!pl08x->phy_chans) {
ret = -ENOMEM;
goto out_no_phychans;
diff --git a/drivers/dma/amd/qdma/qdma.c b/drivers/dma/amd/qdma/qdma.c
index 8fb2d5e1df20..f5a02c6ed348 100644
--- a/drivers/dma/amd/qdma/qdma.c
+++ b/drivers/dma/amd/qdma/qdma.c
@@ -769,7 +769,7 @@ qdma_prep_device_sg(struct dma_chan *chan, struct scatterlist *sgl,
struct dma_async_tx_descriptor *tx;
struct qdma_mm_vdesc *vdesc;
- vdesc = kzalloc(sizeof(*vdesc), GFP_NOWAIT);
+ vdesc = kzalloc_obj(*vdesc, GFP_NOWAIT);
if (!vdesc)
return NULL;
vdesc->sgl = sgl;
diff --git a/drivers/dma/apple-admac.c b/drivers/dma/apple-admac.c
index 04bbd774b3b4..14a5ee14a481 100644
--- a/drivers/dma/apple-admac.c
+++ b/drivers/dma/apple-admac.c
@@ -260,7 +260,7 @@ static struct dma_async_tx_descriptor *admac_prep_dma_cyclic(
if (direction != admac_chan_direction(adchan->no))
return NULL;
- adtx = kzalloc(sizeof(*adtx), GFP_NOWAIT);
+ adtx = kzalloc_obj(*adtx, GFP_NOWAIT);
if (!adtx)
return NULL;
diff --git a/drivers/dma/arm-dma350.c b/drivers/dma/arm-dma350.c
index 9efe2ca7d5ec..84220fa83029 100644
--- a/drivers/dma/arm-dma350.c
+++ b/drivers/dma/arm-dma350.c
@@ -219,7 +219,7 @@ static struct dma_async_tx_descriptor *d350_prep_memcpy(struct dma_chan *chan,
struct d350_desc *desc;
u32 *cmd;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
@@ -257,7 +257,7 @@ static struct dma_async_tx_descriptor *d350_prep_memset(struct dma_chan *chan,
struct d350_desc *desc;
u32 *cmd;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/at_hdmac.c b/drivers/dma/at_hdmac.c
index 22bb604a3f97..935e3264ccec 100644
--- a/drivers/dma/at_hdmac.c
+++ b/drivers/dma/at_hdmac.c
@@ -929,7 +929,7 @@ atc_prep_dma_interleaved(struct dma_chan *chan,
ATC_SRC_PIP | ATC_DST_PIP |
FIELD_PREP(ATC_FC, ATC_FC_MEM2MEM);
- desc = kzalloc(struct_size(desc, sg, 1), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, 1, GFP_ATOMIC);
if (!desc)
return NULL;
desc->sglen = 1;
@@ -992,7 +992,7 @@ atc_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
}
sg_len = DIV_ROUND_UP(len, ATC_BTSIZE_MAX);
- desc = kzalloc(struct_size(desc, sg, sg_len), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
if (!desc)
return NULL;
desc->sglen = sg_len;
@@ -1131,7 +1131,7 @@ atc_prep_dma_memset(struct dma_chan *chan, dma_addr_t dest, int value,
(fill_pattern << 8) |
fill_pattern;
- desc = kzalloc(struct_size(desc, sg, 1), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, 1, GFP_ATOMIC);
if (!desc)
goto err_free_buffer;
desc->sglen = 1;
@@ -1191,7 +1191,7 @@ atc_prep_dma_memset_sg(struct dma_chan *chan,
}
*(u32*)vaddr = value;
- desc = kzalloc(struct_size(desc, sg, sg_len), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
if (!desc)
goto err_free_dma_buf;
desc->sglen = sg_len;
@@ -1274,7 +1274,7 @@ atc_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return NULL;
}
- desc = kzalloc(struct_size(desc, sg, sg_len), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, sg_len, GFP_ATOMIC);
if (!desc)
return NULL;
desc->sglen = sg_len;
@@ -1531,7 +1531,7 @@ atc_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_len,
if (atc_dma_cyclic_check_values(reg_width, buf_addr, period_len))
goto err_out;
- desc = kzalloc(struct_size(desc, sg, periods), GFP_ATOMIC);
+ desc = kzalloc_flex(*desc, sg, periods, GFP_ATOMIC);
if (!desc)
goto err_out;
desc->sglen = periods;
@@ -1818,7 +1818,7 @@ static struct dma_chan *at_dma_xlate(struct of_phandle_args *dma_spec,
dma_cap_zero(mask);
dma_cap_set(DMA_SLAVE, mask);
- atslave = kmalloc(sizeof(*atslave), GFP_KERNEL);
+ atslave = kmalloc_obj(*atslave, GFP_KERNEL);
if (!atslave) {
put_device(&dmac_pdev->dev);
return NULL;
diff --git a/drivers/dma/bcm2835-dma.c b/drivers/dma/bcm2835-dma.c
index 3f638c3e81cd..06d830d36882 100644
--- a/drivers/dma/bcm2835-dma.c
+++ b/drivers/dma/bcm2835-dma.c
@@ -297,7 +297,7 @@ static struct bcm2835_desc *bcm2835_dma_create_cb_chain(
return NULL;
/* allocate and setup the descriptor. */
- d = kzalloc(struct_size(d, cb_list, frames), gfp);
+ d = kzalloc_flex(*d, cb_list, frames, gfp);
if (!d)
return NULL;
diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c
index 6c4d655ffe77..e1b259c781ca 100644
--- a/drivers/dma/bestcomm/bestcomm.c
+++ b/drivers/dma/bestcomm/bestcomm.c
@@ -393,7 +393,7 @@ static int mpc52xx_bcom_probe(struct platform_device *op)
}
/* Get a clean struct */
- bcom_eng = kzalloc(sizeof(struct bcom_engine), GFP_KERNEL);
+ bcom_eng = kzalloc_obj(struct bcom_engine, GFP_KERNEL);
if (!bcom_eng) {
rv = -ENOMEM;
goto error_sramclean;
diff --git a/drivers/dma/bestcomm/sram.c b/drivers/dma/bestcomm/sram.c
index ad74d57cc3ab..c34639c30986 100644
--- a/drivers/dma/bestcomm/sram.c
+++ b/drivers/dma/bestcomm/sram.c
@@ -48,7 +48,7 @@ int bcom_sram_init(struct device_node *sram_node, char *owner)
return -EBUSY;
}
- bcom_sram = kmalloc(sizeof(struct bcom_sram), GFP_KERNEL);
+ bcom_sram = kmalloc_obj(struct bcom_sram, GFP_KERNEL);
if (!bcom_sram) {
printk(KERN_ERR "%s: bcom_sram_init: "
"Couldn't allocate internal state !\n", owner);
diff --git a/drivers/dma/dma-axi-dmac.c b/drivers/dma/dma-axi-dmac.c
index f5caf75dc0e7..eb65872c5d5c 100644
--- a/drivers/dma/dma-axi-dmac.c
+++ b/drivers/dma/dma-axi-dmac.c
@@ -540,7 +540,7 @@ axi_dmac_alloc_desc(struct axi_dmac_chan *chan, unsigned int num_sgs)
dma_addr_t hw_phys;
unsigned int i;
- desc = kzalloc(struct_size(desc, sg, num_sgs), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg, num_sgs, GFP_NOWAIT);
if (!desc)
return NULL;
desc->num_sgs = num_sgs;
diff --git a/drivers/dma/dma-jz4780.c b/drivers/dma/dma-jz4780.c
index 100057603fd4..6070dfdb7114 100644
--- a/drivers/dma/dma-jz4780.c
+++ b/drivers/dma/dma-jz4780.c
@@ -237,7 +237,7 @@ jz4780_dma_desc_alloc(struct jz4780_dma_chan *jzchan, unsigned int count,
if (count > JZ_DMA_MAX_DESC)
return NULL;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/dmaengine.c b/drivers/dma/dmaengine.c
index ca13cd39330b..b43a7b3a6a8d 100644
--- a/drivers/dma/dmaengine.c
+++ b/drivers/dma/dmaengine.c
@@ -1075,7 +1075,7 @@ static int __dma_async_device_channel_register(struct dma_device *device,
chan->local = alloc_percpu(typeof(*chan->local));
if (!chan->local)
return -ENOMEM;
- chan->dev = kzalloc(sizeof(*chan->dev), GFP_KERNEL);
+ chan->dev = kzalloc_obj(*chan->dev, GFP_KERNEL);
if (!chan->dev) {
rc = -ENOMEM;
goto err_free_local;
diff --git a/drivers/dma/dmatest.c b/drivers/dma/dmatest.c
index 91b2fbc0b864..1a18b8985afc 100644
--- a/drivers/dma/dmatest.c
+++ b/drivers/dma/dmatest.c
@@ -677,11 +677,11 @@ static int dmatest_func(void *data)
set_user_nice(current, 10);
- srcs = kcalloc(src->cnt, sizeof(dma_addr_t), GFP_KERNEL);
+ srcs = kzalloc_objs(dma_addr_t, src->cnt, GFP_KERNEL);
if (!srcs)
goto err_dst;
- dma_pq = kcalloc(dst->cnt, sizeof(dma_addr_t), GFP_KERNEL);
+ dma_pq = kzalloc_objs(dma_addr_t, dst->cnt, GFP_KERNEL);
if (!dma_pq)
goto err_srcs_array;
@@ -987,7 +987,7 @@ static int dmatest_add_threads(struct dmatest_info *info,
return -EINVAL;
for (i = 0; i < params->threads_per_chan; i++) {
- thread = kzalloc(sizeof(struct dmatest_thread), GFP_KERNEL);
+ thread = kzalloc_obj(struct dmatest_thread, GFP_KERNEL);
if (!thread) {
pr_warn("No memory for %s-%s%u\n",
dma_chan_name(chan), op, i);
@@ -1025,7 +1025,7 @@ static int dmatest_add_channel(struct dmatest_info *info,
unsigned int thread_count = 0;
int cnt;
- dtc = kmalloc(sizeof(struct dmatest_chan), GFP_KERNEL);
+ dtc = kmalloc_obj(struct dmatest_chan, GFP_KERNEL);
if (!dtc) {
pr_warn("No memory for %s\n", dma_chan_name(chan));
return -ENOMEM;
diff --git a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
index 493c2a32b0fe..5d74bc29cf89 100644
--- a/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
+++ b/drivers/dma/dw-axi-dmac/dw-axi-dmac-platform.c
@@ -293,11 +293,11 @@ static struct axi_dma_desc *axi_desc_alloc(u32 num)
{
struct axi_dma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
- desc->hw_desc = kcalloc(num, sizeof(*desc->hw_desc), GFP_NOWAIT);
+ desc->hw_desc = kzalloc_objs(*desc->hw_desc, num, GFP_NOWAIT);
if (!desc->hw_desc) {
kfree(desc);
return NULL;
diff --git a/drivers/dma/dw-edma/dw-edma-core.c b/drivers/dma/dw-edma/dw-edma-core.c
index 8e5f7defa6b6..e7d698b352d3 100644
--- a/drivers/dma/dw-edma/dw-edma-core.c
+++ b/drivers/dma/dw-edma/dw-edma-core.c
@@ -44,7 +44,7 @@ static struct dw_edma_burst *dw_edma_alloc_burst(struct dw_edma_chunk *chunk)
{
struct dw_edma_burst *burst;
- burst = kzalloc(sizeof(*burst), GFP_NOWAIT);
+ burst = kzalloc_obj(*burst, GFP_NOWAIT);
if (unlikely(!burst))
return NULL;
@@ -68,7 +68,7 @@ static struct dw_edma_chunk *dw_edma_alloc_chunk(struct dw_edma_desc *desc)
struct dw_edma_chan *chan = desc->chan;
struct dw_edma_chunk *chunk;
- chunk = kzalloc(sizeof(*chunk), GFP_NOWAIT);
+ chunk = kzalloc_obj(*chunk, GFP_NOWAIT);
if (unlikely(!chunk))
return NULL;
@@ -111,7 +111,7 @@ static struct dw_edma_desc *dw_edma_alloc_desc(struct dw_edma_chan *chan)
{
struct dw_edma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (unlikely(!desc))
return NULL;
diff --git a/drivers/dma/dw-edma/dw-edma-pcie.c b/drivers/dma/dw-edma/dw-edma-pcie.c
index e9caf8adca1f..df599b563124 100644
--- a/drivers/dma/dw-edma/dw-edma-pcie.c
+++ b/drivers/dma/dw-edma/dw-edma-pcie.c
@@ -167,7 +167,7 @@ static int dw_edma_pcie_probe(struct pci_dev *pdev,
int i, mask;
struct dw_edma_pcie_data *vsec_data __free(kfree) =
- kmalloc(sizeof(*vsec_data), GFP_KERNEL);
+ kmalloc_obj(*vsec_data, GFP_KERNEL);
if (!vsec_data)
return -ENOMEM;
diff --git a/drivers/dma/dw/rzn1-dmamux.c b/drivers/dma/dw/rzn1-dmamux.c
index cbec277af4dd..b0b4ccae2c77 100644
--- a/drivers/dma/dw/rzn1-dmamux.c
+++ b/drivers/dma/dw/rzn1-dmamux.c
@@ -53,7 +53,7 @@ static void *rzn1_dmamux_route_allocate(struct of_phandle_args *dma_spec,
goto put_device;
}
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map) {
ret = -ENOMEM;
goto put_device;
diff --git a/drivers/dma/ep93xx_dma.c b/drivers/dma/ep93xx_dma.c
index e424bb5c40e7..375f608c8266 100644
--- a/drivers/dma/ep93xx_dma.c
+++ b/drivers/dma/ep93xx_dma.c
@@ -966,7 +966,7 @@ static int ep93xx_dma_alloc_chan_resources(struct dma_chan *chan)
for (i = 0; i < DMA_MAX_CHAN_DESCRIPTORS; i++) {
struct ep93xx_dma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc) {
dev_warn(chan2dev(edmac), "not enough descriptors\n");
break;
diff --git a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
index 36384d019263..206e6bdaf99d 100644
--- a/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
+++ b/drivers/dma/fsl-dpaa2-qdma/dpaa2-qdma.c
@@ -99,7 +99,7 @@ dpaa2_qdma_request_desc(struct dpaa2_qdma_chan *dpaa2_chan)
spin_lock_irqsave(&dpaa2_chan->queue_lock, flags);
if (list_empty(&dpaa2_chan->comp_free)) {
spin_unlock_irqrestore(&dpaa2_chan->queue_lock, flags);
- comp_temp = kzalloc(sizeof(*comp_temp), GFP_NOWAIT);
+ comp_temp = kzalloc_obj(*comp_temp, GFP_NOWAIT);
if (!comp_temp)
goto err;
comp_temp->fd_virt_addr =
@@ -353,7 +353,7 @@ static int __cold dpaa2_qdma_setup(struct fsl_mc_device *ls_dev)
}
priv->num_pairs = min(priv->dpdmai_attr.num_of_priorities, prio_def);
- ppriv = kcalloc(priv->num_pairs, sizeof(*ppriv), GFP_KERNEL);
+ ppriv = kzalloc_objs(*ppriv, priv->num_pairs, GFP_KERNEL);
if (!ppriv) {
err = -ENOMEM;
goto exit;
@@ -659,7 +659,7 @@ static int dpaa2_qdma_probe(struct fsl_mc_device *dpdmai_dev)
struct dpaa2_qdma_priv *priv;
int err;
- priv = kzalloc(sizeof(*priv), GFP_KERNEL);
+ priv = kzalloc_obj(*priv, GFP_KERNEL);
if (!priv)
return -ENOMEM;
dev_set_drvdata(dev, priv);
@@ -707,7 +707,7 @@ static int dpaa2_qdma_probe(struct fsl_mc_device *dpdmai_dev)
goto err_enable;
}
- dpaa2_qdma = kzalloc(sizeof(*dpaa2_qdma), GFP_KERNEL);
+ dpaa2_qdma = kzalloc_obj(*dpaa2_qdma, GFP_KERNEL);
if (!dpaa2_qdma) {
err = -ENOMEM;
goto err_eng;
diff --git a/drivers/dma/fsl-edma-common.c b/drivers/dma/fsl-edma-common.c
index 7137f51ff6a0..6a38738e56e2 100644
--- a/drivers/dma/fsl-edma-common.c
+++ b/drivers/dma/fsl-edma-common.c
@@ -565,7 +565,7 @@ static struct fsl_edma_desc *fsl_edma_alloc_desc(struct fsl_edma_chan *fsl_chan,
struct fsl_edma_desc *fsl_desc;
int i;
- fsl_desc = kzalloc(struct_size(fsl_desc, tcd, sg_len), GFP_NOWAIT);
+ fsl_desc = kzalloc_flex(*fsl_desc, tcd, sg_len, GFP_NOWAIT);
if (!fsl_desc)
return NULL;
diff --git a/drivers/dma/fsl-qdma.c b/drivers/dma/fsl-qdma.c
index 6ace5bf80c40..db863bf7b0e6 100644
--- a/drivers/dma/fsl-qdma.c
+++ b/drivers/dma/fsl-qdma.c
@@ -406,7 +406,7 @@ static int fsl_qdma_pre_request_enqueue_desc(struct fsl_qdma_queue *queue)
struct fsl_qdma_comp *comp_temp, *_comp_temp;
for (i = 0; i < queue->n_cq + FSL_COMMAND_QUEUE_OVERFLLOW; i++) {
- comp_temp = kzalloc(sizeof(*comp_temp), GFP_KERNEL);
+ comp_temp = kzalloc_obj(*comp_temp, GFP_KERNEL);
if (!comp_temp)
goto err_alloc;
comp_temp->virt_addr =
diff --git a/drivers/dma/fsl_raid.c b/drivers/dma/fsl_raid.c
index 6e6d7e0e475e..5ba9a14bb78a 100644
--- a/drivers/dma/fsl_raid.c
+++ b/drivers/dma/fsl_raid.c
@@ -290,7 +290,7 @@ static struct fsl_re_desc *fsl_re_chan_alloc_desc(struct fsl_re_chan *re_chan,
spin_unlock_irqrestore(&re_chan->desc_lock, lock_flag);
if (!desc) {
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
@@ -579,7 +579,7 @@ static int fsl_re_alloc_chan_resources(struct dma_chan *chan)
re_chan = container_of(chan, struct fsl_re_chan, chan);
for (i = 0; i < FSL_RE_MIN_DESCS; i++) {
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
break;
diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
index 9b126a260267..1525b6fe54b4 100644
--- a/drivers/dma/fsldma.c
+++ b/drivers/dma/fsldma.c
@@ -1111,7 +1111,7 @@ static int fsl_dma_chan_probe(struct fsldma_device *fdev,
int err;
/* alloc channel */
- chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+ chan = kzalloc_obj(*chan, GFP_KERNEL);
if (!chan) {
err = -ENOMEM;
goto out_return;
@@ -1218,7 +1218,7 @@ static int fsldma_of_probe(struct platform_device *op)
unsigned int i;
int err;
- fdev = kzalloc(sizeof(*fdev), GFP_KERNEL);
+ fdev = kzalloc_obj(*fdev, GFP_KERNEL);
if (!fdev) {
err = -ENOMEM;
goto out_return;
diff --git a/drivers/dma/hisi_dma.c b/drivers/dma/hisi_dma.c
index 25a4134be36b..32a0e95c6a20 100644
--- a/drivers/dma/hisi_dma.c
+++ b/drivers/dma/hisi_dma.c
@@ -485,7 +485,7 @@ hisi_dma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dst, dma_addr_t src,
struct hisi_dma_chan *chan = to_hisi_dma_chan(c);
struct hisi_dma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/hsu/hsu.c b/drivers/dma/hsu/hsu.c
index af5a2e252c25..f62d60d7bc6b 100644
--- a/drivers/dma/hsu/hsu.c
+++ b/drivers/dma/hsu/hsu.c
@@ -245,11 +245,11 @@ static struct hsu_dma_desc *hsu_dma_alloc_desc(unsigned int nents)
{
struct hsu_dma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
- desc->sg = kcalloc(nents, sizeof(*desc->sg), GFP_NOWAIT);
+ desc->sg = kzalloc_objs(*desc->sg, nents, GFP_NOWAIT);
if (!desc->sg) {
kfree(desc);
return NULL;
diff --git a/drivers/dma/idma64.c b/drivers/dma/idma64.c
index d147353d47ab..5fcd1befc92d 100644
--- a/drivers/dma/idma64.c
+++ b/drivers/dma/idma64.c
@@ -196,11 +196,11 @@ static struct idma64_desc *idma64_alloc_desc(unsigned int ndesc)
{
struct idma64_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
- desc->hw = kcalloc(ndesc, sizeof(*desc->hw), GFP_NOWAIT);
+ desc->hw = kzalloc_objs(*desc->hw, ndesc, GFP_NOWAIT);
if (!desc->hw) {
kfree(desc);
return NULL;
diff --git a/drivers/dma/idxd/cdev.c b/drivers/dma/idxd/cdev.c
index 7e4715f92773..49fcc429d262 100644
--- a/drivers/dma/idxd/cdev.c
+++ b/drivers/dma/idxd/cdev.c
@@ -232,7 +232,7 @@ static int idxd_cdev_open(struct inode *inode, struct file *filp)
dev_dbg(dev, "%s called: %d\n", __func__, idxd_wq_refcount(wq));
- ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
+ ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx)
return -ENOMEM;
@@ -538,7 +538,7 @@ int idxd_wq_add_cdev(struct idxd_wq *wq)
struct idxd_cdev_context *cdev_ctx;
int rc, minor;
- idxd_cdev = kzalloc(sizeof(*idxd_cdev), GFP_KERNEL);
+ idxd_cdev = kzalloc_obj(*idxd_cdev, GFP_KERNEL);
if (!idxd_cdev)
return -ENOMEM;
diff --git a/drivers/dma/idxd/irq.c b/drivers/dma/idxd/irq.c
index 1107db3ce0a3..976d8aaa4517 100644
--- a/drivers/dma/idxd/irq.c
+++ b/drivers/dma/idxd/irq.c
@@ -492,7 +492,7 @@ irqreturn_t idxd_misc_thread(int vec, void *data)
val |= IDXD_INTC_INT_HANDLE_REVOKED;
- revoke = kzalloc(sizeof(*revoke), GFP_ATOMIC);
+ revoke = kzalloc_obj(*revoke, GFP_ATOMIC);
if (revoke) {
revoke->idxd = idxd;
INIT_WORK(&revoke->work, idxd_int_handle_revoke);
@@ -567,7 +567,7 @@ bool idxd_queue_int_handle_resubmit(struct idxd_desc *desc)
struct idxd_device *idxd = wq->idxd;
struct idxd_resubmit *irw;
- irw = kzalloc(sizeof(*irw), GFP_KERNEL);
+ irw = kzalloc_obj(*irw, GFP_KERNEL);
if (!irw)
return false;
diff --git a/drivers/dma/idxd/perfmon.c b/drivers/dma/idxd/perfmon.c
index 4b6af2f15d8a..3283841d3ddc 100644
--- a/drivers/dma/idxd/perfmon.c
+++ b/drivers/dma/idxd/perfmon.c
@@ -128,7 +128,7 @@ static int perfmon_validate_group(struct idxd_pmu *pmu,
struct idxd_pmu *fake_pmu;
int i, ret = 0, n, idx;
- fake_pmu = kzalloc(sizeof(*fake_pmu), GFP_KERNEL);
+ fake_pmu = kzalloc_obj(*fake_pmu, GFP_KERNEL);
if (!fake_pmu)
return -ENOMEM;
@@ -484,7 +484,7 @@ int perfmon_pmu_init(struct idxd_device *idxd)
if (idxd->perfmon_offset == 0)
return -ENODEV;
- idxd_pmu = kzalloc(sizeof(*idxd_pmu), GFP_KERNEL);
+ idxd_pmu = kzalloc_obj(*idxd_pmu, GFP_KERNEL);
if (!idxd_pmu)
return -ENOMEM;
diff --git a/drivers/dma/img-mdc-dma.c b/drivers/dma/img-mdc-dma.c
index fd55bcd060ab..b3765ba15803 100644
--- a/drivers/dma/img-mdc-dma.c
+++ b/drivers/dma/img-mdc-dma.c
@@ -294,7 +294,7 @@ static struct dma_async_tx_descriptor *mdc_prep_dma_memcpy(
if (!len)
return NULL;
- mdesc = kzalloc(sizeof(*mdesc), GFP_NOWAIT);
+ mdesc = kzalloc_obj(*mdesc, GFP_NOWAIT);
if (!mdesc)
return NULL;
mdesc->chan = mchan;
@@ -382,7 +382,7 @@ static struct dma_async_tx_descriptor *mdc_prep_dma_cyclic(
if (mdc_check_slave_width(mchan, dir) < 0)
return NULL;
- mdesc = kzalloc(sizeof(*mdesc), GFP_NOWAIT);
+ mdesc = kzalloc_obj(*mdesc, GFP_NOWAIT);
if (!mdesc)
return NULL;
mdesc->chan = mchan;
@@ -465,7 +465,7 @@ static struct dma_async_tx_descriptor *mdc_prep_slave_sg(
if (mdc_check_slave_width(mchan, dir) < 0)
return NULL;
- mdesc = kzalloc(sizeof(*mdesc), GFP_NOWAIT);
+ mdesc = kzalloc_obj(*mdesc, GFP_NOWAIT);
if (!mdesc)
return NULL;
mdesc->chan = mchan;
diff --git a/drivers/dma/imx-dma.c b/drivers/dma/imx-dma.c
index ba434657059a..d20c14f297a7 100644
--- a/drivers/dma/imx-dma.c
+++ b/drivers/dma/imx-dma.c
@@ -746,7 +746,7 @@ static int imxdma_alloc_chan_resources(struct dma_chan *chan)
while (imxdmac->descs_allocated < IMXDMA_MAX_CHAN_DESCRIPTORS) {
struct imxdma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
break;
dma_async_tx_descriptor_init(&desc->desc, chan);
@@ -865,8 +865,8 @@ static struct dma_async_tx_descriptor *imxdma_prep_dma_cyclic(
kfree(imxdmac->sg_list);
- imxdmac->sg_list = kcalloc(periods + 1,
- sizeof(struct scatterlist), GFP_ATOMIC);
+ imxdmac->sg_list = kzalloc_objs(struct scatterlist, periods + 1,
+ GFP_ATOMIC);
if (!imxdmac->sg_list)
return NULL;
diff --git a/drivers/dma/imx-sdma.c b/drivers/dma/imx-sdma.c
index ed9e56de5a9b..4093fba9cc23 100644
--- a/drivers/dma/imx-sdma.c
+++ b/drivers/dma/imx-sdma.c
@@ -1544,7 +1544,7 @@ static struct sdma_desc *sdma_transfer_init(struct sdma_channel *sdmac,
goto err_out;
}
- desc = kzalloc((sizeof(*desc)), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
goto err_out;
@@ -2288,7 +2288,7 @@ static int sdma_probe(struct platform_device *pdev)
sdma->irq = irq;
- sdma->script_addrs = kzalloc(sizeof(*sdma->script_addrs), GFP_KERNEL);
+ sdma->script_addrs = kzalloc_obj(*sdma->script_addrs, GFP_KERNEL);
if (!sdma->script_addrs) {
ret = -ENOMEM;
goto err_irq;
diff --git a/drivers/dma/ioat/dma.c b/drivers/dma/ioat/dma.c
index b8fff8333aef..ee93b029f9e3 100644
--- a/drivers/dma/ioat/dma.c
+++ b/drivers/dma/ioat/dma.c
@@ -378,7 +378,7 @@ ioat_alloc_ring(struct dma_chan *c, int order, gfp_t flags)
int i, chunks;
/* allocate the array to hold the software ring */
- ring = kcalloc(total_descs, sizeof(*ring), flags);
+ ring = kzalloc_objs(*ring, total_descs, flags);
if (!ring)
return NULL;
diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c
index 227398673b73..a4e539e48444 100644
--- a/drivers/dma/ioat/init.c
+++ b/drivers/dma/ioat/init.c
@@ -574,7 +574,7 @@ static void ioat_enumerate_channels(struct ioatdma_device *ioat_dma)
dev_dbg(dev, "%s: xfercap = %d\n", __func__, 1 << xfercap_log);
for (i = 0; i < chancnt; i++) {
- ioat_chan = kzalloc(sizeof(*ioat_chan), GFP_KERNEL);
+ ioat_chan = kzalloc_obj(*ioat_chan, GFP_KERNEL);
if (!ioat_chan)
break;
@@ -1332,7 +1332,7 @@ static void release_ioatdma(struct dma_device *device)
static struct ioatdma_device *
alloc_ioatdma(struct pci_dev *pdev, void __iomem *iobase)
{
- struct ioatdma_device *d = kzalloc(sizeof(*d), GFP_KERNEL);
+ struct ioatdma_device *d = kzalloc_obj(*d, GFP_KERNEL);
if (!d)
return NULL;
diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c
index 63677c0b6f18..e84f197fea76 100644
--- a/drivers/dma/k3dma.c
+++ b/drivers/dma/k3dma.c
@@ -471,7 +471,7 @@ static struct k3_dma_desc_sw *k3_dma_alloc_desc_resource(int num,
return NULL;
}
- ds = kzalloc(sizeof(*ds), GFP_NOWAIT);
+ ds = kzalloc_obj(*ds, GFP_NOWAIT);
if (!ds)
return NULL;
diff --git a/drivers/dma/lgm/lgm-dma.c b/drivers/dma/lgm/lgm-dma.c
index a7b9cf30f6ad..c1f859472a96 100644
--- a/drivers/dma/lgm/lgm-dma.c
+++ b/drivers/dma/lgm/lgm-dma.c
@@ -681,7 +681,7 @@ ldma_chan_desc_cfg(struct dma_chan *chan, dma_addr_t desc_base, int desc_num)
c->desc_cnt = desc_num;
c->desc_phys = desc_base;
- ds = kzalloc(sizeof(*ds), GFP_NOWAIT);
+ ds = kzalloc_obj(*ds, GFP_NOWAIT);
if (!ds)
return NULL;
@@ -982,7 +982,7 @@ dma_alloc_desc_resource(int num, struct ldma_chan *c)
return NULL;
}
- ds = kzalloc(sizeof(*ds), GFP_NOWAIT);
+ ds = kzalloc_obj(*ds, GFP_NOWAIT);
if (!ds)
return NULL;
diff --git a/drivers/dma/loongson1-apb-dma.c b/drivers/dma/loongson1-apb-dma.c
index 255fe7eca212..2e347aba9af8 100644
--- a/drivers/dma/loongson1-apb-dma.c
+++ b/drivers/dma/loongson1-apb-dma.c
@@ -204,7 +204,7 @@ static struct ls1x_dma_desc *ls1x_dma_alloc_desc(void)
{
struct ls1x_dma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
@@ -335,7 +335,7 @@ ls1x_dma_prep_dma_cyclic(struct dma_chan *dchan, dma_addr_t buf_addr,
/* allocate the scatterlist */
sg_len = buf_len / period_len;
- sgl = kmalloc_array(sg_len, sizeof(*sgl), GFP_NOWAIT);
+ sgl = kmalloc_objs(*sgl, sg_len, GFP_NOWAIT);
if (!sgl)
return NULL;
diff --git a/drivers/dma/loongson2-apb-dma.c b/drivers/dma/loongson2-apb-dma.c
index c528f02b9f84..b981475e6779 100644
--- a/drivers/dma/loongson2-apb-dma.c
+++ b/drivers/dma/loongson2-apb-dma.c
@@ -335,7 +335,7 @@ ls2x_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
if (!burst_size)
return NULL;
- desc = kzalloc(struct_size(desc, sg, sg_len), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg, sg_len, GFP_NOWAIT);
if (!desc)
return NULL;
@@ -400,7 +400,7 @@ ls2x_dma_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr, size_t buf_
return NULL;
num_periods = buf_len / period_len;
- desc = kzalloc(struct_size(desc, sg, num_periods), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg, num_periods, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/mediatek/mtk-cqdma.c b/drivers/dma/mediatek/mtk-cqdma.c
index 9f0c41ca7770..80791e30aec2 100644
--- a/drivers/dma/mediatek/mtk-cqdma.c
+++ b/drivers/dma/mediatek/mtk-cqdma.c
@@ -501,12 +501,12 @@ mtk_cqdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest,
* until all the child CVDs completed.
*/
nr_vd = DIV_ROUND_UP(len, MTK_CQDMA_MAX_LEN);
- cvd = kcalloc(nr_vd, sizeof(*cvd), GFP_NOWAIT);
+ cvd = kzalloc_objs(*cvd, nr_vd, GFP_NOWAIT);
if (!cvd)
return NULL;
for (i = 0; i < nr_vd; ++i) {
- cvd[i] = kzalloc(sizeof(*cvd[i]), GFP_NOWAIT);
+ cvd[i] = kzalloc_obj(*cvd[i], GFP_NOWAIT);
if (!cvd[i]) {
for (; i > 0; --i)
kfree(cvd[i - 1]);
diff --git a/drivers/dma/mediatek/mtk-hsdma.c b/drivers/dma/mediatek/mtk-hsdma.c
index fa77bb24a430..a43412ff5edd 100644
--- a/drivers/dma/mediatek/mtk-hsdma.c
+++ b/drivers/dma/mediatek/mtk-hsdma.c
@@ -334,7 +334,7 @@ static int mtk_hsdma_alloc_pchan(struct mtk_hsdma_device *hsdma,
ring->cur_tptr = 0;
ring->cur_rptr = MTK_DMA_SIZE - 1;
- ring->cb = kcalloc(MTK_DMA_SIZE, sizeof(*ring->cb), GFP_NOWAIT);
+ ring->cb = kzalloc_objs(*ring->cb, MTK_DMA_SIZE, GFP_NOWAIT);
if (!ring->cb) {
err = -ENOMEM;
goto err_free_dma;
@@ -722,7 +722,7 @@ mtk_hsdma_prep_dma_memcpy(struct dma_chan *c, dma_addr_t dest,
{
struct mtk_hsdma_vdesc *hvd;
- hvd = kzalloc(sizeof(*hvd), GFP_NOWAIT);
+ hvd = kzalloc_obj(*hvd, GFP_NOWAIT);
if (!hvd)
return NULL;
diff --git a/drivers/dma/mediatek/mtk-uart-apdma.c b/drivers/dma/mediatek/mtk-uart-apdma.c
index 3b9761f4e8a1..c269d84d7bd2 100644
--- a/drivers/dma/mediatek/mtk-uart-apdma.c
+++ b/drivers/dma/mediatek/mtk-uart-apdma.c
@@ -351,7 +351,7 @@ static struct dma_async_tx_descriptor *mtk_uart_apdma_prep_slave_sg
return NULL;
/* Now allocate and setup the descriptor */
- d = kzalloc(sizeof(*d), GFP_NOWAIT);
+ d = kzalloc_obj(*d, GFP_NOWAIT);
if (!d)
return NULL;
diff --git a/drivers/dma/milbeaut-hdmac.c b/drivers/dma/milbeaut-hdmac.c
index 9a5ec247ed6d..b4ebc09e80d0 100644
--- a/drivers/dma/milbeaut-hdmac.c
+++ b/drivers/dma/milbeaut-hdmac.c
@@ -265,11 +265,11 @@ milbeaut_hdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
if (!is_slave_direction(direction))
return NULL;
- md = kzalloc(sizeof(*md), GFP_NOWAIT);
+ md = kzalloc_obj(*md, GFP_NOWAIT);
if (!md)
return NULL;
- md->sgl = kcalloc(sg_len, sizeof(*sgl), GFP_NOWAIT);
+ md->sgl = kzalloc_objs(*sgl, sg_len, GFP_NOWAIT);
if (!md->sgl) {
kfree(md);
return NULL;
diff --git a/drivers/dma/milbeaut-xdmac.c b/drivers/dma/milbeaut-xdmac.c
index 58d4fd6df0bf..0bfa247e746e 100644
--- a/drivers/dma/milbeaut-xdmac.c
+++ b/drivers/dma/milbeaut-xdmac.c
@@ -192,7 +192,7 @@ milbeaut_xdmac_prep_memcpy(struct dma_chan *chan, dma_addr_t dst,
struct virt_dma_chan *vc = to_virt_chan(chan);
struct milbeaut_xdmac_desc *md;
- md = kzalloc(sizeof(*md), GFP_NOWAIT);
+ md = kzalloc_obj(*md, GFP_NOWAIT);
if (!md)
return NULL;
diff --git a/drivers/dma/moxart-dma.c b/drivers/dma/moxart-dma.c
index de09e1ab7767..442f5aa16031 100644
--- a/drivers/dma/moxart-dma.c
+++ b/drivers/dma/moxart-dma.c
@@ -301,7 +301,7 @@ static struct dma_async_tx_descriptor *moxart_prep_slave_sg(
return NULL;
}
- d = kzalloc(struct_size(d, sg, sg_len), GFP_ATOMIC);
+ d = kzalloc_flex(*d, sg, sg_len, GFP_ATOMIC);
if (!d)
return NULL;
d->sglen = sg_len;
diff --git a/drivers/dma/mpc512x_dma.c b/drivers/dma/mpc512x_dma.c
index bf131cb5db66..37550b42c30e 100644
--- a/drivers/dma/mpc512x_dma.c
+++ b/drivers/dma/mpc512x_dma.c
@@ -503,7 +503,7 @@ static int mpc_dma_alloc_chan_resources(struct dma_chan *chan)
/* Alloc descriptors for this channel */
for (i = 0; i < MPC_DMA_DESCRIPTORS; i++) {
- mdesc = kzalloc(sizeof(struct mpc_dma_desc), GFP_KERNEL);
+ mdesc = kzalloc_obj(struct mpc_dma_desc, GFP_KERNEL);
if (!mdesc) {
dev_notice(mdma->dma.dev,
"Memory allocation error. Allocated only %u descriptors\n", i);
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c
index 5e8386296046..f4f65ef44234 100644
--- a/drivers/dma/mv_xor.c
+++ b/drivers/dma/mv_xor.c
@@ -443,7 +443,7 @@ static int mv_xor_alloc_chan_resources(struct dma_chan *chan)
/* Allocate descriptor slots */
idx = mv_chan->slots_allocated;
while (idx < num_descs_in_pool) {
- slot = kzalloc(sizeof(*slot), GFP_KERNEL);
+ slot = kzalloc_obj(*slot, GFP_KERNEL);
if (!slot) {
dev_info(mv_chan_to_devp(mv_chan),
"channel only initialized %d descriptor slots",
diff --git a/drivers/dma/of-dma.c b/drivers/dma/of-dma.c
index 423442e55d36..d27c74f1669b 100644
--- a/drivers/dma/of-dma.c
+++ b/drivers/dma/of-dma.c
@@ -127,7 +127,7 @@ int of_dma_controller_register(struct device_node *np,
return -EINVAL;
}
- ofdma = kzalloc(sizeof(*ofdma), GFP_KERNEL);
+ ofdma = kzalloc_obj(*ofdma, GFP_KERNEL);
if (!ofdma)
return -ENOMEM;
@@ -194,7 +194,7 @@ int of_dma_router_register(struct device_node *np,
return -EINVAL;
}
- ofdma = kzalloc(sizeof(*ofdma), GFP_KERNEL);
+ ofdma = kzalloc_obj(*ofdma, GFP_KERNEL);
if (!ofdma)
return -ENOMEM;
diff --git a/drivers/dma/owl-dma.c b/drivers/dma/owl-dma.c
index 57cec757d8f5..7c80572fc71d 100644
--- a/drivers/dma/owl-dma.c
+++ b/drivers/dma/owl-dma.c
@@ -878,7 +878,7 @@ static struct dma_async_tx_descriptor
if (!len)
return NULL;
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
@@ -929,7 +929,7 @@ static struct dma_async_tx_descriptor
size_t len;
int ret, i;
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
@@ -993,7 +993,7 @@ static struct dma_async_tx_descriptor
unsigned int periods = buf_len / period_len;
int ret, i;
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
diff --git a/drivers/dma/pch_dma.c b/drivers/dma/pch_dma.c
index 6b2793b07694..69560dd8c365 100644
--- a/drivers/dma/pch_dma.c
+++ b/drivers/dma/pch_dma.c
@@ -806,7 +806,7 @@ static int pch_dma_probe(struct pci_dev *pdev,
int i;
nr_channels = id->driver_data;
- pd = kzalloc(sizeof(*pd), GFP_KERNEL);
+ pd = kzalloc_obj(*pd, GFP_KERNEL);
if (!pd)
return -ENOMEM;
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c
index 72f260328ae9..996c259107e3 100644
--- a/drivers/dma/pl330.c
+++ b/drivers/dma/pl330.c
@@ -1887,8 +1887,7 @@ static int dmac_alloc_threads(struct pl330_dmac *pl330)
int i;
/* Allocate 1 Manager and 'chans' Channel threads */
- pl330->channels = kcalloc(1 + chans, sizeof(*thrd),
- GFP_KERNEL);
+ pl330->channels = kzalloc_objs(*thrd, 1 + chans, GFP_KERNEL);
if (!pl330->channels)
return -ENOMEM;
@@ -2548,7 +2547,7 @@ static int add_desc(struct list_head *pool, spinlock_t *lock,
unsigned long flags;
int i;
- desc = kcalloc(count, sizeof(*desc), flg);
+ desc = kzalloc_objs(*desc, count, flg);
if (!desc)
return 0;
@@ -3093,7 +3092,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
pl330->num_peripherals = num_chan;
- pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL);
+ pl330->peripherals = kzalloc_objs(*pch, num_chan, GFP_KERNEL);
if (!pl330->peripherals) {
ret = -ENOMEM;
goto probe_err2;
diff --git a/drivers/dma/plx_dma.c b/drivers/dma/plx_dma.c
index 34b6416c3287..1958fa8f96e4 100644
--- a/drivers/dma/plx_dma.c
+++ b/drivers/dma/plx_dma.c
@@ -378,13 +378,13 @@ static int plx_dma_alloc_desc(struct plx_dma_dev *plxdev)
struct plx_dma_desc *desc;
int i;
- plxdev->desc_ring = kcalloc(PLX_DMA_RING_COUNT,
- sizeof(*plxdev->desc_ring), GFP_KERNEL);
+ plxdev->desc_ring = kzalloc_objs(*plxdev->desc_ring, PLX_DMA_RING_COUNT,
+ GFP_KERNEL);
if (!plxdev->desc_ring)
return -ENOMEM;
for (i = 0; i < PLX_DMA_RING_COUNT; i++) {
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
goto free_and_exit;
@@ -501,7 +501,7 @@ static int plx_dma_create(struct pci_dev *pdev)
struct dma_chan *chan;
int rc;
- plxdev = kzalloc(sizeof(*plxdev), GFP_KERNEL);
+ plxdev = kzalloc_obj(*plxdev, GFP_KERNEL);
if (!plxdev)
return -ENOMEM;
diff --git a/drivers/dma/ppc4xx/adma.c b/drivers/dma/ppc4xx/adma.c
index 61500ad7c850..7c08e80dcc4c 100644
--- a/drivers/dma/ppc4xx/adma.c
+++ b/drivers/dma/ppc4xx/adma.c
@@ -1781,8 +1781,7 @@ static int ppc440spe_adma_alloc_chan_resources(struct dma_chan *chan)
db_sz = sizeof(struct xor_cb);
for (; i < (ppc440spe_chan->device->pool_size / db_sz); i++) {
- slot = kzalloc(sizeof(struct ppc440spe_adma_desc_slot),
- GFP_KERNEL);
+ slot = kzalloc_obj(struct ppc440spe_adma_desc_slot, GFP_KERNEL);
if (!slot) {
printk(KERN_INFO "SPE ADMA Channel only initialized"
" %d descriptor slots", i--);
@@ -4064,7 +4063,7 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
}
/* create a device */
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+ adev = kzalloc_obj(*adev, GFP_KERNEL);
if (!adev) {
initcode = PPC_ADMA_INIT_ALLOC;
ret = -ENOMEM;
@@ -4124,7 +4123,7 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
platform_set_drvdata(ofdev, adev);
/* create a channel */
- chan = kzalloc(sizeof(*chan), GFP_KERNEL);
+ chan = kzalloc_obj(*chan, GFP_KERNEL);
if (!chan) {
initcode = PPC_ADMA_INIT_CHANNEL;
ret = -ENOMEM;
@@ -4161,7 +4160,7 @@ static int ppc440spe_adma_probe(struct platform_device *ofdev)
PAGE_SIZE, DMA_BIDIRECTIONAL);
}
- ref = kmalloc(sizeof(*ref), GFP_KERNEL);
+ ref = kmalloc_obj(*ref, GFP_KERNEL);
if (ref) {
ref->chan = &chan->common;
INIT_LIST_HEAD(&ref->node);
diff --git a/drivers/dma/pxa_dma.c b/drivers/dma/pxa_dma.c
index b639c8b51e87..a48ba9fc9f49 100644
--- a/drivers/dma/pxa_dma.c
+++ b/drivers/dma/pxa_dma.c
@@ -342,8 +342,7 @@ static void pxad_init_debugfs(struct pxad_device *pdev)
struct dentry *chandir;
pdev->dbgfs_chan =
- kmalloc_array(pdev->nr_chans, sizeof(struct dentry *),
- GFP_KERNEL);
+ kmalloc_objs(struct dentry *, pdev->nr_chans, GFP_KERNEL);
if (!pdev->dbgfs_chan)
return;
@@ -742,8 +741,7 @@ pxad_alloc_desc(struct pxad_chan *chan, unsigned int nb_hw_desc)
void *desc;
int i;
- sw_desc = kzalloc(struct_size(sw_desc, hw_desc, nb_hw_desc),
- GFP_NOWAIT);
+ sw_desc = kzalloc_flex(*sw_desc, hw_desc, nb_hw_desc, GFP_NOWAIT);
if (!sw_desc)
return NULL;
sw_desc->desc_pool = chan->desc_pool;
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;
diff --git a/drivers/dma/sa11x0-dma.c b/drivers/dma/sa11x0-dma.c
index 86f1d7461f56..bcbdaf75db15 100644
--- a/drivers/dma/sa11x0-dma.c
+++ b/drivers/dma/sa11x0-dma.c
@@ -551,7 +551,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_slave_sg(
}
j = sg_nents_for_dma(sg, sglen, DMA_MAX_SIZE & ~DMA_ALIGN);
- txd = kzalloc(struct_size(txd, sg, j), GFP_ATOMIC);
+ txd = kzalloc_flex(*txd, sg, j, GFP_ATOMIC);
if (!txd) {
dev_dbg(chan->device->dev, "vchan %p: kzalloc failed\n", &c->vc);
return NULL;
@@ -621,7 +621,7 @@ static struct dma_async_tx_descriptor *sa11x0_dma_prep_dma_cyclic(
if (sglen == 0)
return NULL;
- txd = kzalloc(struct_size(txd, sg, sglen), GFP_ATOMIC);
+ txd = kzalloc_flex(*txd, sg, sglen, GFP_ATOMIC);
if (!txd) {
dev_dbg(chan->device->dev, "vchan %p: kzalloc failed\n", &c->vc);
return NULL;
@@ -848,7 +848,7 @@ static int sa11x0_dma_init_dmadev(struct dma_device *dmadev,
for (i = 0; i < ARRAY_SIZE(chan_desc); i++) {
struct sa11x0_dma_chan *c;
- c = kzalloc(sizeof(*c), GFP_KERNEL);
+ c = kzalloc_obj(*c, GFP_KERNEL);
if (!c) {
dev_err(dev, "no memory for channel %u\n", i);
return -ENOMEM;
@@ -907,7 +907,7 @@ static int sa11x0_dma_probe(struct platform_device *pdev)
if (!res)
return -ENXIO;
- d = kzalloc(sizeof(*d), GFP_KERNEL);
+ d = kzalloc_obj(*d, GFP_KERNEL);
if (!d) {
ret = -ENOMEM;
goto err_alloc;
diff --git a/drivers/dma/sf-pdma/sf-pdma.c b/drivers/dma/sf-pdma/sf-pdma.c
index 7ad3c29be146..b3cba11b6203 100644
--- a/drivers/dma/sf-pdma/sf-pdma.c
+++ b/drivers/dma/sf-pdma/sf-pdma.c
@@ -56,7 +56,7 @@ static struct sf_pdma_desc *sf_pdma_alloc_desc(struct sf_pdma_chan *chan)
{
struct sf_pdma_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/sh/rcar-dmac.c b/drivers/dma/sh/rcar-dmac.c
index 475a347cae1b..44eab2d21d54 100644
--- a/drivers/dma/sh/rcar-dmac.c
+++ b/drivers/dma/sh/rcar-dmac.c
@@ -1254,7 +1254,7 @@ rcar_dmac_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t buf_addr,
* Allocate the sg list dynamically as it would consume too much stack
* space.
*/
- sgl = kmalloc_array(sg_len, sizeof(*sgl), GFP_NOWAIT);
+ sgl = kmalloc_objs(*sgl, sg_len, GFP_NOWAIT);
if (!sgl)
return NULL;
diff --git a/drivers/dma/sh/rz-dmac.c b/drivers/dma/sh/rz-dmac.c
index 7736d33a9641..7f9b45c4553d 100644
--- a/drivers/dma/sh/rz-dmac.c
+++ b/drivers/dma/sh/rz-dmac.c
@@ -443,7 +443,7 @@ static int rz_dmac_alloc_chan_resources(struct dma_chan *chan)
while (channel->descs_allocated < RZ_DMAC_MAX_CHAN_DESCRIPTORS) {
struct rz_dmac_desc *desc;
- desc = kzalloc(sizeof(*desc), GFP_KERNEL);
+ desc = kzalloc_obj(*desc, GFP_KERNEL);
if (!desc)
break;
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c
index 3ff2a8be8faa..59eab919a3e3 100644
--- a/drivers/dma/sh/shdma-base.c
+++ b/drivers/dma/sh/shdma-base.c
@@ -740,7 +740,7 @@ static struct dma_async_tx_descriptor *shdma_prep_dma_cyclic(
* Allocate the sg list dynamically as it would consume too much stack
* space.
*/
- sgl = kmalloc_array(sg_len, sizeof(*sgl), GFP_KERNEL);
+ sgl = kmalloc_objs(*sgl, sg_len, GFP_KERNEL);
if (!sgl)
return NULL;
@@ -1012,7 +1012,7 @@ int shdma_init(struct device *dev, struct shdma_dev *sdev,
!sdev->ops->desc_completed)
return -EINVAL;
- sdev->schan = kcalloc(chan_num, sizeof(*sdev->schan), GFP_KERNEL);
+ sdev->schan = kzalloc_objs(*sdev->schan, chan_num, GFP_KERNEL);
if (!sdev->schan)
return -ENOMEM;
diff --git a/drivers/dma/sh/usb-dmac.c b/drivers/dma/sh/usb-dmac.c
index b42e5a66fd95..16509be0d360 100644
--- a/drivers/dma/sh/usb-dmac.c
+++ b/drivers/dma/sh/usb-dmac.c
@@ -266,7 +266,7 @@ static int usb_dmac_desc_alloc(struct usb_dmac_chan *chan, unsigned int sg_len,
struct usb_dmac_desc *desc;
unsigned long flags;
- desc = kzalloc(struct_size(desc, sg, sg_len), gfp);
+ desc = kzalloc_flex(*desc, sg, sg_len, gfp);
if (!desc)
return -ENOMEM;
diff --git a/drivers/dma/sprd-dma.c b/drivers/dma/sprd-dma.c
index 6207e0b185e1..087fea3af2e4 100644
--- a/drivers/dma/sprd-dma.c
+++ b/drivers/dma/sprd-dma.c
@@ -901,7 +901,7 @@ sprd_dma_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dest, dma_addr_t src,
enum sprd_dma_datawidth datawidth;
u32 step, temp;
- sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT);
+ sdesc = kzalloc_obj(*sdesc, GFP_NOWAIT);
if (!sdesc)
return NULL;
@@ -986,7 +986,7 @@ sprd_dma_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
(flags >> SPRD_DMA_TRG_MODE_SHIFT) & SPRD_DMA_TRG_MODE_MASK;
schan->int_type = flags & SPRD_DMA_INT_TYPE_MASK;
- sdesc = kzalloc(sizeof(*sdesc), GFP_NOWAIT);
+ sdesc = kzalloc_obj(*sdesc, GFP_NOWAIT);
if (!sdesc)
return NULL;
diff --git a/drivers/dma/st_fdma.c b/drivers/dma/st_fdma.c
index 0f42a3c30bdb..d9547017f3bd 100644
--- a/drivers/dma/st_fdma.c
+++ b/drivers/dma/st_fdma.c
@@ -241,7 +241,7 @@ static struct st_fdma_desc *st_fdma_alloc_desc(struct st_fdma_chan *fchan,
struct st_fdma_desc *fdesc;
int i;
- fdesc = kzalloc(struct_size(fdesc, node, sg_len), GFP_NOWAIT);
+ fdesc = kzalloc_flex(*fdesc, node, sg_len, GFP_NOWAIT);
if (!fdesc)
return NULL;
diff --git a/drivers/dma/ste_dma40.c b/drivers/dma/ste_dma40.c
index e67e0d66e6e8..9b803c0aec25 100644
--- a/drivers/dma/ste_dma40.c
+++ b/drivers/dma/ste_dma40.c
@@ -2529,7 +2529,7 @@ dma40_prep_dma_cyclic(struct dma_chan *chan, dma_addr_t dma_addr,
struct scatterlist *sg;
int i;
- sg = kcalloc(periods + 1, sizeof(struct scatterlist), GFP_NOWAIT);
+ sg = kzalloc_objs(struct scatterlist, periods + 1, GFP_NOWAIT);
if (!sg)
return NULL;
diff --git a/drivers/dma/stm32/stm32-dma.c b/drivers/dma/stm32/stm32-dma.c
index 04389936c8a6..d3ad78562a14 100644
--- a/drivers/dma/stm32/stm32-dma.c
+++ b/drivers/dma/stm32/stm32-dma.c
@@ -1101,7 +1101,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_slave_sg(
return NULL;
}
- desc = kzalloc(struct_size(desc, sg_req, sg_len), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg_req, sg_len, GFP_NOWAIT);
if (!desc)
return NULL;
desc->num_sgs = sg_len;
@@ -1213,7 +1213,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_cyclic(
num_periods = buf_len / period_len;
- desc = kzalloc(struct_size(desc, sg_req, num_periods), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg_req, num_periods, GFP_NOWAIT);
if (!desc)
return NULL;
desc->num_sgs = num_periods;
@@ -1250,7 +1250,7 @@ static struct dma_async_tx_descriptor *stm32_dma_prep_dma_memcpy(
int dma_burst, i;
num_sgs = DIV_ROUND_UP(len, STM32_DMA_ALIGNED_MAX_DATA_ITEMS);
- desc = kzalloc(struct_size(desc, sg_req, num_sgs), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, sg_req, num_sgs, GFP_NOWAIT);
if (!desc)
return NULL;
desc->num_sgs = num_sgs;
diff --git a/drivers/dma/stm32/stm32-dma3.c b/drivers/dma/stm32/stm32-dma3.c
index 84b00c436134..4724e7fa0008 100644
--- a/drivers/dma/stm32/stm32-dma3.c
+++ b/drivers/dma/stm32/stm32-dma3.c
@@ -415,7 +415,7 @@ static struct stm32_dma3_swdesc *stm32_dma3_chan_desc_alloc(struct stm32_dma3_ch
return NULL;
}
- swdesc = kzalloc(struct_size(swdesc, lli, count), GFP_NOWAIT);
+ swdesc = kzalloc_flex(*swdesc, lli, count, GFP_NOWAIT);
if (!swdesc)
return NULL;
swdesc->lli_size = count;
diff --git a/drivers/dma/stm32/stm32-dmamux.c b/drivers/dma/stm32/stm32-dmamux.c
index db13498b9c9f..4abd5ba32969 100644
--- a/drivers/dma/stm32/stm32-dmamux.c
+++ b/drivers/dma/stm32/stm32-dmamux.c
@@ -104,7 +104,7 @@ static void *stm32_dmamux_route_allocate(struct of_phandle_args *dma_spec,
goto err_put_pdev;
}
- mux = kzalloc(sizeof(*mux), GFP_KERNEL);
+ mux = kzalloc_obj(*mux, GFP_KERNEL);
if (!mux) {
ret = -ENOMEM;
goto err_put_pdev;
diff --git a/drivers/dma/stm32/stm32-mdma.c b/drivers/dma/stm32/stm32-mdma.c
index b87d41b234df..e3bbdc9ee36e 100644
--- a/drivers/dma/stm32/stm32-mdma.c
+++ b/drivers/dma/stm32/stm32-mdma.c
@@ -318,7 +318,7 @@ static struct stm32_mdma_desc *stm32_mdma_alloc_desc(
struct stm32_mdma_desc *desc;
int i;
- desc = kzalloc(struct_size(desc, node, count), GFP_NOWAIT);
+ desc = kzalloc_flex(*desc, node, count, GFP_NOWAIT);
if (!desc)
return NULL;
desc->count = count;
diff --git a/drivers/dma/sun4i-dma.c b/drivers/dma/sun4i-dma.c
index 00d2fd38d17f..d2321f7287d2 100644
--- a/drivers/dma/sun4i-dma.c
+++ b/drivers/dma/sun4i-dma.c
@@ -532,7 +532,7 @@ generate_ndma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest,
if (ret)
return NULL;
- promise = kzalloc(sizeof(*promise), GFP_NOWAIT);
+ promise = kzalloc_obj(*promise, GFP_NOWAIT);
if (!promise)
return NULL;
@@ -595,7 +595,7 @@ generate_ddma_promise(struct dma_chan *chan, dma_addr_t src, dma_addr_t dest,
struct sun4i_dma_promise *promise;
int ret;
- promise = kzalloc(sizeof(*promise), GFP_NOWAIT);
+ promise = kzalloc_obj(*promise, GFP_NOWAIT);
if (!promise)
return NULL;
@@ -648,7 +648,7 @@ static struct sun4i_dma_contract *generate_dma_contract(void)
{
struct sun4i_dma_contract *contract;
- contract = kzalloc(sizeof(*contract), GFP_NOWAIT);
+ contract = kzalloc_obj(*contract, GFP_NOWAIT);
if (!contract)
return NULL;
diff --git a/drivers/dma/sun6i-dma.c b/drivers/dma/sun6i-dma.c
index c33f151953eb..a9a254dbf8cb 100644
--- a/drivers/dma/sun6i-dma.c
+++ b/drivers/dma/sun6i-dma.c
@@ -678,7 +678,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_memcpy(
if (!len)
return NULL;
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
@@ -736,7 +736,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_slave_sg(
return NULL;
}
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
@@ -819,7 +819,7 @@ static struct dma_async_tx_descriptor *sun6i_dma_prep_dma_cyclic(
return NULL;
}
- txd = kzalloc(sizeof(*txd), GFP_NOWAIT);
+ txd = kzalloc_obj(*txd, GFP_NOWAIT);
if (!txd)
return NULL;
diff --git a/drivers/dma/tegra186-gpc-dma.c b/drivers/dma/tegra186-gpc-dma.c
index 4d6fe0efa76e..5948fbf32c21 100644
--- a/drivers/dma/tegra186-gpc-dma.c
+++ b/drivers/dma/tegra186-gpc-dma.c
@@ -908,7 +908,7 @@ tegra_dma_prep_dma_memset(struct dma_chan *dc, dma_addr_t dest, int value,
/* Set burst size */
mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16;
- dma_desc = kzalloc(struct_size(dma_desc, sg_req, 1), GFP_NOWAIT);
+ dma_desc = kzalloc_flex(*dma_desc, sg_req, 1, GFP_NOWAIT);
if (!dma_desc)
return NULL;
@@ -977,7 +977,7 @@ tegra_dma_prep_dma_memcpy(struct dma_chan *dc, dma_addr_t dest,
/* Set burst size */
mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_16;
- dma_desc = kzalloc(struct_size(dma_desc, sg_req, 1), GFP_NOWAIT);
+ dma_desc = kzalloc_flex(*dma_desc, sg_req, 1, GFP_NOWAIT);
if (!dma_desc)
return NULL;
@@ -1070,7 +1070,7 @@ tegra_dma_prep_slave_sg(struct dma_chan *dc, struct scatterlist *sgl,
else
mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_2;
- dma_desc = kzalloc(struct_size(dma_desc, sg_req, sg_len), GFP_NOWAIT);
+ dma_desc = kzalloc_flex(*dma_desc, sg_req, sg_len, GFP_NOWAIT);
if (!dma_desc)
return NULL;
@@ -1205,8 +1205,7 @@ tegra_dma_prep_dma_cyclic(struct dma_chan *dc, dma_addr_t buf_addr, size_t buf_l
mc_seq |= TEGRA_GPCDMA_MCSEQ_BURST_2;
period_count = buf_len / period_len;
- dma_desc = kzalloc(struct_size(dma_desc, sg_req, period_count),
- GFP_NOWAIT);
+ dma_desc = kzalloc_flex(*dma_desc, sg_req, period_count, GFP_NOWAIT);
if (!dma_desc)
return NULL;
diff --git a/drivers/dma/tegra20-apb-dma.c b/drivers/dma/tegra20-apb-dma.c
index 14a61e53a41b..640b8a218c9a 100644
--- a/drivers/dma/tegra20-apb-dma.c
+++ b/drivers/dma/tegra20-apb-dma.c
@@ -282,7 +282,7 @@ static struct tegra_dma_desc *tegra_dma_desc_get(struct tegra_dma_channel *tdc)
spin_unlock_irqrestore(&tdc->lock, flags);
/* Allocate DMA desc */
- dma_desc = kzalloc(sizeof(*dma_desc), GFP_NOWAIT);
+ dma_desc = kzalloc_obj(*dma_desc, GFP_NOWAIT);
if (!dma_desc)
return NULL;
@@ -321,7 +321,7 @@ tegra_dma_sg_req_get(struct tegra_dma_channel *tdc)
}
spin_unlock_irqrestore(&tdc->lock, flags);
- sg_req = kzalloc(sizeof(*sg_req), GFP_NOWAIT);
+ sg_req = kzalloc_obj(*sg_req, GFP_NOWAIT);
return sg_req;
}
diff --git a/drivers/dma/tegra210-adma.c b/drivers/dma/tegra210-adma.c
index 215bfef37ec6..14e0c408ed1e 100644
--- a/drivers/dma/tegra210-adma.c
+++ b/drivers/dma/tegra210-adma.c
@@ -755,7 +755,7 @@ static struct dma_async_tx_descriptor *tegra_adma_prep_dma_cyclic(
return NULL;
}
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
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;
diff --git a/drivers/dma/timb_dma.c b/drivers/dma/timb_dma.c
index ecaf002558af..968f8cf19ec0 100644
--- a/drivers/dma/timb_dma.c
+++ b/drivers/dma/timb_dma.c
@@ -325,7 +325,7 @@ static struct timb_dma_desc *td_alloc_init_desc(struct timb_dma_chan *td_chan)
struct timb_dma_desc *td_desc;
int err;
- td_desc = kzalloc(sizeof(struct timb_dma_desc), GFP_KERNEL);
+ td_desc = kzalloc_obj(struct timb_dma_desc, GFP_KERNEL);
if (!td_desc)
goto out;
@@ -635,8 +635,7 @@ static int td_probe(struct platform_device *pdev)
DRIVER_NAME))
return -EBUSY;
- td = kzalloc(struct_size(td, channels, pdata->nr_channels),
- GFP_KERNEL);
+ td = kzalloc_flex(*td, channels, pdata->nr_channels, GFP_KERNEL);
if (!td) {
err = -ENOMEM;
goto err_release_region;
diff --git a/drivers/dma/txx9dmac.c b/drivers/dma/txx9dmac.c
index 35d5221683b2..05622b68a936 100644
--- a/drivers/dma/txx9dmac.c
+++ b/drivers/dma/txx9dmac.c
@@ -192,7 +192,7 @@ static struct txx9dmac_desc *txx9dmac_desc_alloc(struct txx9dmac_chan *dc,
struct txx9dmac_dev *ddev = dc->ddev;
struct txx9dmac_desc *desc;
- desc = kzalloc(sizeof(*desc), flags);
+ desc = kzalloc_obj(*desc, flags);
if (!desc)
return NULL;
INIT_LIST_HEAD(&desc->tx_list);
diff --git a/drivers/dma/uniphier-mdmac.c b/drivers/dma/uniphier-mdmac.c
index 7a99f86ecb5a..a8aa904b88be 100644
--- a/drivers/dma/uniphier-mdmac.c
+++ b/drivers/dma/uniphier-mdmac.c
@@ -238,7 +238,7 @@ uniphier_mdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
if (!is_slave_direction(direction))
return NULL;
- md = kzalloc(sizeof(*md), GFP_NOWAIT);
+ md = kzalloc_obj(*md, GFP_NOWAIT);
if (!md)
return NULL;
diff --git a/drivers/dma/uniphier-xdmac.c b/drivers/dma/uniphier-xdmac.c
index ceeb6171c9d1..120c0d4f12dd 100644
--- a/drivers/dma/uniphier-xdmac.c
+++ b/drivers/dma/uniphier-xdmac.c
@@ -292,7 +292,7 @@ uniphier_xdmac_prep_dma_memcpy(struct dma_chan *chan, dma_addr_t dst,
nr = 1 + len / XDMAC_MAX_WORD_SIZE;
- xd = kzalloc(struct_size(xd, nodes, nr), GFP_NOWAIT);
+ xd = kzalloc_flex(*xd, nodes, nr, GFP_NOWAIT);
if (!xd)
return NULL;
xd->nr_node = nr;
@@ -348,7 +348,7 @@ uniphier_xdmac_prep_slave_sg(struct dma_chan *chan, struct scatterlist *sgl,
return NULL;
}
- xd = kzalloc(struct_size(xd, nodes, sg_len), GFP_NOWAIT);
+ xd = kzalloc_flex(*xd, nodes, sg_len, GFP_NOWAIT);
if (!xd)
return NULL;
xd->nr_node = sg_len;
diff --git a/drivers/dma/xilinx/xdma.c b/drivers/dma/xilinx/xdma.c
index 118199a04902..d02a4dac2291 100644
--- a/drivers/dma/xilinx/xdma.c
+++ b/drivers/dma/xilinx/xdma.c
@@ -275,7 +275,7 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num, bool cyclic)
void *addr;
int i, j;
- sw_desc = kzalloc(sizeof(*sw_desc), GFP_NOWAIT);
+ sw_desc = kzalloc_obj(*sw_desc, GFP_NOWAIT);
if (!sw_desc)
return NULL;
@@ -284,8 +284,8 @@ xdma_alloc_desc(struct xdma_chan *chan, u32 desc_num, bool cyclic)
sw_desc->cyclic = cyclic;
sw_desc->error = false;
dblk_num = DIV_ROUND_UP(desc_num, XDMA_DESC_ADJACENT);
- sw_desc->desc_blocks = kcalloc(dblk_num, sizeof(*sw_desc->desc_blocks),
- GFP_NOWAIT);
+ sw_desc->desc_blocks = kzalloc_objs(*sw_desc->desc_blocks, dblk_num,
+ GFP_NOWAIT);
if (!sw_desc->desc_blocks)
goto failed;
diff --git a/drivers/dma/xilinx/xilinx_dma.c b/drivers/dma/xilinx/xilinx_dma.c
index 53229d8ebc52..b53292e02448 100644
--- a/drivers/dma/xilinx/xilinx_dma.c
+++ b/drivers/dma/xilinx/xilinx_dma.c
@@ -836,7 +836,7 @@ xilinx_dma_alloc_tx_descriptor(struct xilinx_dma_chan *chan)
{
struct xilinx_dma_tx_descriptor *desc;
- desc = kzalloc(sizeof(*desc), GFP_NOWAIT);
+ desc = kzalloc_obj(*desc, GFP_NOWAIT);
if (!desc)
return NULL;
diff --git a/drivers/dma/xilinx/xilinx_dpdma.c b/drivers/dma/xilinx/xilinx_dpdma.c
index ee5d9fdbfd7f..d9a3542c4531 100644
--- a/drivers/dma/xilinx/xilinx_dpdma.c
+++ b/drivers/dma/xilinx/xilinx_dpdma.c
@@ -635,7 +635,7 @@ xilinx_dpdma_chan_alloc_tx_desc(struct xilinx_dpdma_chan *chan)
{
struct xilinx_dpdma_tx_desc *tx_desc;
- tx_desc = kzalloc(sizeof(*tx_desc), GFP_NOWAIT);
+ tx_desc = kzalloc_obj(*tx_desc, GFP_NOWAIT);
if (!tx_desc)
return NULL;
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c
index 7bb3716e60da..b9133f4fc3f9 100644
--- a/drivers/dma/xilinx/zynqmp_dma.c
+++ b/drivers/dma/xilinx/zynqmp_dma.c
@@ -482,8 +482,8 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
if (ret < 0)
return ret;
- chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc),
- GFP_KERNEL);
+ chan->sw_desc_pool = kzalloc_objs(*desc, ZYNQMP_DMA_NUM_DESCS,
+ GFP_KERNEL);
if (!chan->sw_desc_pool)
return -ENOMEM;