From patchwork Thu Jun 23 01:08:58 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Hu, Jiayu" X-Patchwork-Id: 113280 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 9584DA0545; Thu, 23 Jun 2022 03:09:05 +0200 (CEST) Received: from [217.70.189.124] (localhost [127.0.0.1]) by mails.dpdk.org (Postfix) with ESMTP id 7A5D14069C; Thu, 23 Jun 2022 03:09:05 +0200 (CEST) Received: from mga06.intel.com (mga06b.intel.com [134.134.136.31]) by mails.dpdk.org (Postfix) with ESMTP id 31195400D6 for ; Thu, 23 Jun 2022 03:09:04 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1655946544; x=1687482544; h=from:to:cc:subject:date:message-id:mime-version: content-transfer-encoding; bh=ynJbUvAdRb0y9SvTodqvLAcqmR3zL3aFBuhkEnh2n5M=; b=IAdaAAuR17sl9XZKI5Dq+LHrrw3HtuKOd3QUJ2VXJjfgCmZW8+1rNLkS wQ9EA+sJxW8bC73zHtlqYeotK24OyM1BZ9rERIJPCYUuIipfEZ+mD/kB9 w1pdXe6WCCCbgOtbkdCeIWJAooIfsCHT7eWEHQ7x3I13e8NQ4y6bwjcsN QcB+X2ohj4po5VhDLcuBIBGYvghMnLSkM9Krt2VtIHFHxeJhvM8JlO5lz 0S9XisdlgckQTz2h3JWqNMoD4jXVl9aHnOiHhK28bKtiNuy8uk24oiBYz VAfde43GHTjJk8PLGd8PMPlUONuo7hCDB5T+o4CvDthug80LGJqJwvM3v A==; X-IronPort-AV: E=McAfee;i="6400,9594,10386"; a="342273982" X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="342273982" Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by orsmga104.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 22 Jun 2022 18:09:02 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.92,215,1650956400"; d="scan'208";a="690782266" Received: from npg-dpdk-virtio-jiayuhu-117.sh.intel.com ([10.67.119.202]) by fmsmga002.fm.intel.com with ESMTP; 22 Jun 2022 18:09:01 -0700 From: Jiayu Hu To: dev@dpdk.org Cc: maxime.coquelin@redhat.com, chenbo.xia@intel.com, Jiayu Hu Subject: [PATCH] vhost: fix unchecked return value Date: Wed, 22 Jun 2022 21:08:58 -0400 Message-Id: <20220623010858.951367-1-jiayu.hu@intel.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 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 This patch checks the return value of rte_dma_info_get() called in rte_vhost_async_dma_configure(). Coverity issue: 379066 Fixes: 53d3f4778c1d ("vhost: integrate dmadev in asynchronous data-path") Signed-off-by: Jiayu Hu Reviewed-by: Chenbo Xia --- lib/vhost/vhost.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/lib/vhost/vhost.c b/lib/vhost/vhost.c index b14521e4d1..70c04c036e 100644 --- a/lib/vhost/vhost.c +++ b/lib/vhost/vhost.c @@ -1868,7 +1868,11 @@ rte_vhost_async_dma_configure(int16_t dma_id, uint16_t vchan_id) return -1; } - rte_dma_info_get(dma_id, &info); + if (rte_dma_info_get(dma_id, &info) != 0) { + VHOST_LOG_CONFIG(ERR, "Fail to get DMA %d information.\n", dma_id); + return -1; + } + if (vchan_id >= info.max_vchans) { VHOST_LOG_CONFIG(ERR, "Invalid DMA %d vChannel %u.\n", dma_id, vchan_id); return -1;