From: Alan Stern Date: Tue, 2 Sep 2008 14:12:11 +0000 (-0400) Subject: usb-storage: report underflow with no sense data X-Git-Tag: v3.12-rc1~17760^2~74 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=8bfa24727087d7252f9ecfb5fea2dfc92d797fbd;p=kernel%2Fkernel-generic.git usb-storage: report underflow with no sense data This patch (as1118) addresses a problem with certain USB mass-storage devices. These devices sometimes return less data than asked for and then provide no sense data to explain the problem. Currently usb-storage leaves it up to the SCSI layer to decide how this should be handled, and the SCSI layer interprets the lack of sense data to mean that nothing went wrong. But if we got less data than required then something definitely _did_ go wrong, and we should say so. The patch tells the SCSI layer to retry the command when this sort of thing happens. Retrying may not solve the underlying problem, but it's better than believing that data was transferred when it wasn't. Signed-off-by: Alan Stern Signed-off-by: Greg Kroah-Hartman --- diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 3523a0b..79108d5 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -663,7 +663,7 @@ void usb_stor_invoke_transport(struct scsi_cmnd *srb, struct us_data *us) } /* Did we transfer less than the minimum amount required? */ - if (srb->result == SAM_STAT_GOOD && + if ((srb->result == SAM_STAT_GOOD || srb->sense_buffer[2] == 0) && scsi_bufflen(srb) - scsi_get_resid(srb) < srb->underflow) srb->result = (DID_ERROR << 16) | (SUGGEST_RETRY << 24);