]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
usb: gadget: atmel: use calloc() to allocate endpoint list
authorZixun LI <admin@hifiphile.com>
Sat, 6 Jun 2026 08:27:09 +0000 (10:27 +0200)
committerMattijs Korpershoek <mkorpershoek@kernel.org>
Mon, 15 Jun 2026 07:15:25 +0000 (09:15 +0200)
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 <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>
drivers/usb/gadget/atmel_usba_udc.c

index a2eee2bca2c4ea4d7962b70beb8eeff4b88063a2..0caf8b8b7b453498c46c00b01e6e202cd9d4d7a0 100644 (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;