From: Mike Christie <michael.christie@oracle.com>
To: mwilck@suse.com, john.g.garry@oracle.com, bvanassche@acm.org,
hch@lst.de, martin.petersen@oracle.com,
linux-scsi@vger.kernel.org,
james.bottomley@hansenpartnership.com
Cc: Mike Christie <michael.christie@oracle.com>
Subject: [PATCH v2 01/12] scsi: sd: Fix sshdr use in read_capacity_16
Date: Wed, 4 Oct 2023 16:00:02 -0500 [thread overview]
Message-ID: <20231004210013.5601-2-michael.christie@oracle.com> (raw)
In-Reply-To: <20231004210013.5601-1-michael.christie@oracle.com>
If scsi_execute_cmd returns < 0, it doesn't initialize the sshdr, so we
shouldn't access the sshdr. If it returns 0, then the cmd executed
successfully, so there is no need to check the sshdr. This has us access
the sshdr when we get a return value > 0.
Signed-off-by: Mike Christie <michael.christie@oracle.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: John Garry <john.g.garry@oracle.com>
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Reviewed-by: Martin Wilck <mwilck@suse.com>
---
drivers/scsi/sd.c | 7 +++----
1 file changed, 3 insertions(+), 4 deletions(-)
diff --git a/drivers/scsi/sd.c b/drivers/scsi/sd.c
index 83b6a3f3863b..0754949c9f55 100644
--- a/drivers/scsi/sd.c
+++ b/drivers/scsi/sd.c
@@ -2435,11 +2435,10 @@ static int read_capacity_16(struct scsi_disk *sdkp, struct scsi_device *sdp,
the_result = scsi_execute_cmd(sdp, cmd, REQ_OP_DRV_IN,
buffer, RC16_LEN, SD_TIMEOUT,
sdkp->max_retries, &exec_args);
-
- if (media_not_present(sdkp, &sshdr))
- return -ENODEV;
-
if (the_result > 0) {
+ if (media_not_present(sdkp, &sshdr))
+ return -ENODEV;
+
sense_valid = scsi_sense_valid(&sshdr);
if (sense_valid &&
sshdr.sense_key == ILLEGAL_REQUEST &&
--
2.34.1
next prev parent reply other threads:[~2023-10-04 21:00 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-04 21:00 [PATCH v2 00/12] scsi: sshdr and retry fixes Mike Christie
2023-10-04 21:00 ` Mike Christie [this message]
2023-10-04 21:00 ` [PATCH v2 02/12] scsi: sd: Fix sshdr use in sd_spinup_disk Mike Christie
2023-10-04 21:00 ` [PATCH v2 03/12] scsi: hp_sw: Fix sshdr use Mike Christie
2023-10-04 21:00 ` [PATCH v2 04/12] scsi: rdac: Fix send_mode_select retry handling Mike Christie
2023-10-04 21:00 ` [PATCH v2 05/12] scsi: rdac: Fix sshdr use Mike Christie
2023-10-04 21:12 ` Bart Van Assche
2023-10-04 21:00 ` [PATCH v2 06/12] scsi: spi: " Mike Christie
2023-10-04 21:00 ` [PATCH v2 07/12] scsi: sd: Fix sshdr use in sd_suspend_common Mike Christie
2023-10-04 21:15 ` Bart Van Assche
2023-10-04 21:00 ` [PATCH v2 08/12] scsi: sd: Fix scsi_mode_sense caller's sshdr use Mike Christie
2023-10-04 22:37 ` Damien Le Moal
2023-10-06 0:36 ` Mike Christie
2023-10-06 1:12 ` Damien Le Moal
2023-10-06 22:39 ` Mike Christie
2023-10-04 21:00 ` [PATCH v2 09/12] scsi: Fix sshdr use in scsi_test_unit_ready Mike Christie
2023-10-04 21:00 ` [PATCH v2 10/12] scsi: Fix sshdr use in scsi_cdl_enable Mike Christie
2023-10-04 21:00 ` [PATCH v2 11/12] scsi: sd: Fix sshdr use in cache_type_store Mike Christie
2023-10-04 21:00 ` [PATCH v2 12/12] scsi: sr: Fix sshdr use in sr_get_events Mike Christie
2023-10-13 20:54 ` [PATCH v2 00/12] scsi: sshdr and retry fixes Martin K. Petersen
2023-10-17 1:11 ` Martin K. Petersen
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=20231004210013.5601-2-michael.christie@oracle.com \
--to=michael.christie@oracle.com \
--cc=bvanassche@acm.org \
--cc=hch@lst.de \
--cc=james.bottomley@hansenpartnership.com \
--cc=john.g.garry@oracle.com \
--cc=linux-scsi@vger.kernel.org \
--cc=martin.petersen@oracle.com \
--cc=mwilck@suse.com \
/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