From e78cafbaa2692f5b6e8e8f0ff306f5826c5dd94d Mon Sep 17 00:00:00 2001 From: Mark Kuo Date: Sun, 10 Jan 2021 16:58:26 +1100 Subject: [PATCH] linux_usbfs: Fix exit crash on Android In commit "89b810ec Android: Add option LIBUSB_OPTION_WEAK_AUTHORITY to support used in apk", we should also check weak_authority when exiting the backend. [dickens] Fixed whitespace Closes #842 Signed-off-by: Mark Kuo Signed-off-by: Chris Dickens --- libusb/os/linux_usbfs.c | 7 +++++++ libusb/version_nano.h | 2 +- 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/libusb/os/linux_usbfs.c b/libusb/os/linux_usbfs.c index 7175b35..4882c0f 100644 --- a/libusb/os/linux_usbfs.c +++ b/libusb/os/linux_usbfs.c @@ -415,6 +415,13 @@ static int op_init(struct libusb_context *ctx) static void op_exit(struct libusb_context *ctx) { UNUSED(ctx); + +#ifdef __ANDROID__ + if (weak_authority) { + return; + } +#endif + usbi_mutex_static_lock(&linux_hotplug_startstop_lock); assert(init_count != 0); if (!--init_count) { diff --git a/libusb/version_nano.h b/libusb/version_nano.h index b74033d..e7da9f6 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11596 +#define LIBUSB_NANO 11597 -- 2.7.4