[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <20180731195155.46664-7-keescook@chromium.org>
Date: Tue, 31 Jul 2018 12:51:51 -0700
From: Kees Cook <keescook@...omium.org>
To: Jens Axboe <axboe@...nel.dk>
Cc: Kees Cook <keescook@...omium.org>,
Christoph Hellwig <hch@...radead.org>,
"Martin K. Petersen" <martin.petersen@...cle.com>,
"James E.J. Bottomley" <jejb@...ux.vnet.ibm.com>,
Tejun Heo <tj@...nel.org>, Borislav Petkov <bp@...en8.de>,
"David S. Miller" <davem@...emloft.net>,
"Manoj N. Kumar" <manoj@...ux.vnet.ibm.com>,
"Matthew R. Ochs" <mrochs@...ux.vnet.ibm.com>,
Uma Krishnan <ukrishn@...ux.vnet.ibm.com>,
"Nicholas A. Bellinger" <nab@...ux-iscsi.org>,
Thomas Gleixner <tglx@...utronix.de>,
Philippe Ombredanne <pombredanne@...b.com>,
Stephen Boyd <sboyd@...eaurora.org>,
Cyrille Pitchen <cyrille.pitchen@...e-electrons.com>,
Juergen Gross <jgross@...e.com>,
Viresh Kumar <viresh.kumar@...aro.org>,
Uwe Kleine-König
<u.kleine-koenig@...gutronix.de>,
Sagar Dharia <sdharia@...eaurora.org>,
Randy Dunlap <rdunlap@...radead.org>,
Vinod Koul <vinod.koul@...el.com>,
David Kershner <david.kershner@...sys.com>,
linux-block@...r.kernel.org, linux-ide@...r.kernel.org,
linux-scsi@...r.kernel.org, target-devel@...r.kernel.org,
linux-kernel@...r.kernel.org
Subject: [PATCH v2 6/9] ide-cd: Remove redundant sense buffer
This is already able to process the sense buffer, so remove the redundant
parsing during the failure path. This also fixes any possible stale values
since the prior code did not check the sense length.
Signed-off-by: Kees Cook <keescook@...omium.org>
---
drivers/ide/ide-cd.c | 17 +++++++++--------
1 file changed, 9 insertions(+), 8 deletions(-)
diff --git a/drivers/ide/ide-cd.c b/drivers/ide/ide-cd.c
index cb90560acf6e..023a7d94eb08 100644
--- a/drivers/ide/ide-cd.c
+++ b/drivers/ide/ide-cd.c
@@ -423,6 +423,7 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
req_flags_t rq_flags)
{
struct cdrom_info *info = drive->driver_data;
+ struct scsi_sense_hdr local_sshdr;
int retries = 10;
bool failed;
@@ -430,6 +431,9 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
"rq_flags: 0x%x",
cmd[0], write, timeout, rq_flags);
+ if (!sshdr)
+ sshdr = &local_sshdr;
+
/* start of retry loop */
do {
struct request *rq;
@@ -456,9 +460,8 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
if (buffer)
*bufflen = scsi_req(rq)->resid_len;
- if (sshdr)
- scsi_normalize_sense(scsi_req(rq)->sense,
- scsi_req(rq)->sense_len, sshdr);
+ scsi_normalize_sense(scsi_req(rq)->sense,
+ scsi_req(rq)->sense_len, sshdr);
/*
* FIXME: we should probably abort/retry or something in case of
@@ -470,12 +473,10 @@ int ide_cd_queue_pc(ide_drive_t *drive, const unsigned char *cmd,
* The request failed. Retry if it was due to a unit
* attention status (usually means media was changed).
*/
- struct request_sense *reqbuf = scsi_req(rq)->sense;
-
- if (reqbuf->sense_key == UNIT_ATTENTION)
+ if (sshdr->sense_key == UNIT_ATTENTION)
cdrom_saw_media_change(drive);
- else if (reqbuf->sense_key == NOT_READY &&
- reqbuf->asc == 4 && reqbuf->ascq != 4) {
+ else if (sshdr->sense_key == NOT_READY &&
+ sshdr->asc == 4 && sshdr->ascq != 4) {
/*
* The drive is in the process of loading
* a disk. Retry, but wait a little to give
--
2.17.1
Powered by blists - more mailing lists