Skip to content

Commit

Permalink
iscsi-scst: Suppress a Coverity taint complaint
Browse files Browse the repository at this point in the history
Suppress the following (false positive) Coverity complaint:

    CID 271578 (#1 of 1): Dereference after null check (FORWARD_NULL)
    var_deref_model: Passing null pointer (*ref_cmd).scst_cmd to
    scst_set_delivery_status, which dereferences it

(*ref_cmd).scst_aen is set when (*ref_cmd).scst_state == ISCSI_CMD_STATE_AEN
and vice versa, so the Coverity complaint is a false positive. Hence rewrite
the code to suppress this complaint and make the code cleaner.
  • Loading branch information
lnocturno committed Jun 26, 2022
1 parent 45501a7 commit e109464
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions iscsi-scst/kernel/nthread.c
Original file line number Diff line number Diff line change
Expand Up @@ -1315,15 +1315,19 @@ static int write_data(struct iscsi_conn *conn)
(unsigned long long)conn->session->sid,
conn->cid, conn->write_cmnd);
}
if (ref_cmd_to_parent &&
((ref_cmd->scst_cmd != NULL) || (ref_cmd->scst_aen != NULL))) {
if (ref_cmd->scst_state == ISCSI_CMD_STATE_AEN)
scst_set_aen_delivery_status(ref_cmd->scst_aen,
SCST_AEN_RES_FAILED);
else
scst_set_delivery_status(ref_cmd->scst_cmd,
SCST_CMD_DELIVERY_FAILED);

if (ref_cmd_to_parent) {
if (ref_cmd->scst_state == ISCSI_CMD_STATE_AEN) {
if (ref_cmd->scst_aen)
scst_set_aen_delivery_status(ref_cmd->scst_aen,
SCST_AEN_RES_FAILED);
} else {
if (ref_cmd->scst_cmd)
scst_set_delivery_status(ref_cmd->scst_cmd,
SCST_CMD_DELIVERY_FAILED);
}
}

goto out;
}

Expand Down

0 comments on commit e109464

Please sign in to comment.