lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <07e80d55-d766-1781-ffc9-fab9ddcd33e3@zhaoxin.com>
Date: Thu, 29 Feb 2024 06:32:48 +0800
From: "WeitaoWang-oc@...oxin.com" <WeitaoWang-oc@...oxin.com>
To: Oliver Neukum <oneukum@...e.com>, <stern@...land.harvard.edu>,
	<gregkh@...uxfoundation.org>, <linux-usb@...r.kernel.org>,
	<linux-kernel@...r.kernel.org>, <linux-scsi@...r.kernel.org>,
	<usb-storage@...ts.one-eyed-alien.net>
CC: <WeitaoWang@...oxin.com>, <stable@...r.kernel.org>
Subject: Re: [PATCH v2] USB:UAS:return ENODEV when submit urbs fail with
 device not attached.

On 2024/2/28 16:00, Oliver Neukum wrote:
> 
>> @@ -562,9 +561,9 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
>>
>>       lockdep_assert_held(&devinfo->lock);
>>       if (cmdinfo->state & SUBMIT_STATUS_URB) {
>> -             urb = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
>> -             if (!urb)
>> -                     return SCSI_MLQUEUE_DEVICE_BUSY;
>> +             err = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
>> +             if (err)
>> +                     return (err == -ENODEV) ? -ENODEV : SCSI_MLQUEUE_DEVICE_BUSY;
> 
> Either we ought to use SCSI error codes or generic error codes.
> There is no need to translate all but one error condition here.
> 

  static int uas_submit_urbs(struct scsi_cmnd *cmnd,
@@ -562,10 +561,13 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,

  	lockdep_assert_held(&devinfo->lock);
  	if (cmdinfo->state & SUBMIT_STATUS_URB) {
-		urb = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
-		if (!urb)
+		err = uas_submit_sense_urb(cmnd, GFP_ATOMIC);
+		if (!err)
+			cmdinfo->state &= ~SUBMIT_STATUS_URB;
+		else if (err == -ENODEV)
+			return -ENODEV;
+		else
  			return SCSI_MLQUEUE_DEVICE_BUSY;
-		cmdinfo->state &= ~SUBMIT_STATUS_URB;
  	}

  	if (cmdinfo->state & ALLOC_DATA_IN_URB) {
@@ -582,6 +584,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
  		if (err) {
  			usb_unanchor_urb(cmdinfo->data_in_urb);
  			uas_log_cmd_state(cmnd, "data in submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
  			return SCSI_MLQUEUE_DEVICE_BUSY;
  		}
  		cmdinfo->state &= ~SUBMIT_DATA_IN_URB;
@@ -602,6 +606,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
  		if (err) {
  			usb_unanchor_urb(cmdinfo->data_out_urb);
  			uas_log_cmd_state(cmnd, "data out submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
  			return SCSI_MLQUEUE_DEVICE_BUSY;
  		}
  		cmdinfo->state &= ~SUBMIT_DATA_OUT_URB;
@@ -621,6 +627,8 @@ static int uas_submit_urbs(struct scsi_cmnd *cmnd,
  		if (err) {
  			usb_unanchor_urb(cmdinfo->cmd_urb);
  			uas_log_cmd_state(cmnd, "cmd submit err", err);
+			if (err == -ENODEV)
+				return -ENODEV;
  			return SCSI_MLQUEUE_DEVICE_BUSY;
  		}

I'm not sure I fully understand what your mean.
Whether the above code is more reasonable? If not,could you give me some
suggestion? Thanks for your help!

Weitao



Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ