All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] gpu: drm: use struct_size() in kmalloc()
@ 2019-05-17  8:46 xiaolinkui
  2019-05-17 16:44 ` Pan, Xinhui
  2019-05-20 17:41   ` Alex Deucher
  0 siblings, 2 replies; 16+ 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 related	[flat|nested] 16+ messages in thread

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

Thread overview: 16+ 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
2019-05-17 16:44 ` Pan, Xinhui
2019-05-20 16:28   ` Daniel Vetter
2019-05-20 16:28     ` Daniel Vetter
2019-05-20 22:54     ` Pan, Xinhui
2019-05-20 23:19     ` 回复: " Pan, Xinhui
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  8:59             ` Christian König
2019-05-21 12:57             ` Gustavo A. R. Silva
2019-05-20 17:41 ` Alex Deucher
2019-05-20 17:41   ` Alex Deucher
2019-05-20 18:21   ` Gustavo A. R. Silva
2019-05-20 18:21     ` Gustavo A. R. Silva

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.