Skip site navigation (1)Skip section navigation (2)
Date:      Wed, 25 Jun 2025 12:40:10 GMT
From:      Baptiste Daroussin <bapt@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Subject:   git: 4981b8968d19 - main - libusb: consider bad fd as a broken event
Message-ID:  <202506251240.55PCeAEC039276@gitrepo.freebsd.org>

next in thread | raw e-mail | index | archive | help
The branch main has been updated by bapt:

URL: https://cgit.FreeBSD.org/src/commit/?id=4981b8968d19f009347ee8844770e84f9b83311e

commit 4981b8968d19f009347ee8844770e84f9b83311e
Author:     SHENGYI HUNG <aokblast@FreeBSD.org>
AuthorDate: 2025-06-20 21:45:27 +0000
Commit:     Baptiste Daroussin <bapt@FreeBSD.org>
CommitDate: 2025-06-25 12:40:02 +0000

    libusb: consider bad fd as a broken event
    
    Application can use libusb_get_pollfds to get pollfds from libusb then
    close the fd themselves. This cause the hotplug thread unable to leave
    because it will be consider as a invalid event then loop forever instead
    of a broken event that should be quit immediately.
    
    Reviewed by: bapt
    Sponsored by: FreeBSD Foundation
    Differential Revision: https://reviews.freebsd.org/D50959
---
 lib/libusb/libusb10_hotplug.c | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/lib/libusb/libusb10_hotplug.c b/lib/libusb/libusb10_hotplug.c
index f148e4dd43f5..369539d4512e 100644
--- a/lib/libusb/libusb10_hotplug.c
+++ b/lib/libusb/libusb10_hotplug.c
@@ -140,6 +140,8 @@ verify_event_validity(libusb_context *ctx)
 				return (valid_event);
 			return (invalid_event);
 		}
+		if (errno == EBADF)
+			return (broken_event);
 		return (invalid_event);
 	} else if (ctx->usb_event_mode == usb_event_devd) {
 		char buf[DEVCTL_MAXBUF];



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202506251240.55PCeAEC039276>