public inbox for linux-kernel-mentees@lists.linux-foundation.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/amdgpu: use kmalloc_array instead of kmalloc
@ 2025-09-22 18:56 Moktar SELLAMI
  2025-09-23 13:47 ` Alex Deucher
  0 siblings, 1 reply; 2+ messages in thread
From: Moktar SELLAMI @ 2025-09-22 18:56 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, airlied, simona,
	Hawking.Zhang, tao.zhou1, lijo.lazar, ganglxie, victor.skvortsov,
	candice.li, amd-gfx, dri-devel, linux-kernel,
	linux-kernel-mentees, skhan, david.hunter.linux
  Cc: Moktar SELLAMI

Replace kmalloc -> kmalloc_array in drm/amd/amdgpu/amdgpu_ras.c .

As per said in the Documentation/process/deprecated.rst, dynamic size
calculation should not be performed in memory allocator function
arguments due to the risk of overflow.

Signed-off-by: Moktar SELLAMI <smokthar925@gmail.com>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 540817e296da..8dbb9e349a8e 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -2566,7 +2566,7 @@ static int amdgpu_ras_badpages_read(struct amdgpu_device *adev,
 		goto out;
 	}
 
-	*bps = kmalloc(sizeof(struct ras_badpage) * data->count, GFP_KERNEL);
+	*bps = kmalloc_array(data->count, sizeof(struct ras_badpage), GFP_KERNEL);
 	if (!*bps) {
 		ret = -ENOMEM;
 		goto out;
-- 
2.34.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2025-09-23 13:47 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-09-22 18:56 [PATCH] drm/amd/amdgpu: use kmalloc_array instead of kmalloc Moktar SELLAMI
2025-09-23 13:47 ` Alex Deucher

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox