]> sigrok.org Git - libsigrok.git/commitdiff
brymen-bm86x: add some error checking
authorAurelien Jacobs <redacted>
Thu, 13 Aug 2015 23:03:57 +0000 (01:03 +0200)
committerUwe Hermann <redacted>
Sat, 15 Aug 2015 15:23:28 +0000 (17:23 +0200)
src/hardware/brymen-bm86x/api.c

index 834f11bb80cc140f4802771e7d8f156352875c23..92baed540c4a292a678b40647afe8798c40aaf3a 100644 (file)
@@ -109,6 +109,8 @@ static int dev_open(struct sr_dev_inst *sdi)
 
        if ((ret = sr_usb_open(drvc->sr_ctx->libusb_ctx, usb)) == SR_OK)
                sdi->status = SR_ST_ACTIVE;
+       else
+               return SR_ERR;
 
        /* Detach kernel drivers which grabbed this device (if any). */
        if (libusb_kernel_driver_active(usb->devhdl, 0) == 1) {
@@ -141,6 +143,9 @@ static int dev_close(struct sr_dev_inst *sdi)
        struct dev_context *devc;
        int ret;
 
+       if (sdi->status != SR_ST_ACTIVE)
+               return SR_ERR_DEV_CLOSED;
+
        usb = sdi->conn;
        devc = sdi->priv;