devices/wwan: don't assert on unexpected state

On very particular timing, if a connection is currently activating
on a modem device and user remove the remote settings associated
an device state change:

prepare -> deactivating (reason 'connection-removed', sys-iface-state: 'managed')

pops before entering into modem_prepare_result, resulting to a crash
on assertion.

We can simply check for the modem state to failed, set the success flag
to FALSE and continue.

Closes: https://gitlab.freedesktop.org/NetworkManager/NetworkManager/-/issues/1354

Signed-off-by: Frederic Martinsons <frederic.martinsons@unabiz.com>
This commit is contained in:
Frederic Martinsons 2023-09-01 07:34:43 +02:00 committed by Beniamino Galvani
parent 07b46b7873
commit 2d85b11660

View file

@ -70,14 +70,17 @@ ppp_failed(NMModem *modem, guint i_reason, gpointer user_data)
static void
modem_prepare_result(NMModem *modem, gboolean success, guint i_reason, gpointer user_data)
{
NMDeviceModem *self = NM_DEVICE_MODEM(user_data);
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self);
NMDevice *device = NM_DEVICE(self);
NMDeviceStateReason reason = i_reason;
NMDeviceModem *self = NM_DEVICE_MODEM(user_data);
NMDeviceModemPrivate *priv = NM_DEVICE_MODEM_GET_PRIVATE(self);
NMDevice *device = NM_DEVICE(self);
NMDeviceStateReason reason = i_reason;
NMDeviceState device_state = nm_device_get_state(device);
if (nm_device_get_state(device) != NM_DEVICE_STATE_PREPARE
if (device_state != NM_DEVICE_STATE_PREPARE
|| priv->stage1_state != NM_DEVICE_STAGE_STATE_PENDING) {
nm_assert_not_reached();
_LOGD(LOGD_MB,
"device no longer in prepare state when modem prepare finished ('%s')",
nm_device_state_to_string(device_state));
success = FALSE;
}