From: Aurelien Jacobs Date: Thu, 13 Aug 2015 23:03:57 +0000 (+0200) Subject: brymen-bm86x: add some error checking X-Git-Tag: libsigrok-0.4.0~449 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=6d930b4159c2df2a500610f50c6df360f4dcd29a;p=libsigrok.git brymen-bm86x: add some error checking --- diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 834f11bb..92baed54 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -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;