Changeset 9748336 in mainline


Ignore:
Timestamp:
2018-01-10T20:08:54Z (6 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
a70f349
Parents:
94a0904
Message:

usbhost: be more careful with detached endpoints

Location:
uspace/lib/usbhost
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • uspace/lib/usbhost/include/usb/host/endpoint.h

    r94a0904 r9748336  
    116116static inline bus_t *endpoint_get_bus(endpoint_t *ep)
    117117{
    118         return ep->device->bus;
     118        device_t * const device = ep->device;
     119        return device ? device->bus : NULL;
    119120}
    120121
  • uspace/lib/usbhost/src/endpoint.c

    r94a0904 r9748336  
    248248            name, target.address, target.endpoint, size, ep->max_packet_size);
    249249
    250         bus_t *bus = endpoint_get_bus(ep);
    251         const bus_ops_t *ops = BUS_OPS_LOOKUP(bus->ops, batch_schedule);
     250        device_t * const device = ep->device;
     251        if (!device) {
     252                usb_log_warning("Endpoint detached");
     253                return EAGAIN;
     254        }
     255
     256        const bus_ops_t *ops = BUS_OPS_LOOKUP(device->bus->ops, batch_schedule);
    252257        if (!ops) {
    253258                usb_log_error("HCD does not implement scheduler.\n");
     
    256261
    257262        /* Offline devices don't schedule transfers other than on EP0. */
    258         if (!ep->device->online && ep->endpoint > 0) {
     263        if (!device->online && ep->endpoint > 0) {
    259264                return EAGAIN;
    260265        }
     
    265270                usb_log_error("Endpoint(%d:%d) %s needs %zu bw "
    266271                    "but only %zu is reserved.\n",
    267                     ep->device->address, ep->endpoint, name, bw, ep->bandwidth);
     272                    device->address, ep->endpoint, name, bw, ep->bandwidth);
    268273                return ENOSPC;
    269274        }
Note: See TracChangeset for help on using the changeset viewer.