From e23231ccffb149108bb9f80d0b467b24153fcbfa Mon Sep 17 00:00:00 2001 From: Jingkui Wang Date: Wed, 20 Mar 2019 11:16:26 -0700 Subject: usb: fix serial devices by removing device context verification 1. Removed for device slot reset and evaluate context. The verification was unnecessary and may cause some guest kernel operations to fail. 2. The context was updated after dequeue pointer set 3. Reset device when it's attached. 4. Add seccomp rules to allow the above reset. The verification was copied from another implementation which works for adb, but does not work with serial devices. The verification is also not part of the spec, so we removed it here. BUG=b:131336977 TEST=local build and test Change-Id: Ifd7994ff5512346d1bab27654e60c97a602da8a6 Signed-off-by: Daniel Verkamp Signed-off-by: Zach Reizner Reviewed-on: https://chromium-review.googlesource.com/1558934 Tested-by: kokoro --- usb_util/src/device_handle.rs | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'usb_util') diff --git a/usb_util/src/device_handle.rs b/usb_util/src/device_handle.rs index 72ee178..32a963f 100644 --- a/usb_util/src/device_handle.rs +++ b/usb_util/src/device_handle.rs @@ -39,6 +39,12 @@ impl DeviceHandle { } } + /// Reset this usb device. + pub fn reset(&self) -> Result<()> { + // Safe because 'self.handle' is a valid pointer to device handle. + try_libusb!(unsafe { bindings::libusb_reset_device(self.handle) }); + Ok(()) + } /// Get bConfigurationValue of the currently active configuration. pub fn get_active_configuration(&self) -> Result { let mut config: c_int = 0; -- cgit 1.4.1