usb: gadget: aspeed_udc: fix handling of tx_len == 0
Subsystems (4)
PATCH v3 1/1 usb: gadget: aspeed_udc: fix handling of tx_len == 0
The bug is that we should still enter this loop if "tx_len" is zero.
After adding the "last" variable, then the "chunk >= 0" condition is no longer required but I left it for readability.
Reported-by Neal Liu <[email protected]>
Fixes c09b1f372e74 ("usb: gadget: aspeed_udc: cleanup loop in ast_dma_descriptor_setup()")
Signed-off-by Dan Carpenter <[email protected]>
Reviewed-by Neal Liu <[email protected]>
---
v3: We went back and forth on the style on this. This is just v1 but with Neal's Reviewed-by.
drivers/usb/gadget/udc/aspeed_udc.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-)
drivers/usb/gadget/udc/aspeed_udc.c +6 -3
@@ -476,6 +476,7 @@ static int ast_dma_descriptor_setup(struct ast_udc_ep *ep, u32 dma_buf, {struct ast_udc_dev *udc = ep->udc;struct device *dev = &udc->pdev->dev; +bool last = false;int chunk, count;u32 offset;
@@ -493,14 +494,16 @@ static int ast_dma_descriptor_setup(struct ast_udc_ep *ep, u32 dma_buf, "tx_len", tx_len);/* Create Descriptor Lists */ -while (chunk >0 && count <AST_UDC_DESCS_COUNT ) { +while (chunk >=0 && !last && count <AST_UDC_DESCS_COUNT ) { ep->descs[ep->descs_wptr].des_0 = dma_buf + offset; -if (chunk > ep->chunk_max) +if (chunk > ep->chunk_max) { ep->descs[ep->descs_wptr].des_1 = ep->chunk_max; -else + }else { ep->descs[ep->descs_wptr].des_1 = chunk; + last = true; + } chunk -= ep->chunk_max;
Signature · 1 line
2.35.1