mirror of
https://github.com/Motorhead1991/qemu.git
synced 2025-08-02 23:33:54 -06:00
virtio: Allow .get_vhost() without vhost_started
Historically, .get_vhost() was probably only called when vdev->vhost_started is true. However, we now decidedly want to call it also when vhost_started is false, specifically so we can issue a reset to the vhost back-end while device operation is stopped. Some .get_vhost() implementations dereference some pointers (or return offsets from them) that are probably guaranteed to be non-NULL when vhost_started is true, but not necessarily otherwise. This patch makes all such implementations check all such pointers, returning NULL if any is NULL. Signed-off-by: Hanna Czenczek <hreitz@redhat.com> Message-Id: <20240723163941.48775-2-hreitz@redhat.com> Reviewed-by: Michael S. Tsirkin <mst@redhat.com> Signed-off-by: Michael S. Tsirkin <mst@redhat.com> Reviewed-by: Stefan Hajnoczi <stefanha@redhat.com>
This commit is contained in:
parent
a66f28df65
commit
00adced5c3
4 changed files with 34 additions and 6 deletions
|
@ -1247,9 +1247,21 @@ static bool virtio_crypto_guest_notifier_pending(VirtIODevice *vdev, int idx)
|
|||
static struct vhost_dev *virtio_crypto_get_vhost(VirtIODevice *vdev)
|
||||
{
|
||||
VirtIOCrypto *vcrypto = VIRTIO_CRYPTO(vdev);
|
||||
CryptoDevBackend *b = vcrypto->cryptodev;
|
||||
CryptoDevBackendClient *cc = b->conf.peers.ccs[0];
|
||||
CryptoDevBackendVhost *vhost_crypto = cryptodev_get_vhost(cc, b, 0);
|
||||
CryptoDevBackend *b;
|
||||
CryptoDevBackendClient *cc;
|
||||
CryptoDevBackendVhost *vhost_crypto;
|
||||
|
||||
b = vcrypto->cryptodev;
|
||||
if (!b) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
cc = b->conf.peers.ccs[0];
|
||||
vhost_crypto = cryptodev_get_vhost(cc, b, 0);
|
||||
if (!vhost_crypto) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return &vhost_crypto->dev;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue