[libvirt] [PATCH] util: Avoid calling closedir(NULL)

Jiri Denemark jdenemar at redhat.com
Thu Feb 25 11:53:46 UTC 2016


Signed-off-by: Jiri Denemark <jdenemar at redhat.com>
---
 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




More information about the libvir-list mailing list