diff options
author | Harald Welte <laforge@osmocom.org> | 2022-11-03 23:09:07 +0100 |
---|---|---|
committer | Harald Welte <laforge@osmocom.org> | 2022-11-05 22:26:07 +0100 |
commit | 5806606ce59435f78800ceda4e36efc54eeded15 (patch) | |
tree | d0a6c82cc56a3dafff9b40a898e4eb55d226e5f5 | |
parent | 7f204ac42ab70cbd105d5862c2e2348287ebddf5 (diff) |
avoid segfault in 'show interface' of absent icE1usb
Don't segfault when processing a "show interfaces" for an interface
that is configured via VTY but not actually attached/found in the
system:
usb.c:693:29: runtime error: member access within null pointer of type 'struct e1_usb_intf_data'
Depends: https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/30019
Depends: https://gerrit.osmocom.org/c/osmo-gsm-manuals/+/30020
Change-Id: I2ce990bb57f6ae4edb3a99a4b7bf26a49f362410
-rw-r--r-- | src/usb.c | 6 |
1 files changed, 6 insertions, 0 deletions
@@ -694,6 +694,12 @@ e1_usb_intf_gpsdo_state_string(char *buf, size_t len, const struct e1_intf *intf OSMO_ASSERT(intf->drv == E1_DRIVER_USB); + if (!id) { + /* This can happen for statically configured devices (config/vty) which are not + * currently present */ + return snprintf(buf, len, "unknown"); + } + return snprintf(buf, len, "mode=%s, fix=%s, state=%s antenna=%s, tune=%u/%u, freq_est=%u", get_value_string(ice1usb_gpsdo_mode_str, last_st->mode), last_st->valid_fix ? "TRUE" : "FALSE", |