From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:55613) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cCIWR-0007Eq-EH for qemu-devel@nongnu.org; Wed, 30 Nov 2016 22:59:00 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cCIWQ-0004Qu-DV for qemu-devel@nongnu.org; Wed, 30 Nov 2016 22:58:59 -0500 Received: from mail.kernel.org ([198.145.29.136]:58562) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1cCIWQ-0004Ql-7p for qemu-devel@nongnu.org; Wed, 30 Nov 2016 22:58:58 -0500 Date: Thu, 1 Dec 2016 05:58:54 +0200 From: "Michael S. Tsirkin" Message-ID: <1480564455-23933-6-git-send-email-mst@redhat.com> References: <1480564455-23933-1-git-send-email-mst@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1480564455-23933-1-git-send-email-mst@redhat.com> Subject: [Qemu-devel] [PULL 5/5] virtio-crypto: fix uninitialized variables List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: Peter Maydell , Stefan Hajnoczi , Gonglei , Markus Armbruster From: Gonglei Though crypto_cfg.reserve is an unused field, let me initialize the structure in order to make coverity happy. *** CID 1365923: Uninitialized variables (UNINIT) /hw/virtio/virtio-crypto.c: 851 in virtio_crypto_get_config() 845 stl_le_p(&crypto_cfg.mac_algo_h, c->conf.mac_algo_h); 846 stl_le_p(&crypto_cfg.aead_algo, c->conf.aead_algo); 847 stl_le_p(&crypto_cfg.max_cipher_key_len, c->conf.max_cipher_key_len); 848 stl_le_p(&crypto_cfg.max_auth_key_len, c->conf.max_auth_key_len); 849 stq_le_p(&crypto_cfg.max_size, c->conf.max_size); 850 >>> CID 1365923: Uninitialized variables (UNINIT) >>> Using uninitialized value "crypto_cfg". Field "crypto_cfg.reserve" is uninitialized when calling "memcpy". [Note: The source code implementation of the function has been overridden by a builtin model.] 851 memcpy(config, &crypto_cfg, c->config_size); 852 } 853 Rported-by: Markus Armbruster Signed-off-by: Gonglei Reviewed-by: Michael S. Tsirkin Signed-off-by: Michael S. Tsirkin --- hw/virtio/virtio-crypto.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 847dc9d..2f2467e 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -838,7 +838,7 @@ static Property virtio_crypto_properties[] = { static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config) { VirtIOCrypto *c = VIRTIO_CRYPTO(vdev); - struct virtio_crypto_config crypto_cfg; + struct virtio_crypto_config crypto_cfg = {}; /* * Virtio-crypto device conforms to VIRTIO 1.0 which is always LE, -- MST