From: Sean Y. <se...@me...> - 2013-10-25 09:04:40
|
On Fri, Oct 25, 2013 at 12:57:27AM +0200, Peter Stuge wrote: > Sean Young wrote: > > @@ -321,21 +335,25 @@ static int logic16_dev_open(struct sr_dev_inst *sdi) > > } > > libusb_free_device_list(devlist, 1); > > > > - if (sdi->status != SR_ST_ACTIVE) > > + if (sdi->status != SR_ST_ACTIVE) { > > + if (usb->devhdl) { > > + libusb_release_interface(usb->devhdl, USB_INTERFACE); > > + libusb_close(usb->devhdl); > > + usb->devhdl = NULL; > > + } > > return SR_ERR; > > + } > > > > return SR_OK; > > } > > Are you sure that this is really correct? I'm not, but I don't know > the relevant code on the other hand. > > libusb_release_interface() must be called 1:1 with > libusb_claim_interface(), just like libusb_close() must be called 1:1 > with libusb_open(). The sdi->status != SR_ST_ACTIVE isn't obviously > a good way to determine whether a _claim() was successful? No, you're right. Silly mistake. Sean --- From: Sean Young <se...@me...> Date: Fri, 25 Oct 2013 09:59:12 +0100 Subject: [PATCH] Fix error path: do not release unless claimed --- hardware/saleae-logic16/api.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hardware/saleae-logic16/api.c b/hardware/saleae-logic16/api.c index dfcbe04..3dc8734 100644 --- a/hardware/saleae-logic16/api.c +++ b/hardware/saleae-logic16/api.c @@ -323,6 +323,7 @@ static int logic16_dev_open(struct sr_dev_inst *sdi) } if ((ret = logic16_init_device(sdi)) != SR_OK) { + libusb_release_interface(usb->devhdl, USB_INTERFACE); sr_err("Failed to init device."); break; } @@ -337,7 +338,6 @@ static int logic16_dev_open(struct sr_dev_inst *sdi) if (sdi->status != SR_ST_ACTIVE) { if (usb->devhdl) { - libusb_release_interface(usb->devhdl, USB_INTERFACE); libusb_close(usb->devhdl); usb->devhdl = NULL; } -- 1.8.3.1 |