From fe970cfe2cf1490641aa3e753e205b1345ff078d Mon Sep 17 00:00:00 2001 From: Nick Chan Date: Wed, 15 Feb 2023 14:13:52 +0800 Subject: [PATCH] fix crash on no usb ports --- src/main.c | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/main.c b/src/main.c index e04b307..63b5931 100644 --- a/src/main.c +++ b/src/main.c @@ -109,6 +109,18 @@ int palera1n(int argc, char *argv[]) { else goto normal_exit; } #endif +#ifdef USE_LIBUSB + { + int test_libusb = libusb_init(NULL); + if (test_libusb) { + LOG(LOG_ERROR, "cannot initialize libusb: %d (%s)\n", test_libusb, libusb_strerror(test_libusb)); + libusb_exit(NULL); + goto cleanup; + } + libusb_exit(NULL); + } +#endif + if (!checkrain_option_enabled(host_flags, host_option_device_info)) LOG(LOG_INFO, "Waiting for devices");