]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
vhost-scsi: Handle vhost_vq_work_queue failures for events
authorMike Christie <michael.christie@oracle.com>
Sat, 16 Mar 2024 00:46:59 +0000 (19:46 -0500)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 11 Jul 2024 10:51:21 +0000 (12:51 +0200)
commit36e493d2c3ab5de14578b264ba5fd1bfeff3757e
tree9c876cbc34658bb1db31deaa90517d3f54481654
parent53d5ac2566628941a2e2f2da791722b5b4c78f94
vhost-scsi: Handle vhost_vq_work_queue failures for events

[ Upstream commit b1b2ce58ed23c5d56e0ab299a5271ac01f95b75c ]

Currently, we can try to queue an event's work before the vhost_task is
created. When this happens we just drop it in vhost_scsi_do_plug before
even calling vhost_vq_work_queue. During a device shutdown we do the
same thing after vhost_scsi_clear_endpoint has cleared the backends.

In the next patches we will be able to kill the vhost_task before we
have cleared the endpoint. In that case, vhost_vq_work_queue can fail
and we will leak the event's memory. This has handle the failure by
just freeing the event. This is safe to do, because
vhost_vq_work_queue will only return failure for us when the vhost_task
is killed and so userspace will not be able to handle events if we
sent them.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Message-Id: <20240316004707.45557-2-michael.christie@oracle.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/vhost/scsi.c