linux_usbfs: Fix exit crash on Android
authorMark Kuo <starryalley@gmail.com>
Sun, 10 Jan 2021 05:58:26 +0000 (16:58 +1100)
committerChris Dickens <christopher.a.dickens@gmail.com>
Fri, 15 Jan 2021 16:07:56 +0000 (08:07 -0800)
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 <starryalley@gmail.com>
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
libusb/os/linux_usbfs.c
libusb/version_nano.h

index 7175b354905af785793bc034cef5b609f1799d9d..4882c0f6369067ab14885403896642b2961fd602 100644 (file)
@@ -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) {
index b74033d04c351ee3f9ec6e3df5d2450dbdf1770f..e7da9f6cc7a7d3774eca40ec3abb6d375ba1cf03 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11596
+#define LIBUSB_NANO 11597