Skip to content

Commit 5e7e822

Browse files
fdavid-amdalexdeucher
authored andcommitted
drm/amdgpu: Handle null atom context in VBIOS info ioctl
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. Reviewed-by: Alex Deucher <[email protected]> Signed-off-by: David Francis <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent 9296da8 commit 5e7e822

File tree

1 file changed

+11
-6
lines changed

1 file changed

+11
-6
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -940,12 +940,17 @@ int amdgpu_info_ioctl(struct drm_device *dev, void *data, struct drm_file *filp)
940940
struct atom_context *atom_context;
941941

942942
atom_context = adev->mode_info.atom_context;
943-
memcpy(vbios_info.name, atom_context->name, sizeof(atom_context->name));
944-
memcpy(vbios_info.vbios_pn, atom_context->vbios_pn, sizeof(atom_context->vbios_pn));
945-
vbios_info.version = atom_context->version;
946-
memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
947-
sizeof(atom_context->vbios_ver_str));
948-
memcpy(vbios_info.date, atom_context->date, sizeof(atom_context->date));
943+
if (atom_context) {
944+
memcpy(vbios_info.name, atom_context->name,
945+
sizeof(atom_context->name));
946+
memcpy(vbios_info.vbios_pn, atom_context->vbios_pn,
947+
sizeof(atom_context->vbios_pn));
948+
vbios_info.version = atom_context->version;
949+
memcpy(vbios_info.vbios_ver_str, atom_context->vbios_ver_str,
950+
sizeof(atom_context->vbios_ver_str));
951+
memcpy(vbios_info.date, atom_context->date,
952+
sizeof(atom_context->date));
953+
}
949954

950955
return copy_to_user(out, &vbios_info,
951956
min((size_t)size, sizeof(vbios_info))) ? -EFAULT : 0;

0 commit comments

Comments
 (0)