diff options
-rw-r--r-- | drivers/usb/storage/uas.c | 14 |
1 files changed, 13 insertions, 1 deletions
diff --git a/drivers/usb/storage/uas.c b/drivers/usb/storage/uas.c index b589b2e0e928..d8b7bc6ea141 100644 --- a/drivers/usb/storage/uas.c +++ b/drivers/usb/storage/uas.c | |||
@@ -242,6 +242,13 @@ static void uas_stat_cmplt(struct urb *urb) | |||
242 | uas_sense_old(urb, cmnd); | 242 | uas_sense_old(urb, cmnd); |
243 | else | 243 | else |
244 | uas_sense(urb, cmnd); | 244 | uas_sense(urb, cmnd); |
245 | if (cmnd->result != 0) { | ||
246 | /* cancel data transfers on error */ | ||
247 | if (cmdinfo->state & DATA_IN_URB_INFLIGHT) | ||
248 | usb_unlink_urb(cmdinfo->data_in_urb); | ||
249 | if (cmdinfo->state & DATA_OUT_URB_INFLIGHT) | ||
250 | usb_unlink_urb(cmdinfo->data_out_urb); | ||
251 | } | ||
245 | cmdinfo->state &= ~COMMAND_INFLIGHT; | 252 | cmdinfo->state &= ~COMMAND_INFLIGHT; |
246 | uas_try_complete(cmnd, __func__); | 253 | uas_try_complete(cmnd, __func__); |
247 | break; | 254 | break; |
@@ -272,7 +279,12 @@ static void uas_data_cmplt(struct urb *urb) | |||
272 | cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT; | 279 | cmdinfo->state &= ~DATA_OUT_URB_INFLIGHT; |
273 | } | 280 | } |
274 | BUG_ON(sdb == NULL); | 281 | BUG_ON(sdb == NULL); |
275 | sdb->resid = sdb->length - urb->actual_length; | 282 | if (urb->status) { |
283 | /* error: no data transfered */ | ||
284 | sdb->resid = sdb->length; | ||
285 | } else { | ||
286 | sdb->resid = sdb->length - urb->actual_length; | ||
287 | } | ||
276 | uas_try_complete(cmnd, __func__); | 288 | uas_try_complete(cmnd, __func__); |
277 | } | 289 | } |
278 | 290 | ||