-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cdcecm: early exit on inactive usb interface #12534
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
replaced -EBUSY
with -ENOTCONN
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
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_netdev
code 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
DEBUG
insys/usb/usbus/cdc/ecm/cdc_ecm.c
.examples/usbus_cdc_ecm
on a supported board.ping6 ff02::1%5
sys/usb/usbus/cdc/ecm/cdc_ecm.c
is not triggered.Issues/PRs references
None, but maybe test this together with #12533