From c54b3726418c8211bf9cb19323b5ba09ad409e1c Mon Sep 17 00:00:00 2001 From: Martin Atkins Date: Sun, 25 Oct 2020 13:16:37 -0700 Subject: [PATCH] scpi-pps: Data capture dynamically-probed channels For the few device profiles that probe the device dynamically to determine channel settings, the results end up in the dynamically-allocated devc->channels instead of in the statically-configured devc->device->channels field. Previously this would crash by dereferencing a null ch_spec for the device types that do dynamic channel configuration. [ gsi: address minor style nits ] --- src/hardware/scpi-pps/protocol.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hardware/scpi-pps/protocol.c b/src/hardware/scpi-pps/protocol.c index 9609936a..825fdb94 100644 --- a/src/hardware/scpi-pps/protocol.c +++ b/src/hardware/scpi-pps/protocol.c @@ -97,7 +97,13 @@ SR_PRIV int scpi_pps_receive_data(int fd, int revents, void *cb_data) if (ret != SR_OK) return ret; - ch_spec = &devc->device->channels[pch->hw_output_idx]; + if (devc->channels) { + /* Dynamically-probed devices. */ + ch_spec = &devc->channels[pch->hw_output_idx]; + } else { + /* Statically-configured devices. */ + ch_spec = &devc->device->channels[pch->hw_output_idx]; + } packet.type = SR_DF_ANALOG; packet.payload = &analog; /* Note: digits/spec_digits will be overridden later. */ -- 2.30.2