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

From: Huihui Huang

Date: Thu Apr 16 2026 - 03:49:40 EST


Our code analyzer reported 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.

My patch adds the missing ipu7_dma_free() call and sets boot_config
to NULL before returning on the error path, matching the cleanup in
ipu7_boot_release_boot_config().

Signed-off-by: Huihui Huang <hhhuang@xxxxxxxxxx>
---
drivers/staging/media/ipu7/ipu7-boot.c | 3 +++
1 file changed, 3 insertions(+)

diff --git a/drivers/staging/media/ipu7/ipu7-boot.c b/drivers/staging/media/ipu7/ipu7-boot.c
index d7901ff78b38..063312d33603 100644
--- a/drivers/staging/media/ipu7/ipu7-boot.c
+++ b/drivers/staging/media/ipu7/ipu7-boot.c
@@ -263,6 +263,9 @@ 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);
+ adev->boot_config = NULL;
return -ENOMEM;
}
syscom->queue_mem_size = total_queue_size_aligned;
--
2.50.1