Fixing NULL pointer dereferences accessing dev->d_sense

git-svn-id: http://svn.code.sf.net/p/scst/svn/trunk@706 d57e44dd-8a1f-0410-8b47-8ef2f437770f
This commit is contained in:
Vladislav Bolkhovitin
2009-03-20 12:29:20 +00:00
parent 071e0a720c
commit a20e32ad33
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -2407,7 +2407,7 @@ static inline int scst_cmd_aborted(struct scst_cmd *cmd)
/* Returns sense data format for cmd's dev */
static inline bool scst_get_cmd_dev_d_sense(struct scst_cmd *cmd)
{
return cmd->dev->d_sense;
return (cmd->dev != NULL) ? cmd->dev->d_sense : 0;
}
/*
+2 -2
View File
@@ -141,8 +141,8 @@ void scst_set_cmd_error(struct scst_cmd *cmd, int key, int asc, int ascq)
goto out;
}
scst_set_sense(cmd->sense, SCST_SENSE_BUFFERSIZE, cmd->dev->d_sense,
key, asc, ascq);
scst_set_sense(cmd->sense, SCST_SENSE_BUFFERSIZE,
scst_get_cmd_dev_d_sense(cmd), key, asc, ascq);
TRACE_BUFFER("Sense set", cmd->sense, SCST_SENSE_BUFFERSIZE);
out: