Skip to content

Commit 48cee8d

Browse files
tmon-nordicbjarki-andreasen
authored andcommitted
[nrf fromtree] usb: device_next: Fail enqueue on disabled endpoints
Do not allow enqueuing buffers on endpoints that were not enabled. Doing so can lead to division by zero later on because the max packet size can be 0 in disabled endpoint configuration. Signed-off-by: Tomasz Moń <[email protected]> (cherry picked from commit d39d7e5)
1 parent ff14e88 commit 48cee8d

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

drivers/usb/udc/udc_common.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -592,6 +592,11 @@ int udc_ep_enqueue(const struct device *dev, struct net_buf *const buf)
592592
goto ep_enqueue_error;
593593
}
594594

595+
if (!cfg->stat.enabled) {
596+
ret = -ENODEV;
597+
goto ep_enqueue_error;
598+
}
599+
595600
LOG_DBG("Queue ep 0x%02x %p len %u", cfg->addr, buf,
596601
USB_EP_DIR_IS_IN(cfg->addr) ? buf->len : buf->size);
597602

0 commit comments

Comments
 (0)