drm/amd/ras: work around write overflow attribute warning
Subsystems (2)
PATCH 1/1 drm/amd/ras: work around write overflow attribute warning
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.
--- drivers/gpu/drm/amd/ras/rascore/ras_umc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/ras/rascore/ras_umc.c +1 -1
@@ -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 );
Signature · 1 line
2.39.5
Quoted 12 lines · Arnd Bergmann
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 fromdrivers/gpu/drm/amd/amdgpu/../ras/rascore/ras.h:27:
In file included fromdrivers/gpu/drm/amd/amdgpu/../ras/ras_mgr/ras_sys.h:29:
In file included frominclude/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 usestruct_group()? [-Werror,-Wattribute-warning]569 | __write_overflow_field(p_size_field, size); | ^
Quoted 6 lines
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]>
Yeah, direct assignment is much preferred anyway. :)
Signature · 1 line
Kees Cook