[PATCH] Check source_id before to call to g_source_remove function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



---
 health/mcap.c |   23 +++++++++++++++--------
 1 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/health/mcap.c b/health/mcap.c
index 17e16d8..7dc06ba 100644
--- a/health/mcap.c
+++ b/health/mcap.c
@@ -44,9 +44,11 @@
 
 #define MCAP_ERROR g_quark_from_static_string("mcap-error-quark")
 
-#define RELEASE_TIMER(__mcl) do {	\
-	g_source_remove(__mcl->tid);	\
-	__mcl->tid = 0;			\
+#define RELEASE_TIMER(__mcl) do {		\
+	if (__mcl->tid)	{			\
+		g_source_remove(__mcl->tid);	\
+		__mcl->tid = 0;			\
+	}					\
 } while(0)
 
 struct connect_mcl {
@@ -227,7 +229,10 @@ static void shutdown_mdl(struct mcap_mdl *mdl)
 {
 	mdl->state = MDL_CLOSED;
 
-	g_source_remove(mdl->wid);
+	if (mdl->wid) {
+		g_source_remove(mdl->wid);
+		mdl->wid = 0;
+	}
 
 	if (mdl->dc) {
 		g_io_channel_shutdown(mdl->dc, TRUE, NULL);
@@ -678,9 +683,7 @@ static void close_mcl(struct mcap_mcl *mcl, gboolean cache_requested)
 {
 	gboolean save = ((!(mcl->ctrl & MCAP_CTRL_FREE)) && cache_requested);
 
-	if (mcl->tid) {
-		RELEASE_TIMER(mcl);
-	}
+	RELEASE_TIMER(mcl);
 
 	if (mcl->cc) {
 		g_io_channel_shutdown(mcl->cc, TRUE, NULL);
@@ -688,7 +691,11 @@ static void close_mcl(struct mcap_mcl *mcl, gboolean cache_requested)
 		mcl->cc = NULL;
 	}
 
-	g_source_remove(mcl->wid);
+	if (mcl->wid) {
+		g_source_remove(mcl->wid);
+		mcl->wid = 0;
+	}
+
 	if (mcl->lcmd) {
 		g_free(mcl->lcmd);
 		mcl->lcmd = NULL;
-- 
1.7.0.4

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux