amd-gfx.lists.freedesktop.org archive mirror
 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; 11+ 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] 11+ messages in thread

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

Thread overview: 11+ 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
     [not found]   ` <SN6PR12MB2800A7AEC22121C8704CBB09870B0-kxOKjb6HO/EqkY47FTA1ogdYzm3356FpvxpqHgZTriW3zl9H0oFU5g@public.gmane.org>
2019-05-20 16:28     ` Daniel Vetter
2019-05-20 22:54       ` Pan, Xinhui
     [not found]       ` <20190520162807.GE21222-dv86pmgwkMBes7Z6vYuT8azUEOm+Xw19@public.gmane.org>
2019-05-20 23:19         ` 回复: " Pan, Xinhui
2019-05-21  2:32           ` Alex Deucher
2019-05-21  7:23             ` Daniel Vetter
     [not found]               ` <CAKMK7uHS837L9Ze_K5q-AsFgOtAMD+n_i_Y404BX-_CwJeP08Q-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
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;
as well as URLs for NNTP newsgroup(s).