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)
committerMichael S. Tsirkin <mst@redhat.com>
Wed, 22 May 2024 12:31:15 +0000 (08:31 -0400)
commitb1b2ce58ed23c5d56e0ab299a5271ac01f95b75c
tree40a9175d8907d5cc071921e3d682ed8014c27240
parent7b1b5c7fff05bdf2dc21ee124907df1f8cc819ad
vhost-scsi: Handle vhost_vq_work_queue failures for events

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>
drivers/vhost/scsi.c