lab.nexedi.com will be down from Thursday, 20 March 2025, 07:30:00 UTC for a duration of approximately 2 hours

Commit 33a0b734 authored by Yu Liao's avatar Yu Liao Committed by Vinod Koul

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: default avatarYu Liao <liaoyu15@huawei.com>
Link: https://lore.kernel.org/r/20230821073600.4078584-1-liaoyu15@huawei.comSigned-off-by: default avatarVinod Koul <vkoul@kernel.org>
parent 923b1383
...@@ -270,9 +270,8 @@ static int fsl_edma_probe(struct platform_device *pdev) ...@@ -270,9 +270,8 @@ static int fsl_edma_probe(struct platform_device *pdev)
struct device_node *np = pdev->dev.of_node; struct device_node *np = pdev->dev.of_node;
struct fsl_edma_engine *fsl_edma; struct fsl_edma_engine *fsl_edma;
const struct fsl_edma_drvdata *drvdata = NULL; const struct fsl_edma_drvdata *drvdata = NULL;
struct fsl_edma_chan *fsl_chan;
struct edma_regs *regs; struct edma_regs *regs;
int len, chans; int chans;
int ret, i; int ret, i;
if (of_id) if (of_id)
...@@ -288,8 +287,8 @@ static int fsl_edma_probe(struct platform_device *pdev) ...@@ -288,8 +287,8 @@ static int fsl_edma_probe(struct platform_device *pdev)
return ret; return ret;
} }
len = sizeof(*fsl_edma) + sizeof(*fsl_chan) * chans; fsl_edma = devm_kzalloc(&pdev->dev, struct_size(fsl_edma, chans, chans),
fsl_edma = devm_kzalloc(&pdev->dev, len, GFP_KERNEL); GFP_KERNEL);
if (!fsl_edma) if (!fsl_edma)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment