From: Gerhard Sittig Date: Sun, 30 Sep 2018 19:52:21 +0000 (+0200) Subject: brymen-bm86x: avoid NULL deref when usb->devhdl does not exist X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=3ef305b0798bdad70d8b57a606139446507a99e0;p=libsigrok.git brymen-bm86x: avoid NULL deref when usb->devhdl does not exist 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 --- diff --git a/src/hardware/brymen-bm86x/api.c b/src/hardware/brymen-bm86x/api.c index 892a4828..f0713010 100644 --- a/src/hardware/brymen-bm86x/api.c +++ b/src/hardware/brymen-bm86x/api.c @@ -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));