drm/amdkfd: Fix the memory overrun
authorMa Jun <Jun.Ma2@amd.com>
Sun, 6 Nov 2022 12:34:27 +0000 (20:34 +0800)
committerAlex Deucher <alexander.deucher@amd.com>
Wed, 9 Nov 2022 22:41:41 +0000 (17:41 -0500)
Fix the memory overrun issue caused by wrong array size.

Signed-off-by: Ma Jun <Jun.Ma2@amd.com>
Reviewed-by: Felix Kuehling <Felix.Kuehling@amd.com>
Reported-by: coverity-bot <keescook+coverity-bot@chromium.org>
Addresses-Coverity-ID: 1527133 ("Memory - corruptions")
Fixes: c0cc999f3c32e6 ("drm/amdkfd: Fix the warning of array-index-out-of-bounds")
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_crat.c

index 267dd69..af01ba0 100644 (file)
@@ -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;