ncr5380: Dont re-enter NCR5380_select()

Calling NCR5380_select() from the abort handler causes various problems.
Firstly, it means potentially re-entering NCR5380_select(). Secondly, it
means that the lock is released, which permits the EH handlers to be
re-entered. The combination results in crashes. Don't do it.

Fixes: 8b00c3d5d4 ("ncr5380: Implement new eh_abort_handler")
Reported-and-tested-by: Michael Schmitz <schmitzmic@gmail.com>
Cc: <stable@vger.kernel.org> # 4.5
Signed-off-by: Finn Thain <fthain@telegraphics.com.au>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
Finn Thain 2016-02-23 10:07:06 +11:00 committed by Martin K. Petersen
parent 1678847ec9
commit 71a00593ec
2 changed files with 16 additions and 16 deletions

View File

@ -2302,6 +2302,9 @@ static bool list_del_cmd(struct list_head *haystack,
* If cmd was not found at all then presumably it has already been completed, * If cmd was not found at all then presumably it has already been completed,
* in which case return SUCCESS to try to avoid further EH measures. * in which case return SUCCESS to try to avoid further EH measures.
* If the command has not completed yet, we must not fail to find it. * If the command has not completed yet, we must not fail to find it.
*
* The lock protects driver data structures, but EH handlers also use it
* to serialize their own execution and prevent their own re-entry.
*/ */
static int NCR5380_abort(struct scsi_cmnd *cmd) static int NCR5380_abort(struct scsi_cmnd *cmd)
@ -2338,14 +2341,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
if (list_del_cmd(&hostdata->disconnected, cmd)) { if (list_del_cmd(&hostdata->disconnected, cmd)) {
dsprintk(NDEBUG_ABORT, instance, dsprintk(NDEBUG_ABORT, instance,
"abort: removed %p from disconnected list\n", cmd); "abort: removed %p from disconnected list\n", cmd);
cmd->result = DID_ERROR << 16; /* Can't call NCR5380_select() and send ABORT because that
if (!hostdata->connected) * means releasing the lock. Need a bus reset.
NCR5380_select(instance, cmd); */
if (hostdata->connected != cmd) { result = FAILED;
complete_cmd(instance, cmd); goto out;
result = FAILED;
goto out;
}
} }
if (hostdata->connected == cmd) { if (hostdata->connected == cmd) {

View File

@ -2497,6 +2497,9 @@ static bool list_del_cmd(struct list_head *haystack,
* If cmd was not found at all then presumably it has already been completed, * If cmd was not found at all then presumably it has already been completed,
* in which case return SUCCESS to try to avoid further EH measures. * in which case return SUCCESS to try to avoid further EH measures.
* If the command has not completed yet, we must not fail to find it. * If the command has not completed yet, we must not fail to find it.
*
* The lock protects driver data structures, but EH handlers also use it
* to serialize their own execution and prevent their own re-entry.
*/ */
static int NCR5380_abort(struct scsi_cmnd *cmd) static int NCR5380_abort(struct scsi_cmnd *cmd)
@ -2533,14 +2536,11 @@ static int NCR5380_abort(struct scsi_cmnd *cmd)
if (list_del_cmd(&hostdata->disconnected, cmd)) { if (list_del_cmd(&hostdata->disconnected, cmd)) {
dsprintk(NDEBUG_ABORT, instance, dsprintk(NDEBUG_ABORT, instance,
"abort: removed %p from disconnected list\n", cmd); "abort: removed %p from disconnected list\n", cmd);
cmd->result = DID_ERROR << 16; /* Can't call NCR5380_select() and send ABORT because that
if (!hostdata->connected) * means releasing the lock. Need a bus reset.
NCR5380_select(instance, cmd); */
if (hostdata->connected != cmd) { result = FAILED;
complete_cmd(instance, cmd); goto out;
result = FAILED;
goto out;
}
} }
if (hostdata->connected == cmd) { if (hostdata->connected == cmd) {