AMD General

The series is:  Reviewed-by: Tao Zhou <[email protected]>

> -----Original Message-----
> From: amd-gfx <[email protected]> On Behalf Of Ce
> Sun
> Sent: Tuesday, June 23, 2026 3:39 PM
> To: [email protected]
> Cc: Zhang, Hawking <[email protected]>; Chai, Thomas
> <[email protected]>; Zhou1, Tao <[email protected]>; Yang, Stanley
> <[email protected]>; Sun, Ce(Overlord) <[email protected]>
> Subject: [PATCH v1 2/2] drm/amdgpu: fix resource leak on ACP reset timeout
>
> When ACP soft reset poll times out, original code returns early without
> cleanup, leaking MFD child devices, genpd links and all ACP heap allocations.
>
> Replace direct early return with goto out to force run all cleanup logic
> regardless of reset success, preserve timeout error code for caller.
>
> Signed-off-by: Ce Sun <[email protected]>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | 11 +++++++----
>  1 file changed, 7 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> index b0db0834bfff..1d77d0cd3ec3 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
> @@ -510,6 +510,7 @@ static int acp_hw_fini(struct amdgpu_ip_block
> *ip_block)
>       u32 val = 0;
>       u32 count = 0;
>       struct amdgpu_device *adev = ip_block->adev;
> +     int ret = 0;
>
>       /* return early if no ACP */
>       if (!adev->acp.acp_genpd) {
> @@ -531,7 +532,8 @@ static int acp_hw_fini(struct amdgpu_ip_block
> *ip_block)
>                       break;
>               if (--count == 0) {
>                       dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
> -                     return -ETIMEDOUT;
> +                     ret = -ETIMEDOUT;
> +                     goto out;
>               }
>               udelay(100);
>       }
> @@ -548,11 +550,12 @@ static int acp_hw_fini(struct amdgpu_ip_block
> *ip_block)
>                       break;
>               if (--count == 0) {
>                       dev_err(&adev->pdev->dev, "Failed to reset ACP\n");
> -                     return -ETIMEDOUT;
> +                     ret = -ETIMEDOUT;
> +                     goto out;
>               }
>               udelay(100);
>       }
> -
> +out:
>       device_for_each_child(adev->acp.parent, NULL,
>                             acp_genpd_remove_device);
>
> @@ -564,7 +567,7 @@ static int acp_hw_fini(struct amdgpu_ip_block
> *ip_block)
>       adev->acp.acp_genpd = NULL;
>       kfree(adev->acp.acp_cell);
>
> -     return 0;
> +     return ret;
>  }
>
>  static int acp_suspend(struct amdgpu_ip_block *ip_block)
> --
> 2.34.1

Reply via email to