All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()'
@ 2024-01-04  9:26 Srinivasan Shanmugam
  2024-01-04  9:35 ` Christian König
  2024-01-04 14:16 ` Alex Deucher
  0 siblings, 2 replies; 3+ messages in thread
From: Srinivasan Shanmugam @ 2024-01-04  9:26 UTC (permalink / raw)
  To: Alex Deucher, Christian König
  Cc: Lijo Lazar, Srinivasan Shanmugam, Mario Limonciello, amd-gfx

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@amd.com>
Cc: Lijo Lazar <lijo.lazar@amd.com>
Cc: Christian König <christian.koenig@amd.com>
Cc: Alex Deucher <alexander.deucher@amd.com>
Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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);
-
 	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


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()'
  2024-01-04  9:26 [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()' Srinivasan Shanmugam
@ 2024-01-04  9:35 ` Christian König
  2024-01-04 14:16 ` Alex Deucher
  1 sibling, 0 replies; 3+ messages in thread
From: Christian König @ 2024-01-04  9:35 UTC (permalink / raw)
  To: Srinivasan Shanmugam, Alex Deucher; +Cc: Lijo Lazar, Mario Limonciello, amd-gfx



Am 04.01.24 um 10:26 schrieb Srinivasan Shanmugam:
> 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@amd.com>
> Cc: Lijo Lazar <lijo.lazar@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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);
> -

Please keep the empty line between declaration and code.

Apart from that feel free to add my rb to the patch.

Regards,
Christian.

>   	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;
>   }


^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()'
  2024-01-04  9:26 [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()' Srinivasan Shanmugam
  2024-01-04  9:35 ` Christian König
@ 2024-01-04 14:16 ` Alex Deucher
  1 sibling, 0 replies; 3+ messages in thread
From: Alex Deucher @ 2024-01-04 14:16 UTC (permalink / raw)
  To: Srinivasan Shanmugam
  Cc: Alex Deucher, Lijo Lazar, Christian König, amd-gfx,
	Mario Limonciello

On Thu, Jan 4, 2024 at 4:46 AM Srinivasan Shanmugam
<srinivasan.shanmugam@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@amd.com>
> Cc: Lijo Lazar <lijo.lazar@amd.com>
> Cc: Christian König <christian.koenig@amd.com>
> Cc: Alex Deucher <alexander.deucher@amd.com>
> Signed-off-by: Srinivasan Shanmugam <srinivasan.shanmugam@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@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
>

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2024-01-04 14:16 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-01-04  9:26 [PATCH v2] drm/amdgpu: Fix '*fw' from request_firmware() not released in 'amdgpu_ucode_request()' Srinivasan Shanmugam
2024-01-04  9:35 ` Christian König
2024-01-04 14:16 ` Alex Deucher

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.