mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] drm/amdkfd: Remove the redundant NULL check for the 'svms' object
@ 2025-03-25 10:09 Ваторопин Андрей
  2025-03-25 16:32 ` Felix Kuehling
  0 siblings, 1 reply; 2+ messages in thread
From: Ваторопин Андрей @ 2025-03-25 10:09 UTC (permalink / raw)
  To: Felix Kuehling
  Cc: Ваторопин
	Андрей,
	Alex Deucher, Christian König, David Airlie, Simona Vetter,
	amd-gfx, dri-devel, linux-kernel, lvc-project

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

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

* Re: [PATCH] drm/amdkfd: Remove the redundant NULL check for the 'svms' object
  2025-03-25 10:09 [PATCH] drm/amdkfd: Remove the redundant NULL check for the 'svms' object Ваторопин Андрей
@ 2025-03-25 16:32 ` Felix Kuehling
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Kuehling @ 2025-03-25 16:32 UTC (permalink / raw)
  To: Ваторопин
	Андрей
  Cc: Alex Deucher, Christian König, David Airlie, Simona Vetter,
	amd-gfx, dri-devel, linux-kernel, lvc-project

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) {

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

end of thread, other threads:[~2025-03-25 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2025-03-25 10:09 [PATCH] drm/amdkfd: Remove the redundant NULL check for the 'svms' object Ваторопин Андрей
2025-03-25 16:32 ` Felix Kuehling

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®