From: HÃ¥vard Espeland Date: Sat, 15 Jan 2011 13:03:08 +0000 (+0100) Subject: Sigma: Check state in hw_closedev X-Git-Tag: libsigrok-0.1.0~436 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=9be9893eed4acf03533d1a2fb63719de6eb10753;p=libsigrok.git Sigma: Check state in hw_closedev If the device is closed without previously running hw_openedev the driver crashes (happens in cleanup). This patch checks if the device has been opened. --- diff --git a/hardware/asix-sigma/asix-sigma.c b/hardware/asix-sigma/asix-sigma.c index d4d9fddf..cac38620 100644 --- a/hardware/asix-sigma/asix-sigma.c +++ b/hardware/asix-sigma/asix-sigma.c @@ -644,9 +644,15 @@ static int configure_probes(GSList *probes) static void hw_closedev(int device_index) { - device_index = device_index; + struct sigrok_device_instance *sdi; - ftdi_usb_close(&ftdic); + if ((sdi = get_sigrok_device_instance(device_instances, device_index))) + { + if (sdi->status == ST_ACTIVE) + ftdi_usb_close(&ftdic); + + sdi->status = ST_INACTIVE; + } } static void hw_cleanup(void)