Re: [PATCH v4 1/2] media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem()

From: Bin Du

Date: Thu Jul 30 2026 - 06:26:07 EST




On 7/29/2026 3:07 AM, Yifei Gao wrote:
> isp4if_alloc_fw_gpumem() allocates several GPU memory pools in sequence.
> If one of them fails, it jumps to error_no_memory and returns -ENOMEM
> without releasing the pools that were already allocated, leaking them.
>
> Release the already-allocated pools before returning. isp4if_gpu_mem_free()
> is a no-op on pools that were not allocated, so calling
> isp4if_dealloc_fw_gpumem() here safely frees exactly the pools that
> succeeded.
>
> Fixes: 4c5feef6a62c ("media: platform: amd: Add isp4 fw and hw interface")
> Signed-off-by: Yifei Gao <gyf161023@xxxxxxxxx>
> ---
> drivers/media/platform/amd/isp4/isp4_interface.c | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/media/platform/amd/isp4/isp4_interface.c b/drivers/media/platform/amd/isp4/isp4_interface.c
> index 8d73f66bb42c..8e3616cce479 100644
> --- a/drivers/media/platform/amd/isp4/isp4_interface.c
> +++ b/drivers/media/platform/amd/isp4/isp4_interface.c
> @@ -201,6 +201,7 @@ static int isp4if_alloc_fw_gpumem(struct isp4_interface *ispif)
>
> error_no_memory:
> dev_err(dev, "failed to allocate gpu memory\n");
> + isp4if_dealloc_fw_gpumem(ispif);

The cleanup is needed, but isp4if_gpu_mem_free() currently logs
"invalid mem_info" at error level for every NULL entry. NULL entries are
expected during partial-allocation cleanup, so an early failure can
generate multiple misleading errors.

Please make the NULL case silent or call isp4if_gpu_mem_free() only for
allocated entries. With that fixed, the patch looks good to me.

> return -ENOMEM;
> }
>