On Wed, Jun 10, 2026 at 08:52:41PM -0700, Rosen Penev wrote:
> Convert fsl_dma_chan_probe from kzalloc_obj() to devm_kzalloc(), tying
> the channel lifetime to the parent DMA device. Remove kfree(chan) in both
> the probe error path and the remove function.
>
> Assisted-by: opencode:big-pickle
> Signed-off-by: Rosen Penev <[email protected]>
> ---

If use flexible array, needn't allocate channel

Frank

>  drivers/dma/fsldma.c | 12 +++---------
>  1 file changed, 3 insertions(+), 9 deletions(-)
>
> diff --git a/drivers/dma/fsldma.c b/drivers/dma/fsldma.c
> index e4a3315a7d9d..0df09789187d 100644
> --- a/drivers/dma/fsldma.c
> +++ b/drivers/dma/fsldma.c
> @@ -1114,11 +1114,9 @@ static int fsl_dma_chan_probe(struct fsldma_device 
> *fdev,
>       int err;
>
>       /* alloc channel */
> -     chan = kzalloc_obj(*chan);
> -     if (!chan) {
> -             err = -ENOMEM;
> -             goto out_return;
> -     }
> +     chan = devm_kzalloc(fdev->dev, sizeof(*chan), GFP_KERNEL);
> +     if (!chan)
> +             return -ENOMEM;
>
>       /* ioremap registers for use */
>       chan->regs = of_iomap(node, 0);
> @@ -1200,9 +1198,6 @@ static int fsl_dma_chan_probe(struct fsldma_device 
> *fdev,
>
>  out_iounmap_regs:
>       iounmap(chan->regs);
> -out_free_chan:
> -     kfree(chan);
> -out_return:
>       return err;
>  }
>
> @@ -1215,7 +1210,6 @@ static void fsl_dma_chan_remove(struct fsldma_chan 
> *chan)
>       tasklet_kill(&chan->tasklet);
>       list_del(&chan->common.device_node);
>       iounmap(chan->regs);
> -     kfree(chan);
>  }
>
>  static void fsldma_device_release(struct dma_device *dma_dev);
> --
> 2.54.0
>

Reply via email to