From patchwork Sat Nov 26 02:08:43 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Gonglei (Arei)" X-Patchwork-Id: 9448223 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id B25BD60778 for ; Sat, 26 Nov 2016 02:09:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 95E5627AB2 for ; Sat, 26 Nov 2016 02:09:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 8932027D85; Sat, 26 Nov 2016 02:09:32 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id D754B27AB2 for ; Sat, 26 Nov 2016 02:09:31 +0000 (UTC) Received: from localhost ([::1]:48804 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cASQj-000869-Lv for patchwork-qemu-devel@patchwork.kernel.org; Fri, 25 Nov 2016 21:09:29 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:39086) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1cASQR-00085r-DZ for qemu-devel@nongnu.org; Fri, 25 Nov 2016 21:09:12 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1cASQO-0005ZN-At for qemu-devel@nongnu.org; Fri, 25 Nov 2016 21:09:11 -0500 Received: from szxga02-in.huawei.com ([119.145.14.65]:4415) by eggs.gnu.org with esmtps (TLS1.0:RSA_ARCFOUR_SHA1:16) (Exim 4.71) (envelope-from ) id 1cASQN-0005Yc-OJ for qemu-devel@nongnu.org; Fri, 25 Nov 2016 21:09:08 -0500 Received: from 172.24.1.36 (EHLO szxeml430-hub.china.huawei.com) ([172.24.1.36]) by szxrg02-dlp.huawei.com (MOS 4.3.7-GA FastPath queued) with ESMTP id DRH22509; Sat, 26 Nov 2016 10:09:01 +0800 (CST) Received: from localhost (10.177.18.62) by szxeml430-hub.china.huawei.com (10.82.67.185) with Microsoft SMTP Server id 14.3.235.1; Sat, 26 Nov 2016 10:08:54 +0800 From: Gonglei To: Date: Sat, 26 Nov 2016 10:08:43 +0800 Message-ID: <1480126123-161960-1-git-send-email-arei.gonglei@huawei.com> X-Mailer: git-send-email 2.8.2.windows.1 MIME-Version: 1.0 X-Originating-IP: [10.177.18.62] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.4.x-2.6.x [generic] [fuzzy] X-Received-From: 119.145.14.65 Subject: [Qemu-devel] [PATCH] virtio-crypto: fix uninitialized variables X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Gonglei , mst@redhat.com Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP Though crypto_cfg.reserve is an unused field, let me initialize it 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 --- hw/virtio/virtio-crypto.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/hw/virtio/virtio-crypto.c b/hw/virtio/virtio-crypto.c index 847dc9d..a4cda19 100644 --- a/hw/virtio/virtio-crypto.c +++ b/hw/virtio/virtio-crypto.c @@ -856,6 +856,8 @@ static void virtio_crypto_get_config(VirtIODevice *vdev, uint8_t *config) stl_le_p(&crypto_cfg.max_cipher_key_len, c->conf.max_cipher_key_len); stl_le_p(&crypto_cfg.max_auth_key_len, c->conf.max_auth_key_len); stq_le_p(&crypto_cfg.max_size, c->conf.max_size); + /* Reserved field */ + crypto_cfg.reserve = 0; memcpy(config, &crypto_cfg, c->config_size); }