AMD-GFX Archive mirror
 help / color / mirror / Atom feed
From: Alex Deucher <alexdeucher@gmail.com>
To: Ma Jun <Jun.Ma2@amd.com>
Cc: amd-gfx@lists.freedesktop.org, Kenneth.Feng@amd.com,
	 Alexander.Deucher@amd.com, kevinyang.wang@amd.com,
	christian.koenig@amd.com
Subject: Re: [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl
Date: Mon, 6 May 2024 11:21:00 -0400	[thread overview]
Message-ID: <CADnq5_N4qt0CH9ERjwryiu4PmRw2o_8rBgT1se9UUKcTmabbwQ@mail.gmail.com> (raw)
In-Reply-To: <20240506095630.258594-1-Jun.Ma2@amd.com>

On Mon, May 6, 2024 at 6:22 AM Ma Jun <Jun.Ma2@amd.com> wrote:
>
> Check the return value of amdgpu_xcp_get_inst_details, otherwise we
> may use an uninitialized variable inst_mask
>
> Signed-off-by: Ma Jun <Jun.Ma2@amd.com>

Acked-by: Alex Deucher <alexander.deucher@amd.com>

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 11 +++++++++--
>  1 file changed, 9 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index a0ea6fe8d060..977cde6d1362 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -623,25 +623,32 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>                         switch (type) {
>                         case AMD_IP_BLOCK_TYPE_GFX:
>                                 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_GFX, &inst_mask);
> +                               if (ret)
> +                                       return ret;
>                                 count = hweight32(inst_mask);
>                                 break;
>                         case AMD_IP_BLOCK_TYPE_SDMA:
>                                 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_SDMA, &inst_mask);
> +                               if (ret)
> +                                       return ret;
>                                 count = hweight32(inst_mask);
>                                 break;
>                         case AMD_IP_BLOCK_TYPE_JPEG:
>                                 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
> +                               if (ret)
> +                                       return ret;
>                                 count = hweight32(inst_mask) * adev->jpeg.num_jpeg_rings;
>                                 break;
>                         case AMD_IP_BLOCK_TYPE_VCN:
>                                 ret = amdgpu_xcp_get_inst_details(xcp, AMDGPU_XCP_VCN, &inst_mask);
> +                               if (ret)
> +                                       return ret;
>                                 count = hweight32(inst_mask);
>                                 break;
>                         default:
>                                 return -EINVAL;
>                         }
> -                       if (ret)
> -                               return ret;
> +
>                         return copy_to_user(out, &count, min(size, 4u)) ? -EFAULT : 0;
>                 }
>
> --
> 2.34.1
>

      parent reply	other threads:[~2024-05-06 15:21 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-06  9:56 [PATCH 1/2] drm/amdgpu: Fix uninitialized variable warning in amdgpu_info_ioctl Ma Jun
2024-05-06  9:56 ` [PATCH 2/2] drm/amdgpu/pm: Fix the param type of set_power_profile_mode Ma Jun
2024-05-06 15:21 ` Alex Deucher [this message]

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=CADnq5_N4qt0CH9ERjwryiu4PmRw2o_8rBgT1se9UUKcTmabbwQ@mail.gmail.com \
    --to=alexdeucher@gmail.com \
    --cc=Alexander.Deucher@amd.com \
    --cc=Jun.Ma2@amd.com \
    --cc=Kenneth.Feng@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=christian.koenig@amd.com \
    --cc=kevinyang.wang@amd.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;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).