summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoe Rubinstein <nrubinstein@avencall.com>2012-11-08 14:38:11 +0100
committerNoe Rubinstein <nrubinstein@avencall.com>2012-11-08 14:38:11 +0100
commite7bdaa4cec115c4154a09a2b7447a8a5755d1184 (patch)
treeb797399a531fae747ba8ca65f7010df5da4e1c64
parent78e0de6a536c8eca00d4cd801fb5fbc8a15d0968 (diff)
fix dump_count underflow
-rw-r--r--tdm/xivo_tdm.c21
1 files changed, 17 insertions, 4 deletions
diff --git a/tdm/xivo_tdm.c b/tdm/xivo_tdm.c
index c814a4b..ba8d711 100644
--- a/tdm/xivo_tdm.c
+++ b/tdm/xivo_tdm.c
@@ -81,7 +81,8 @@ MODULE_PARM_DESC(dump_count, "number of traces to emit "
"(can be reset at runtime via /sys)");
#define DBG_TRACE(...) \
do { \
- if (dump_count-- > 0) { \
+ if (dump_count > 0) { \
+ dump_count--; \
printk(KERN_ERR __VA_ARGS__); \
} \
} while (0)
@@ -1568,14 +1569,26 @@ static int __init xivo_tdm_init(void)
return 0;
}
-static void __exit xivo_tdm_exit(void)
+static void xivo_tdm_pre_exit(void)
{
- printk(KERN_ERR "BUGBUG WARNING MEMORY LEAK YOU'LL DIE and probably "
- "crash too (triggered by module unload)\n");
+ static int pre_exit_done;
+
+ if (pre_exit_done) return;
+ pre_exit_done = 1; // race condition
tdm_register_trigger_hardirq_handler(NULL);
msleep(10); // BUGBUG racy hack
xivo_internal_cleanup();
+}
+EXPORT_SYMBOL(xivo_tdm_pre_exit);
+
+static void __exit xivo_tdm_exit(void)
+{
+ printk(KERN_ERR "BUGBUG WARNING MEMORY LEAK YOU'LL DIE and probably "
+ "crash too (triggered by module unload)\n");
+
+ xivo_tdm_pre_exit();
+
#ifdef DEBUGFS_MY_STUFF
hrtimer_cancel(&debug_timer);