[PATCH v3 1/2] util: add file exists check in virReadFCHost

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



File open errors are prevented by a file exists check before
virFileReadAll is called since all callers of the virReadFCHost
method handle errors themselves based on the NULL return anyway.
Also included is a minor spelling correction in a comment.

Signed-off-by: Boris Fiuczynski <fiuczy@xxxxxxxxxxxxxxxxxx>
---
 src/util/virutil.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/src/util/virutil.c b/src/util/virutil.c
index aeaa7f9..91178d1 100644
--- a/src/util/virutil.c
+++ b/src/util/virutil.c
@@ -2011,7 +2011,7 @@ virGetSCSIHostNameByParentaddr(unsigned int domain,
  *
  * Read the value of sysfs "fc_host" entry.
  *
- * Returns result as a stringon success, caller must free @result after
+ * Returns result as a string on success, caller must free @result after
  * Otherwise returns NULL.
  */
 char *
@@ -2029,6 +2029,9 @@ virReadFCHost(const char *sysfs_prefix,
                     host, entry) < 0)
         goto cleanup;
 
+    if (!virFileExists(sysfs_path))
+        goto cleanup;
+
     if (virFileReadAll(sysfs_path, 1024, &buf) < 0)
         goto cleanup;
 
-- 
2.5.5

--
libvir-list mailing list
libvir-list@xxxxxxxxxx
https://www.redhat.com/mailman/listinfo/libvir-list



[Index of Archives]     [Virt Tools]     [Libvirt Users]     [Lib OS Info]     [Fedora Users]     [Fedora Desktop]     [Fedora SELinux]     [Big List of Linux Books]     [Yosemite News]     [KDE Users]     [Fedora Tools]
  Powered by Linux