Skip to contentSkip to conversation

drm/amdkfd: convert CRIU event-private allocation to kvcalloc()

PATCH In review William Theesfeld 2 participants 2 messages Jun 1 – Jun 3

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/amdkfd: convert CRIU event-private allocation to kvcalloc()

criu_checkpoint_events() allocates the ev_privs[] array, sized by the runtime count returned from kfd_get_num_events(), using the open-coded kvzalloc(n * sizeof(*p), ...) form. Switch to kvcalloc(), which carries the same zero-on-allocation semantics and adds the standard size_mul overflow check on the n * sizeof multiplication.

No functional change.

---
 drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -1
index 44150a71f..9739214e2 100644
@@ -543,7 +543,7 @@ int kfd_criu_checkpoint_events(struct kfd_process *p,
 	if (!num_events)
 		return 0;
 
-	ev_privs = kvzalloc(num_events * sizeof(*ev_privs), GFP_KERNEL);
+	ev_privs = kvcalloc(num_events, sizeof(*ev_privs), GFP_KERNEL);
 	if (!ev_privs)
 		return -ENOMEM;
 
Signature · 1 line
2.54.0
maintainer Reviewed-by on v1 1/1
#1 lore raw
Quoted 11 lines · William Theesfeld

[You don't often get email from [email protected]. Learn why this is important at https://aka.ms/LearnAboutSenderIdentification ]

criu_checkpoint_events() allocates the ev_privs[] array, sized by the runtime count returned from kfd_get_num_events(), using the open-coded kvzalloc(n * sizeof(*p), ...) form. Switch to kvcalloc(), which carries the same zero-on-allocation semantics and adds the standard size_mul overflow check on the n * sizeof multiplication.

No functional change.

Quoted 20 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_events.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/amdkfd/kfd_events.c +1 -2
index 44150a71f..9739214e2 100644
@@ -543,7 +543,7 @@ int kfd_criu_checkpoint_events(struct kfd_process *p,
         if (!num_events)
                 return 0;
 
-       ev_privs = kvzalloc(num_events * sizeof(*ev_privs), GFP_KERNEL);
+       ev_privs = kvcalloc(num_events, sizeof(*ev_privs), GFP_KERNEL);
         if (!ev_privs)
                 return -ENOMEM;
 
--

2.54.0