Skip to content

Commit

Permalink
libftdi1: fix critical bug
Browse files Browse the repository at this point in the history
This broke the standard Context::open function...
  • Loading branch information
v4hn committed Sep 1, 2014
1 parent 7936245 commit b5ca1ce
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 1 deletion.
4 changes: 3 additions & 1 deletion devel/libftdi1/PRE_BUILD
@@ -1,4 +1,6 @@
default_pre_build &&

# make cmake report correct C++ library
sedit 's/ftdi1pp/ftdipp1/' CMakeLists.txt
sedit 's/ftdi1pp/ftdipp1/' CMakeLists.txt &&

patch_it $SCRIPT_DIRECTORY/libftdi1-1.1-no-double-open.diff 1
21 changes: 21 additions & 0 deletions devel/libftdi1/libftdi1-1.1-no-double-open.diff
@@ -0,0 +1,21 @@
commit bc3841238bac9cb6955848fd661bbf19a5ed42c6
Author: Denis Sirotkin <reg.libftdi@demitel.ru>
Date: Fri May 16 17:40:13 2014 +0200

ftdi_usb_get_strings(): Don't try to open an already open device

diff --git a/src/ftdi.c b/src/ftdi.c
index b6caf6c..add6dc2 100644
--- a/src/ftdi.c
+++ b/src/ftdi.c
@@ -413,8 +413,8 @@ int ftdi_usb_get_strings(struct ftdi_context * ftdi, struct libusb_device * dev,
if ((ftdi==NULL) || (dev==NULL))
return -1;

- if (libusb_open(dev, &ftdi->usb_dev) < 0)
- ftdi_error_return(-4, "libusb_open() failed");
+ if (ftdi->usb_dev == NULL && libusb_open(dev, &ftdi->usb_dev) < 0)
+ ftdi_error_return(-4, "libusb_open() failed");

if (libusb_get_device_descriptor(dev, &desc) < 0)
ftdi_error_return(-11, "libusb_get_device_descriptor() failed");

0 comments on commit b5ca1ce

Please sign in to comment.