All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH][next] amd/amdgpu_ctx: Use struct_size() helper and kmalloc()
@ 2020-10-08 14:34 ` Gustavo A. R. Silva
  0 siblings, 0 replies; 18+ messages in thread
From: Gustavo A. R. Silva @ 2020-10-08 14:34 UTC (permalink / raw)
  To: Alex Deucher, Christian König, David Airlie, Daniel Vetter
  Cc: Gustavo A. R. Silva, linux-hardening, dri-devel, amd-gfx,
	linux-kernel

Make use of the new struct_size() helper instead of the offsetof() idiom.
Also, use kmalloc() instead of kcalloc().

Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org>
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
index c80d8339f58c..5be125f3b92a 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ctx.c
@@ -100,7 +100,7 @@ static int amdgpu_ctx_init_entity(struct amdgpu_ctx *ctx, u32 hw_ip,
 	enum drm_sched_priority priority;
 	int r;
 
-	entity = kcalloc(1, offsetof(typeof(*entity), fences[amdgpu_sched_jobs]),
+	entity = kmalloc(struct_size(entity, fences, amdgpu_sched_jobs),
 			 GFP_KERNEL);
 	if (!entity)
 		return  -ENOMEM;
-- 
2.27.0

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

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

end of thread, other threads:[~2020-10-09 14:34 UTC | newest]

Thread overview: 18+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2020-10-08 14:34 [PATCH][next] amd/amdgpu_ctx: Use struct_size() helper and kmalloc() Gustavo A. R. Silva
2020-10-08 14:34 ` Gustavo A. R. Silva
2020-10-08 14:34 ` Gustavo A. R. Silva
2020-10-08 17:22 ` Alex Deucher
2020-10-08 17:22   ` Alex Deucher
2020-10-08 17:22   ` Alex Deucher
2020-10-09  7:08 ` Christian König
2020-10-09  7:08   ` Christian König
2020-10-09  7:08   ` Christian König
2020-10-09 13:54   ` Gustavo A. R. Silva
2020-10-09 13:54     ` Gustavo A. R. Silva
2020-10-09 13:54     ` Gustavo A. R. Silva
2020-10-09 14:29     ` Christian König
2020-10-09 14:29       ` Christian König
2020-10-09 14:29       ` Christian König
2020-10-09 14:39       ` Gustavo A. R. Silva
2020-10-09 14:39         ` Gustavo A. R. Silva
2020-10-09 14:39         ` 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.