cdcecm: early exit on inactive usb interface

This adds an early exit when the usb interface with the data endpoints
is not activated. This prevents the cdc_ecm_netdev code from attempting
to send the PDU when the USB device is not yet initialized or activated
by a host.
This commit is contained in:
Koen Zandberg 2019-10-21 20:03:34 +02:00
parent d49c48368a
commit 45745579bc
No known key found for this signature in database
GPG Key ID: 0E63411F8FCA8247

View File

@ -59,6 +59,11 @@ static int _send(netdev_t *netdev, const iolist_t *iolist)
uint8_t *buf = cdcecm->ep_in->ep->buf;
const iolist_t *iolist_start = iolist;
size_t len = iolist_size(iolist);
/* interface with alternative function ID 1 is the interface containing the
* data endpoints, no sense trying to transmit data if it is not active */
if (cdcecm->active_iface != 1) {
return -ENOTCONN;
}
DEBUG("CDC_ECM_netdev: sending %u bytes\n", len);
/* load packet data into FIFO */
size_t iol_offset = 0;