diff options
author | Thomas Haller <thaller@redhat.com> | 2018-03-14 08:19:47 +0100 |
---|---|---|
committer | Thomas Haller <thaller@redhat.com> | 2018-03-18 21:09:56 +0100 |
commit | 5dce8c18854e8884ac7282d662fd691f0c0709a1 (patch) | |
tree | a825e3e6abd4f6414ce07849d01065f219c25f74 | |
parent | d60199502756b6dce6b4610e2c5c7f6e1892f086 (diff) | |
download | NetworkManager-5dce8c18854e8884ac7282d662fd691f0c0709a1.tar.gz |
ofono: fix crash during complete-connection for Ofono modem
nm_modem_complete_connection() cannot just return FALSE in case
the modem doesn't overwrite complete_connection(). It must set
the error variable.
This leads to a crash when calling AddAndActivate for Ofono type
modem. It does not affect the ModemManager implementation
NMModemBroadband, because that one implements the method.
-rw-r--r-- | src/devices/wwan/nm-modem.c | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/src/devices/wwan/nm-modem.c b/src/devices/wwan/nm-modem.c index 85f6eb039e..b21861730c 100644 --- a/src/devices/wwan/nm-modem.c +++ b/src/devices/wwan/nm-modem.c @@ -1094,9 +1094,17 @@ nm_modem_complete_connection (NMModem *self, const GSList *existing_connections, GError **error) { - if (NM_MODEM_GET_CLASS (self)->complete_connection) - return NM_MODEM_GET_CLASS (self)->complete_connection (self, connection, existing_connections, error); - return FALSE; + NMModemClass *klass; + + klass = NM_MODEM_GET_CLASS (self); + if (!klass->complete_connection) { + g_set_error (error, NM_DEVICE_ERROR, NM_DEVICE_ERROR_INVALID_CONNECTION, + "Modem class %s had no complete_connection method", + G_OBJECT_TYPE_NAME (self)); + return FALSE; + } + + return NM_MODEM_GET_CLASS (self)->complete_connection (self, connection, existing_connections, error); } /*****************************************************************************/ |