scsi: ufs: Initialize cmd_id and check lrbp->cmd NULL

In commit d70b0a18f6 ("scsi: ufs: add command
logging infrastructure"), cmd_id is not initialized
and lrbp->cmd is explicitly dereferenced without
checking NULL. Fix them by initializing cmd_id with
an initial value 0 and checking NULL for lrbp->cmd.

Change-Id: I6f66066adc8d53e3615df50ac49dd313f6d7ea8e
Signed-off-by: Can Guo <cang@codeaurora.org>
This commit is contained in:
Can Guo 2017-05-11 08:46:03 +08:00
parent d70b0a18f6
commit 6a4c4fcfe2

View file

@ -653,7 +653,7 @@ static inline void ufshcd_cond_add_cmd_trace(struct ufs_hba *hba,
struct ufshcd_lrb *lrbp; struct ufshcd_lrb *lrbp;
char *cmd_type; char *cmd_type;
u8 opcode = 0; u8 opcode = 0;
u8 cmd_id, idn = 0; u8 cmd_id = 0, idn = 0;
sector_t lba = -1; sector_t lba = -1;
int transfer_len = -1; int transfer_len = -1;
@ -674,7 +674,7 @@ static inline void ufshcd_cond_add_cmd_trace(struct ufs_hba *hba,
} }
} }
if (lrbp->command_type == UTP_CMD_TYPE_SCSI) { if (lrbp->cmd && (lrbp->command_type == UTP_CMD_TYPE_SCSI)) {
cmd_type = "scsi"; cmd_type = "scsi";
cmd_id = (u8)(*lrbp->cmd->cmnd); cmd_id = (u8)(*lrbp->cmd->cmnd);
} else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) { } else if (lrbp->command_type == UTP_CMD_TYPE_DEV_MANAGE) {