From 9501adff2455446aa6ce017525c9d747be67c115 Mon Sep 17 00:00:00 2001 From: Aymeric Vincent Date: Thu, 28 Feb 2019 22:38:21 +0100 Subject: Initialize the non-control endpoint fds in netbsd_open() Not all users of libusb use libusb_claim_interface(), and in that case, the NetBSD backend fails to open() the necessary /dev/ugenX.Y and will try to send ioctl()s to fd 0, which fortunately fails. This unbreaks e.g. openocd on NetBSD. Closes #539 Signed-off-by: Nathan Hjelm --- libusb/os/netbsd_usb.c | 5 +++++ libusb/version_nano.h | 2 +- 2 files changed, 6 insertions(+), 1 deletion(-) diff --git a/libusb/os/netbsd_usb.c b/libusb/os/netbsd_usb.c index d9c059a..79aeca9 100644 --- a/libusb/os/netbsd_usb.c +++ b/libusb/os/netbsd_usb.c @@ -215,6 +215,8 @@ int netbsd_open(struct libusb_device_handle *handle) { struct device_priv *dpriv = (struct device_priv *)handle->dev->os_priv; + struct handle_priv *hpriv = (struct handle_priv *)handle->os_priv; + int i; dpriv->fd = open(dpriv->devnode, O_RDWR); if (dpriv->fd < 0) { @@ -223,6 +225,9 @@ netbsd_open(struct libusb_device_handle *handle) return _errno_to_libusb(errno); } + for (i = 0; i < USB_MAX_ENDPOINTS; i++) + hpriv->endpoints[i] = -1; + usbi_dbg("open %s: fd %d", dpriv->devnode, dpriv->fd); return (LIBUSB_SUCCESS); diff --git a/libusb/version_nano.h b/libusb/version_nano.h index dc15091..0d6bc45 100644 --- a/libusb/version_nano.h +++ b/libusb/version_nano.h @@ -1 +1 @@ -#define LIBUSB_NANO 11348 +#define LIBUSB_NANO 11349 -- cgit v1.2.1