Skip to content

Commit de7275c

Browse files
David Laightgregkh
authored andcommitted
drivers/usb/storage: use min() instead of min_t()
min_t(unsigned int, a, b) casts an 'unsigned long' to 'unsigned int'. Use min(a, b) instead as it promotes any 'unsigned int' to 'unsigned long' and so cannot discard significant bits. In this case the 'unsigned long' value is small enough that the result is ok. Detected by an extra check added to min_t(). Signed-off-by: David Laight <david.laight.linux@gmail.com> Link: https://patch.msgid.link/20251119224140.8616-29-david.laight.linux@gmail.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
1 parent a5160af commit de7275c

1 file changed

Lines changed: 1 addition & 2 deletions

File tree

drivers/usb/storage/protocol.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,8 +139,7 @@ unsigned int usb_stor_access_xfer_buf(unsigned char *buffer,
139139
return cnt;
140140

141141
while (sg_miter_next(&miter) && cnt < buflen) {
142-
unsigned int len = min_t(unsigned int, miter.length,
143-
buflen - cnt);
142+
unsigned int len = min(miter.length, buflen - cnt);
144143

145144
if (dir == FROM_XFER_BUF)
146145
memcpy(buffer + cnt, miter.addr, len);

0 commit comments

Comments
 (0)