[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <cd965916-b1cb-4911-ba66-155e9eba0234@amd.com>
Date: Tue, 25 Mar 2025 09:32:59 -0700
From: Felix Kuehling <felix.kuehling@....com>
To: Ваторопин Андрей
<a.vatoropin@...t.ru>
Cc: Alex Deucher <alexander.deucher@....com>,
Christian König <christian.koenig@....com>,
David Airlie <airlied@...il.com>, Simona Vetter <simona@...ll.ch>,
"amd-gfx@...ts.freedesktop.org" <amd-gfx@...ts.freedesktop.org>,
"dri-devel@...ts.freedesktop.org" <dri-devel@...ts.freedesktop.org>,
"linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
"lvc-project@...uxtesting.org" <lvc-project@...uxtesting.org>
Subject: Re: [PATCH] drm/amdkfd: Remove the redundant NULL check for the
'svms' object
On 2025-03-25 3:09, Ваторопин Андрей wrote:
> From: Andrey Vatoropin <a.vatoropin@...t.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@...t.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) {
Powered by blists - more mailing lists