Commit 82c16b42 authored by Yong Zhao's avatar Yong Zhao Committed by Oded Gabbay

drm/amdkfd: Return NULL if kfd_lookup_process_by_pasid fails

If no matching process is found, return NULL instead of a pointer
to the last process in the kfd_processes_table.
Signed-off-by: default avatarYong Zhao <yong.zhao@amd.com>
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
Signed-off-by: default avatarOded Gabbay <oded.gabbay@gmail.com>
parent abb208a8
...@@ -570,7 +570,7 @@ bool kfd_has_process_device_data(struct kfd_process *p) ...@@ -570,7 +570,7 @@ bool kfd_has_process_device_data(struct kfd_process *p)
/* This increments the process->ref counter. */ /* This increments the process->ref counter. */
struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid) struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid)
{ {
struct kfd_process *p; struct kfd_process *p, *ret_p = NULL;
unsigned int temp; unsigned int temp;
int idx = srcu_read_lock(&kfd_processes_srcu); int idx = srcu_read_lock(&kfd_processes_srcu);
...@@ -578,13 +578,14 @@ struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid) ...@@ -578,13 +578,14 @@ struct kfd_process *kfd_lookup_process_by_pasid(unsigned int pasid)
hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) { hash_for_each_rcu(kfd_processes_table, temp, p, kfd_processes) {
if (p->pasid == pasid) { if (p->pasid == pasid) {
kref_get(&p->ref); kref_get(&p->ref);
ret_p = p;
break; break;
} }
} }
srcu_read_unlock(&kfd_processes_srcu, idx); srcu_read_unlock(&kfd_processes_srcu, idx);
return p; return ret_p;
} }
int kfd_reserved_mem_mmap(struct kfd_process *process, int kfd_reserved_mem_mmap(struct kfd_process *process,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment