summaryrefslogtreecommitdiff
path: root/drivers
diff options
context:
space:
mode:
authorDenis Kenzior <denkenz@gmail.com>2010-05-11 09:10:58 -0500
committerDenis Kenzior <denkenz@gmail.com>2010-05-11 09:10:58 -0500
commitdea4c88906bdbc1fb488cc3239ba08342209e006 (patch)
tree81f7bed8575e3f22a3a0c453154d095a225d72ca /drivers
parent1794ad32fd2ad702a94c6c14e0f9fbcf281a70de (diff)
atmodem: Fix crashes related to unremoved timeouts
Any timeouts set must be removed using g_source_remove. Failure to do so results in sigsegvs when the modem is randomly removed during the initialization cycle.
Diffstat (limited to 'drivers')
-rw-r--r--drivers/atmodem/sms.c14
1 files changed, 12 insertions, 2 deletions
diff --git a/drivers/atmodem/sms.c b/drivers/atmodem/sms.c
index 13f57231..8049df6e 100644
--- a/drivers/atmodem/sms.c
+++ b/drivers/atmodem/sms.c
@@ -75,6 +75,7 @@ struct sms_data {
gboolean cnma_enabled;
char *cnma_ack_pdu;
int cnma_ack_pdu_len;
+ guint timeout_source;
GAtChat *chat;
unsigned int vendor;
};
@@ -802,7 +803,7 @@ static void at_cpms_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
return at_sms_not_supported(sms);
}
- g_timeout_add_seconds(1, set_cpms, sms);
+ data->timeout_source = g_timeout_add_seconds(1, set_cpms, sms);
}
static gboolean set_cpms(gpointer user_data)
@@ -818,6 +819,9 @@ static gboolean set_cpms(gpointer user_data)
g_at_chat_send(data->chat, buf, cpms_prefix,
at_cpms_set_cb, sms, NULL);
+
+ data->timeout_source = 0;
+
return FALSE;
}
@@ -839,7 +843,7 @@ static void at_cmgf_set_cb(gboolean ok, GAtResult *result, gpointer user_data)
return at_sms_not_supported(sms);
}
- g_timeout_add_seconds(1, set_cmgf, sms);
+ data->timeout_source = g_timeout_add_seconds(1, set_cmgf, sms);
}
static gboolean set_cmgf(gpointer user_data)
@@ -849,6 +853,9 @@ static gboolean set_cmgf(gpointer user_data)
g_at_chat_send(data->chat, "AT+CMGF=0", cmgf_prefix,
at_cmgf_set_cb, sms, NULL);
+
+ data->timeout_source = 0;
+
return FALSE;
}
@@ -1070,6 +1077,9 @@ static void at_sms_remove(struct ofono_sms *sms)
if (data->cnma_ack_pdu)
g_free(data->cnma_ack_pdu);
+ if (data->timeout_source > 0)
+ g_source_remove(data->timeout_source);
+
g_free(data);
}