Commit 172e4ee2 authored by Felix Kuehling's avatar Felix Kuehling Committed by Alex Deucher

drm/amdkfd: Cleanup kfd_process if init_cwsr_apu fails

If init_cwsr_apu fails, we currently leave the kfd_process structure in
place anyway. The next kfd_open will then succeed, using the existing
kfd_process structure. Fix that by cleaning up the kfd_process after a
failure in init_cwsr_apu.
Signed-off-by: default avatarFelix Kuehling <Felix.Kuehling@amd.com>
Reviewed-by: default avatarPhilip Yang <philip.yang@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 3248b6d3
...@@ -775,10 +775,8 @@ struct kfd_process *kfd_create_process(struct file *filep) ...@@ -775,10 +775,8 @@ struct kfd_process *kfd_create_process(struct file *filep)
goto out; goto out;
ret = kfd_process_init_cwsr_apu(process, filep); ret = kfd_process_init_cwsr_apu(process, filep);
if (ret) { if (ret)
process = ERR_PTR(ret); goto out_destroy;
goto out;
}
if (!procfs.kobj) if (!procfs.kobj)
goto out; goto out;
...@@ -826,6 +824,14 @@ struct kfd_process *kfd_create_process(struct file *filep) ...@@ -826,6 +824,14 @@ struct kfd_process *kfd_create_process(struct file *filep)
mutex_unlock(&kfd_processes_mutex); mutex_unlock(&kfd_processes_mutex);
return process; return process;
out_destroy:
hash_del_rcu(&process->kfd_processes);
mutex_unlock(&kfd_processes_mutex);
synchronize_srcu(&kfd_processes_srcu);
/* kfd_process_free_notifier will trigger the cleanup */
mmu_notifier_put(&process->mmu_notifier);
return ERR_PTR(ret);
} }
struct kfd_process *kfd_get_process(const struct task_struct *thread) struct kfd_process *kfd_get_process(const struct task_struct *thread)
......
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