[PATCH] util: Avoid calling closedir(NULL)

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

 



Signed-off-by: Jiri Denemark <jdenemar@xxxxxxxxxx>
---
 src/util/virnetdev.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/src/util/virnetdev.c b/src/util/virnetdev.c
index ea95552..5c79c42 100644
--- a/src/util/virnetdev.c
+++ b/src/util/virnetdev.c
@@ -3104,63 +3104,63 @@ static int
 virNetDevRDMAFeature(const char *ifname,
                      virBitmapPtr *out)
 {
     char *eth_devpath = NULL;
     char *ib_devpath = NULL;
     char *eth_res_buf = NULL;
     char *ib_res_buf = NULL;
     DIR *dirp = NULL;
     struct dirent *dp;
     int ret = -1;
 
     if (!virFileExists(SYSFS_INFINIBAND_DIR))
         return 0;
 
     if (!(dirp = opendir(SYSFS_INFINIBAND_DIR))) {
         virReportSystemError(errno,
                              _("Failed to opendir path '%s'"),
                              SYSFS_INFINIBAND_DIR);
-        goto cleanup;
+        return -1;
     }
 
     if (virAsprintf(&eth_devpath, SYSFS_NET_DIR "%s/device/resource", ifname) < 0)
         goto cleanup;
     if (!virFileExists(eth_devpath))
         goto cleanup;
     if (virFileReadAll(eth_devpath, RESOURCE_FILE_LEN, &eth_res_buf) < 0)
         goto cleanup;
 
     while (virDirRead(dirp, &dp, SYSFS_INFINIBAND_DIR) > 0) {
         if (dp->d_name[0] == '.')
             continue;
         if (virAsprintf(&ib_devpath, SYSFS_INFINIBAND_DIR "%s/device/resource",
                         dp->d_name) < 0)
             continue;
         if (virFileReadAll(ib_devpath, RESOURCE_FILE_LEN, &ib_res_buf) > 0 &&
             STREQ(eth_res_buf, ib_res_buf)) {
             ignore_value(virBitmapSetBit(*out, VIR_NET_DEV_FEAT_RDMA));
             break;
         }
         VIR_FREE(ib_devpath);
         VIR_FREE(ib_res_buf);
     }
     ret = 0;
 
  cleanup:
     closedir(dirp);
     VIR_FREE(eth_devpath);
     VIR_FREE(ib_devpath);
     VIR_FREE(eth_res_buf);
     VIR_FREE(ib_res_buf);
     return ret;
 }
 
 
 /**
  * virNetDevSendEthtoolIoctl
  * This function sends ethtool ioctl request
  *
  * @ifname: name of the interface
  * @cmd: reference to an ethtool command structure
  *
  * Returns 0 on success, -1 on failure.
  */
-- 
2.7.2

--
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]