atmodem: Shutdown ppp cleanly on remove
authorDenis Kenzior <denkenz@gmail.com>
Fri, 11 Jun 2010 14:17:27 +0000 (09:17 -0500)
committerDenis Kenzior <denkenz@gmail.com>
Fri, 11 Jun 2010 14:20:05 +0000 (09:20 -0500)
There is a race condition from udev / kernel when a USB dongle is
removed.  Sometimes all ports are removed first (and the io channels for
those ports are signaled as hupped) while other times the udev remove
event fires first.

If the latter happens, then gprs_context remove is called with a
potentially live ppp object.  This patch shuts it down cleanly.

drivers/atmodem/gprs-context.c

index c7f681d..4ddf88e 100644 (file)
@@ -254,6 +254,13 @@ static void at_gprs_context_remove(struct ofono_gprs_context *gc)
 {
        struct gprs_context_data *gcd = ofono_gprs_context_get_data(gc);
 
+       DBG("");
+
+       if (gcd->state != STATE_IDLE) {
+               g_at_ppp_unref(gcd->ppp);
+               g_at_chat_resume(gcd->chat);
+       }
+
        ofono_gprs_context_set_data(gc, NULL);
        g_free(gcd);
 }