From: Zixun LI Date: Sat, 6 Jun 2026 08:27:09 +0000 (+0200) Subject: usb: gadget: atmel: use calloc() to allocate endpoint list X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=033eb908d0a8ed938bc652f34a2d702a29a8726f;p=thirdparty%2Fu-boot.git 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: 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag in struct usb_ep") Signed-off-by: Zixun LI Reviewed-by: Marek Vasut Reviewed-by: Mattijs Korpershoek Link: https://patch.msgid.link/20260606-udc_malloc-v2-1-1155326b182b@hifiphile.com Signed-off-by: Mattijs Korpershoek --- diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c index a2eee2bca2c..0caf8b8b7b4 100644 --- a/drivers/usb/gadget/atmel_usba_udc.c +++ b/drivers/usb/gadget/atmel_usba_udc.c @@ -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;