virtio-net: check the existence of peer before accessing vDPA config
authorJason Wang <jasowang@redhat.com>
Sat, 25 Jul 2020 00:13:17 +0000 (08:13 +0800)
committerJason Wang <jasowang@redhat.com>
Tue, 28 Jul 2020 08:57:58 +0000 (16:57 +0800)
commitc546ecf27da1114d0274abe600cc6bde6584e659
tree874f6c5c665a390968ea986138c7536256b9f079
parenta48aaf882b100b30111b5c7c75e1d9e83fe76cfd
virtio-net: check the existence of peer before accessing vDPA config

We try to check whether a peer is VDPA in order to get config from
there - with no peer, this leads to a NULL
pointer dereference. Add a check before trying to access the peer
type. No peer means not VDPA.

Fixes: 108a64818e69b ("vhost-vdpa: introduce vhost-vdpa backend")
Cc: Cindy Lu <lulu@redhat.com>
Tested-by: Cornelia Huck <cohuck@redhat.com>
Reviewed-by: Cornelia Huck <cohuck@redhat.com>
Signed-off-by: Jason Wang <jasowang@redhat.com>
hw/net/virtio-net.c