diff options
author | Benjamin Berg <bberg@redhat.com> | 2022-03-01 15:08:38 +0100 |
---|---|---|
committer | Tormod Volden <debian.tormod@gmail.com> | 2022-03-16 17:53:00 +0100 |
commit | 0846456f3a9fda8ff5469d9d0b9700837ff16f04 (patch) | |
tree | 1e03f2219253afb74df422b5889861cf95309c40 /libusb/hotplug.c | |
parent | 7cc06ea5c7c3b36801421a6be17b51b92c1bc05a (diff) | |
download | libusb-0846456f3a9fda8ff5469d9d0b9700837ff16f04.tar.gz |
core: Suppress hotplug events during initial enumeration
The initial enumeration should not result in hotplug events to be fired.
This is just a convenience though, API users still need to be prepared
to be notified a second time for a device that was plugged in between
libusb_init and libusb_hotplug_register_callback.
This regressed with commit 6929b82 ("Fix segmentation fault in
libusb_init() if usbi_backend.init() fails"). This commit avoids the
mentioned segmentation fault by avoiding to clean up the hotplug code if
it was not yet initialised.
Fixes #1082
Closes #1090
References #989
Diffstat (limited to 'libusb/hotplug.c')
-rw-r--r-- | libusb/hotplug.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/libusb/hotplug.c b/libusb/hotplug.c index 402e693..6b743c7 100644 --- a/libusb/hotplug.c +++ b/libusb/hotplug.c @@ -171,6 +171,9 @@ void usbi_hotplug_exit(struct libusb_context *ctx) if (!libusb_has_capability(LIBUSB_CAP_HAS_HOTPLUG)) return; + if (!usbi_atomic_load(&ctx->hotplug_ready)) + return; + /* free all registered hotplug callbacks */ for_each_hotplug_cb_safe(ctx, hotplug_cb, next_cb) { list_del(&hotplug_cb->list); |