From: Bin Du <Bin.Du@amd.com>
To: Yifei Gao <gyf161023@gmail.com>,
Nirujogi Pratap <pratap.nirujogi@amd.com>,
Mauro Carvalho Chehab <mchehab@kernel.org>,
Sakari Ailus <sakari.ailus@linux.intel.com>
Cc: Sultan Alsawaf <sultan@kerneltoast.com>,
linux-media@vger.kernel.org, linux-kernel@vger.kernel.org, "Chan,
Benjamin (Koon Pan)" <Benjamin.Chan@amd.com>,
"Li, King" <King.Li@amd.com>
Subject: Re: [PATCH v5 1/2] media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem()
Date: Mon, 3 Aug 2026 15:22:24 +0800 [thread overview]
Message-ID: <baf0db6f-0e68-4d35-a141-a9a3f5caef0d@amd.com> (raw)
In-Reply-To: <20260730141413.4136502-2-gyf161023@gmail.com>
On 7/30/2026 10:14 PM, 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.
>
> isp4if_gpu_mem_free() previously logged an error for a NULL entry, which
> is a normal case during partial-allocation cleanup, so make it silent.
>
> Fixes: 4c5feef6a62c ("media: platform: amd: Add isp4 fw and hw interface")
> Signed-off-by: Yifei Gao <gyf161023@gmail.com>
> ---
> drivers/media/platform/amd/isp4/isp4_interface.c | 6 ++----
> 1 file changed, 2 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/media/platform/amd/isp4/isp4_interface.c b/drivers/media/platform/amd/isp4/isp4_interface.c
> index 8d73f66bb42c..4fefd0f7fbab 100644
> --- a/drivers/media/platform/amd/isp4/isp4_interface.c
> +++ b/drivers/media/platform/amd/isp4/isp4_interface.c
> @@ -148,12 +148,9 @@ static void isp4if_gpu_mem_free(struct isp4_interface *ispif,
> struct isp4if_gpu_mem_info **mem_info_ptr)
> {
> struct isp4if_gpu_mem_info *mem_info = *mem_info_ptr;
> - struct device *dev = ispif->dev;
>
> - if (!mem_info) {
> - dev_err(dev, "invalid mem_info\n");
> + if (!mem_info)
> return;
> - }
>
> *mem_info_ptr = NULL;
> isp_kernel_buffer_free(&mem_info->mem_handle, &mem_info->gpu_mc_addr,
> @@ -201,6 +198,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);
> return -ENOMEM;
> }
>
Reviewed-by: Bin Du <bin.du@amd.com>
next prev parent reply other threads:[~2026-08-03 7:22 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-25 20:36 [PATCH] media: amd: isp4: fix self-deadlock in power-on error path Yifei Gao
2026-07-27 3:32 ` Bin Du
2026-07-27 18:34 ` [PATCH v2] media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() " Yifei Gao
2026-07-28 10:17 ` Bin Du
2026-07-28 14:16 ` [PATCH v3 0/2] media: amd: isp4: fix error handling in isp4sd_pwron_and_init() Yifei Gao
2026-07-28 14:16 ` [PATCH v3 1/2] media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem() Yifei Gao
2026-07-28 14:16 ` [PATCH v3 2/2] media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path Yifei Gao
2026-07-28 17:35 ` Sakari Ailus
2026-07-28 19:07 ` [PATCH v4 0/2] media: amd: isp4: fix error handling in isp4sd_pwron_and_init() Yifei Gao
2026-07-28 19:07 ` [PATCH v4 1/2] media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem() Yifei Gao
2026-07-30 9:57 ` Bin Du
2026-07-28 19:07 ` [PATCH v4 2/2] media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path Yifei Gao
2026-07-30 14:14 ` [PATCH v5 0/2] media: amd: isp4: fix error handling in isp4sd_pwron_and_init() Yifei Gao
2026-07-30 14:14 ` [PATCH v5 1/2] media: amd: isp4: release partial allocations in isp4if_alloc_fw_gpumem() Yifei Gao
2026-08-03 7:22 ` Bin Du [this message]
2026-07-30 14:14 ` [PATCH v5 2/2] media: amd: isp4: fix self-deadlock in isp4sd_pwron_and_init() error path Yifei Gao
2026-08-03 7:22 ` Bin Du
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=baf0db6f-0e68-4d35-a141-a9a3f5caef0d@amd.com \
--to=bin.du@amd.com \
--cc=Benjamin.Chan@amd.com \
--cc=King.Li@amd.com \
--cc=gyf161023@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-media@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=pratap.nirujogi@amd.com \
--cc=sakari.ailus@linux.intel.com \
--cc=sultan@kerneltoast.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®