]> git.droids-corp.org - dpdk.git/commitdiff
bus/pci: fix allocation of device path
authorFerruh Yigit <ferruh.yigit@intel.com>
Fri, 23 Nov 2018 00:29:45 +0000 (00:29 +0000)
committerThomas Monjalon <thomas@monjalon.net>
Sun, 25 Nov 2018 10:51:11 +0000 (11:51 +0100)
The pci_resource_by_index called strlen() on uninitialized
memory which would lead to the wrong size of memory allocated
for the path portion of the resource map. This would either cause
excessively large allocation, or worse memory corruption.

Coverity issue: 300868
Fixes: ea9d56226e72 ("pci: introduce function to map uio resource by index")
Cc: stable@dpdk.org
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Ferruh Yigit <ferruh.yigit@intel.com>
Reviewed-by: Andrew Rybchenko <arybchenko@solarflare.com>
Reviewed-by: Maxime Coquelin <maxime.coquelin@redhat.com>
drivers/bus/pci/linux/pci_uio.c

index a7c14421aa79e42d33ac85168feead58bdf30b27..09ecbb7aad25c86d92bd68c76c001b5c18666206 100644 (file)
@@ -296,7 +296,7 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx,
        maps = uio_res->maps;
 
        /* allocate memory to keep path */
-       maps[map_idx].path = rte_malloc(NULL, strlen(devname) + 1, 0);
+       maps[map_idx].path = rte_malloc(NULL, sizeof(devname), 0);
        if (maps[map_idx].path == NULL) {
                RTE_LOG(ERR, EAL, "Cannot allocate memory for path: %s\n",
                                strerror(errno));