File tcmu-runner-fix-g_object_unref-assertion-G_IS_OBJECT-object.patch of Package tcmu-runner.23488

From 5d1623920e271ff5711670133f6cd0a8f59b9f64 Mon Sep 17 00:00:00 2001
From: Xiubo Li <xiubli@redhat.com>
Date: Mon, 6 Sep 2021 14:23:08 +0800
Subject: [PATCH] main: fix g_object_unref: assertion 'G_IS_OBJECT (object)'
 failed

If the 'manager' is not initialized just skip it. And at the same
time this will fix a potential loop reference leak in case adding
signal handlers fails.

Signed-off-by: Xiubo Li <xiubli@redhat.com>
---
 main.c | 9 +++++----
 1 file changed, 5 insertions(+), 4 deletions(-)

diff --git a/main.c b/main.c
index 976615d..44a08e0 100644
--- a/main.c
+++ b/main.c
@@ -1398,7 +1398,7 @@ int main(int argc, char **argv)
 	    g_unix_signal_add(SIGTERM, handle_sig, loop) <= 0 ||
 	    g_unix_signal_add(SIGHUP, handle_sighup, loop) <= 0) {
 		tcmu_err("couldn't setup signal handlers\n");
-		goto unwatch_cfg;
+		goto loop_unref;
 	}
 
 	/* Set up event for libtcmu */
@@ -1424,15 +1424,16 @@ int main(int argc, char **argv)
 
 	tcmu_crit("Exiting...\n");
 	g_bus_unown_name(reg_id);
-	g_main_loop_unref(loop);
 	g_source_remove(watch_id);
 	g_io_channel_shutdown(libtcmu_gio, TRUE, NULL);
 	g_io_channel_unref (libtcmu_gio);
-	g_object_unref(manager);
+	if (manager)
+		g_object_unref(manager);
 
 	ret = 0;
 
-unwatch_cfg:
+loop_unref:
+	g_main_loop_unref(loop);
 	if (watching_cfg)
 		tcmu_unwatch_config(tcmu_cfg);
 	tcmulib_close(tcmulib_context);
-- 
2.34.1

openSUSE Build Service is sponsored by