diff options
Diffstat (limited to 'src/k8055.c')
-rw-r--r-- | src/k8055.c | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/src/k8055.c b/src/k8055.c index 6f3bc17..6b10cca 100644 --- a/src/k8055.c +++ b/src/k8055.c @@ -181,6 +181,8 @@ int k8055_open_device(int port, k8055_device** device) { ssize_t size = libusb_get_device_list(context, &connected_devices); /* get all devices on system */ if (size <= 0) { print_error("no usb devices found on system"); + if (k8055_open_devices <= 0) + libusb_exit(context); return K8055_ERROR_NO_DEVICES; } @@ -195,6 +197,9 @@ int k8055_open_device(int port, k8055_device** device) { } if (k8055 == NULL) { print_error("velleman k8055 not found at port"); + libusb_free_device_list(connected_devices, 1); // cleanup + if (k8055_open_devices <= 0) + libusb_exit(context); return K8055_ERROR_NO_K8055; } |