From patchwork Wed Apr 7 03:25:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Marvin Liu X-Patchwork-Id: 90759 X-Patchwork-Delegate: maxime.coquelin@redhat.com Return-Path: X-Original-To: patchwork@inbox.dpdk.org Delivered-To: patchwork@inbox.dpdk.org Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 0358EA0546; Wed, 7 Apr 2021 05:26:50 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 861CA140F8B; Wed, 7 Apr 2021 05:26:50 +0200 (CEST) Received: from mga06.intel.com (mga06.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 432EF407FF; Wed, 7 Apr 2021 05:26:48 +0200 (CEST) IronPort-SDR: V+8jJOMOYAZRA6uj7ughipZd2+tsbfNnwiUODdKsUWtZ5kK3AkT2t2+MjAO919sMWWYdyzC7gk XI9C8dT/dr7w== X-IronPort-AV: E=McAfee;i="6000,8403,9946"; a="254545009" X-IronPort-AV: E=Sophos;i="5.82,201,1613462400"; d="scan'208";a="254545009" Received: from fmsmga008.fm.intel.com ([10.253.24.58]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 06 Apr 2021 20:26:46 -0700 IronPort-SDR: trpSWUM5pHUyeMspcPxUVdEKzl2ER7JMpnRNZVO4wvEHWDDlzIu5hsc1IhETS9o2JSEZ24M37N 8TAKoUnWWCAA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.82,201,1613462400"; d="scan'208";a="415076134" Received: from npg-dpdk-virtual-marvin-dev.sh.intel.com ([10.67.119.108]) by fmsmga008.fm.intel.com with ESMTP; 06 Apr 2021 20:26:45 -0700 From: Marvin Liu To: maxime.coquelin@redhat.com, chenbo.xia@intel.com Cc: dev@dpdk.org, Marvin Liu , stable@dpdk.org Date: Wed, 7 Apr 2021 11:25:15 +0800 Message-Id: <20210407032516.79091-1-yong.liu@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-dev] [PATCH 1/2] vhost: fix accessing uninitialized variables X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dev-bounces@dpdk.org Sender: "dev" This patch fixs coverity issue by adding initialization step before using temporary virtio header. Coverity issue: 366181 Fixes: fb3815cc614d ("vhost: handle virtually non-contiguous buffers in Rx-mrg") Cc: stable@dpdk.org Signed-off-by: Marvin Liu Reviewed-by: Maxime Coquelin diff --git a/lib/librte_vhost/virtio_net.c b/lib/librte_vhost/virtio_net.c index 7f621fb6dd..48b013a9b4 100644 --- a/lib/librte_vhost/virtio_net.c +++ b/lib/librte_vhost/virtio_net.c @@ -812,9 +812,10 @@ copy_mbuf_to_desc(struct virtio_net *dev, struct vhost_virtqueue *vq, hdr_mbuf = m; hdr_addr = buf_addr; - if (unlikely(buf_len < dev->vhost_hlen)) + if (unlikely(buf_len < dev->vhost_hlen)) { + memset(&tmp_hdr, 0, sizeof(struct virtio_net_hdr_mrg_rxbuf)); hdr = &tmp_hdr; - else + } else hdr = (struct virtio_net_hdr_mrg_rxbuf *)(uintptr_t)hdr_addr; VHOST_LOG_DATA(DEBUG, "(%d) RX: num merge buffers %d\n",