From 8d47d31b29ebec367dfbc64782961d7c30a0a83e Mon Sep 17 00:00:00 2001 From: Aleksander Morgado Date: Mon, 8 Oct 2012 09:53:28 +0200 Subject: [PATCH] broadband-modem: cancellable may not be given during disable() If the modem is currently being disposed, we may not get a proper GCancellable when disabling, so try to handle that case in order to avoid warnings like: GLib-GObject-CRITICAL **: g_object_ref: assertion `G_IS_OBJECT (object)' failed #0 0x00007ffff7ab1ba0 in g_log () from /usr/lib64/libglib-2.0.so.0 #1 0x00007ffff7b99784 in g_object_ref () from /usr/lib64/libgobject-2.0.so.0 #2 0x0000000000456c05 in disable (self=0x50d3f0, cancellable=0x0, callback=, user_data=) at mm-broadband-modem.c:7052 #3 0x0000000000431e69 in handle_enable_auth_ready (self=0x50d3f0, res=, ctx=0xa41200) at mm-iface-modem.c:1216 #4 0x00007ffff7e7f447 in g_simple_async_result_complete () from /usr/lib64/libgio-2.0.so.0 #5 0x0000000000427bc1 in authorize_ready (authp=, res=, simple=0x51d810) at mm-base-modem.c:1015 #6 0x00007ffff7e7f447 in g_simple_async_result_complete () from /usr/lib64/libgio-2.0.so.0 #7 0x00007ffff7e7f549 in ?? () from /usr/lib64/libgio-2.0.so.0 #8 0x00007ffff7aaa5c3 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0 #9 0x00007ffff7aaa940 in ?? () from /usr/lib64/libglib-2.0.so.0 #10 0x00007ffff7aaad7a in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0 #11 0x0000000000417ef2 in main (argc=, argv=) at main.c:150 GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed #0 0x00007ffff7ab1ba0 in g_log () from /usr/lib64/libglib-2.0.so.0 #1 0x000000000044af26 in disabling_context_complete_and_free (ctx=0xa408a0) at mm-broadband-modem.c:6788 #2 0x0000000000431e69 in handle_enable_auth_ready (self=0x50d3f0, res=, ctx=0xa41200) at mm-iface-modem.c:1216 #3 0x00007ffff7e7f447 in g_simple_async_result_complete () from /usr/lib64/libgio-2.0.so.0 #4 0x0000000000427bc1 in authorize_ready (authp=, res=, simple=0x51d810) at mm-base-modem.c:1015 #5 0x00007ffff7e7f447 in g_simple_async_result_complete () from /usr/lib64/libgio-2.0.so.0 #6 0x00007ffff7e7f549 in ?? () from /usr/lib64/libgio-2.0.so.0 #7 0x00007ffff7aaa5c3 in g_main_context_dispatch () from /usr/lib64/libglib-2.0.so.0 #8 0x00007ffff7aaa940 in ?? () from /usr/lib64/libglib-2.0.so.0 #9 0x00007ffff7aaad7a in g_main_loop_run () from /usr/lib64/libglib-2.0.so.0 #10 0x0000000000417ef2 in main (argc=, argv=) at main.c:150 Reported by: Ben Chan Partially fixes: https://bugzilla.gnome.org/show_bug.cgi?id=684693 --- src/mm-broadband-modem.c | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/mm-broadband-modem.c b/src/mm-broadband-modem.c index c3f02c0b..7423130a 100644 --- a/src/mm-broadband-modem.c +++ b/src/mm-broadband-modem.c @@ -6813,7 +6813,8 @@ disabling_context_complete_and_free (DisablingContext *ctx) } g_object_unref (ctx->result); - g_object_unref (ctx->cancellable); + if (ctx->cancellable) + g_object_unref (ctx->cancellable); g_object_unref (ctx->self); g_free (ctx); } @@ -6837,10 +6838,7 @@ disable_finish (MMBaseModem *self, GAsyncResult *res, GError **error) { - if (g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error)) - return FALSE; - - return TRUE; + return !g_simple_async_result_propagate_error (G_SIMPLE_ASYNC_RESULT (res), error); } #undef INTERFACE_DISABLE_READY_FN @@ -7079,12 +7077,12 @@ disable (MMBaseModem *self, ctx = g_new0 (DisablingContext, 1); ctx->self = g_object_ref (self); ctx->result = result; - ctx->cancellable = g_object_ref (cancellable); + ctx->cancellable = (cancellable ? g_object_ref (cancellable) : NULL); ctx->step = DISABLING_STEP_FIRST; disabling_step (ctx); return; - } + } } g_simple_async_result_complete_in_idle (result);