From 990b4136608ad1ae69e9727ccb16b9ecf88644e5 Mon Sep 17 00:00:00 2001
From: Tomas Bzatek <tbzatek@redhat.com>
Date: Mon, 20 Nov 2023 17:49:46 +0100
Subject: [PATCH] lvm-dbus: Fix leaking error

---
 src/plugins/lvm-dbus.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/src/plugins/lvm-dbus.c b/src/plugins/lvm-dbus.c
index e822bd6..e1a9079 100644
--- a/src/plugins/lvm-dbus.c
+++ b/src/plugins/lvm-dbus.c
@@ -362,10 +362,14 @@ void bd_lvm_close (void) {
 
     /* the check() call should create the DBus connection for us, but let's not
        completely rely on it */
-    if (!g_dbus_connection_flush_sync (bus, NULL, &error))
+    if (!g_dbus_connection_flush_sync (bus, NULL, &error)) {
         bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to flush DBus connection: %s", error->message);
-    if (!g_dbus_connection_close_sync (bus, NULL, &error))
+        g_clear_error (&error);
+    }
+    if (!g_dbus_connection_close_sync (bus, NULL, &error)) {
         bd_utils_log_format (BD_UTILS_LOG_CRIT, "Failed to close DBus connection: %s", error->message);
+        g_clear_error (&error);
+    }
 
     dm_log_with_errno_init (NULL);
     dm_log_init_verbose (0);
-- 
2.27.0

