Skip to contentSkip to conversation

USB: gadget: atmel: zero out allocated requests

PATCH New Stephen Warren 2 participants 2 messages Jul 1, 2014 – Jul 2, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 USB: gadget: atmel: zero out allocated requests

From: Stephen Warren <[email protected]>

A UDC's alloc_request method should zero out the newly allocated request. Ensure the Atmel driver does so. This issue was found by code inspection, following the investigation of an intermittent issue with ci_udc, which was tracked down to failing to zero out allocated requests following some of my changes. All other UDC drivers already zero out requests in one way or another.

---
 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 c99208d10200..2c709738a3cb 100644
@@ -314,7 +314,7 @@ usba_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
 
 	DBG(DBG_GADGET, "ep_alloc_request: %p, 0x%x\n", _ep, gfp_flags);
 
-	req = malloc(sizeof(struct usba_request));
+	req = calloc(1, sizeof(struct usba_request));
 	if (!req)
 		return NULL;
 
Signature · 1 line
1.8.1.5
#1 lore raw

PATCH 1/1 USB: gadget: atmel: zero out allocated requests

Hi Stephen Warren,

Quoted 9 lines · Stephen Warren

From: Stephen Warren <[email protected]>

A UDC's alloc_request method should zero out the newly allocated request. Ensure the Atmel driver does so. This issue was found by code inspection, following the investigation of an intermittent issue with ci_udc, which was tracked down to failing to zero out allocated requests following some of my changes. All other UDC drivers already zero out requests in one way or another.

Quoted 4 lines
---
  drivers/usb/gadget/atmel_usba_udc.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

Thanks.

Quoted 6 lines
drivers/usb/gadget/atmel_usba_udc.c +0 -0
index c99208d10200..2c709738a3cb 100644

drivers/usb/gadget/atmel_usba_udc.c usba_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags) · line 320

Quoted 8 lines
drivers/usb/gadget/atmel_usba_udc.c +1 -1
@@ -314,7 +314,7 @@ usba_ep_alloc_request(struct usb_ep *_ep, gfp_t gfp_flags)
 
  	DBG(DBG_GADGET, "ep_alloc_request: %p, 0x%x\n", _ep, gfp_flags);
 
-	req = malloc(sizeof(struct usba_request));
+	req = calloc(1, sizeof(struct usba_request));
  	if (!req)
  		return NULL;
 

Best Regards,
Bo Shen