Everything is released in `udevEventDataDispose` except for the threads, change
this as this makes the code easier to read as it can be simplified a little.

Reviewed-by: Jonathon Jongsma <jjong...@redhat.com>
Reviewed-by: Boris Fiuczynski <fiu...@linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhart...@linux.ibm.com>
---
 src/node_device/node_device_udev.c | 14 ++++++--------
 1 file changed, 6 insertions(+), 8 deletions(-)

diff --git a/src/node_device/node_device_udev.c 
b/src/node_device/node_device_udev.c
index 0ad83efc86a8..9aab4340fa2d 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -86,12 +86,16 @@ udevEventDataDispose(void *obj)
     struct udev *udev = NULL;
     udevEventData *priv = obj;
 
+    g_clear_pointer(&priv->initThread, g_free);
+
     if (priv->watch != -1)
         virEventRemoveHandle(priv->watch);
 
     if (priv->mdevctlTimeout != -1)
         virEventRemoveTimeout(priv->mdevctlTimeout);
 
+    g_clear_pointer(&priv->udevThread, g_free);
+
     if (!priv->udev_monitor)
         return;
 
@@ -1730,14 +1734,10 @@ nodeStateCleanup(void)
             priv->udevThreadQuit = true;
             virCondSignal(&priv->udevThreadCond);
         }
-        if (priv->initThread) {
+        if (priv->initThread)
             virThreadJoin(priv->initThread);
-            g_clear_pointer(&priv->initThread, g_free);
-        }
-        if (priv->udevThread) {
+        if (priv->udevThread)
             virThreadJoin(priv->udevThread);
-            g_clear_pointer(&priv->udevThread, g_free);
-        }
     }
 
     virObjectUnref(priv);
@@ -2328,7 +2328,6 @@ nodeStateInitialize(bool privileged,
                             "udev-event", false, NULL) < 0) {
         virReportSystemError(errno, "%s",
                              _("failed to create udev handler thread"));
-        g_clear_pointer(&priv->udevThread, g_free);
         goto unlock;
     }
 
@@ -2360,7 +2359,6 @@ nodeStateInitialize(bool privileged,
                             "nodedev-init", false, udev) < 0) {
         virReportSystemError(errno, "%s",
                              _("failed to create udev enumerate thread"));
-        g_clear_pointer(&priv->initThread, g_free);
         goto cleanup;
     }
 
-- 
2.34.1
_______________________________________________
Devel mailing list -- devel@lists.libvirt.org
To unsubscribe send an email to devel-le...@lists.libvirt.org

Reply via email to