mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] gpu: drm: use struct_size() in kmalloc()
@ 2019-05-17  8:46 xiaolinkui
       [not found] ` <SN6PR12MB2800A7AEC22121C8704CBB09870B0@SN6PR12MB2800.namprd12.prod.outlook.com>
  2019-05-20 17:41 ` Alex Deucher
  0 siblings, 2 replies; 9+ messages in thread
From: xiaolinkui @ 2019-05-17  8:46 UTC (permalink / raw)
  To: alexander.deucher, christian.koenig, David1.Zhou, airlied,
	daniel, xinhui.pan, evan.quan
  Cc: amd-gfx, dri-devel, linux-kernel, xiaolinkui

Use struct_size() helper to keep code simple.

Signed-off-by: xiaolinkui <xiaolinkui@kylinos.cn>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
index 22bd21e..4717a64 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ras.c
@@ -1375,8 +1375,7 @@ int amdgpu_ras_init(struct amdgpu_device *adev)
 	if (con)
 		return 0;
 
-	con = kmalloc(sizeof(struct amdgpu_ras) +
-			sizeof(struct ras_manager) * AMDGPU_RAS_BLOCK_COUNT,
+	con = kmalloc(struct_size(con, objs, AMDGPU_RAS_BLOCK_COUNT),
 			GFP_KERNEL|__GFP_ZERO);
 	if (!con)
 		return -ENOMEM;
-- 
2.7.4




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

end of thread, other threads:[~2019-05-21 13:22 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-05-17  8:46 [PATCH] gpu: drm: use struct_size() in kmalloc() xiaolinkui
     [not found] ` <SN6PR12MB2800A7AEC22121C8704CBB09870B0@SN6PR12MB2800.namprd12.prod.outlook.com>
2019-05-20 16:28   ` Daniel Vetter
2019-05-20 23:19     ` 回复: " Pan, Xinhui
2019-05-21  2:32       ` Alex Deucher
2019-05-21  7:23         ` Daniel Vetter
2019-05-21  8:59           ` Christian König
2019-05-21 12:57             ` Gustavo A. R. Silva
2019-05-20 17:41 ` Alex Deucher
2019-05-20 18:21   ` Gustavo A. R. Silva

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

all inboxes | Powered by JetHome®