提交 4556e12c 编写于 作者: M Mian Yousaf Kaukab 提交者: Felipe Balbi

usb: dwc2: gadget: fix fifo allocation leak

When selecting different alt setting, s3c_hsotg_ep_enable can be
called with fifo already allocated. Allocate fifo again only if
required and after deallocating the previous fifo.
Tested-by: NRobert Baldyga <r.baldyga@samsung.com>
Acked-by: NPaul Zimmerman <paulz@synopsys.com>
Signed-off-by: NMian Yousaf Kaukab <yousaf.kaukab@intel.com>
Signed-off-by: NFelipe Balbi <balbi@ti.com>
上级 ca4c55ad
......@@ -2528,11 +2528,22 @@ static int s3c_hsotg_ep_enable(struct usb_ep *ep,
break;
}
/* If fifo is already allocated for this ep */
if (hs_ep->fifo_index) {
size = hs_ep->ep.maxpacket * hs_ep->mc;
/* If bigger fifo is required deallocate current one */
if (size > hs_ep->fifo_size) {
hsotg->fifo_map &= ~(1 << hs_ep->fifo_index);
hs_ep->fifo_index = 0;
hs_ep->fifo_size = 0;
}
}
/*
* if the hardware has dedicated fifos, we must give each IN EP
* a unique tx-fifo even if it is non-periodic.
*/
if (dir_in && hsotg->dedicated_fifos) {
if (dir_in && hsotg->dedicated_fifos && !hs_ep->fifo_index) {
u32 fifo_index = 0;
u32 fifo_size = UINT_MAX;
size = hs_ep->ep.maxpacket*hs_ep->mc;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册