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

From: Dikshita Agarwal
Date: Thu Jan 09 2025 - 06:27:54 EST


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@xxxxxxxxxxx>
---
drivers/media/platform/qcom/iris/iris_hfi_queue.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

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;

--
2.34.1