Even if `priv->udev_monitor` was never initialized, the mdevctlLock, udevThread
were. Therefore let's match the order of releasing the resources the order of
allocating the resources in `nodeStateInitialize`.
In addition, use `g_steal_pointer` in `g_list_free_full`.
Reviewed-by: Jonathon Jongsma <jjongsma(a)redhat.com>
Reviewed-by: Boris Fiuczynski <fiuczy(a)linux.ibm.com>
Signed-off-by: Marc Hartmayer <mhartmay(a)linux.ibm.com>
---
src/node_device/node_device_udev.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/node_device/node_device_udev.c b/src/node_device/node_device_udev.c
index 9aab4340fa2d..906b16778eef 100644
--- a/src/node_device/node_device_udev.c
+++ b/src/node_device/node_device_udev.c
@@ -88,6 +88,10 @@ udevEventDataDispose(void *obj)
g_clear_pointer(&priv->initThread, g_free);
+ VIR_WITH_MUTEX_LOCK_GUARD(&priv->mdevctlLock) {
+ g_list_free_full(g_steal_pointer(&priv->mdevctlMonitors),
g_object_unref);
+ }
+
if (priv->watch != -1)
virEventRemoveHandle(priv->watch);
@@ -96,16 +100,12 @@ udevEventDataDispose(void *obj)
g_clear_pointer(&priv->udevThread, g_free);
- if (!priv->udev_monitor)
- return;
-
- udev = udev_monitor_get_udev(priv->udev_monitor);
- udev_monitor_unref(priv->udev_monitor);
- udev_unref(udev);
-
- VIR_WITH_MUTEX_LOCK_GUARD(&priv->mdevctlLock) {
- g_list_free_full(priv->mdevctlMonitors, g_object_unref);
+ if (priv->udev_monitor) {
+ udev = udev_monitor_get_udev(priv->udev_monitor);
+ udev_monitor_unref(priv->udev_monitor);
+ udev_unref(udev);
}
+
virMutexDestroy(&priv->mdevctlLock);
virCondDestroy(&priv->udevThreadCond);
--
2.34.1