usb: gadget: atmel: use calloc() to allocate endpoint list
Subsystems (2)
PATCH v2 1/1 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.
---
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/[email protected]
--- drivers/usb/gadget/atmel_usba_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/atmel_usba_udc.c +1 -1
@@ -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,
Signature · 1 line
Zixun LI <[email protected]>
Quoted 8 lines · Zixun LI
malloc()doesn't zero out memory, leavingep->ep.enableduninitiated, which could make this flag falsely true.In next
usb_ep_enable()call since this flag is true,ep->ops->enable()will be skipped. Thenusb_ep_queue()will fail on uninitialized endpoint.Fixes 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag in struct usb_ep")Signed-off-by Zixun LI <[email protected]>
Hi Zixun,
Thank you for the patch.
Quoted 8 lines · Zixun LI
malloc()doesn't zero out memory, leavingep->ep.enableduninitiated, which could make this flag falsely true.In next
usb_ep_enable()call since this flag is true,ep->ops->enable()will be skipped. Thenusb_ep_queue()will fail on uninitialized endpoint.Fixes 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag in struct usb_ep")Signed-off-by Zixun LI <[email protected]>
Quoted 32 lines
---
On SAM9X60 I had a problem with unreliableusb_etherfunctionality, 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/[email protected]--- drivers/usb/gadget/atmel_usba_udc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)drivers/usb/gadget/atmel_usba_udc.c +1
-2@@ -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-eb8355d08afeBest regards,
Signature · 1 line
Zixun LI <[email protected]>
Hi,
Quoted 8 lines · Zixun LI
malloc()doesn't zero out memory, leavingep->ep.enableduninitiated, which could make this flag falsely true.In next
usb_ep_enable()call since this flag is true,ep->ops->enable()will be skipped. Thenusb_ep_queue()will fail on uninitialized endpoint.[...]
Thanks, Applied to https://source.denx.de/u-boot/custodians/u-boot-dfu (u-boot-dfu)
[1/1] usb: gadget: atmel: use calloc() to allocate endpoint list
https://source.denx.de/u-boot/custodians/u-boot-dfu/-/commit/033eb908d0a8ed938bc652f34a2d702a29a8726f
--
Mattijs