patch "USB: UAS: fix disconnect by unplugging a hub" added to usb-linus
Subsystems (4)
This is a note to let you know that I've just added the patch titled
USB: UAS: fix disconnect by unplugging a hub
to my usb git tree which can be found at
git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git
in the usb-linus branch.
The patch will show up in the next release of the linux-next tree (usually sometime within the next 24 hours during the week.)
The patch will hopefully also be merged in Linus's tree for the next -rc kernel release.
If you have any questions about this process, please let me know.
From 325b008723b2dd31de020e85ab9d2e9aa4637d35 Mon Sep 17 00:00:00 2001
From: Oliver Neukum <[email protected]>
Date: Wed, 16 Sep 2020 11:40:25 +0200
Subject: USB: UAS: fix disconnect by unplugging a hub
The SCSI layer can go into an ugly loop if you ignore that a device is gone. You need to report an error in the command rather than in the return value of the queue method.
We need to specifically check for ENODEV. The issue goes back to the introduction of the driver.
--- drivers/usb/storage/uas.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-)
drivers/usb/storage/uas.c +12 -2
@@ -662,8 +662,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd,if (devinfo->resetting) { cmnd->result =DID_ERROR <<16 ; cmnd->scsi_done (cmnd); -spin_unlock_irqrestore (&devinfo->lock, flags); -return 0 ; + goto zombie; }/* Find a free uas-tag */
@@ -699,6 +698,16 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, cmdinfo->state &= ~(SUBMIT_DATA_IN_URB |SUBMIT_DATA_OUT_URB ); err =uas_submit_urbs (cmnd, devinfo); +/* +* in case of fatal errors the SCSI layer is peculiar +* a command that has finished is a success for the purpose +* of queueing, no matter how fatal the error +*/ +if (err == -ENODEV ) { + cmnd->result =DID_ERROR <<16 ; + cmnd->scsi_done (cmnd); + goto zombie; + }if (err) {/* If we did nothing, give up now */ if (cmdinfo->state &SUBMIT_STATUS_URB ) {
@@ -709,6 +718,7 @@ static int uas_queuecommand_lck(struct scsi_cmnd *cmnd, } devinfo->cmnd[idx] = cmnd; +zombie:spin_unlock_irqrestore (&devinfo->lock, flags);return 0 ; }
Signature · 1 line
2.28.0