Convert fdev allocation from kzalloc_obj to devm_kzalloc to simplify the probe error and remove paths by dropping the explicit kfree.
While at it, fix a goto target mismatch introduced in the recent platform_get_irq_optional() conversion: goto err_iounmap should be goto out_iounmap. Assisted-by: opencode:big-pickle Signed-off-by: Rosen Penev <[email protected]> --- drivers/dma/fsldma.c | 18 ++++++------------ 1 file changed, 6 insertions(+), 12 deletions(-) diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c index 0d28f8299bf8..2efa16d12679 100644 --- a/drivers/dma/fsldma.c +++ b/drivers/dma/fsldma.c @@ -1213,18 +1213,17 @@ static void fsl_dma_chan_remove(struct fsldma_chan *chan) static int fsldma_of_probe(struct platform_device *op) { + struct device *dev = &op->dev; struct fsldma_device *fdev; struct device_node *child; unsigned int i; int err; - fdev = kzalloc_obj(*fdev); - if (!fdev) { - err = -ENOMEM; - goto out_return; - } + fdev = devm_kzalloc(dev, sizeof(*fdev), GFP_KERNEL); + if (!fdev) + return -ENOMEM; - fdev->dev = &op->dev; + fdev->dev = dev; INIT_LIST_HEAD(&fdev->common.channels); /* The DMA address bits supported for this device. */ fdev->addr_bits = (long)device_get_match_data(fdev->dev); @@ -1233,8 +1232,7 @@ static int fsldma_of_probe(struct platform_device *op) fdev->regs = of_iomap(op->dev.of_node, 0); if (!fdev->regs) { dev_err(&op->dev, "unable to ioremap registers\n"); - err = -ENOMEM; - goto out_free; + return -ENOMEM; } /* map the channel IRQ if it exists, but don't hookup the handler yet */ @@ -1313,9 +1311,6 @@ static int fsldma_of_probe(struct platform_device *op) } out_iounmap: iounmap(fdev->regs); -out_free: - kfree(fdev); -out_return: return err; } @@ -1335,7 +1330,6 @@ static void fsldma_of_remove(struct platform_device *op) } iounmap(fdev->regs); - kfree(fdev); } #ifdef CONFIG_PM -- 2.54.0
