On 11/5/26 11:48 PM, Yuho Choi wrote: > vhost_scsi_clear_endpoint() checks every virtqueue with vhost_vq_access_ok() > before disabling the backends and waiting for in-flight SCSI commands. If > that check fails, endpoint teardown is skipped. vhost_scsi_release() ignores > the error and > > > vhost_scsi_clear_endpoint() checks every virtqueue with > vhost_vq_access_ok() before disabling the backends and waiting for > in-flight SCSI commands. If that check fails, endpoint teardown is > skipped. > > vhost_scsi_release() ignores the error and frees the vhost-scsi state. > vhost_dev_stop() drains vhost work, but it does not wait for commands > owned by the target core. A later command or TMF completion can therefore > dereference its saved virtqueue pointer after the virtqueue has been freed. > > Vring access is not a prerequisite for tearing an endpoint down. Remove > the check so teardown always disables the backends and waits for in-flight > commands before releasing their state. > Can you describe the bug a little more?
If we have done vhost_scsi_set_endpoint successfully, are you saying a later call to vhost_scsi_clear_endpoint could fail the vhost_vq_access_ok check and not teardown the endpoint? Or are you saying that even if we never did vhost_scsi_set_endpoint then when vhost_scsi_release is called, a command could be running in the vhost-scsi driver and so we need to do something? Is the something a "vhost_vq_set_backend(vq, NULL)" and vhost_scsi_flush(vs)?
