drm/amdkfd: Change svm_range_get_info return type
authorAndrey Vatoropin <a.vatoropin@crpt.ru>
Wed, 2 Apr 2025 14:12:25 +0000 (14:12 +0000)
committerAlex Deucher <alexander.deucher@amd.com>
Thu, 22 May 2025 16:00:30 +0000 (12:00 -0400)
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.

In the function svm_range_get_info() there is no possibility of failure.
Therefore, the caller of the function svm_range_get_info() does not need
a return value. Change the function svm_range_get_info() return type from
"int" to "void".

Since the function svm_range_get_info() has a return type of "void". The
caller of the function svm_range_get_info() does not need a return value.
Delete extra code.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Andrey Vatoropin <a.vatoropin@crpt.ru>
Signed-off-by: Felix Kuehling <felix.kuehling@amd.com>
Reviewed-by: Felix Kuehling <felix.kuehling@amd.com>
Signed-off-by: Alex Deucher <alexander.deucher@amd.com>
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
drivers/gpu/drm/amd/amdkfd/kfd_svm.h

index 1e9dd00620bf4104a8ab0354656fc0db07d618f6..a2149afa5803e2fe4f0320315848ff1d9a7e038c 100644 (file)
@@ -2039,9 +2039,7 @@ static int criu_get_process_object_info(struct kfd_process *p,
 
        num_events = kfd_get_num_events(p);
 
-       ret = svm_range_get_info(p, &num_svm_ranges, &svm_priv_data_size);
-       if (ret)
-               return ret;
+       svm_range_get_info(p, &num_svm_ranges, &svm_priv_data_size);
 
        *num_objects = num_queues + num_events + num_svm_ranges;
 
index 72be6e152e881e6475ec9a9fe4c9b6a52270e76b..865dca2547de5b6557925a2d2411dff8a3d65898 100644 (file)
@@ -4075,8 +4075,8 @@ exit:
        return ret;
 }
 
-int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
-                      uint64_t *svm_priv_data_size)
+void svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
+                       uint64_t *svm_priv_data_size)
 {
        uint64_t total_size, accessibility_size, common_attr_size;
        int nattr_common = 4, nattr_accessibility = 1;
@@ -4088,8 +4088,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) {
@@ -4131,7 +4129,6 @@ int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
 
        pr_debug("num_svm_ranges %u total_priv_size %llu\n", *num_svm_ranges,
                 *svm_priv_data_size);
-       return 0;
 }
 
 int kfd_criu_checkpoint_svm(struct kfd_process *p,
@@ -4148,8 +4145,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) {
index 6ea23c78009ce1b0a3a2c9b6647f56e991cc5049..01c7a487790444ef6451c255f43935b6a2a61915 100644 (file)
@@ -184,8 +184,8 @@ void schedule_deferred_list_work(struct svm_range_list *svms);
 void svm_range_dma_unmap_dev(struct device *dev, dma_addr_t *dma_addr,
                         unsigned long offset, unsigned long npages);
 void svm_range_dma_unmap(struct svm_range *prange);
-int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
-                      uint64_t *svm_priv_data_size);
+void svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges,
+                       uint64_t *svm_priv_data_size);
 int kfd_criu_checkpoint_svm(struct kfd_process *p,
                            uint8_t __user *user_priv_data,
                            uint64_t *priv_offset);
@@ -237,13 +237,12 @@ static inline int svm_range_schedule_evict_svm_bo(
        return -EINVAL;
 }
 
-static inline int svm_range_get_info(struct kfd_process *p,
-                                    uint32_t *num_svm_ranges,
-                                    uint64_t *svm_priv_data_size)
+static inline void svm_range_get_info(struct kfd_process *p,
+                                     uint32_t *num_svm_ranges,
+                                     uint64_t *svm_priv_data_size)
 {
        *num_svm_ranges = 0;
        *svm_priv_data_size = 0;
-       return 0;
 }
 
 static inline int kfd_criu_checkpoint_svm(struct kfd_process *p,