aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/amd/amdgpu
diff options
context:
space:
mode:
authorMirsad Todorovac <[email protected]>2024-12-17 22:58:10 +0000
committerAlex Deucher <[email protected]>2024-12-18 17:39:08 +0000
commita21ab06b8c2d8d25c4a83bdf39542834b1f3beae (patch)
tree64bc12279eb2aeee83e04611960514b7049e405c /drivers/gpu/drm/amd/amdgpu
parentdrm/amd/display: Fix NULL pointer dereference in dmub_tracebuffer_show (diff)
downloadkernel-a21ab06b8c2d8d25c4a83bdf39542834b1f3beae.tar.gz
kernel-a21ab06b8c2d8d25c4a83bdf39542834b1f3beae.zip
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: 84a2947ecc85 ("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]>
Diffstat (limited to 'drivers/gpu/drm/amd/amdgpu')
-rw-r--r--drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c4
1 files changed, 1 insertions, 3 deletions
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
index c704e9803e11..0af469ec6fcc 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_virt.c
@@ -1263,12 +1263,10 @@ static int amdgpu_virt_cache_host_error_counts(struct amdgpu_device *adev,
if (used_size > (AMD_SRIOV_RAS_TELEMETRY_SIZE_KB << 10))
return 0;
- tmp = kmalloc(used_size, GFP_KERNEL);
+ tmp = kmemdup(&host_telemetry->body.error_count, used_size, GFP_KERNEL);
if (!tmp)
return -ENOMEM;
- memcpy(tmp, &host_telemetry->body.error_count, used_size);
-
if (checksum != amd_sriov_msg_checksum(tmp, used_size, 0, 0))
goto out;