Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

drm/amdkfd: Reconcile the definition and use of oem_id in struct kfd_topology_device

Currently oem_id is defined as uint8_t[6] and casted to uint64_t*
in some use case. This would lead code scanner to complain about
access beyond. Re-define it in union to enforce 8-byte size and
alignment to avoid potential issue.

Signed-off-by: Michael Chen <michael.chen@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>

authored by

Michael Chen and committed by
Alex Deucher
10f624ef c4dcb47d

+5 -5
-2
drivers/gpu/drm/amd/amdkfd/kfd_crat.h
··· 42 42 #define CRAT_OEMTABLEID_LENGTH 8 43 43 #define CRAT_RESERVED_LENGTH 6 44 44 45 - #define CRAT_OEMID_64BIT_MASK ((1ULL << (CRAT_OEMID_LENGTH * 8)) - 1) 46 - 47 45 /* Compute Unit flags */ 48 46 #define COMPUTE_UNIT_CPU (1 << 0) /* Create Virtual CRAT for CPU */ 49 47 #define COMPUTE_UNIT_GPU (1 << 1) /* Create Virtual CRAT for GPU */
+1 -2
drivers/gpu/drm/amd/amdkfd/kfd_topology.c
··· 958 958 dev = list_last_entry(&topology_device_list, 959 959 struct kfd_topology_device, list); 960 960 if (dev) { 961 - sys_props.platform_id = 962 - (*((uint64_t *)dev->oem_id)) & CRAT_OEMID_64BIT_MASK; 961 + sys_props.platform_id = dev->oem_id64; 963 962 sys_props.platform_oem = *((uint64_t *)dev->oem_table_id); 964 963 sys_props.platform_rev = dev->oem_revision; 965 964 }
+4 -1
drivers/gpu/drm/amd/amdkfd/kfd_topology.h
··· 154 154 struct attribute attr_gpuid; 155 155 struct attribute attr_name; 156 156 struct attribute attr_props; 157 - uint8_t oem_id[CRAT_OEMID_LENGTH]; 157 + union { 158 + uint8_t oem_id[CRAT_OEMID_LENGTH]; 159 + uint64_t oem_id64; 160 + }; 158 161 uint8_t oem_table_id[CRAT_OEMTABLEID_LENGTH]; 159 162 uint32_t oem_revision; 160 163 };