From: Mattijs Korpershoek <mkorpershoek@kernel.org>
To: Zixun LI <admin@hifiphile.com>,
Mattijs Korpershoek <mkorpershoek@kernel.org>,
Stephan Gerhold <stephan.gerhold@linaro.org>,
u-boot@lists.denx.de
Cc: Lukasz Majewski <lukma@denx.de>, Marek Vasut <marex@denx.de>,
Tom Rini <trini@konsulko.com>,
Andrew Goodbody <andrew.goodbody@linaro.org>,
Zixun LI <admin@hifiphile.com>
Subject: Re: [PATCH v2] usb: gadget: atmel: use calloc() to allocate endpoint list
Date: Mon, 08 Jun 2026 09:02:27 +0200 [thread overview]
Message-ID: <87pl21zf98.fsf@kernel.org> (raw)
In-Reply-To: <20260606-udc_malloc-v2-1-1155326b182b@hifiphile.com>
Hi Zixun,
Thank you for the patch.
On Sat, Jun 06, 2026 at 10:27, Zixun LI <admin@hifiphile.com> wrote:
> 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: Mattijs Korpershoek <mkorpershoek@kernel.org>
> ---
> On SAM9X60 I had a problem with unreliable usb_ether functionality,
> sometimes 'dhcp' command returns with error 'rx submit --> -108'.
> ---
> Changes in v2:
> - Add more details to commit message.
> - Link to v1: https://patch.msgid.link/20260521-udc_malloc-v1-1-b6118f809ada@hifiphile.com
> ---
> drivers/usb/gadget/atmel_usba_udc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/usb/gadget/atmel_usba_udc.c b/drivers/usb/gadget/atmel_usba_udc.c
> index f7a92ded6da..a5a2252dee9 100644
> --- a/drivers/usb/gadget/atmel_usba_udc.c
> +++ b/drivers/usb/gadget/atmel_usba_udc.c
> @@ -1219,7 +1219,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;
>
> ---
> base-commit: 5732bd0f457b4c671e46574d64d4acb099c0f0a5
> change-id: 20260521-udc_malloc-eb8355d08afe
>
> Best regards,
> --
> Zixun LI <admin@hifiphile.com>
prev parent reply other threads:[~2026-06-08 7:02 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-06 8:27 [PATCH v2] usb: gadget: atmel: use calloc() to allocate endpoint list Zixun LI
2026-06-06 19:12 ` Marek Vasut
2026-06-08 7:02 ` Mattijs Korpershoek [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=87pl21zf98.fsf@kernel.org \
--to=mkorpershoek@kernel.org \
--cc=admin@hifiphile.com \
--cc=andrew.goodbody@linaro.org \
--cc=lukma@denx.de \
--cc=marex@denx.de \
--cc=stephan.gerhold@linaro.org \
--cc=trini@konsulko.com \
--cc=u-boot@lists.denx.de \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.