diff mbox series

[2/2] media: iris: fix memory leak while freeing queue memory

Message ID 20250109-iris-driver-fixes-v1-2-789a0f5dd7ee@quicinc.com (mailing list archive)
State New
Headers show
Series media: iris: fix memory leak and improve driver | expand

Commit Message

Dikshita Agarwal Jan. 9, 2025, 11:26 a.m. UTC
Memory allocated for shared queues is not freed completely in tear down
sequence. Fix it by passing the correct value while freeing the queue
memory.

Signed-off-by: Dikshita Agarwal <quic_dikshita@quicinc.com>
---
 drivers/media/platform/qcom/iris/iris_hfi_queue.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/media/platform/qcom/iris/iris_hfi_queue.c b/drivers/media/platform/qcom/iris/iris_hfi_queue.c
index 9195715c5d5a..d1113708644b 100644
--- a/drivers/media/platform/qcom/iris/iris_hfi_queue.c
+++ b/drivers/media/platform/qcom/iris/iris_hfi_queue.c
@@ -292,6 +292,7 @@  int iris_hfi_queues_init(struct iris_core *core)
 
 void iris_hfi_queues_deinit(struct iris_core *core)
 {
+	u32 queue_size;
 	if (!core->iface_q_table_vaddr)
 		return;
 
@@ -305,9 +306,10 @@  void iris_hfi_queues_deinit(struct iris_core *core)
 	core->sfr_vaddr = NULL;
 	core->sfr_daddr = 0;
 
-	dma_free_attrs(core->dev, sizeof(struct iris_hfi_queue_table_header),
-		       core->iface_q_table_vaddr, core->iface_q_table_daddr,
-		       DMA_ATTR_WRITE_COMBINE);
+	queue_size = ALIGN(sizeof(struct iris_hfi_queue_table_header) +
+		(IFACEQ_QUEUE_SIZE * IFACEQ_NUMQ), SZ_4K);
+	dma_free_attrs(core->dev, queue_size, core->iface_q_table_vaddr,
+		       core->iface_q_table_daddr, DMA_ATTR_WRITE_COMBINE);
 
 	core->iface_q_table_vaddr = NULL;
 	core->iface_q_table_daddr = 0;