From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mails.dpdk.org (mails.dpdk.org [217.70.189.124]) by inbox.dpdk.org (Postfix) with ESMTP id 92A99A055D for ; Fri, 19 Feb 2021 03:49:05 +0100 (CET) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 81E8B160841; Fri, 19 Feb 2021 03:49:05 +0100 (CET) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by mails.dpdk.org (Postfix) with ESMTP id 041D540042; Fri, 19 Feb 2021 03:49:02 +0100 (CET) IronPort-SDR: Ng+ZBRRNiYUzdZnMH5r9h6VeHmIJ/9C9PqkfXZ18+mNXaooaLOyR1CFp76bMGz5je7n+MViAr9 k1msxy0k3nJQ== X-IronPort-AV: E=McAfee;i="6000,8403,9899"; a="202986907" X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="202986907" Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga101.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Feb 2021 18:49:01 -0800 IronPort-SDR: z0UgN4IXI+i8SPyINvqtj29lkACQBWHCrY6uCeWwaqaJ4mfz23PB8dxc18bFqoJN7V5fwe8unr W0mhN0NbqCDA== X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.81,189,1610438400"; d="scan'208";a="362786453" Received: from npg-dpdk-virtio-xiachenbo-nw.sh.intel.com ([10.67.118.240]) by orsmga003.jf.intel.com with ESMTP; 18 Feb 2021 18:49:00 -0800 From: Chenbo Xia To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, stable@dpdk.org Date: Fri, 19 Feb 2021 10:40:11 +0800 Message-Id: <20210219024011.77233-1-chenbo.xia@intel.com> X-Mailer: git-send-email 2.17.1 Subject: [dpdk-stable] [PATCH] examples/vhost: fix unchecked return value X-BeenThere: stable@dpdk.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: patches for DPDK stable branches List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: stable-bounces@dpdk.org Sender: "stable" This patch fixes unchecked return value for rte_vhost_get_mem_table(), which is reported by coverity. Coverity issue: 364233 Fixes: ca059fa5e290 ("examples/vhost: demonstrate the new generic APIs") Cc: stable@dpdk.org Signed-off-by: Chenbo Xia --- examples/vhost/virtio_net.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/examples/vhost/virtio_net.c b/examples/vhost/virtio_net.c index 64bf3d19ff..9064fc3a82 100644 --- a/examples/vhost/virtio_net.c +++ b/examples/vhost/virtio_net.c @@ -23,6 +23,7 @@ vs_vhost_net_setup(struct vhost_dev *dev) uint16_t i; int vid = dev->vid; struct vhost_queue *queue; + int ret; RTE_LOG(INFO, VHOST_CONFIG, "setting builtin vhost-user net driver\n"); @@ -33,7 +34,12 @@ vs_vhost_net_setup(struct vhost_dev *dev) else dev->hdr_len = sizeof(struct virtio_net_hdr); - rte_vhost_get_mem_table(vid, &dev->mem); + ret = rte_vhost_get_mem_table(vid, &dev->mem); + if (ret < 0) { + RTE_LOG(ERR, VHOST_CONFIG, "Failed to get " + "VM memory layout for device(%d)\n", vid); + return; + } dev->nr_vrings = rte_vhost_get_vring_num(vid); for (i = 0; i < dev->nr_vrings; i++) { -- 2.17.1