patches for DPDK stable branches
 help / color / mirror / Atom feed
From: Anatoly Burakov <anatoly.burakov@intel.com>
To: dev@dpdk.org
Cc: ferruh.yigit@intel.com, xiao.w.wang@intel.com, stable@dpdk.org
Subject: [dpdk-stable] [PATCH 3/3] vfio: fix uninitialized variable
Date: Fri,  1 Jun 2018 10:08:12 +0100	[thread overview]
Message-ID: <a4845f90b73d1bcb7c3d9cf67cd50abaab69bbf2.1527843615.git.anatoly.burakov@intel.com> (raw)
In-Reply-To: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com>
In-Reply-To: <5f73e30c5159ff7476641036f2d81c78d15b38a3.1527843615.git.anatoly.burakov@intel.com>

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 <anatoly.burakov@intel.com>
---
 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;
 	}
-- 
2.17.0

  parent reply	other threads:[~2018-06-01  9:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-06-01  9:08 [dpdk-stable] [PATCH 1/3] eal/linuxapp: fix invalid syntax in interrupts Anatoly Burakov
2018-06-01  9:08 ` [dpdk-stable] [PATCH 2/3] eal/linux: fix uninitialized value Anatoly Burakov
2018-06-01  9:08 ` Anatoly Burakov [this message]
2018-07-13  9:45 ` [dpdk-stable] [dpdk-dev] [PATCH 1/3] eal/linuxapp: fix invalid syntax in interrupts Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=a4845f90b73d1bcb7c3d9cf67cd50abaab69bbf2.1527843615.git.anatoly.burakov@intel.com \
    --to=anatoly.burakov@intel.com \
    --cc=dev@dpdk.org \
    --cc=ferruh.yigit@intel.com \
    --cc=stable@dpdk.org \
    --cc=xiao.w.wang@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).