OpenBSD: allow opening ugen devices multiple times
Fix an OpenBSD backend bug where an existing open file descriptor is
overwritten if a libusb user attempts to open the same ugen(4) device
multiple times. This was observed with sane-backends and broke scanning.
Fix from stsp@openbsd.org
Closes #763
Signed-off-by: Chris Dickens <christopher.a.dickens@gmail.com>
diff --git a/libusb/os/openbsd_usb.c b/libusb/os/openbsd_usb.c
index f5b0470..acd8c2a 100644
--- a/libusb/os/openbsd_usb.c
+++ b/libusb/os/openbsd_usb.c
@@ -225,15 +225,17 @@
char devnode[16];
if (dpriv->devname) {
+ int fd;
/*
* Only open ugen(4) attached devices read-write, all
* read-only operations are done through the bus node.
*/
snprintf(devnode, sizeof(devnode), DEVPATH "%s.00",
dpriv->devname);
- dpriv->fd = open(devnode, O_RDWR);
- if (dpriv->fd < 0)
+ fd = open(devnode, O_RDWR);
+ if (fd < 0)
return _errno_to_libusb(errno);
+ dpriv->fd = fd;
usbi_dbg("open %s: fd %d", devnode, dpriv->fd);
}
diff --git a/libusb/version_nano.h b/libusb/version_nano.h
index 6d12f78..baa7aa2 100644
--- a/libusb/version_nano.h
+++ b/libusb/version_nano.h
@@ -1 +1 @@
-#define LIBUSB_NANO 11527
+#define LIBUSB_NANO 11528