]> sigrok.org Git - libsigrok.git/blobdiff - src/hardware/sysclk-lwla/api.c
sysclk-lwla: silence potential NULL dereference compiler warning
[libsigrok.git] / src / hardware / sysclk-lwla / api.c
index 93e54895e08ffd8352e7342f772e552fecd3df4d..231df4dbf270b2181c6f8ea3f7f59e98aa6116f1 100644 (file)
@@ -259,6 +259,8 @@ static int dev_open(struct sr_dev_inst *sdi)
                /* This delay appears to be necessary for reliable operation. */
                g_usleep(30 * 1000);
 
+               sdi->status = SR_ST_ACTIVE;
+
                devc->active_fpga_config = FPGA_NOCONF;
                devc->short_transfer_quirk = FALSE;
                devc->state = STATE_IDLE;
@@ -271,6 +273,7 @@ static int dev_open(struct sr_dev_inst *sdi)
                        break;
 
                /* Rinse and repeat. */
+               sdi->status = SR_ST_INACTIVE;
                sr_usb_close(usb);
        }
 
@@ -301,11 +304,12 @@ static int dev_close(struct sr_dev_inst *sdi)
        if (ret != SR_OK)
                sr_warn("Unable to shut down device.");
 
-       libusb_release_interface(usb->devhdl, USB_INTERFACE);
+       if (usb->devhdl)
+               libusb_release_interface(usb->devhdl, USB_INTERFACE);
 
        sr_usb_close(usb);
 
-       return SR_OK;
+       return ret;
 }
 
 /* Check whether the device options contain a specific key.
@@ -584,6 +588,8 @@ static int config_list(uint32_t key, GVariant **data,
                        (devc) ? devc->model->num_devopts : 0);
        }
 
+       if (!devc)
+               return SR_ERR_ARG;
        if (!has_devopt(devc->model, key | SR_CONF_LIST))
                return SR_ERR_NA;