]> sigrok.org Git - libsigrok.git/commitdiff
brymen-bm86x: avoid NULL deref when usb->devhdl does not exist
authorGerhard Sittig <redacted>
Sun, 30 Sep 2018 19:52:21 +0000 (21:52 +0200)
committerUwe Hermann <redacted>
Tue, 2 Oct 2018 17:01:04 +0000 (19:01 +0200)
There are code paths where dev_close() tries to access a USB handle
which does not exist. This was observed with this command:

  $ sigrok-cli -d brymen-bm86x --scan

src/hardware/brymen-bm86x/api.c

index 892a4828bb5d0e761170e486ac5e19b82d5d2d08..f0713010ea820ac60706f987ace12ec3545b81a4 100644 (file)
@@ -129,6 +129,9 @@ static int dev_close(struct sr_dev_inst *sdi)
        usb = sdi->conn;
        devc = sdi->priv;
 
+       if (!usb->devhdl)
+               return SR_OK;
+
        if ((ret = libusb_release_interface(usb->devhdl, 0)))
                sr_err("Failed to release interface 0: %s.\n", libusb_error_name(ret));