Skip to content
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

[RP2040] Fix null dereference in usb_lld_disable_endpoints #375

Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 0 additions & 33 deletions os/hal/ports/RP/LLD/USBDv1/hal_usb_lld.c
Original file line number Diff line number Diff line change
Expand Up @@ -153,31 +153,6 @@ static void reset_ep0(USBDriver *usbp) {
usbp->epc[0]->in_state->stalled = false;
}

#if 0
/**
* @brief Reset specified endpoint.
*/
static void reset_endpoint(USBDriver *usbp, usbep_t ep, bool is_in) {
const USBEndpointConfig *epcp = usbp->epc[ep];

if (is_in) {
USBInEndpointState *in_state = epcp->in_state;
if (in_state) {
in_state->active = false;
in_state->stalled = false;
in_state->next_pid = 0U;
}
} else {
USBOutEndpointState *out_state = epcp->out_state;
if (out_state) {
out_state->active = false;
out_state->stalled = false;
out_state->next_pid = 0U;
}
}
}
#endif

/**
* @brief Prepare buffer for receiving data.
*/
Expand Down Expand Up @@ -689,16 +664,8 @@ void usb_lld_init_endpoint(USBDriver *usbp, usbep_t ep) {
* @notapi
*/
void usb_lld_disable_endpoints(USBDriver *usbp) {
/* Ignore zero */
for (uint8_t ep = 1; ep <= USB_ENDOPOINTS_NUMBER; ep++) {
usbp->epc[ep]->in_state->active = false;
usbp->epc[ep]->in_state->stalled = false;
usbp->epc[ep]->in_state->next_pid = 0;
EP_CTRL(ep).IN &= ~USB_EP_EN;

usbp->epc[ep]->out_state->active = false;
usbp->epc[ep]->out_state->stalled = false;
usbp->epc[ep]->out_state->next_pid = 0;
EP_CTRL(ep).OUT &= ~USB_EP_EN;
}
}
Expand Down