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ń <tomasz.mon@nordicsemi.no>
This commit is contained in:
Tomasz Moń 2024-12-05 11:29:55 +01:00 committed by Benjamin Cabé
commit d39d7e5c60

View file

@ -592,6 +592,11 @@ int udc_ep_enqueue(const struct device *dev, struct net_buf *const buf)
goto ep_enqueue_error;
}
if (!cfg->stat.enabled) {
ret = -ENODEV;
goto ep_enqueue_error;
}
LOG_DBG("Queue ep 0x%02x %p len %u", cfg->addr, buf,
USB_EP_DIR_IS_IN(cfg->addr) ? buf->len : buf->size);