summaryrefslogtreecommitdiff
path: root/sys/dev/usb/usb_subr.c
AgeCommit message (Collapse)Author
2020-08-27usbd_get_cdesc() returns usb_config_descriptor_t *. Therefore returnMarcus Glocker
'NULL' instead of '0'. ok deraadt@
2020-07-31Nuke all occurrences of usbd_abort_pipe() if it gets called rightMarcus Glocker
before usbd_close_pipe(), since usbd_close_pipe() already takes care about aborting non-empty pipes. As investigated by gerhard@ usbdi.c rev. 1.57 did add usbd_abort_pipe() to usbd_close_pipe(), but the drivers didn't get cleaned up afterwards. ok gerhard@
2019-10-06tsleep(9) to tsleep_nsec(9) conversions.Martin Pieuchot
ok visa@, kn@, cheloha@
2019-06-24Don't retry to get the usb descriptor in usbd_new_device() if the callClaudio Jeker
timed out. If usbd_get_desc() returns USBD_TIMEOUT the chance is high that the next call will do the same and it slows down attachement of devices a lot. Makes reattaching USB at resume a lot faster with my umb(4) card (which likes to time out). "move fast and fix things" deraadt@
2019-02-17Publish new attached device once it is fully initialized.Martin Pieuchot
Should prevent a race seen by florian@ where userland emits an USB_DEVICEINFO ioctl(2) for a device whose product/vendor names haven't yet been filled. ok florian@
2019-01-22Remove unused variable.Martin Pieuchot
2018-11-27Free sizes for the subdevs array.Martin Pieuchot
ok anton@, visa@
2018-11-20Revert free sizes for `subdevs' array, it is incorrect.Martin Pieuchot
Reported by anton@ and Natasha Kerensikova
2018-11-18More uses of __func__ in debug printfs.Martin Pieuchot
2018-11-18Use "%s", __func__ in DPRINTF() to reduce grep noise.Martin Pieuchot
2018-11-17free(9) size for USB subdevs array.Martin Pieuchot
ok ratchov@, visa@
2018-11-16free(9) sizes for array of interfaces.Martin Pieuchot
ok visa@
2018-11-14free(9) sizes for configuration descriptors.Martin Pieuchot
ok tedu@, visa@
2018-11-10free(9) sizes for endpoints array.Martin Pieuchot
ok okan@, tedu@, visa@
2018-07-19Reuse implicit padding to export the port number of a USB device inMartin Pieuchot
USB_DEVICEINFO. devel/libusb1 requires this piece of information. ok jcs@, mikeb@, jasper@, sthen@
2018-07-10Change USB_DEVICEINFO to report USB port status/changes as currentlyMartin Pieuchot
seen by the stack. This will allows us to debug port status changes without relying on external tools, like lsusb(1), that generate I/O. While here correct USB3 LS port defines.
2018-05-01Simplify/refactor the way vendor/product/serial informations areLandry Breuil
gathered from usb devices. Cache them early in usbd_new_device() instead of querying the device several times (the content wont change anyway) and uselessly generating usb traffic (which could conflict with other access..) The heuristic stays the same, first look in the device descriptor, then try to match against usb_known_vendors/usb_known_products, then fallback to use the idVendor/idProduct codes. Remove the now useless 'usedev' parameter from usbd_fill_deviceinfo(). Tested from bsd & bsd.rd. suggested by and ok mpi@
2018-04-24Fill the 'card' member of v4l2_capability struct with the usb productLandry Breuil
name coming from usbd_devinfo_vp() instead of the dummy "Generic USB video class device" string, makes it easier to differentiate multiple webcams in firefox's webrtc permission dialog. ok/help mpi@
2017-04-08A pile of sizes to free(9). In test for a few days in snapshots.Theo de Raadt
Errors will result in nice clean panic messages so we know what's wrong. Reviewed by dhill visa natano jsg.
2017-04-053 more mallocarray() usesTheo de Raadt
2017-03-26Add sizes to various free(9) calls. Fixing the simpler ones first.Theo de Raadt
ok natano visa
2016-09-19Correctly check for valid maximum packet size.Martin Pieuchot
from jsg@
2016-09-19``bMaxPacketSize'' is reported as a power of 2 for super speed devicesMartin Pieuchot
as per section 4.8.2.1 of xHCI specification. Note that we never got this correctly. Spotted by and ok jsg@
2016-09-18Ensure that the device descriptor ``bMaxPacketSize'' value is usableMartin Pieuchot
before using it as the ``wMaxPacketSize'' of the default endpoint. This prevents host controller drivers from using incorrect value, in particular 0, that makes ehci(4) crash. While here do the 0xff -> 512 conversion for super speed devices. Crash found with a facedancer21. ok deraadt@
2016-09-12Split usbd_fill_iface_data() in two and introduce usbd_parse_idesc() aMartin Pieuchot
function for parsing and checking endpoint descriptors. More checks will be added later to prevent malformed descriptors of being used.
2016-09-02Pass M_ZERO when allocating memory for "struct usbd_endpoint".Martin Pieuchot
These descriptors are filled with value parsed from untrusted USB descriptors and we don't want to left memory unitialized if an error occurs during the parsing.
2016-09-02Cleanup usbd_fill_iface_data() to make it easier to check for badMartin Pieuchot
descriptors. No functionnal change.
2016-09-02Do not free the configuration descriptor without setting ``dev->cdesc''Martin Pieuchot
to NULL. Prevent a use after free triggerable with invalid interface descriptor. Found with umap2 and a facedancer21.
2016-09-02Prevent a NULL dereference, triggerable with a crafted configurationMartin Pieuchot
descriptor with a bad type. Found with umap2 and a facedancer21.
2016-05-23Get rid of usbd_get_device_strings() because we use it only once.Martin Pieuchot
Return a char * rather using a void function for usbd_get_device_string() ok patrick@
2016-05-21Free the cache if the string cannot be retrieved. This allows thePatrick Wildt
fallback method to actually do its work and look up the strings via the vendor and product id. Regression noticed and ok tb@, ok mpi@
2016-05-18Cache vendor, product and serial info for each usb device. This allowsPatrick Wildt
ioctl(USB_DEVICEINFO) not to issue any further requests to gather information. Thus reducing stress on connected usb devices. This fixes an issue where usbdevs called in a loop causes a USB mass storage device to halt operation. Adapted from a similar commit in NetBSD. ok mpi@
2016-03-03Convert uiomovei to uiomove. Fixes a few integer truncations along theStefan Kempf
way. ok natano@
2016-01-14Prevent a NULL dereference when detaching a USB device with ugen(4)Martin Pieuchot
disabled or if allocating memory during the attachment process failed. Problem reported by and original diff from James Hastings on bugs@. ok deraadt@
2015-10-24Wait a short while between setting a USB device's address and reloadingStefan Sperling
its descriptor. Fixes flaky attach of USB devices (most importantly the detachable keyboard) on the Thinkpad Helix 2, and perhaps elsewhere. Problem diagnosed by mpi; ok mpi@
2015-03-23Return an error if getting the config descriptor failed.Jonathan Gray
Avoids a NULL dereference encountered with a device I have. ok mpi@
2014-12-21Always clear a port reset feature after setting it, or at least try to.Martin Pieuchot
Otherwise we might leave a port in an unwanted state. Found while investigating timeout issues on xhci(4).
2014-12-13yet more mallocarray() changes.Doug Hogan
ok tedu@ deraadt@
2014-12-09More malloc() -> mallocarray() in the kernel.Doug Hogan
ok deraadt@ tedu@
2014-11-10Remove USB locators. They are currently unused and this wont change dueMartin Pieuchot
to the way USB buses are discovered.
2014-11-01Remove the port status argument from usbd_reset_port(). We don't doMartin Pieuchot
anything with it and it simplifies this mess in order to implement warm reset.
2014-11-01Use usbd_set_port_feature() instead of rerolling it.Martin Pieuchot
2014-10-05Do not re-establish the default pipe twice for every controller. MoveMartin Pieuchot
this hack in the drivers that need it. Tested by many, thanks! ok pirofti@, kettenis@
2014-10-01Check that the speed of a new device does not exceed its parent's speedMartin Pieuchot
prior to calling usbd_new_device(). This will let us set the specified default Max Packet Size before opening the control pipe and reduces spaghetti! ok stsp@
2014-08-10Do not allocate space for the whole structure when we just want to storeMartin Pieuchot
a pointer, found by clang.
2014-08-09Do not store the whole USB hub descriptor in the "struct usbd_hub"Martin Pieuchot
to help integrating super speed hubs that use a different descriptor.
2014-07-12add a size argument to free. will be used soon, but for now default to 0.Ted Unangst
after discussions with beck deraadt kettenis.
2014-07-12Remove incorrect comment about how autoconf(9) works and documentMartin Pieuchot
that usbd_detach() should only be called by the thread doing USB bus exploration to prevent attach/detach races.
2014-07-12Only detach the USB device you disconnected, fix a regression reportedMartin Pieuchot
by guenther@. While here set the dying flag of the disconnected device so that most of the DVACT_ACTIVATE handlers can go.
2014-07-10Always assign the device address found by the USB stack even if itMartin Pieuchot
does not match the hardware address. This change only matters for xHCI buses where the controller assigns device addresses. But it is the simplest way to comply with the stack requirement of assigning the first `logical' address to the root hub device. Device addresses are not much used anyway and a cleanup will follow to avoid possible confusions. This makes usbdevs(8) correctly report devices connected to xhci(4).