Initialize the non-control endpoint fds in netbsd_open()
authorAymeric Vincent <aymericvincent@free.fr>
Thu, 28 Feb 2019 21:38:21 +0000 (22:38 +0100)
committerNathan Hjelm <hjelmn@me.com>
Fri, 5 Apr 2019 03:19:07 +0000 (21:19 -0600)
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 <hjelmn@me.com>
libusb/os/netbsd_usb.c
libusb/version_nano.h

index d9c059a..79aeca9 100644 (file)
@@ -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);
index dc15091..0d6bc45 100644 (file)
@@ -1 +1 @@
-#define LIBUSB_NANO 11348
+#define LIBUSB_NANO 11349