Re: [PATCH] drm/amdgpu: Handle null atom context in VBIOS info ioctl

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Tue, Sep 5, 2023 at 10:50 AM David Francis <David.Francis@xxxxxxx> wrote:
>
> On some APU systems, there is no atom context and so the
> atom_context struct is null.
>
> Add a check to the VBIOS_INFO branch of amdgpu_info_ioctl
> to handle this case, returning all zeroes.
>
> Signed-off-by: David Francis <David.Francis@xxxxxxx>
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 19 ++++++++++++-------
>  1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 3a48bec10aea..86748290ead7 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -947,16 +947,21 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
>                                         ? -EFAULT : 0;
>                 }
>                 case AMDGPU_INFO_VBIOS_INFO: {
> -                       struct drm_amdgpu_info_vbios vbios_info = {};
> +                       struct drm_amdgpu_info_vbios vbios_info = {0};

IIRC, these should be equivalent.  That said, I believe memset is
generally preferred as not all compilers seem to handle these cases
correctly.

Alex

>                         struct atom_context *atom_context;
>
>                         atom_context = adev->mode_info.atom_context;
> -                       memcpy(vbios_info.name, atom_context->name, sizeof(atom_context->name));
> -                       memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, sizeof(atom_context->vbios_pn));
> -                       vbios_info.version = atom_context->version;
> -                       memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
> -                                               sizeof(atom_context->vbios_ver_str));
> -                       memcpy(vbios_info.date, atom_context->date, sizeof(atom_context->date));
> +                       if (atom_context) {
> +                               memcpy(vbios_info.name, atom_context->name,
> +                                      sizeof(atom_context->name));
> +                               memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,
> +                                      sizeof(atom_context->vbios_pn));
> +                               vbios_info.version = atom_context->version;
> +                               memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
> +                                      sizeof(atom_context->vbios_ver_str));
> +                               memcpy(vbios_info.date, atom_context->date,
> +                                      sizeof(atom_context->date));
> +                       }
>
>                         return copy_to_user(out, &vbios_info,
>                                                 min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;
> --
> 2.34.1
>




[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux