From 623183d99650530eedf45c28033420fed072f087 Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Wed, 11 May 2011 12:07:41 -0500 Subject: gprs: Fix valgrind error This fixes an invalid access condition for the case where the gprs atom is destroyed before context atoms are. --- src/gprs.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'src/gprs.c') diff --git a/src/gprs.c b/src/gprs.c index 412e0b87..6a3c44ec 100644 --- a/src/gprs.c +++ b/src/gprs.c @@ -2137,17 +2137,18 @@ static void gprs_context_unregister(struct ofono_atom *atom) DBG("%p, %p", gc, gc->gprs); if (gc->gprs == NULL) - return; + goto done; + + gc->gprs->context_drivers = g_slist_remove(gc->gprs->context_drivers, + gc); + gc->gprs = NULL; +done: if (gc->settings) { context_settings_free(gc->settings); g_free(gc->settings); gc->settings = NULL; } - - gc->gprs->context_drivers = g_slist_remove(gc->gprs->context_drivers, - gc); - gc->gprs = NULL; } void ofono_gprs_add_context(struct ofono_gprs *gprs, @@ -2494,6 +2495,7 @@ static void gprs_unregister(struct ofono_atom *atom) static void gprs_remove(struct ofono_atom *atom) { struct ofono_gprs *gprs = __ofono_atom_get_data(atom); + GSList *l; DBG("atom: %p", atom); @@ -2508,6 +2510,12 @@ static void gprs_remove(struct ofono_atom *atom) gprs->pid_map = NULL; } + for (l = gprs->context_drivers; l; l = l->next) { + struct ofono_gprs_context *gc = l->data; + + gc->gprs = NULL; + } + g_slist_free(gprs->context_drivers); if (gprs->driver && gprs->driver->remove) -- cgit v1.2.3