[PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()'

Alex Deucher alexdeucher at gmail.com
Thu Jan 4 14:16:30 UTC 2024


On Thu, Jan 4, 2024 at 4:46 AM Srinivasan Shanmugam
<srinivasan.shanmugam at amd.com> wrote:
>
> Fixes the below:
> drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c:1404 amdgpu_ucode_request() warn: '*fw' from request_firmware() not released on lines: 1404.
>
> Cc: Mario Limonciello <mario.limonciello at amd.com>
> Cc: Lijo Lazar <lijo.lazar at amd.com>
> Cc: Christian König <christian.koenig at amd.com>
> Cc: Alex Deucher <alexander.deucher at amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam at amd.com>
> ---
> v2:
>    - Fix some indendations.
>    - release the fw only when ucode validate fails.
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c | 7 +++++--
>  1 file changed, 5 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
> index 1f67914568f6..d30c39cd8bb8 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ucode.c
> @@ -1395,12 +1395,15 @@ int amdgpu_ucode_request(struct amdgpu_device *adev, const struct firmware **fw,
>                          const char *fw_name)
>  {
>         int err = request_firmware(fw, fw_name, adev->dev);
> -

Leave this new line.  With that fixed, patch is:
Acked-by: Alex Deucher <alexander.deucher at amd.com>

>         if (err)
>                 return -ENODEV;
> +
>         err = amdgpu_ucode_validate(*fw);
> -       if (err)
> +       if (err) {
>                 dev_dbg(adev->dev, "\"%s\" failed to validate\n", fw_name);
> +               release_firmware(*fw);
> +               *fw = NULL;
> +       }
>
>         return err;
>  }
> --
> 2.34.1
>


More information about the amd-gfx mailing list