Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

vhost: Fix kthread worker cgroup failure handling

If we fail to attach to a cgroup we are leaking the id. This adds
a new goto to free the id.

Fixes: 7d9896e9f6d0 ("vhost: Reintroduce kthread API and add mode selection")
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Acked-by: Jason Wang <jasowang@redhat.com>
Reviewed-by: Chaitanya Kulkarni <kch@nvidia.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Message-Id: <20251101194358.13605-1-michael.christie@oracle.com>

authored by

Mike Christie and committed by
Michael S. Tsirkin
f3f64c2e b41ca62c

+3 -1
+3 -1
drivers/vhost/vhost.c
··· 804 804 805 805 ret = vhost_attach_task_to_cgroups(worker); 806 806 if (ret) 807 - goto stop_worker; 807 + goto free_id; 808 808 809 809 worker->id = id; 810 810 return 0; 811 811 812 + free_id: 813 + xa_erase(&dev->worker_xa, id); 812 814 stop_worker: 813 815 vhost_kthread_do_stop(worker); 814 816 return ret;