Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

drm/amdkfd: Change svm_range_get_info return type

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>

authored by

Andrey Vatoropin and committed by
Alex Deucher
eed6a6b2 c4f8ac09

+8 -16
+1 -3
drivers/gpu/drm/amd/amdkfd/kfd_chardev.c
··· 2039 2039 2040 2040 num_events = kfd_get_num_events(p); 2041 2041 2042 - ret = svm_range_get_info(p, &num_svm_ranges, &svm_priv_data_size); 2043 - if (ret) 2044 - return ret; 2042 + svm_range_get_info(p, &num_svm_ranges, &svm_priv_data_size); 2045 2043 2046 2044 *num_objects = num_queues + num_events + num_svm_ranges; 2047 2045
+2 -7
drivers/gpu/drm/amd/amdkfd/kfd_svm.c
··· 4075 4075 return ret; 4076 4076 } 4077 4077 4078 - int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges, 4079 - uint64_t *svm_priv_data_size) 4078 + void svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges, 4079 + uint64_t *svm_priv_data_size) 4080 4080 { 4081 4081 uint64_t total_size, accessibility_size, common_attr_size; 4082 4082 int nattr_common = 4, nattr_accessibility = 1; ··· 4088 4088 *svm_priv_data_size = 0; 4089 4089 4090 4090 svms = &p->svms; 4091 - if (!svms) 4092 - return -EINVAL; 4093 4091 4094 4092 mutex_lock(&svms->lock); 4095 4093 list_for_each_entry(prange, &svms->list, list) { ··· 4129 4131 4130 4132 pr_debug("num_svm_ranges %u total_priv_size %llu\n", *num_svm_ranges, 4131 4133 *svm_priv_data_size); 4132 - return 0; 4133 4134 } 4134 4135 4135 4136 int kfd_criu_checkpoint_svm(struct kfd_process *p, ··· 4145 4148 struct mm_struct *mm; 4146 4149 4147 4150 svms = &p->svms; 4148 - if (!svms) 4149 - return -EINVAL; 4150 4151 4151 4152 mm = get_task_mm(p->lead_thread); 4152 4153 if (!mm) {
+5 -6
drivers/gpu/drm/amd/amdkfd/kfd_svm.h
··· 184 184 void svm_range_dma_unmap_dev(struct device *dev, dma_addr_t *dma_addr, 185 185 unsigned long offset, unsigned long npages); 186 186 void svm_range_dma_unmap(struct svm_range *prange); 187 - int svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges, 188 - uint64_t *svm_priv_data_size); 187 + void svm_range_get_info(struct kfd_process *p, uint32_t *num_svm_ranges, 188 + uint64_t *svm_priv_data_size); 189 189 int kfd_criu_checkpoint_svm(struct kfd_process *p, 190 190 uint8_t __user *user_priv_data, 191 191 uint64_t *priv_offset); ··· 237 237 return -EINVAL; 238 238 } 239 239 240 - static inline int svm_range_get_info(struct kfd_process *p, 241 - uint32_t *num_svm_ranges, 242 - uint64_t *svm_priv_data_size) 240 + static inline void svm_range_get_info(struct kfd_process *p, 241 + uint32_t *num_svm_ranges, 242 + uint64_t *svm_priv_data_size) 243 243 { 244 244 *num_svm_ranges = 0; 245 245 *svm_priv_data_size = 0; 246 - return 0; 247 246 } 248 247 249 248 static inline int kfd_criu_checkpoint_svm(struct kfd_process *p,