Skip to content

Commit a72b69d

Browse files
stefanhaRHmstsirkin
authored andcommitted
vhost/vsock: fix uninitialized vhost_vsock->guest_cid
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>
1 parent ca2c5b3 commit a72b69d

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

drivers/vhost/vsock.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -518,6 +518,8 @@ static int vhost_vsock_dev_open(struct inode *inode, struct file *file)
518518
goto out;
519519
}
520520

521+
vsock->guest_cid = 0; /* no CID assigned yet */
522+
521523
atomic_set(&vsock->queued_replies, 0);
522524

523525
vqs[VSOCK_VQ_TX] = &vsock->vqs[VSOCK_VQ_TX];

0 commit comments

Comments
 (0)