Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

usb-storage: update earlier scatter-gather bug fix

This patch (as1037) makes a small update to the earlier as1035 patch.
The minimum-length computation shouldn't be done in
usb_stor_access_xfer_buf(), since that routine can be called multiple
times for a single transfer. It should be done in
usb_stor_set_xfer_buf() instead, which gets called only once.

The way it is now isn't really _wrong_, but it isn't really _right_
either. Moving the statement will be an improvement.

Signed-off-by: Alan Stern <stern@rowland.harvard.edu>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>

authored by

Alan Stern and committed by
Greg Kroah-Hartman
6d512a80 0ed930bf

+1 -1
+1 -1
drivers/usb/storage/protocol.c
··· 170 170 171 171 if (!sg) 172 172 sg = scsi_sglist(srb); 173 - buflen = min(buflen, scsi_bufflen(srb)); 174 173 175 174 /* This loop handles a single s-g list entry, which may 176 175 * include multiple pages. Find the initial page structure ··· 231 232 unsigned int offset = 0; 232 233 struct scatterlist *sg = NULL; 233 234 235 + buflen = min(buflen, scsi_bufflen(srb)); 234 236 buflen = usb_stor_access_xfer_buf(buffer, buflen, srb, &sg, &offset, 235 237 TO_XFER_BUF); 236 238 if (buflen < scsi_bufflen(srb))