diff --git a/scst/src/scst_lib.c b/scst/src/scst_lib.c index 9b99c3e73..0d3e2881d 100644 --- a/scst/src/scst_lib.c +++ b/scst/src/scst_lib.c @@ -8264,6 +8264,9 @@ int scst_block_generic_dev_done(struct scst_cmd *cmd, TRACE_ENTRY(); + /* Do not call this function for aborted commands. */ + WARN_ON_ONCE(!cmd->completed); + if (unlikely(opcode == READ_CAPACITY)) { if ((status == SAM_STAT_GOOD) || (status == SAM_STAT_CONDITION_MET)) { /* Always keep track of disk capacity */ @@ -8314,6 +8317,9 @@ int scst_tape_generic_dev_done(struct scst_cmd *cmd, TRACE_ENTRY(); + /* Do not call this function for aborted commands. */ + WARN_ON_ONCE(!cmd->completed); + if (unlikely(cmd->status != SAM_STAT_GOOD)) goto out; diff --git a/scst/src/scst_targ.c b/scst/src/scst_targ.c index 79247a4e5..5a1e258a1 100644 --- a/scst/src/scst_targ.c +++ b/scst/src/scst_targ.c @@ -3762,8 +3762,9 @@ static int scst_dev_done(struct scst_cmd *cmd) state = SCST_CMD_STATE_PRE_XMIT_RESP1; - if (likely((cmd->op_flags & SCST_FULLY_LOCAL_CMD) == 0) && - likely(devt->dev_done != NULL)) { + if (likely(cmd->completed && + !(cmd->op_flags & SCST_FULLY_LOCAL_CMD) && + devt->dev_done)) { int rc; if (unlikely(!devt->dev_done_atomic &&