From patchwork Fri Jun 1 09:08:12 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Anatoly Burakov X-Patchwork-Id: 40565 X-Patchwork-Delegate: thomas@monjalon.net Return-Path: X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [127.0.0.1]) by dpdk.org (Postfix) with ESMTP id 062494CBB; Fri, 1 Jun 2018 11:08:21 +0200 (CEST) Received: from mga11.intel.com (mga11.intel.com [192.55.52.93]) by dpdk.org (Postfix) with ESMTP id 7D98C2BC8; Fri, 1 Jun 2018 11:08:17 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from fmsmga001.fm.intel.com ([10.253.24.23]) by fmsmga102.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 01 Jun 2018 02:08:14 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,465,1520924400"; d="scan'208";a="60389826" Received: from irvmail001.ir.intel.com ([163.33.26.43]) by fmsmga001.fm.intel.com with ESMTP; 01 Jun 2018 02:08:13 -0700 Received: from sivswdev01.ir.intel.com (sivswdev01.ir.intel.com [10.237.217.45]) by irvmail001.ir.intel.com (8.14.3/8.13.6/MailSET/Hub) with ESMTP id w5198Ck2009044; Fri, 1 Jun 2018 10:08:12 +0100 Received: from sivswdev01.ir.intel.com (localhost [127.0.0.1]) by sivswdev01.ir.intel.com with ESMTP id w5198CTT013856; Fri, 1 Jun 2018 10:08:12 +0100 Received: (from aburakov@localhost) by sivswdev01.ir.intel.com with LOCAL id w5198CTp013852; Fri, 1 Jun 2018 10:08:12 +0100 From: Anatoly Burakov To: dev@dpdk.org Cc: ferruh.yigit@intel.com, xiao.w.wang@intel.com, stable@dpdk.org Date: Fri, 1 Jun 2018 10:08:12 +0100 Message-Id: X-Mailer: git-send-email 1.7.0.7 In-Reply-To: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com> References: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com> In-Reply-To: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com> References: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com> Subject: [dpdk-dev] [PATCH 3/3] vfio: fix uninitialized variable X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 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" Some static analyzers complain about it, even though value is never used if not initialized. To avoid additional false positives about a potential null-pointer dereferences, also add a null-check. Bugzilla ID: 58 Fixes: ea2dc1066870 ("vfio: add multi container support") Cc: xiao.w.wang@intel.com Cc: stable@dpdk.org Signed-off-by: Anatoly Burakov --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index a2bbdfbf4..4b7fcf3d6 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -1778,7 +1778,7 @@ int __rte_experimental rte_vfio_container_group_unbind(int container_fd, int iommu_group_num) { struct vfio_config *vfio_cfg; - struct vfio_group *cur_grp; + struct vfio_group *cur_grp = NULL; int i; vfio_cfg = get_vfio_cfg_by_container_fd(container_fd); @@ -1795,7 +1795,7 @@ rte_vfio_container_group_unbind(int container_fd, int iommu_group_num) } /* This should not happen */ - if (i == VFIO_MAX_GROUPS) { + if (i == VFIO_MAX_GROUPS || cur_grp == NULL) { RTE_LOG(ERR, EAL, "Specified group number not found\n"); return -1; }