Skip to content

Commit cb38090

Browse files
keithbuschbonzini
authored andcommitted
vhost: return task creation error instead of NULL
Lets callers distinguish why the vhost task creation failed. No one currently cares why it failed, so no real runtime change from this patch, but that will not be the case for long. Signed-off-by: Keith Busch <[email protected]> Message-ID: <[email protected]> Reviewed-by: Mike Christie <[email protected]> Signed-off-by: Paolo Bonzini <[email protected]>
1 parent 982caaa commit cb38090

File tree

3 files changed

+4
-4
lines changed

3 files changed

+4
-4
lines changed

arch/x86/kvm/mmu/mmu.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -7471,7 +7471,7 @@ static void kvm_mmu_start_lpage_recovery(struct once *once)
74717471
kvm_nx_huge_page_recovery_worker_kill,
74727472
kvm, "kvm-nx-lpage-recovery");
74737473

7474-
if (!nx_thread)
7474+
if (IS_ERR(nx_thread))
74757475
return;
74767476

74777477
vhost_task_start(nx_thread);

drivers/vhost/vhost.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -666,7 +666,7 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev)
666666

667667
vtsk = vhost_task_create(vhost_run_work_list, vhost_worker_killed,
668668
worker, name);
669-
if (!vtsk)
669+
if (IS_ERR(vtsk))
670670
goto free_worker;
671671

672672
mutex_init(&worker->mutex);

kernel/vhost_task.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -133,7 +133,7 @@ struct vhost_task *vhost_task_create(bool (*fn)(void *),
133133

134134
vtsk = kzalloc(sizeof(*vtsk), GFP_KERNEL);
135135
if (!vtsk)
136-
return NULL;
136+
return ERR_PTR(-ENOMEM);
137137
init_completion(&vtsk->exited);
138138
mutex_init(&vtsk->exit_mutex);
139139
vtsk->data = arg;
@@ -145,7 +145,7 @@ struct vhost_task *vhost_task_create(bool (*fn)(void *),
145145
tsk = copy_process(NULL, 0, NUMA_NO_NODE, &args);
146146
if (IS_ERR(tsk)) {
147147
kfree(vtsk);
148-
return NULL;
148+
return ERR_PTR(PTR_ERR(tsk));
149149
}
150150

151151
vtsk->task = tsk;

0 commit comments

Comments
 (0)