diff options
author | Frederic Martinsons <frederic.martinsons@sigfox.com> | 2020-12-20 18:11:06 +0100 |
---|---|---|
committer | Aleksander Morgado <aleksander@aleksander.es> | 2020-12-21 13:00:40 +0000 |
commit | 18b72a046e89d00d7e7b9f2d718c43d64e595de0 (patch) | |
tree | 42cdd907168810f0aea7d4b080ffa7e56d48c44f /cli/mmcli-manager.c | |
parent | 2f53a08e5f1eef8c1892dc55f32fbacba85565a0 (diff) |
mmcli: don't assume that mm_object_peek_modem or mm_object_get_modem return non null
This very peculiar case can happen when an intermediate initiliazition step
of a modem fails.
The ModemManager daemon should always expose the modem interface but let not
assume that in mmcli and protect these calls.
Signed-off-by: Frederic Martinsons <frederic.martinsons@sigfox.com>
Diffstat (limited to 'cli/mmcli-manager.c')
-rw-r--r-- | cli/mmcli-manager.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/cli/mmcli-manager.c b/cli/mmcli-manager.c index 01d2972c..011c8c11 100644 --- a/cli/mmcli-manager.c +++ b/cli/mmcli-manager.c @@ -332,9 +332,14 @@ output_modem_info (MMObject *obj, gchar *extra; const gchar *manufacturer; const gchar *model; + MMModem *modem; - manufacturer = mm_modem_get_manufacturer (mm_object_peek_modem (obj)); - model = mm_modem_get_model (mm_object_peek_modem (obj)); + modem = mm_object_peek_modem (obj); + if (!modem) + return; + + manufacturer = mm_modem_get_manufacturer (modem); + model = mm_modem_get_model (modem); extra = g_strdup_printf ("[%s] %s", manufacturer ? manufacturer : "manufacturer unknown", model ? model : "model unknown"); |