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.
This commit is contained in:
Håvard Espeland 2011-01-15 14:03:08 +01:00
parent 02440dd88c
commit 9be9893eed
1 changed files with 8 additions and 2 deletions

View File

@ -644,9 +644,15 @@ static int configure_probes(GSList *probes)
static void hw_closedev(int device_index) static void hw_closedev(int device_index)
{ {
device_index = device_index; struct sigrok_device_instance *sdi;
if ((sdi = get_sigrok_device_instance(device_instances, device_index)))
{
if (sdi->status == ST_ACTIVE)
ftdi_usb_close(&ftdic); ftdi_usb_close(&ftdic);
sdi->status = ST_INACTIVE;
}
} }
static void hw_cleanup(void) static void hw_cleanup(void)