diff --git a/drivers/usb/storage/scsiglue.c b/drivers/usb/storage/scsiglue.c index cd64dc35b258ebe978d0a74e713df082df3003f8..2c1990b74d6895498a19710157b84cc24c74c817 100644 --- a/drivers/usb/storage/scsiglue.c +++ b/drivers/usb/storage/scsiglue.c @@ -166,7 +166,11 @@ static int device_reset( Scsi_Cmnd *srb ) /* lock the device pointers and do the reset */ down(&(us->dev_semaphore)); - result = us->transport_reset(us); + if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { + result = FAILED; + US_DEBUGP("No reset during disconnect\n"); + } else + result = us->transport_reset(us); up(&(us->dev_semaphore)); /* lock access to the state and clear it */ @@ -202,7 +206,7 @@ static int bus_reset( Scsi_Cmnd *srb ) down(&(us->dev_semaphore)); if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { result = -EIO; - US_DEBUGP("Attempt to reset during disconnect\n"); + US_DEBUGP("No reset during disconnect\n"); } else if (us->pusb_dev->actconfig->desc.bNumInterfaces != 1) { result = -EBUSY; US_DEBUGP("Refusing to reset a multi-interface device\n"); diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c index 1acd6079f98205dbf380c8da0a1ba683b3444f23..982e0314b84aefa84dccd4e21b62a12b83f0c6c6 100644 --- a/drivers/usb/storage/transport.c +++ b/drivers/usb/storage/transport.c @@ -1065,6 +1065,10 @@ static int usb_stor_reset_common(struct us_data *us, schedule_timeout(HZ*6); set_current_state(TASK_RUNNING); down(&us->dev_semaphore); + if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { + US_DEBUGP("Reset interrupted by disconnect\n"); + return FAILED; + } US_DEBUGP("Soft reset: clearing bulk-in endpoint halt\n"); result = usb_stor_clear_halt(us, us->recv_bulk_pipe); diff --git a/drivers/usb/storage/usb.c b/drivers/usb/storage/usb.c index a22fa07176d3dc63f5853480745bcdd485ec4562..55a62178e731a63513bcf816b19b83dbaf504928 100644 --- a/drivers/usb/storage/usb.c +++ b/drivers/usb/storage/usb.c @@ -338,10 +338,16 @@ static int usb_stor_control_thread(void * __us) /* lock the device pointers */ down(&(us->dev_semaphore)); + /* don't do anything if we are disconnecting */ + if (test_bit(US_FLIDX_DISCONNECTING, &us->flags)) { + US_DEBUGP("No command during disconnect\n"); + us->srb->result = DID_BAD_TARGET << 16; + } + /* reject the command if the direction indicator * is UNKNOWN */ - if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) { + else if (us->srb->sc_data_direction == SCSI_DATA_UNKNOWN) { US_DEBUGP("UNKNOWN data direction\n"); us->srb->result = DID_ERROR << 16; }