From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from netronome.com (host-79-78-33-110.static.as9105.net [79.78.33.110]) by dpdk.org (Postfix) with ESMTP id 2FCF3DE0 for ; Fri, 12 May 2017 12:18:27 +0200 (CEST) Received: from netronome.com (localhost [127.0.0.1]) by netronome.com (8.14.4/8.14.4/Debian-4.1ubuntu1) with ESMTP id v4CAIQdc036317; Fri, 12 May 2017 11:18:26 +0100 Received: (from alucero@localhost) by netronome.com (8.14.4/8.14.4/Submit) id v4CAIPe4036316; Fri, 12 May 2017 11:18:25 +0100 From: Alejandro Lucero To: dev@dpdk.org Cc: anatoly.burakov@intel.com Date: Fri, 12 May 2017 11:18:25 +0100 Message-Id: <1494584305-36279-1-git-send-email-alejandro.lucero@netronome.com> X-Mailer: git-send-email 1.9.1 Subject: [dpdk-dev] [PATCH] vfio: fix array bounds check 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: , X-List-Received-Date: Fri, 12 May 2017 10:18:27 -0000 Checking against VFIO_MAX_GROUPS goes beyond the maximum array index which should be (VFIO_MAX_GROUPS - 1). Fixes: 94c0776b1bad("support hotplug") Coverity issue: 144555 Coverity issue: 144556 Coverity issue: 144557 Signed-off-by: Alejandro Lucero --- lib/librte_eal/linuxapp/eal/eal_vfio.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/eal_vfio.c b/lib/librte_eal/linuxapp/eal/eal_vfio.c index 5486dca..4816afc 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -189,7 +189,7 @@ int i; i = get_vfio_group_idx(vfio_group_fd); - if (i < 0 || i > VFIO_MAX_GROUPS) + if (i < 0 || i > (VFIO_MAX_GROUPS - 1)) RTE_LOG(ERR, EAL, " wrong vfio_group index (%d)\n", i); else vfio_cfg.vfio_groups[i].devices++; @@ -201,7 +201,7 @@ int i; i = get_vfio_group_idx(vfio_group_fd); - if (i < 0 || i > VFIO_MAX_GROUPS) + if (i < 0 || i > (VFIO_MAX_GROUPS - 1)) RTE_LOG(ERR, EAL, " wrong vfio_group index (%d)\n", i); else vfio_cfg.vfio_groups[i].devices--; @@ -213,7 +213,7 @@ int i; i = get_vfio_group_idx(vfio_group_fd); - if (i < 0 || i > VFIO_MAX_GROUPS) { + if (i < 0 || i > (VFIO_MAX_GROUPS - 1)) { RTE_LOG(ERR, EAL, " wrong vfio_group index (%d)\n", i); return -1; } -- 1.9.1