[PATCH v2] staging: media: ipu7: fix boot_config leak on queue_mem failure

From: Huihui Huang

Date: Fri Apr 17 2026 - 03:48:04 EST


There is a memory leak in drivers/staging/media/ipu7/ipu7-boot.c.

In ipu7_boot_init_boot_config(), boot_config is allocated by
ipu7_dma_alloc(). If the second ipu7_dma_alloc() for queue_mem fails,
the function returns -ENOMEM without freeing the previously allocated
boot_config.

Add the missing ipu7_dma_free() call before returning on the error
path.

Signed-off-by: Huihui Huang <hhhuang@xxxxxxxxxx>
---
v2: Reword commit message in imperative mood. Remove unnecessary
NULL assignment on the error path.
---
drivers/staging/media/ipu7/ipu7-boot.c | 2 ++
1 file changed, 2 insertions(+)

diff --git a/drivers/staging/media/ipu7/ipu7-boot.c b/drivers/staging/media/ipu7/ipu7-boot.c
index d7901ff78b38..495b3e05a9b1 100644
--- a/drivers/staging/media/ipu7/ipu7-boot.c
+++ b/drivers/staging/media/ipu7/ipu7-boot.c
@@ -263,6 +263,8 @@ int ipu7_boot_init_boot_config(struct ipu7_bus_device *adev,
GFP_KERNEL, 0);
if (!syscom->queue_mem) {
dev_err(dev, "Failed to allocate queue memory.\n");
+ ipu7_dma_free(adev, adev->boot_config_size,
+ adev->boot_config, adev->boot_config_dma_addr, 0);
return -ENOMEM;
}
syscom->queue_mem_size = total_queue_size_aligned;
--
2.50.1