Skip to content

Commit 33a0b73

Browse files
yuliao0214vinodkoul
authored andcommitted
dmaengine: fsl-edma: use struct_size() helper
Make use of the struct_size() helper instead of an open-coded version, in order to avoid any potential type mistakes or integer overflows that, in the worst scenario, could lead to heap overflows. Signed-off-by: Yu Liao <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent 923b138 commit 33a0b73

File tree

1 file changed

+3
-4
lines changed

1 file changed

+3
-4
lines changed

drivers/dma/fsl-edma.c

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,8 @@ static int fsl_edma_probe(struct platform_device *pdev)
270270
struct device_node *np = pdev->dev.of_node;
271271
struct fsl_edma_engine *fsl_edma;
272272
const struct fsl_edma_drvdata *drvdata = NULL;
273-
struct fsl_edma_chan *fsl_chan;
274273
struct edma_regs *regs;
275-
int len, chans;
274+
int chans;
276275
int ret, i;
277276

278277
if (of_id)
@@ -288,8 +287,8 @@ static int fsl_edma_probe(struct platform_device *pdev)
288287
return ret;
289288
}
290289

291-
len = sizeof(*fsl_edma) + sizeof(*fsl_chan) * chans;
292-
fsl_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL);
290+
fsl_edma = devm_kzalloc(&pdev->dev, struct_size(fsl_edma, chans, chans),
291+
GFP_KERNEL);
293292
if (!fsl_edma)
294293
return -ENOMEM;
295294

0 commit comments

Comments
 (0)