Skip to content

Commit

Permalink
vhost: return task creation error instead of NULL
Browse files Browse the repository at this point in the history
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 <kbusch@kernel.org>
Message-ID: <20250227230631.303431-2-kbusch@meta.com>
Reviewed-by: Mike Christie <michael.christie@oracle.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
  • Loading branch information
Keith Busch authored and Paolo Bonzini committed Mar 1, 2025
1 parent 982caaa commit cb38090
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion arch/x86/kvm/mmu/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -7471,7 +7471,7 @@ static void kvm_mmu_start_lpage_recovery(struct once *once)
kvm_nx_huge_page_recovery_worker_kill,
kvm, "kvm-nx-lpage-recovery");

if (!nx_thread)
if (IS_ERR(nx_thread))
return;

vhost_task_start(nx_thread);
Expand Down
2 changes: 1 addition & 1 deletion drivers/vhost/vhost.c
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,7 @@ static struct vhost_worker *vhost_worker_create(struct vhost_dev *dev)

vtsk = vhost_task_create(vhost_run_work_list, vhost_worker_killed,
worker, name);
if (!vtsk)
if (IS_ERR(vtsk))
goto free_worker;

mutex_init(&worker->mutex);
Expand Down
4 changes: 2 additions & 2 deletions kernel/vhost_task.c
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ struct vhost_task *vhost_task_create(bool (*fn)(void *),

vtsk = kzalloc(sizeof(*vtsk), GFP_KERNEL);
if (!vtsk)
return NULL;
return ERR_PTR(-ENOMEM);
init_completion(&vtsk->exited);
mutex_init(&vtsk->exit_mutex);
vtsk->data = arg;
Expand All @@ -145,7 +145,7 @@ struct vhost_task *vhost_task_create(bool (*fn)(void *),
tsk = copy_process(NULL, 0, NUMA_NO_NODE, &args);
if (IS_ERR(tsk)) {
kfree(vtsk);
return NULL;
return ERR_PTR(PTR_ERR(tsk));
}

vtsk->task = tsk;
Expand Down

0 comments on commit cb38090

Please sign in to comment.