]> sigrok.org Git - libsigrok.git/commitdiff
kingst-la2016: handle sdi==NULL in config_list
authorMike Walters <redacted>
Sun, 14 Nov 2021 22:03:01 +0000 (22:03 +0000)
committerSoeren Apel <redacted>
Sun, 14 Nov 2021 22:53:22 +0000 (23:53 +0100)
The hardware driver API specifies that the sdi argument to config_list
is optional and can be NULL. This change handles that case, instead of
dereferencing without a check.

src/hardware/kingst-la2016/api.c

index 1b1b425a0204169440429807430067f4ac58064a..216869ed8f222b29bb7599712a24e26ee72b01c4 100644 (file)
@@ -504,13 +504,14 @@ static int config_list(uint32_t key, GVariant **data,
 {
        struct dev_context *devc;
 
-       devc = sdi->priv;
-
        switch (key) {
        case SR_CONF_SCAN_OPTIONS:
        case SR_CONF_DEVICE_OPTIONS:
                return STD_CONFIG_LIST(key, data, sdi, cg, scanopts, drvopts, devopts);
        case SR_CONF_SAMPLERATE:
+               if (!sdi)
+                       return SR_ERR_ARG;
+               devc = sdi->priv;
                if (devc->max_samplerate == SR_MHZ(200)) {
                        *data = std_gvar_samplerates(ARRAY_AND_SIZE(samplerates_la2016));
                }