dm: fix NULL pointer dereference risk in vhost vsock
Pointer 'vsock->vhost_vsock' returned from call to function 'vhost_vsock_init' may be NULL and will be dereferenced when calling 'vhost_vsock_set_guest_cid()'. Tracked-On: #8439 Signed-off-by: Yonghua Huang <yonghua.huang@intel.com> Signed-off-by: Jiaqing Zhao <jiaqing.zhao@linux.intel.com> Reviewed-by: Jian Jun Chen <jian.jun.chen@intel.com>
This commit is contained in:
parent
89d11d91e2
commit
955703a95e
|
@ -298,14 +298,16 @@ virtio_vhost_vsock_init(struct vmctx *ctx, struct pci_vdev *dev, char *opts)
|
|||
virtio_set_modern_bar(&vsock->base, false);
|
||||
|
||||
vsock->vhost_vsock = vhost_vsock_init(&vsock->base, 0);
|
||||
if (!vsock->vhost_vsock) {
|
||||
pr_err("vhost vosck init failed.");
|
||||
free(vsock);
|
||||
return -1;
|
||||
}
|
||||
vhost_vsock_set_guest_cid(&vsock->vhost_vsock->vdev, vsock->config.guest_cid);
|
||||
|
||||
if (virtio_interrupt_init(&vsock->base, virtio_uses_msix())) {
|
||||
if (vsock) {
|
||||
if (vsock->vhost_vsock)
|
||||
vhost_vsock_deinit(vsock->vhost_vsock);
|
||||
free(vsock);
|
||||
}
|
||||
vhost_vsock_deinit(vsock->vhost_vsock);
|
||||
free(vsock);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
|
|
Loading…
Reference in New Issue