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

drivers: usb_dc_nrfx: free memory block if event is intended to be dropped #21244

Merged
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
6 changes: 2 additions & 4 deletions drivers/usb/device/usb_dc_nrfx.c
Original file line number Diff line number Diff line change
Expand Up @@ -452,7 +452,7 @@ static inline struct usbd_event *usbd_evt_alloc(void)
if (ret < 0) {
LOG_ERR("USBD event allocation failed!");

/* This should NOT happen in a properly designed system.
/*
* Allocation may fail if workqueue thread is starved or event
* queue size is too small (CONFIG_USB_NRFX_EVT_QUEUE_SIZE).
* Wipe all events, free the space and schedule
Expand All @@ -464,9 +464,6 @@ static inline struct usbd_event *usbd_evt_alloc(void)
sizeof(struct usbd_event),
K_NO_WAIT);
if (ret < 0) {
/* This should never fail in a properly
* operating system.
*/
LOG_ERR("USBD event memory corrupted");
__ASSERT_NO_MSG(0);
return NULL;
Expand Down Expand Up @@ -1246,6 +1243,7 @@ static void usbd_work_handler(struct k_work *item)
while ((ev = usbd_evt_get()) != NULL) {
if (!dev_ready() && ev->evt_type != USBD_EVT_POWER) {
/* Drop non-power events when cable is detached. */
usbd_evt_free(ev);
continue;
}

Expand Down