libxl: correct file open success check in libxl__device_pci_reset
authorMatthew Daley <mattjd@gmail.com>
Wed, 30 Oct 2013 07:51:51 +0000 (20:51 +1300)
committerIan Campbell <ian.campbell@citrix.com>
Thu, 31 Oct 2013 21:55:51 +0000 (21:55 +0000)
It could, even if only in theory, be fd 0.

Coverity-ID: 1055895
Signed-off-by: Matthew Daley <mattjd@gmail.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Acked-by: Ian Campbell <ian.campbell@citrix.com>
tools/libxl/libxl_pci.c

index b9960bb6ceb2a4b4890b5d38d3baa05748eb3ef7..26ba3e665cd1466d1e016bc2bc07e298be0d9937 100644 (file)
@@ -967,7 +967,7 @@ static int libxl__device_pci_reset(libxl__gc *gc, unsigned int domain, unsigned
 
     reset = libxl__sprintf(gc, "%s/pciback/do_flr", SYSFS_PCI_DEV);
     fd = open(reset, O_WRONLY);
-    if (fd > 0) {
+    if (fd >= 0) {
         char *buf = libxl__sprintf(gc, PCI_BDF, domain, bus, dev, func);
         rc = write(fd, buf, strlen(buf));
         if (rc < 0)