From: Theo Buehler Date: Wed, 5 Aug 2020 13:23:45 +0000 (+0200) Subject: OpenBSD: allow opening ugen devices multiple times X-Git-Tag: upstream/1.0.24~56 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=94519df868e59a7ea133b12c92823733645f8877;p=platform%2Fupstream%2Flibusb.git 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 --- 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 @@ obsd_open(struct libusb_device_handle *handle) 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