From 4af00fb1a2449f23a7c0fc32159207ae68b0fbbb Mon Sep 17 00:00:00 2001 From: Alejandro Lucero Date: Fri, 12 May 2017 11:18:25 +0100 Subject: [PATCH] vfio: fix array bounds check Checking against VFIO_MAX_GROUPS goes beyond the maximum array index which should be (VFIO_MAX_GROUPS - 1). Coverity issue: 144555, 144556, 144557 Fixes: 94c0776b1bad ("support hotplug") Cc: stable@dpdk.org Signed-off-by: Alejandro Lucero Acked-by: Anatoly Burakov --- 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 53ac725d22..946df7e31f 100644 --- a/lib/librte_eal/linuxapp/eal/eal_vfio.c +++ b/lib/librte_eal/linuxapp/eal/eal_vfio.c @@ -189,7 +189,7 @@ vfio_group_device_get(int vfio_group_fd) 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 @@ vfio_group_device_put(int vfio_group_fd) 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 @@ vfio_group_device_count(int vfio_group_fd) 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; } -- 2.20.1