The memory region allocated by kfifo_alloc() should be freed using kfifo_free(). There are two possible cases that could result in a memory leak: - When hidma_ll_setup() fails, the initialization does not complete. - hidma_ll_init() succeeds and the lldev is then uninitialized. Fixes: d1615ca2e085 ("dmaengine: qcom_hidma: implement lower level hardware interface") Signed-off-by: Keisuke Nishimura <keisuke.nishimura@xxxxxxxx> --- drivers/dma/qcom/hidma_ll.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/drivers/dma/qcom/hidma_ll.c b/drivers/dma/qcom/hidma_ll.c index 53244e0e34a3..6da611c61f8c 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); @@ -812,6 +814,7 @@ int hidma_ll_uninit(struct hidma_lldev *lldev) lldev->initialized = 0; + kfifo_free(&lldev->handoff_fifo); required_bytes = sizeof(struct hidma_tre) * lldev->nr_tres; tasklet_kill(&lldev->task); memset(lldev->trepool, 0, required_bytes); -- 2.34.1