Skip to content

Commit

Permalink
Merge pull request #375 from KarlK90/fix/rp2040-usb-disable-ep-null-d…
Browse files Browse the repository at this point in the history
…ereference

[RP2040] Fix null dereference in `usb_lld_disable_endpoints`
  • Loading branch information
fpoussin committed Jul 17, 2023
2 parents 5d2d95c + c3e2a04 commit a52d55a
Showing 1 changed file with 0 additions and 33 deletions.
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 @@ -698,16 +673,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

0 comments on commit a52d55a

Please sign in to comment.