Patch "usb: fotg210-hcd: delete an incorrect bounds test" has been added to the 5.10-stable tree

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This is a note to let you know that I've just added the patch titled

    usb: fotg210-hcd: delete an incorrect bounds test

to the 5.10-stable tree which can be found at:
    http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
     usb-fotg210-hcd-delete-an-incorrect-bounds-test.patch
and it can be found in the queue-5.10 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@xxxxxxxxxxxxxxx> know about it.



commit 075d2a67983df017985e1ac14dd1028bce48ffde
Author: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
Date:   Wed Dec 13 16:22:43 2023 +0300

    usb: fotg210-hcd: delete an incorrect bounds test
    
    [ Upstream commit 7fbcd195e2b8cc952e4aeaeb50867b798040314c ]
    
    Here "temp" is the number of characters that we have written and "size"
    is the size of the buffer.  The intent was clearly to say that if we have
    written to the end of the buffer then stop.
    
    However, for that to work the comparison should have been done on the
    original "size" value instead of the "size -= temp" value.  Not only
    will that not trigger when we want to, but there is a small chance that
    it will trigger incorrectly before we want it to and we break from the
    loop slightly earlier than intended.
    
    This code was recently changed from using snprintf() to scnprintf().  With
    snprintf() we likely would have continued looping and passed a negative
    size parameter to snprintf().  This would have triggered an annoying
    WARN().  Now that we have converted to scnprintf() "size" will never
    drop below 1 and there is no real need for this test.  We could change
    the condition to "if (temp <= 1) goto done;" but just deleting the test
    is cleanest.
    
    Fixes: 7d50195f6c50 ("usb: host: Faraday fotg210-hcd driver")
    Cc: stable <stable@xxxxxxxxxx>
    Signed-off-by: Dan Carpenter <dan.carpenter@xxxxxxxxxx>
    Reviewed-by: Linus Walleij <linus.walleij@xxxxxxxxxx>
    Reviewed-by: Lee Jones <lee@xxxxxxxxxx>
    Link: https://lore.kernel.org/r/ZXmwIwHe35wGfgzu@suswa
    Signed-off-by: Greg Kroah-Hartman <gregkh@xxxxxxxxxxxxxxxxxxx>
    Signed-off-by: Sasha Levin <sashal@xxxxxxxxxx>

diff --git a/drivers/usb/host/fotg210-hcd.c b/drivers/usb/host/fotg210-hcd.c
index ff0b3457fd342..de925433d4c5f 100644
--- a/drivers/usb/host/fotg210-hcd.c
+++ b/drivers/usb/host/fotg210-hcd.c
@@ -429,8 +429,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
 			temp = size;
 		size -= temp;
 		next += temp;
-		if (temp == size)
-			goto done;
 	}
 
 	temp = snprintf(next, size, "\n");
@@ -440,7 +438,6 @@ static void qh_lines(struct fotg210_hcd *fotg210, struct fotg210_qh *qh,
 	size -= temp;
 	next += temp;
 
-done:
 	*sizep = size;
 	*nextp = next;
 }




[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux