All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] amdkfd: initialize svm lists at where they are defined
@ 2025-02-21  9:23 Zhu Lingshan
  2025-02-28  6:25 ` Zhu, Lingshan
  2025-03-04  5:49 ` Felix Kuehling
  0 siblings, 2 replies; 7+ messages in thread
From: Zhu Lingshan @ 2025-02-21  9:23 UTC (permalink / raw)
  To: Felix.Kuehling, alexander.deucher; +Cc: ray.huang, amd-gfx, Zhu Lingshan

This commit initialized svm lists at where they are
defined. This is defensive programing for security
and consistency.

Initalizing variables ensures that their states are
always valid, avoiding issues caused by
uninitialized variables that could lead to
unpredictable behaviros.

And we should not assume the callee would always
initialize them

Signed-off-by: Zhu Lingshan <lingshan.zhu@amd.com>
---
 drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index bd3e20d981e0..cbc997449379 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -2130,11 +2130,7 @@ svm_range_add(struct kfd_process *p, uint64_t start, uint64_t size,
 
 	pr_debug("svms 0x%p [0x%llx 0x%lx]\n", &p->svms, start, last);
 
-	INIT_LIST_HEAD(update_list);
-	INIT_LIST_HEAD(insert_list);
-	INIT_LIST_HEAD(remove_list);
 	INIT_LIST_HEAD(&new_list);
-	INIT_LIST_HEAD(remap_list);
 
 	node = interval_tree_iter_first(&svms->objects, start, last);
 	while (node) {
@@ -3635,6 +3631,11 @@ svm_range_set_attr(struct kfd_process *p, struct mm_struct *mm,
 	if (r)
 		return r;
 
+	INIT_LIST_HEAD(&update_list);
+	INIT_LIST_HEAD(&insert_list);
+	INIT_LIST_HEAD(&remove_list);
+	INIT_LIST_HEAD(&remap_list);
+
 	svms = &p->svms;
 
 	mutex_lock(&process_info->lock);
-- 
2.47.1


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

end of thread, other threads:[~2025-03-05 15:22 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-02-21  9:23 [PATCH] amdkfd: initialize svm lists at where they are defined Zhu Lingshan
2025-02-28  6:25 ` Zhu, Lingshan
2025-03-04  5:49 ` Felix Kuehling
2025-03-04  7:40   ` Zhu Lingshan
2025-03-04 15:16     ` Felix Kuehling
2025-03-05  3:11       ` Zhu Lingshan
2025-03-05 15:22         ` Felix Kuehling

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.