summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFerruh Yigit <ferruh.yigit@intel.com>2018-11-23 00:29:45 +0000
committerThomas Monjalon <thomas@monjalon.net>2018-11-25 11:51:11 +0100
commitd3110b124af64199b0901223c7e0117f7480480f (patch)
treede5ed00a36f844921d1b84660e77cc3cec6a79ac
parent705dced4a72a1053368c84c4b68f04f028a78b30 (diff)
downloaddpdk-d3110b124af64199b0901223c7e0117f7480480f.zip
dpdk-d3110b124af64199b0901223c7e0117f7480480f.tar.gz
dpdk-d3110b124af64199b0901223c7e0117f7480480f.tar.xz
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 <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>
-rw-r--r--drivers/bus/pci/linux/pci_uio.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c
index a7c1442..09ecbb7 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));