Skip to contentSkip to conversation

drm/amdkfd: Fix the memory overrun

PATCH In review Ma Jun 3 participants 3 messages Nov 7, 2022 – Nov 19, 2022

Subsystems (3)
lore
Share & tools
lore

Ma Jun

author
#0 lore raw

PATCH 1/1 drm/amdkfd: Fix the memory overrun

Fix the memory overrun issue caused by wrong array size.

Addresses-Coverity-ID: 1527133 ("Memory - corruptions")

Fixes 6246000093863 ("drm/amdkfd: Fix the warning of array-index-out-of-bounds")
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -1
index 7029e3bdff3e..6e81f50ad912 100644
@@ -1111,7 +1111,7 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache,
 			props->cache_latency = cache->cache_latency;
 
 			memcpy(props->sibling_map, cache->sibling_map,
-					sizeof(props->sibling_map));
+					CRAT_SIBLINGMAP_SIZE);
 
 			/* set the sibling_map_size as 32 for CRAT from ACPI */
 			props->sibling_map_size = CRAT_SIBLINGMAP_SIZE;
Signature · 1 line
2.25.1
maintainer Reviewed-by on v1 1/1
#1 lore raw

Am 2022-11-07 um 02:08 schrieb Ma Jun:

Quoted 6 lines

Fix the memory overrun issue caused by wrong array size.

Addresses-Coverity-ID: 1527133 ("Memory - corruptions")

Fixes 6246000093863 ("drm/amdkfd: Fix the warning of array-index-out-of-bounds")
Quoted 17 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +1 -1
index 7029e3bdff3e..6e81f50ad912 100644
@@ -1111,7 +1111,7 @@ static int kfd_parse_subtype_cache(struct crat_subtype_cache *cache,
  			props->cache_latency = cache->cache_latency;
 
  			memcpy(props->sibling_map, cache->sibling_map,
-					sizeof(props->sibling_map));
+					CRAT_SIBLINGMAP_SIZE);
 
  			/* set the sibling_map_size as 32 for CRAT from ACPI */
  			props->sibling_map_size = CRAT_SIBLINGMAP_SIZE;