From 125c7c392f266bb4700ff97ed2de944f40fde515 Mon Sep 17 00:00:00 2001 From: Kalle Valo Date: Wed, 26 May 2010 18:36:21 +0300 Subject: [PATCH] atmodem: fix crash during context deactivation Ofono either crashed or busy looped with my Huawei E1552 3G modem when I tried to deactivate GPRS context. The reason was that gcd->chat was unreferenced already in setup_ppp() but the chat was still accessed later in at_gprs_deactivate_primary(). To fix the problem, change the logic instead to suspend chat session for PPP and resume when PPP has disconnected. Now it doesn't crash anymore. Deactivation still doesn't work properly with Huawei E1552, and most probably with other Huawei modems, because the modem hangs up the chat line after PPP deactivation. This needs to be fixed separately. The workaround is to reboot the modem, for example physically unplug and plug it in again. --- drivers/atmodem/gprs-context.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) diff --git a/drivers/atmodem/gprs-context.c b/drivers/atmodem/gprs-context.c index 9b32d594..24d1c58c 100644 --- a/drivers/atmodem/gprs-context.c +++ b/drivers/atmodem/gprs-context.c @@ -90,6 +90,8 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) DBG(""); + g_at_chat_resume(gcd->chat); + switch (gcd->state) { case STATE_ENABLING: CALLBACK_WITH_FAILURE(gcd->up_cb, NULL, FALSE, NULL, @@ -110,16 +112,19 @@ static void ppp_disconnect(GAtPPPDisconnectReason reason, gpointer user_data) static gboolean setup_ppp(struct ofono_gprs_context *gc) { struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc); - GIOChannel *channel; + GAtIO *io; - channel = g_at_chat_get_channel(gcd->chat); - g_at_chat_unref(gcd->chat); + io = g_at_chat_get_io(gcd->chat); + + g_at_chat_suspend(gcd->chat); /* open ppp */ - gcd->ppp = g_at_ppp_new(channel); + gcd->ppp = g_at_ppp_new_from_io(io); - if (gcd->ppp == NULL) + if (gcd->ppp == NULL) { + g_at_chat_resume(gcd->chat); return FALSE; + } g_at_ppp_set_credentials(gcd->ppp, gcd->username, gcd->password);