[PATCH 1/2] dmaengine: qcom_hidma: fix memory leak on probe failure

From: Qasim Ijaz
Date: Sun Jun 01 2025 - 18:43:13 EST


hidma_ll_init() is invoked to create and initialise a struct hidma_lldev
object during hidma probe. During this a FIFO buffer is allocated, but
if some failure occurs after (like hidma_ll_setup failure) we should
clean up the FIFO.

Fixes: d1615ca2e085 ("dmaengine: qcom_hidma: implement lower level hardware interface")
Cc: stable@xxxxxxxxxxxxxxx
Signed-off-by: Qasim Ijaz <qasdev00@xxxxxxxxx>
---
drivers/dma/qcom/hidma_ll.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/dma/qcom/hidma_ll.c b/drivers/dma/qcom/hidma_ll.c
index 53244e0e34a3..fee448499777 100644
--- a/drivers/dma/qcom/hidma_ll.c
+++ b/drivers/dma/qcom/hidma_ll.c
@@ -788,8 +788,10 @@ struct hidma_lldev *hidma_ll_init(struct device *dev, u32 nr_tres,
return NULL;

rc = hidma_ll_setup(lldev);
- if (rc)
+ if (rc) {
+ kfifo_free(&lldev->handoff_fifo);
return NULL;
+ }

spin_lock_init(&lldev->lock);
tasklet_setup(&lldev->task, hidma_ll_tre_complete);
--
2.39.5