From: Arnd Bergmann <[email protected]>

clang-22 warns about possibly copying beyind the end of an array:

In file included from drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras_umc.c:24:
In file included from drivers/gpu/drm/amd/amdgpu/../ras/rascore/ras.h:27:
In file included from drivers/gpu/drm/amd/amdgpu/../ras/ras_mgr/ras_sys.h:29:
In file included from include/linux/string.h:386:
include/linux/fortify-string.h:569:4: error: call to '__write_overflow_field' 
declared with 'warning' attribute: detected write beyond size of field (1st 
parameter); maybe use struct_group()? [-Werror,-Wattribute-warning]
  569 |                         __write_overflow_field(p_size_field, size);
      |                         ^

As far as I can tell, this is a false-postive warning, but there is
an easy workaround, by using a direct struct assignment in place of
the memcpy.

Fixes: 7a3f9c0992c4 ("drm/amd/ras: Add umc common ras functions")
Signed-off-by: Arnd Bergmann <[email protected]>
---
 drivers/gpu/drm/amd/ras/rascore/ras_umc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c 
b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
index 23118f41eb96..fb426386b384 100644
--- a/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
+++ b/drivers/gpu/drm/amd/ras/rascore/ras_umc.c
@@ -290,7 +290,7 @@ static int ras_umc_get_new_records(struct ras_core_context 
*ras_core,
                if (!entries[i])
                        continue;
 
-               memcpy(&records[i], entries[i], sizeof(struct 
eeprom_umc_record));
+               records[i] = *entries[i];
                count++;
                radix_tree_tag_clear(&ras_umc->root,
                                entries[i]->cur_nps_retired_row_pfn, 
UMC_ECC_NEW_DETECTED_TAG);
-- 
2.39.5

Reply via email to