laforge has uploaded this change for review.

View Change

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
---
M src/usb.c
1 file changed, 6 insertions(+), 0 deletions(-)

git pull ssh://gerrit.osmocom.org:29418/osmo-e1d refs/changes/21/30021/1
diff --git a/src/usb.c b/src/usb.c
index fc461c4..ff624ea 100644
--- a/src/usb.c
+++ b/src/usb.c
@@ -694,6 +694,12 @@

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",

To view, visit change 30021. To unsubscribe, or for help writing mail filters, visit settings.

Gerrit-Project: osmo-e1d
Gerrit-Branch: master
Gerrit-Change-Id: I2ce990bb57f6ae4edb3a99a4b7bf26a49f362410
Gerrit-Change-Number: 30021
Gerrit-PatchSet: 1
Gerrit-Owner: laforge <laforge@osmocom.org>
Gerrit-MessageType: newchange