From f420aea45830cb958cefa9cccd75eec94591f76d Mon Sep 17 00:00:00 2001 From: Denis Kenzior Date: Mon, 6 Jun 2016 11:00:25 -0500 Subject: [PATCH] allowed-apns: Fix crash When a modem is being removed, all of the modem's atom watches have already been cleaned up. Trying to remove it again results in a crash. Fix by registering a destroy callback which will be notified when the atomwatch has been removed. --- plugins/allowed-apns.c | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/plugins/allowed-apns.c b/plugins/allowed-apns.c index fd68e35d..532d17af 100644 --- a/plugins/allowed-apns.c +++ b/plugins/allowed-apns.c @@ -72,6 +72,13 @@ static void context_destroy(gpointer data) g_free(ctx); } +static void atomwatch_destroy(gpointer data) +{ + struct allowed_apns_ctx *ctx = data; + + ctx->atomwatch_id = 0; +} + static void sim_acl_read_cb(int ok, int total_length, int record, const unsigned char *data, int record_length, void *userdata) @@ -246,7 +253,8 @@ static void modem_watch(struct ofono_modem *modem, ctx->atomwatch_id = __ofono_modem_add_atom_watch(ctx->modem, OFONO_ATOM_TYPE_SIM, - sim_watch, ctx, NULL); + sim_watch, ctx, + atomwatch_destroy); } static void call_modemwatch(struct ofono_modem *modem, void *userdata)