Skip to content

Commit a21ab06

Browse files
Mirsad Todorovacalexdeucher
authored andcommitted
drm/admgpu: replace kmalloc() and memcpy() with kmemdup()
The static analyser tool gave the following advice: ./drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c:1266:7-14: WARNING opportunity for kmemdup → 1266 tmp = kmalloc(used_size, GFP_KERNEL); 1267 if (!tmp) 1268 return -ENOMEM; 1269 → 1270 memcpy(tmp, &host_telemetry->body.error_count, used_size); Replacing kmalloc() + memcpy() with kmemdump() doesn't change semantics. Original code works without fault, so this is not a bug fix but proposed improvement. Link: https://lwn.net/Articles/198928/ Fixes: 84a2947 ("drm/amdgpu: Implement virt req_ras_err_count") Cc: Alex Deucher <[email protected]> Cc: "Christian König" <[email protected]> Cc: Xinhui Pan <[email protected]> Cc: David Airlie <[email protected]> Cc: Simona Vetter <[email protected]> Cc: Zhigang Luo <[email protected]> Cc: Victor Skvortsov <[email protected]> Cc: Hawking Zhang <[email protected]> Cc: Lijo Lazar <[email protected]> Cc: Yunxiang Li <[email protected]> Cc: Jack Xiao <[email protected]> Cc: Vignesh Chander <[email protected]> Cc: Danijel Slivka <[email protected]> Cc: [email protected] Cc: [email protected] Cc: [email protected] Reviewed-by: Lijo Lazar <[email protected]> Signed-off-by: Mirsad Todorovac <[email protected]> Signed-off-by: Alex Deucher <[email protected]>
1 parent b64f2f3 commit a21ab06

File tree

1 file changed

+1
-3
lines changed

1 file changed

+1
-3
lines changed

drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1263,12 +1263,10 @@ static int amdgpu_virt_cache_host_error_counts(struct amdgpu_device *adev,
12631263
if (used_size > (AMD_SRIOV_RAS_TELEMETRY_SIZE_KB << 10))
12641264
return 0;
12651265

1266-
tmp = kmalloc(used_size, GFP_KERNEL);
1266+
tmp = kmemdup(&host_telemetry->body.error_count, used_size, GFP_KERNEL);
12671267
if (!tmp)
12681268
return -ENOMEM;
12691269

1270-
memcpy(tmp, &host_telemetry->body.error_count, used_size);
1271-
12721270
if (checksum != amd_sriov_msg_checksum(tmp, used_size, 0, 0))
12731271
goto out;
12741272

0 commit comments

Comments
 (0)