File tree Expand file tree Collapse file tree 1 file changed +10
-1
lines changed
src/platform/windows_winusb Expand file tree Collapse file tree 1 file changed +10
-1
lines changed Original file line number Diff line number Diff line change @@ -36,7 +36,7 @@ const DEVICE_IS_SUPER_SPEED_CAPABLE_OR_HIGHER: u32 = 0x02;
3636const DEVICE_IS_OPERATING_AT_SUPER_SPEED_PLUS_OR_HIGHER : u32 = 0x04 ;
3737const DEVICE_IS_SUPER_SPEED_PLUS_CAPABLE_OR_HIGHER : u32 = 0x08 ;
3838
39- use crate :: { Error , Speed } ;
39+ use crate :: { descriptors :: DESCRIPTOR_TYPE_DEVICE , Error , Speed } ;
4040
4141use super :: {
4242 cfgmgr32:: DevInst ,
@@ -83,6 +83,15 @@ impl HubHandle {
8383 ) ;
8484
8585 if r == TRUE {
86+ if info. DeviceDescriptor . bDescriptorType != DESCRIPTOR_TYPE_DEVICE {
87+ // When the device is disconnected during this call, Windows is observed to
88+ // sometimes return an all-zero device descriptor.
89+ return Err ( Error :: new (
90+ std:: io:: ErrorKind :: Other ,
91+ "IOCTL_USB_GET_NODE_CONNECTION_INFORMATION_EX returned an invalid device descriptor" ,
92+ ) ) ;
93+ }
94+
8695 Ok ( info)
8796 } else {
8897 let err = Error :: last_os_error ( ) ;
You can’t perform that action at this time.
0 commit comments