Skip to contentSkip to conversation

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

PATCH RESEND Superseded Zixun LI 2 participants 2 messages Jun 5 – Jun 6

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore

Zixun LI

author
#0 lore raw

PATCH RESEND 1/1 usb: gadget: atmel: use calloc() to allocate endpoint list

malloc() doesn't zero out memory, leaving ep->ep.enabled uninitiated.

Fixes 59310d1ecb9f ("usb: gadget: introduce 'enabled' flag in struct usb_ep")
---
 drivers/usb/gadget/atmel_usba_udc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/usb/gadget/atmel_usba_udc.c +1 -1
index f7a92ded6da..a5a2252dee9 100644
@@ -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 <[email protected]>

Signature · 1 line
Zixun LI <[email protected]>
#1 lore raw
Quoted 1 line · Zixun LI

malloc() doesn't zero out memory, leaving ep->ep.enabled uninitiated.

... and that is a problem because ?

The _WHY_ part should be included in the commit message. Why is this change needed ? What does it fix ?