Commit 4ea64d48 authored by Eric Huang's avatar Eric Huang Committed by Alex Deucher
Browse files

drm/amdkfd: fix kernel crash on releasing NULL sysfs entry



there is an abnormal case that When a process re-opens kfd
with different mm_struct(execve() called by user), the
allocated p->kobj will be freed, but missed setting it to NULL,
that will cause sysfs/kernel crash with NULL pointers in p->kobj
on kfd_process_remove_sysfs() when releasing process, and the
similar error on kfd_procfs_del_queue() as well.

Signed-off-by: default avatarEric Huang <jinhuieric.huang@amd.com>
Reviewed-by: default avatarKent Russell <kent.russell@amd.com>
Signed-off-by: default avatarAlex Deucher <alexander.deucher@amd.com>
parent 964e532d
Loading
Loading
Loading
Loading
+2 −1
Original line number Diff line number Diff line
@@ -679,7 +679,7 @@ static void kfd_procfs_add_sysfs_files(struct kfd_process *p)

void kfd_procfs_del_queue(struct queue *q)
{
	if (!q)
	if (!q || !q->process->kobj)
		return;

	kobject_del(&q->kobj);
@@ -858,6 +858,7 @@ int kfd_create_process_sysfs(struct kfd_process *process)
	if (ret) {
		pr_warn("Creating procfs pid directory failed");
		kobject_put(process->kobj);
		process->kobj = NULL;
		return ret;
	}