From: Desnes Nunes <desnesn@redhat.com>
To: linux-kernel@vger.kernel.org, linux-usb@vger.kernel.org
Cc: gregkh@linuxfoundation.org, stern@rowland.harvard.edu,
Desnes Nunes <desnesn@redhat.com>
Subject: [PATCH 2/2] usb: storage: rearrange triple nested CSW data phase check
Date: Wed, 29 Oct 2025 16:14:14 -0300 [thread overview]
Message-ID: <20251029191414.410442-3-desnesn@redhat.com> (raw)
In-Reply-To: <20251029191414.410442-1-desnesn@redhat.com>
This rearranges the triple nested CSW data phase if clause, in order to
make usb_stor_Bulk_transport() code more readlable. No functional change.
Signed-off-by: Desnes Nunes <desnesn@redhat.com>
---
drivers/usb/storage/transport.c | 21 ++++++++++-----------
1 file changed, 10 insertions(+), 11 deletions(-)
diff --git a/drivers/usb/storage/transport.c b/drivers/usb/storage/transport.c
index 96b81cf6adc7..3f2e1df5ad1e 100644
--- a/drivers/usb/storage/transport.c
+++ b/drivers/usb/storage/transport.c
@@ -1188,18 +1188,17 @@ int usb_stor_Bulk_transport(struct scsi_cmnd *srb, struct us_data *us)
* check whether it really is a CSW.
*/
if (result == USB_STOR_XFER_SHORT &&
- srb->sc_data_direction == DMA_FROM_DEVICE &&
- transfer_length - scsi_get_resid(srb) ==
- US_BULK_CS_WRAP_LEN) {
+ srb->sc_data_direction == DMA_FROM_DEVICE &&
+ transfer_length - scsi_get_resid(srb) == US_BULK_CS_WRAP_LEN) {
struct scatterlist *sg = NULL;
- unsigned int offset = 0;
-
- if (usb_stor_access_xfer_buf((unsigned char *) bcs,
- US_BULK_CS_WRAP_LEN, srb, &sg,
- &offset, FROM_XFER_BUF) ==
- US_BULK_CS_WRAP_LEN &&
- bcs->Signature ==
- cpu_to_le32(US_BULK_CS_SIGN)) {
+ unsigned int offset = 0, buflen = 0;
+
+ buflen = usb_stor_access_xfer_buf((unsigned char *) bcs,
+ US_BULK_CS_WRAP_LEN, srb, &sg,
+ &offset, FROM_XFER_BUF);
+
+ if (buflen == US_BULK_CS_WRAP_LEN &&
+ bcs->Signature == cpu_to_le32(US_BULK_CS_SIGN)) {
unsigned char buf[US_BULK_CS_WRAP_LEN];
sg = NULL;
--
2.50.1
next prev parent reply other threads:[~2025-10-29 19:15 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-10-29 19:14 [PATCH 0/2] usb: storage: Fix memory leak in USB bulk transport Desnes Nunes
2025-10-29 19:14 ` [PATCH 1/2] " Desnes Nunes
2025-10-29 21:49 ` Alan Stern
2025-10-30 0:36 ` Desnes Nunes
2025-10-30 4:42 ` Desnes Nunes
2025-10-30 13:52 ` Alan Stern
2025-10-30 21:20 ` Desnes Nunes
2025-10-29 19:14 ` Desnes Nunes [this message]
2025-10-29 21:54 ` [PATCH 2/2] usb: storage: rearrange triple nested CSW data phase check Alan Stern
2025-10-30 0:39 ` Desnes Nunes
2025-10-30 1:59 ` Alan Stern
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20251029191414.410442-3-desnesn@redhat.com \
--to=desnesn@redhat.com \
--cc=gregkh@linuxfoundation.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-usb@vger.kernel.org \
--cc=stern@rowland.harvard.edu \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox