atmodem: remove pending idle callbacks at removal

If device probe and removal happen in short succession, it's possible
that the idle handler registered in the probe function doesn't run before
the device is removed.  In this case, the idle handler needs to be
unregistered so that it does not run and try to access the data that's
destroyed during the removal.
This commit is contained in:
Mingli Wu 2012-12-04 16:33:47 +01:00 committed by Denis Kenzior
parent 25e7ecd3c7
commit 911eeb6565
6 changed files with 6 additions and 0 deletions

View File

@ -207,6 +207,7 @@ static void at_call_barring_remove(struct ofono_call_barring *cb)
{
GAtChat *chat = ofono_call_barring_get_data(cb);
g_idle_remove_by_data(cb);
g_at_chat_unref(chat);
ofono_call_barring_set_data(cb, NULL);
}

View File

@ -259,6 +259,7 @@ static void at_ccfc_remove(struct ofono_call_forwarding *cf)
{
GAtChat *chat = ofono_call_forwarding_get_data(cf);
g_idle_remove_by_data(cf);
g_at_chat_unref(chat);
ofono_call_forwarding_set_data(cf, NULL);
}

View File

@ -393,6 +393,7 @@ static void at_call_settings_remove(struct ofono_call_settings *cs)
{
GAtChat *chat = ofono_call_settings_get_data(cs);
g_idle_remove_by_data(cs);
g_at_chat_unref(chat);
ofono_call_settings_set_data(cs, NULL);
}

View File

@ -139,6 +139,7 @@ static void at_sim_auth_remove(struct ofono_sim_auth *sa)
{
struct sim_auth_data *sad = ofono_sim_auth_get_data(sa);
g_idle_remove_by_data(sa);
ofono_sim_auth_set_data(sa, NULL);
g_at_chat_unref(sad->chat);

View File

@ -1493,6 +1493,7 @@ static void at_sim_remove(struct ofono_sim *sim)
{
struct sim_data *sd = ofono_sim_get_data(sim);
g_idle_remove_by_data(sim);
/* Cleanup potential SIM state polling */
at_util_sim_state_query_free(sd->sim_state_query);

View File

@ -216,6 +216,7 @@ static void at_stk_remove(struct ofono_stk *stk)
{
struct stk_data *sd = ofono_stk_get_data(stk);
g_idle_remove_by_data(stk);
ofono_stk_set_data(stk, NULL);
g_at_chat_unref(sd->chat);