usb: uas: do not leak error codes from usb_alloc_streams()
Subsystems (3)
Oliver Neukum
maintainerPATCH 1/1 usb: uas: do not leak error codes from usb_alloc_streams()
While a UAS device is undergoing a reset not triggered by the SCSI layer there is a short window in the error case of reallocating streams during which internal error codes of the USB layer are exported as nonsensical queue depths.
The error has been noticed by Sashiko in a different context, but it is a general issue.
--- drivers/usb/storage/uas.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)
drivers/usb/storage/uas.c +5 -3
@@ -983,10 +983,12 @@ static int uas_configure_endpoints(struct uas_dev_info *devinfo) devinfo->qdepth =32 ; devinfo->use_streams =0 ; }else { - devinfo->qdepth =usb_alloc_streams (devinfo->intf, eps +1 , + r =usb_alloc_streams (devinfo->intf, eps +1 ,3 ,MAX_CMNDS ,GFP_NOIO ); -if (devinfo->qdepth <0 ) -return devinfo->qdepth; +if (r <0 ) +return r; + + devinfo->qdepth = r; devinfo->use_streams =1 ; }
Signature · 1 line
2.55.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 10 lines
While a UAS device is undergoing a reset not triggered by the SCSI layer there is a short window in the error case of reallocating streams during which internal error codes of the USB layer are exported as nonsensical queue depths.
The error has been noticed by Sashiko in a different context, but it is a general issue.
Fixes 4de7a3735bdc4 ("uas: Fix reset handling for externally triggered reset")Signed-off-by Oliver Neukum <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 19 lines · Oliver Neukum
While a UAS device is undergoing a reset not triggered by the SCSI layer there is a short window in the error case of reallocating streams during which internal error codes of the USB layer are exported as nonsensical queue depths.
The error has been noticed by Sashiko in a different context, but it is a general issue.
Fixes 4de7a3735bdc4 ("uas: Fix reset handling for externally triggered reset")Signed-off-by Oliver Neukum <[email protected]>--- drivers/usb/storage/uas.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-)drivers/usb/storage/uas.c +0
-0
drivers/usb/storage/uas.c static int uas_configure_endpoints(struct uas_dev_info *devinfo) · line 987
Quoted 6 lines
drivers/usb/storage/uas.c +1
-1@@ -983,10 +983,12 @@ static int uas_configure_endpoints(struct uas_dev_info *devinfo) devinfo->qdepth =32 ; devinfo->use_streams =0 ; }else { - devinfo->qdepth =usb_alloc_streams (devinfo->intf, eps +1 , + r =usb_alloc_streams (devinfo->intf, eps +1 ,3 ,MAX_CMNDS ,GFP_NOIO );
This line now needs to be realigned...
[...]
MBR, Sergey
drivers/usb/storage/uas.c static int uas_configure_endpoints(struct uas_dev_info *devinfo) · line 987
Quoted 3 lines · Oliver Neukum
drivers/usb/storage/uas.c +1
-1- devinfo->qdepth =usb_alloc_streams (devinfo->intf, eps +1 , + r =usb_alloc_streams (devinfo->intf, eps +1 ,3 ,MAX_CMNDS ,GFP_NOIO );
Looks correct to me. Keeping the negative errno out of qdepth by assigning only on success is the right fix.