]> xenbits.xensource.com Git - xen.git/commitdiff
libxl: correct file open success check in libxl__device_pci_reset
authorMatthew Daley <mattd@bugfuzz.com>
Sun, 1 Dec 2013 10:14:57 +0000 (23:14 +1300)
committerIan Jackson <Ian.Jackson@eu.citrix.com>
Mon, 2 Dec 2013 11:56:39 +0000 (11:56 +0000)
It could, even if only in theory, be fd 0.

(This is not the same as commit 4b62556b57!)

Coverity-ID: 1055895
Signed-off-by: Matthew Daley <mattd@bugfuzz.com>
Acked-by: Ian Jackson <ian.jackson@eu.citrix.com>
tools/libxl/libxl_pci.c

index c8eceb4a3b63045563deacd9d49d63a2a8542b4d..095d5643d94735b749c9d9389edaad884d5a9692 100644 (file)
@@ -979,7 +979,7 @@ static int libxl__device_pci_reset(libxl__gc *gc, unsigned int domain, unsigned
         LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "Failed to access pciback path %s", reset);
     reset = libxl__sprintf(gc, "%s/"PCI_BDF"/reset", SYSFS_PCI_DEV, domain, bus, dev, func);
     fd = open(reset, O_WRONLY);
-    if (fd > 0) {
+    if (fd >= 0) {
         rc = write(fd, "1", 1);
         if (rc < 0)
             LIBXL__LOG_ERRNO(ctx, LIBXL__LOG_ERROR, "write to %s returned %d", reset, rc);