Thread (32 messages) 32 messages, 2 authors, 23d ago

Re: [PATCHv4 11/15] dmaengine: fsldma: convert channel allocation to devm_kzalloc()

From: Rosen Penev <hidden>
Date: 2026-06-11 16:08:46
Also in: dmaengine, lkml, llvm

On Thu, Jun 11, 2026 at 8:36 AM Frank Li [off-list ref] wrote:
On Wed, Jun 10, 2026 at 08:52:41PM -0700, Rosen Penev wrote:
quoted
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 <redacted>
---
If use flexible array, needn't allocate channel
Not sure what you mean. A regular array avoids that as well.
Frank
quoted
 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
  
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help