From: Stefan Hajnoczi Subject: [PATCH] vhost/vsock: fix uninitialized vhost_vsock->guest_cid Date: Thu, 9 Nov 2017 13:29:10 +0000 Message-ID: <20171109132910.23150-1-stefanha@redhat.com> Cc: Peng Tao , "Michael S. Tsirkin" , Gao feng , virtualization@lists.linux-foundation.org, Stefan Hajnoczi To: kvm@vger.kernel.org Return-path: Received: from mx1.redhat.com ([209.132.183.28]:56860 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754268AbdKIN3S (ORCPT ); Thu, 9 Nov 2017 08:29:18 -0500 Sender: kvm-owner@vger.kernel.org List-ID: 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 --- drivers/vhost/vsock.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/vhost/vsock.c b/drivers/vhost/vsock.c index c9de9c41aa97..5a5e981bd8e4 100644 --- a/drivers/vhost/vsock.c +++ b/drivers/vhost/vsock.c @@ -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]; -- 2.13.6