sim: Fix crash due to uninitialized spn_watch
authorDenis Kenzior <denkenz@gmail.com>
Tue, 24 Jan 2012 17:33:16 +0000 (11:33 -0600)
committerDenis Kenzior <denkenz@gmail.com>
Thu, 2 Feb 2012 02:12:51 +0000 (20:12 -0600)
src/sim.c

index 703e0db..eb25e07 100644 (file)
--- a/src/sim.c
+++ b/src/sim.c
@@ -2530,6 +2530,14 @@ static void sim_spn_close(struct ofono_sim *sim)
        __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
+        * post_sim state
+        */
+       if (sim->ef_spn_watch == 0)
+               return;
+
        ofono_sim_remove_file_watch(sim->context, sim->ef_spn_watch);
        sim->ef_spn_watch = 0;