Re: [libvirt PATCH v6 2/2] nodedev: fix resource leak

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

 



Oh shoot! I wrote/posted a patch for this (because I'd just finished making a long patch series to use g_autoptr for all DIR*, and wanted to update it to take this into account) on Tuesday or Wednesday, it was reviewed, and I pulled it into master of my local tree; I *thought* I had pushed it so it would be in rc2, but I just looked now and I forgot to push :-(

https://www.redhat.com/archives/libvir-list/2020-October/msg01467.html

Anyway, if it's okay with you, I'd prefer to push my patch (which doesn't create a cleanup label, since I would be removing it in my "use g_autoptr for DIR*" patches later.

If I don't hear anything by sometime tomorrow (Saturday), I'll push my version of the patch.

On 10/30/20 4:01 PM, Jonathon Jongsma wrote:
Ensure that the directory is closed when opening chardev path for a vDPA
device.

Signed-off-by: Jonathon Jongsma <jjongsma@xxxxxxxxxx>
---
  src/node_device/node_device_udev.c | 11 ++++++++---
  1 file changed, 8 insertions(+), 3 deletions(-)

diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index b1b8427c05..eb4ae22151 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -1150,6 +1150,7 @@ udevGetVDPACharDev(const char *sysfs_path,
      struct dirent *entry;
      DIR *dir = NULL;
      int direrr;
+    int ret = -1;
if (virDirOpenIfExists(&dir, sysfs_path) <= 0)
          return -1;
@@ -1162,7 +1163,7 @@ udevGetVDPACharDev(const char *sysfs_path,
                  virReportError(VIR_ERR_INTERNAL_ERROR,
                                 _("vDPA chardev path '%s' does not exist"),
                                 chardev);
-                return -1;
+                goto cleanup;
              }
              VIR_DEBUG("vDPA chardev is at '%s'", chardev);
@@ -1172,9 +1173,13 @@ udevGetVDPACharDev(const char *sysfs_path,
      }
if (direrr < 0)
-        return -1;
+        goto cleanup;
- return 0;
+    ret = 0;
+
+ cleanup:
+    VIR_DIR_CLOSE(dir);
+    return ret;
  }
static int





[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