cdcecm: early exit on inactive usb interface#12534
Conversation
| /* 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 -EBUSY; |
There was a problem hiding this comment.
Is -EBUSY the correct error code here? @miri64 Do you have an opinion on this? What should a _send() call return when the interface is unable to transmit a PDU?
There was a problem hiding this comment.
Mhhh... -EBUSY was introduced in #11264 to signal the device is busy (even though I abandoned that idea for now for at86rf2xx at least). Is that the case here as well? How about -ENXIO (No such device or address)?
There was a problem hiding this comment.
The case here is that either the 'cable' is not connected or the other end of the 'cable' is not configured.
'cable': the point-to-point network data stream over the USB endpoints.
-EBUSY is probably wrong in that case, -ENXIO is a better match, -ENOTCONN could also work and based on a quick look the Linux kernel also seems to use it for the USB gadget framework.
There was a problem hiding this comment.
replaced -EBUSY with -ENOTCONN
dylad
left a comment
There was a problem hiding this comment.
Provided testing procedure is OK
Changes look good.
Please squash !
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.
dc0e52e to
4574557
Compare
|
Squashed! |
|
Here we go ! |
Contribution description
This adds an early exit when the usb interface with the data endpoints
is not activated. This prevents the
cdc_ecm_netdevcode from attemptingto send the PDU when the USB device is not yet initialized or activated
by a host.
Also prevents an null pointer access when the netdev code happens to initialize before the usbus code.
Testing procedure
DEBUGinsys/usb/usbus/cdc/ecm/cdc_ecm.c.examples/usbus_cdc_ecmon a supported board.ping6 ff02::1%5sys/usb/usbus/cdc/ecm/cdc_ecm.cis not triggered.Issues/PRs references
None, but maybe test this together with #12533