eenurkka commented on code in PR #6601:
URL: https://github.com/apache/incubator-nuttx/pull/6601#discussion_r918709665


##########
drivers/usbdev/usbmsc_scsi.c:
##########
@@ -2444,8 +2444,24 @@ static int usbmsc_cmdwritestate(FAR struct usbmsc_dev_s 
*priv)
           src  = &req->buf[xfrd - priv->nreqbytes];
           dest = &priv->iobuffer[priv->nsectbytes];
 
-          nbytes = MIN(lun->sectorsize - priv->nsectbytes, priv->nreqbytes);
+#ifdef CONFIG_USBMSC_WRMULTIPLE
+          /* nbytes may end up being zero, after which the loop no longer
+           * proceeds but will be stuck forever.  Make sure nbytes isn't
+           * zero.
+           */
 
+          if (lun->sectorsize > priv->nsectbytes)
+            {
+              nbytes = MIN(lun->sectorsize - priv->nsectbytes,
+                           priv->nreqbytes);
+            }
+          else
+            {
+              nbytes = priv->nreqbytes;
+            }
+#else
+          nbytes = MIN(lun->sectorsize - priv->nsectbytes, priv->nreqbytes);

Review Comment:
   If sectorsize is nsectbytes, it has already exited the loop. So there it's 
unnecessary



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to