X-Git-Url: http://git.droids-corp.org/?a=blobdiff_plain;f=drivers%2Fbus%2Fpci%2Flinux%2Fpci_uio.c;h=6dca05a9868c4c8d500700509aa924d81cb0e172;hb=7d087a0a8b8e53278302601cd4b22e50ef0d5ee2;hp=a7c14421aa79e42d33ac85168feead58bdf30b27;hpb=4a928ef9f6114d119899b95ba47acc0e9562f7a5;p=dpdk.git diff --git a/drivers/bus/pci/linux/pci_uio.c b/drivers/bus/pci/linux/pci_uio.c index a7c14421aa..6dca05a986 100644 --- a/drivers/bus/pci/linux/pci_uio.c +++ b/drivers/bus/pci/linux/pci_uio.c @@ -16,10 +16,10 @@ #include #endif +#include #include #include #include -#include #include #include @@ -268,7 +268,7 @@ pci_uio_alloc_resource(struct rte_pci_device *dev, goto error; } - snprintf((*uio_res)->path, sizeof((*uio_res)->path), "%s", devname); + strlcpy((*uio_res)->path, devname, sizeof((*uio_res)->path)); memcpy(&(*uio_res)->pci_addr, &dev->addr, sizeof((*uio_res)->pci_addr)); return 0; @@ -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)); @@ -314,12 +314,11 @@ pci_uio_map_resource_by_index(struct rte_pci_device *dev, int res_idx, loc->domain, loc->bus, loc->devid, loc->function, res_idx); - if (access(devname, R_OK|W_OK) != -1) { - fd = open(devname, O_RDWR); - if (fd < 0) - RTE_LOG(INFO, EAL, "%s cannot be mapped. " - "Fall-back to non prefetchable mode.\n", - devname); + fd = open(devname, O_RDWR); + if (fd < 0 && errno != ENOENT) { + RTE_LOG(INFO, EAL, "%s cannot be mapped. " + "Fall-back to non prefetchable mode.\n", + devname); } } @@ -376,6 +375,12 @@ pci_uio_ioport_map(struct rte_pci_device *dev, int bar, int uio_num; unsigned long start; + if (rte_eal_iopl_init() != 0) { + RTE_LOG(ERR, EAL, "%s(): insufficient ioport permissions for PCI device %s\n", + __func__, dev->name); + return -1; + } + uio_num = pci_get_uio_dev(dev, dirname, sizeof(dirname), 0); if (uio_num < 0) return -1;