From d3110b124af64199b0901223c7e0117f7480480f Mon Sep 17 00:00:00 2001 From: Ferruh Yigit Date: Fri, 23 Nov 2018 00:29:45 +0000 Subject: [PATCH] bus/pci: fix allocation of device path 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 Signed-off-by: Ferruh Yigit Reviewed-by: Andrew Rybchenko Reviewed-by: Maxime Coquelin --- drivers/bus/pci/linux/pci_uio.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index a7c14421aa..09ecbb7aad 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -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)); -- 2.20.1