summaryrefslogtreecommitdiffstats
path: root/drivers/hfpmodem
diff options
context:
space:
mode:
authorMikel Astiz <mikel.astiz@bmw-carit.de>2011-10-21 18:51:33 +0200
committerDenis Kenzior <denkenz@gmail.com>2011-10-21 13:17:17 -0500
commit6e5edc8ead8f1639e848cd5074014e7fc124b732 (patch)
treeabfec8f276290e64afe302e1f9fe6e7b3606b190 /drivers/hfpmodem
parentc1ed32db9d456e0756441c1d820cd619d8f344e9 (diff)
downloadofono-6e5edc8ead8f1639e848cd5074014e7fc124b732.tar.bz2
hfpmodem: Avoid segfault in call-volume
The use of g_idle_add can cause a segmentation fault if the object is destroyed in the meantime.
Diffstat (limited to 'drivers/hfpmodem')
-rw-r--r--drivers/hfpmodem/call-volume.c8
1 files changed, 7 insertions, 1 deletions
diff --git a/drivers/hfpmodem/call-volume.c b/drivers/hfpmodem/call-volume.c
index 504b0a5e..0d7431e2 100644
--- a/drivers/hfpmodem/call-volume.c
+++ b/drivers/hfpmodem/call-volume.c
@@ -50,6 +50,7 @@ struct cv_data {
GAtChat *chat;
unsigned char sp_volume;
unsigned char mic_volume;
+ guint register_source;
};
static void cv_generic_set_cb(gboolean ok, GAtResult *result,
@@ -173,6 +174,8 @@ static gboolean hfp_call_volume_register(gpointer user_data)
DBG("");
+ vd->register_source = 0;
+
g_at_chat_register(vd->chat, "+VGS:", vgs_notify, FALSE, cv, NULL);
g_at_chat_register(vd->chat, "+VGM:", vgm_notify, FALSE, cv, NULL);
@@ -197,7 +200,7 @@ static int hfp_call_volume_probe(struct ofono_call_volume *cv,
ofono_call_volume_set_data(cv, vd);
- g_idle_add(hfp_call_volume_register, cv);
+ vd->register_source = g_idle_add(hfp_call_volume_register, cv);
return 0;
}
@@ -206,6 +209,9 @@ static void hfp_call_volume_remove(struct ofono_call_volume *cv)
{
struct cv_data *vd = ofono_call_volume_get_data(cv);
+ if (vd->register_source != 0)
+ g_source_remove(vd->register_source);
+
ofono_call_volume_set_data(cv, NULL);
g_at_chat_unref(vd->chat);