diff mbox series

[v2,3/3] usb: gadget: uvc: improve sg exit condition

Message ID 20220402232744.3622565-4-m.grzeschik@pengutronix.de (mailing list archive)
State Accepted
Commit aef11279888c00e1841a3533a35d279285af3a51
Headers show
Series usb: gadget: uvc: fix sg handling | expand

Commit Message

Michael Grzeschik April 2, 2022, 11:27 p.m. UTC
The exit condition to quit iterating over the sg_list, while encoding
the sg entries, has to consider the case that the dma_len of the entry
could be zero. This patch takes this condition to account.

Signed-off-by: Michael Grzeschik <m.grzeschik@pengutronix.de>

---
v1 - >v2: - new patch

 drivers/usb/gadget/function/uvc_video.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/usb/gadget/function/uvc_video.c b/drivers/usb/gadget/function/uvc_video.c
index ceeabc4ba3b167..a9bb4553db847e 100644
--- a/drivers/usb/gadget/function/uvc_video.c
+++ b/drivers/usb/gadget/function/uvc_video.c
@@ -155,7 +155,7 @@  uvc_video_encode_isoc_sg(struct usb_request *req, struct uvc_video *video,
 	sg = sg_next(sg);
 
 	for_each_sg(sg, iter, ureq->sgt.nents - 1, i) {
-		if (!len || !buf->sg)
+		if (!len || !buf->sg || !sg_dma_len(buf->sg))
 			break;
 
 		sg_left = sg_dma_len(buf->sg) - buf->offset;