libusbx/1058.patch
Benjamin Berg 992f6b72da Update to 1.0.25
- Fix a crash after libusb_exit API has been misused
- Add patchset to fix covscan reports
  Resolves: #1938801
2022-02-11 15:55:01 +01:00

25 lines
860 B
Diff

From 2529a3fc4f987f93e0774af865ac7cb6557bd0c2 Mon Sep 17 00:00:00 2001
From: Benjamin Berg <bberg@redhat.com>
Date: Fri, 4 Feb 2022 22:50:28 +0100
Subject: [PATCH] core: Unset device ctx if it has been destroyed
Devices can outlive their context in some cases (in particular with
python garbage collection). Guard against this happening by clearing the
ctx pointer so that it is not pointing to uninitialized memory.
---
libusb/core.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/libusb/core.c b/libusb/core.c
index 7893ac23..1c1ada14 100644
--- a/libusb/core.c
+++ b/libusb/core.c
@@ -2441,6 +2441,7 @@ void API_EXPORTED libusb_exit(libusb_context *ctx)
for_each_device(_ctx, dev) {
usbi_warn(_ctx, "device %d.%d still referenced",
dev->bus_number, dev->device_address);
+ DEVICE_CTX(dev) = NULL;
}
if (!list_empty(&_ctx->open_devs))