linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] drm/amd/pm: initialize variable
@ 2021-04-30 17:16 trix
  2021-05-04 19:16 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: trix @ 2021-04-30 17:16 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, daniel, evan.quan,
	nirmoy.das, kevin1.wang, ray.huang, darren.powell
  Cc: amd-gfx, dri-devel, linux-kernel, Tom Rix

From: Tom Rix <trix@redhat.com>

Static analysis reports this problem

amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value
  for (i = 0; i < data.nums; i++) {
                ^ ~~~~~~~~~

In some cases data is not set.  Initialize to 0 and flag not setting
data as an error with the existing check.

Signed-off-by: Tom Rix <trix@redhat.com>
---
 drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
index 4e459ef632ef..9a54066ec0af 100644
--- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
+++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
@@ -451,7 +451,7 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
 	struct drm_device *ddev = dev_get_drvdata(dev);
 	struct amdgpu_device *adev = drm_to_adev(ddev);
 	const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
-	struct pp_states_info data;
+	struct pp_states_info data = {0};
 	enum amd_pm_state_type pm = 0;
 	int i = 0, ret = 0;
 
-- 
2.26.3


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

* Re: [PATCH] drm/amd/pm: initialize variable
  2021-04-30 17:16 [PATCH] drm/amd/pm: initialize variable trix
@ 2021-05-04 19:16 ` Alex Deucher
  0 siblings, 0 replies; 2+ messages in thread
From: Alex Deucher @ 2021-05-04 19:16 UTC (permalink / raw)
  To: Tom Rix
  Cc: Deucher, Alexander, Christian Koenig, Dave Airlie, Daniel Vetter,
	Quan, Evan, Nirmoy Das, Kevin Wang, Huang Rui, Powell, Darren,
	Maling list - DRI developers, amd-gfx list, LKML

On Fri, Apr 30, 2021 at 2:05 PM <trix@redhat.com> wrote:
>
> From: Tom Rix <trix@redhat.com>
>
> Static analysis reports this problem
>
> amdgpu_pm.c:478:16: warning: The right operand of '<' is a garbage value
>   for (i = 0; i < data.nums; i++) {
>                 ^ ~~~~~~~~~
>
> In some cases data is not set.  Initialize to 0 and flag not setting
> data as an error with the existing check.
>
> Signed-off-by: Tom Rix <trix@redhat.com>

Applied.  Thanks!

Alex


> ---
>  drivers/gpu/drm/amd/pm/amdgpu_pm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/pm/amdgpu_pm.c b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> index 4e459ef632ef..9a54066ec0af 100644
> --- a/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> +++ b/drivers/gpu/drm/amd/pm/amdgpu_pm.c
> @@ -451,7 +451,7 @@ static ssize_t amdgpu_get_pp_cur_state(struct device *dev,
>         struct drm_device *ddev = dev_get_drvdata(dev);
>         struct amdgpu_device *adev = drm_to_adev(ddev);
>         const struct amd_pm_funcs *pp_funcs = adev->powerplay.pp_funcs;
> -       struct pp_states_info data;
> +       struct pp_states_info data = {0};
>         enum amd_pm_state_type pm = 0;
>         int i = 0, ret = 0;
>
> --
> 2.26.3
>
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel

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

end of thread, other threads:[~2021-05-04 19:16 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-04-30 17:16 [PATCH] drm/amd/pm: initialize variable trix
2021-05-04 19:16 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).