Skip to content

Commit

Permalink
vhost/vsock: fix uninitialized vhost_vsock->guest_cid
Browse files Browse the repository at this point in the history
The vhost_vsock->guest_cid field is uninitialized when /dev/vhost-vsock
is opened until the VHOST_VSOCK_SET_GUEST_CID ioctl is called.

kvmalloc(..., GFP_KERNEL | __GFP_RETRY_MAYFAIL) does not zero memory.
All other vhost_vsock fields are initialized explicitly so just
initialize this field too.

Signed-off-by: Stefan Hajnoczi <stefanha@redhat.com>
Signed-off-by: Michael S. Tsirkin <mst@redhat.com>
  • Loading branch information
Stefan Hajnoczi authored and Michael S. Tsirkin committed Nov 14, 2017
1 parent ca2c5b3 commit a72b69d
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions drivers/vhost/vsock.c
Original file line number Diff line number Diff line change
Expand Up @@ -518,6 +518,8 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file)
goto out;
}

vsock->guest_cid = 0; /* no CID assigned yet */

atomic_set(&vsock->queued_replies, 0);

vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX];
Expand Down

0 comments on commit a72b69d

Please sign in to comment.