From: Zhu Lingshan <lingshan.zhu@amd.com>
To: <Felix.Kuehling@amd.com>, <alexander.deucher@amd.com>
Cc: <ray.huang@amd.com>, <amd-gfx@lists.freedesktop.org>,
Zhu Lingshan <lingshan.zhu@amd.com>
Subject: [PATCH] amdkfd: initialize svm lists at where they are defined
Date: Fri, 21 Feb 2025 17:23:55 +0800 [thread overview]
Message-ID: <20250221092355.336312-1-lingshan.zhu@amd.com> (raw)
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
next reply other threads:[~2025-02-21 9:24 UTC|newest]
Thread overview: 7+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-21 9:23 Zhu Lingshan [this message]
2025-02-28 6:25 ` [PATCH] amdkfd: initialize svm lists at where they are defined 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
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250221092355.336312-1-lingshan.zhu@amd.com \
--to=lingshan.zhu@amd.com \
--cc=Felix.Kuehling@amd.com \
--cc=alexander.deucher@amd.com \
--cc=amd-gfx@lists.freedesktop.org \
--cc=ray.huang@amd.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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.