vhost: fix possible out of bound access
authorFerruh Yigit <ferruh.yigit@intel.com>
Sun, 28 Oct 2018 01:08:46 +0000 (01:08 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Tue, 6 Nov 2018 00:14:23 +0000 (01:14 +0100)
Fixes: d7280c9fffcb ("vhost: support selective datapath")
Cc: stable@dpdk.org
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
lib/librte_vhost/vdpa.c

index c2c5dff..e7d849e 100644 (file)
@@ -63,6 +63,9 @@ rte_vdpa_register_device(struct rte_vdpa_dev_addr *addr,
                        break;
        }
 
+       if (i == MAX_VHOST_DEVICE)
+               return -1;
+
        sprintf(device_name, "vdpa-dev-%d", i);
        dev = rte_zmalloc(device_name, sizeof(struct rte_vdpa_device),
                        RTE_CACHE_LINE_SIZE);