iface-modem: don't try to use the bearer list if there is none

When the modem gets unplugged, or system gone into suspend, we start losing the
modem ports one by one. When the last is lost, we trigger the disposal of the
modem (we call g_object_run_dispose() and then we call the main-reference
unref()). So, if we end up losing all ports while the connection sequence was
being run, we would end up in this situation, where we try to disconnect the
bearers (the bearer and modem objects are still valid, as we have references
around, but the list of bearers won't be available any more in the modem object
as it was cleared in the modem dispose().

Thread 0 *CRASHED* ( SIGSEGV @ 0x00000000 )

0x7f5cdbd5cda0   [ModemManager]                 - mm-bearer-list.c:163]      mm_bearer_list_foreach
0x7f5cdbd6a4bd   [ModemManager]                 - mm-iface-modem.c:110]      bearer_status_changed
0x7f5cdbad0903   [libgobject-2.0.so.0.3000.2]   - gclosure.c:774]            g_closure_invoke
0x7f5cdbae1dbb   [libgobject-2.0.so.0.3000.2]   - gsignal.c:3272]            signal_emit_unlocked_R
0x7f5cdbaeac82   [libgobject-2.0.so.0.3000.2]   - gsignal.c:3003]            g_signal_emit_valist
0x7f5cdbaeae5e   [libgobject-2.0.so.0.3000.2]   - gsignal.c:3060]            g_signal_emit
0x7f5cdbad3876   [libgobject-2.0.so.0.3000.2]   - gobject.c:925]             g_object_dispatch_properties_changed
0x7f5cdbad5ceb   [libgobject-2.0.so.0.3000.2]   - gobjectnotifyqueue.c:132]  g_object_notify_by_pspec
0x7f5cdbd56b08   [ModemManager]                 - mm-bearer.c:112]           bearer_update_status
0x7f5cdbd56ffd   [ModemManager]                 - mm-bearer.c:393]           disconnect_ready
0x7f5cdbbcc676   [libgio-2.0.so.0.3000.2]       - gsimpleasyncresult.c:749]  g_simple_async_result_complete
0x7f5cdbbcc788   [libgio-2.0.so.0.3000.2]       - gsimpleasyncresult.c:761]  complete_in_idle_cb
0x7f5cdb7cff44   [libglib-2.0.so.0.3000.2]      - gmain.c:2441]              g_main_context_dispatch
0x7f5cdb7d0597   [libglib-2.0.so.0.3000.2]      - gmain.c:3089]              g_main_context_iterate
0x7f5cdb7d0b51   [libglib-2.0.so.0.3000.2]      - gmain.c:3297]              g_main_loop_run
0x7f5cdbd4e331   [ModemManager]                 - main.c:150]                main
0x7f5cdb1ea41c   [libc-2.15.so]                 - libc-start.c:234]          __libc_start_main
0x7f5cdbd4de48   [ModemManager]   + 0x00019e48]

Reported by Ben Chan <benchan@google.com>
(cherry picked from commit d99169022eefe658e405051ef58c1af6c653faee)
1 file changed