Skip to content

Commit d0eca71

Browse files
Sebastian Andrzej SiewiorFelipe Balbi
authored andcommitted
usb: gadget: phonet: free requests in pn_bind()'s error path
Cc: stable <[email protected]> Signed-off-by: Sebastian Andrzej Siewior <[email protected]> Signed-off-by: Felipe Balbi <[email protected]>
1 parent 7f2a926 commit d0eca71

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

drivers/usb/gadget/f_phonet.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -531,7 +531,7 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
531531

532532
req = usb_ep_alloc_request(fp->out_ep, GFP_KERNEL);
533533
if (!req)
534-
goto err;
534+
goto err_req;
535535

536536
req->complete = pn_rx_complete;
537537
fp->out_reqv[i] = req;
@@ -540,14 +540,18 @@ int pn_bind(struct usb_configuration *c, struct usb_function *f)
540540
/* Outgoing USB requests */
541541
fp->in_req = usb_ep_alloc_request(fp->in_ep, GFP_KERNEL);
542542
if (!fp->in_req)
543-
goto err;
543+
goto err_req;
544544

545545
INFO(cdev, "USB CDC Phonet function\n");
546546
INFO(cdev, "using %s, OUT %s, IN %s\n", cdev->gadget->name,
547547
fp->out_ep->name, fp->in_ep->name);
548548
return 0;
549549

550+
err_req:
551+
for (i = 0; i < phonet_rxq_size && fp->out_reqv[i]; i++)
552+
usb_ep_free_request(fp->out_ep, fp->out_reqv[i]);
550553
err:
554+
551555
if (fp->out_ep)
552556
fp->out_ep->driver_data = NULL;
553557
if (fp->in_ep)

0 commit comments

Comments
 (0)