drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ---- 1 file changed, 4 deletions(-)
From: Andrey Vatoropin <a.vatoropin@crpt.ru>
Static analysis shows that pointer "svms" cannot be NULL because it points
to the object "struct svm_range_list".
Remove the extra NULL check. It is meaningless and harms the readability
of the code.
Found by Linux Verification Center (linuxtesting.org) with SVACE.
Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
---
drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ----
1 file changed, 4 deletions(-)
diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
index bd3e20d981e0..9f0c6b623176 100644
--- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
+++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
@@ -4089,8 +4089,6 @@ int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
*svm_priv_data_size = 0;
svms = &p->svms;
- if (!svms)
- return -EINVAL;
mutex_lock(&svms->lock);
list_for_each_entry(prange, &svms->list, list) {
@@ -4149,8 +4147,6 @@ int kfd_criu_checkpoint_svm(struct kfd_process *p,
struct mm_struct *mm;
svms = &p->svms;
- if (!svms)
- return -EINVAL;
mm = get_task_mm(p->lead_thread);
if (!mm) {
--
2.43.0
On 2025-03-25 3:09, Ваторопин Андрей wrote:
> From: Andrey Vatoropin <a.vatoropin@crpt.ru>
>
> Static analysis shows that pointer "svms" cannot be NULL because it points
> to the object "struct svm_range_list".
>
> Remove the extra NULL check. It is meaningless and harms the readability
> of the code.
>
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
> ---
> drivers/gpu/drm/amd/amdkfd/kfd_svm.c | 4 ----
> 1 file changed, 4 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> index bd3e20d981e0..9f0c6b623176 100644
> --- a/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> +++ b/drivers/gpu/drm/amd/amdkfd/kfd_svm.c
> @@ -4089,8 +4089,6 @@ int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
> *svm_priv_data_size = 0;
>
> svms = &p->svms;
> - if (!svms)
> - return -EINVAL;
Thank you, I agree with the patch. You could improve it further, though. This was the only way this function could fail. Therefore you could make this function a void function and remove the error handling in the caller.
Regards,
Felix
>
> mutex_lock(&svms->lock);
> list_for_each_entry(prange, &svms->list, list) {
> @@ -4149,8 +4147,6 @@ int kfd_criu_checkpoint_svm(struct kfd_process *p,
> struct mm_struct *mm;
>
> svms = &p->svms;
> - if (!svms)
> - return -EINVAL;
>
> mm = get_task_mm(p->lead_thread);
> if (!mm) {
© 2016 - 2025 Red Hat, Inc.