usb: gadget: atmel: use calloc() to allocate endpoint list

malloc() doesn't zero out memory, leaving ep->ep.enabled uninitiated,
which could make this flag falsely true.

In next usb_ep_enable() call since this flag is true, ep->ops->enable()
will be skipped. Then usb_ep_queue() will fail on uninitialized endpoint.

Fixes: 59310d1ecb ("usb: gadget: introduce 'enabled' flag in struct usb_ep")
Signed-off-by: Zixun LI <admin@hifiphile.com>
Reviewed-by: Marek Vasut <marek.vasut+usb@mailbox.org>
Reviewed-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
Link: https://patch.msgid.link/20260606-udc_malloc-v2-1-1155326b182b@hifiphile.com
Signed-off-by: Mattijs Korpershoek <mkorpershoek@kernel.org>
This commit is contained in:
Zixun LI
2026-06-15 09:15:25 +02:00
committed by Mattijs Korpershoek
parent e41e97e6e6
commit 033eb908d0
+1 -1
View File
@@ -1201,7 +1201,7 @@ static struct usba_ep *usba_udc_pdata(struct usba_platform_data *pdata,
struct usba_ep *eps;
int i;
eps = malloc(sizeof(struct usba_ep) * pdata->num_ep);
eps = calloc(pdata->num_ep, sizeof(struct usba_ep));
if (!eps) {
log_err("failed to alloc eps\n");
return NULL;