[PATCH] serial-port: turn open_count assertion in mm_serial_port_close into simple return

Ben Chan benchan at chromium.org
Fri Jan 10 16:54:45 PST 2014


When mm_serial_port_close is clearing a non-empty command queue, the
response handler callback of a command could potentially call
mm_serial_port_close again (e.g. via at_command_context_free,
at_sequence_context_free in mm-base-modem-at.c), which triggers the
following assertion:

  ModemManager: <debug> (ttyACM0) forced to close port
  ModemManager: <debug> (ttyACM0) device open count is 0 (close)
  ModemManager: <debug> (ttyACM0) closing serial port...
  ModemManager: <debug> (ttyACM0) serial port closed
  ModemManager: mm_serial_port_close: assertion `priv->open_count > 0' failed

The assertion is confusing as the condition is normal. This patch thus turns
the 'priv->open_count > 0' assertion in mm_serial_port_close into a simple
return.
---
 src/mm-serial-port.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/src/mm-serial-port.c b/src/mm-serial-port.c
index cc4fc46..ba29e8e 100644
--- a/src/mm-serial-port.c
+++ b/src/mm-serial-port.c
@@ -1015,7 +1015,8 @@ mm_serial_port_close (MMSerialPort *self)
     if (priv->forced_close)
         return;
 
-    g_return_if_fail (priv->open_count > 0);
+    if (priv->open_count == 0)
+        return;
 
     device = mm_port_get_device (MM_PORT (self));
 
-- 
1.8.5.1



More information about the ModemManager-devel mailing list