]> git.droids-corp.org - dpdk.git/blobdiff - drivers/bus/pci/linux/pci_uio.c
bus/pci: fix TOCTOU for sysfs access
[dpdk.git] / drivers / bus / pci / linux / pci_uio.c
index 65f4896b9f8b5e6d2ed5d4b4f670580558fbc91a..f240fe4f2123222a2ada109dd63a0896a50947d6 100644 (file)
@@ -315,12 +315,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);
                }
        }