sim: fix crash when going into state LOCKED_OUT

After input PIN wrong 3 times, sim main state (include spn_watches)
is freed. but the watch id still be kept by other atoms (network and
gprs), when remove the atom, it will try to remove the watch from
spn_watches, ofono daemon will crash.
This commit is contained in:
Caiwen Zhang 2016-04-20 16:09:45 +08:00 committed by Denis Kenzior
parent b44f59e5e4
commit 66160f9b63
1 changed files with 3 additions and 6 deletions

View File

@ -1840,7 +1840,6 @@ static void sim_efphase_read_cb(int ok, int length, int record,
static void sim_initialize_after_pin(struct ofono_sim *sim)
{
sim->context = ofono_sim_context_create(sim);
sim->spn_watches = __ofono_watchlist_new(g_free);
ofono_sim_read(sim->context, SIM_EFPHASE_FILEID,
OFONO_SIM_FILE_STRUCTURE_TRANSPARENT,
@ -2348,11 +2347,6 @@ static void sim_free_early_state(struct ofono_sim *sim)
static void sim_spn_close(struct ofono_sim *sim)
{
if (sim->spn_watches) {
__ofono_watchlist_free(sim->spn_watches);
sim->spn_watches = NULL;
}
/*
* We have not initialized SPN logic at all yet, either because
* no netreg / gprs atom has been needed or we have not reached the
@ -2881,6 +2875,8 @@ static void sim_unregister(struct ofono_atom *atom)
__ofono_watchlist_free(sim->state_watches);
sim->state_watches = NULL;
__ofono_watchlist_free(sim->spn_watches);
sim->spn_watches = NULL;
g_dbus_unregister_interface(conn, path, OFONO_SIM_MANAGER_INTERFACE);
ofono_modem_remove_interface(modem, OFONO_SIM_MANAGER_INTERFACE);
@ -3011,6 +3007,7 @@ void ofono_sim_register(struct ofono_sim *sim)
ofono_modem_add_interface(modem, OFONO_SIM_MANAGER_INTERFACE);
sim->state_watches = __ofono_watchlist_new(g_free);
sim->spn_watches = __ofono_watchlist_new(g_free);
sim->simfs = sim_fs_new(sim, sim->driver);
__ofono_atom_register(sim->atom, sim_unregister);