Skip to content

Commit

Permalink
uas: improve error handling
Browse files Browse the repository at this point in the history
(1) Handle data pipe errors: When the data urb failed we
    didn't transfer anything, update scsi_cmnd accordingly.
(2) Cancel data transfers when we got back an error on the
    status pipe.

Signed-off-by: Gerd Hoffmann <kraxel@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
  • Loading branch information
Gerd Hoffmann authored and Greg Kroah-Hartman committed Jun 25, 2012
1 parent b1d6769 commit 8aac863
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion drivers/usb/storage/uas.c
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,13 @@ static void uas_stat_cmplt(struct urb *urb)
uas_sense_old(urb, cmnd);
else
uas_sense(urb, cmnd);
if (cmnd->result != 0) {
/* cancel data transfers on error */
if (cmdinfo->state & DATA_IN_URB_INFLIGHT)
usb_unlink_urb(cmdinfo->data_in_urb);
if (cmdinfo->state & DATA_OUT_URB_INFLIGHT)
usb_unlink_urb(cmdinfo->data_out_urb);
}
cmdinfo->state &= ~COMMAND_INFLIGHT;
uas_try_complete(cmnd, __func__);
break;
Expand Down Expand Up @@ -272,7 +279,12 @@ static void uas_data_cmplt(struct urb *urb)
cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT;
}
BUG_ON(sdb == NULL);
sdb->resid = sdb->length - urb->actual_length;
if (urb->status) {
/* error: no data transfered */
sdb->resid = sdb->length;
} else {
sdb->resid = sdb->length - urb->actual_length;
}
uas_try_complete(cmnd, __func__);
}

Expand Down

0 comments on commit 8aac863

Please sign in to comment.