usb: device_next: Do not leak memory on set address
USB stack did leak memory on every SET ADDRESS request. UDC control allocator could cope with up to 13 leaked allocations. Therefore, issuing bus reset 13 times in a row (in addition to automatic reset after connecting the USB cable) was enough to exhaust memory and thus drive USB stack inoperable. Signed-off-by: Tomasz Moń <tomasz.mon@nordicsemi.no>
This commit is contained in:
parent
7b221fbe45
commit
7608f54433
1 changed files with 2 additions and 2 deletions
|
@ -811,6 +811,8 @@ int usbd_handle_ctrl_xfer(struct usbd_contex *const uds_ctx,
|
|||
}
|
||||
|
||||
if (bi->status && bi->ep == USB_CONTROL_EP_IN) {
|
||||
net_buf_unref(buf);
|
||||
|
||||
if (ch9_get_ctrl_type(uds_ctx) == CTRL_AWAIT_STATUS_STAGE) {
|
||||
LOG_INF("s-(out)-status finished");
|
||||
if (unlikely(uds_ctx->ch9_data.new_address)) {
|
||||
|
@ -820,8 +822,6 @@ int usbd_handle_ctrl_xfer(struct usbd_contex *const uds_ctx,
|
|||
LOG_WRN("Awaited s-(out)-status not finished");
|
||||
}
|
||||
|
||||
net_buf_unref(buf);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue