]> git.ipfire.org Git - thirdparty/kernel/stable.git/commitdiff
vhost: Fix kthread worker cgroup failure handling
authorMike Christie <michael.christie@oracle.com>
Sat, 1 Nov 2025 19:43:58 +0000 (14:43 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 18 Dec 2025 13:03:24 +0000 (14:03 +0100)
[ Upstream commit f3f64c2eaffbc3169bbe1e5d1e897e6dacc839d1 ]

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>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vhost/vhost.c

index a78226b37739d7b8ceb188ecd23edaf68e7ef11d..bccdc9eab267a7e4b03f9b4d5f0897f11fa9ba4e 100644 (file)
@@ -804,11 +804,13 @@ static int vhost_kthread_worker_create(struct vhost_worker *worker,
 
        ret = vhost_attach_task_to_cgroups(worker);
        if (ret)
-               goto stop_worker;
+               goto free_id;
 
        worker->id = id;
        return 0;
 
+free_id:
+       xa_erase(&dev->worker_xa, id);
 stop_worker:
        vhost_kthread_do_stop(worker);
        return ret;