From 1f21b5c10bf2ddab7c055bf918203e1a832686c6 Mon Sep 17 00:00:00 2001 From: Maksim Ivanov Date: Fri, 12 Apr 2024 18:57:20 +0000 Subject: [PATCH] Ensure cleanup on hotplug_libusb shutdown Make sure the hotplug_libusb cleanup code is executed on all exit branches from the thread. Before the commit, it was possible that the cleanup code in HPRescanUsbBus() would be skipped if the caller (HPEstablishUSBNotifications()) decides to exit on its own. Also libusb_exit() was skipped in some branches. The commit moves the cleanup code to the end of HPEstablishUSBNotifications() and removes pthread_exit() from HPRescanUsbBus(), so that cleanup isn't skipped. --- src/hotplug_libusb.c | 48 +++++++++++++++++++++----------------------- 1 file changed, 23 insertions(+), 25 deletions(-) diff --git a/src/hotplug_libusb.c b/src/hotplug_libusb.c index 46d5506c..6678f3db 100644 --- a/src/hotplug_libusb.c +++ b/src/hotplug_libusb.c @@ -447,30 +447,6 @@ static void HPRescanUsbBus(void) /* free the libusb allocated list & devices */ libusb_free_device_list(devs, 1); - - if (AraKiriHotPlug) - { - int retval; - - for (i=0; i