The qmi-proxy/mbim-proxy processes spawned by the daemon live in the
service's cgroup, so with the default KillMode=control-group systemd
sends SIGTERM to them at the same time as to the daemon on every unit
stop. The proxy exits immediately, tearing the control channel from
under the daemon while it is still disabling the modems:
<msg> caught signal, shutting down...
<msg> [modem0] state changed (connected -> disabling)
<msg> [modem0] port 'cdc-wdm0' no longer controllable, reprobing
<wrn> [/dev/cdc-wdm0] MBIM error: Device must be open to send commands
<wrn> shutdown failed: timeout waiting for sleep preparation to complete
The consequences of losing the proxy mid-shutdown:
- the modem disable/disconnect never reaches the device, so an MBIM
session with an active bearer is left open in the firmware (observed
to occasionally wedge the MBIM function of a Sierra EM7565 until a
firmware reset);
- the port teardown stalls waiting on the dead proxy until the
shutdown timeout, so stopping the unit always takes the full
MAX_SHUTDOWN_TIME_SECS instead of a second or two;
- the port invalidation triggers the device reprobe path in the middle
of the shutdown.
With KillMode=mixed only the daemon receives SIGTERM; the proxies
survive long enough for a clean disconnect and MBIM/QMI close, and
whatever remains in the cgroup afterwards (an idle, stateless proxy) is
killed when the unit finally stops.
Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
On my modem, AT!ICCID? command gives response without a preceding `!`:
```
AT!ICCID?
ICCID: 8970162010103256136
OK
```
Signed-off-by: Semyon Maryasin <simeon@maryasin.name>
device_caps_query_ready() declares caps_custom_data_class_str as
g_autofree without an initializer. On every early error return
(command failure such as a transaction timeout or NotOpened, or a
response parse failure) the variable is never assigned, so the
autofree cleanup runs g_free() on uninitialized stack garbage,
crashing ModemManager with a glibc "invalid free" abort (or SIGSEGV)
whenever the device caps query fails during modem initialization.
Fixes: 19c817cfe9 ("broadband-modem-mbim: consistently handle custom data classes")
Closes: #1094
Signed-off-by: Semyon Maryasin <simeon@maryasin.name>