Skip to content

Commit

Permalink
mmc: cavium: Check pointer before de-reference
Browse files Browse the repository at this point in the history
Add a pointer check to prevent this smatch warning:

drivers/mmc/host/cavium.c:803 cvm_mmc_request()
	error: we previously assumed 'cmd->data' could be null (see line 782)

This is a theoretical fix because MMC_CMD_ADTC seems to imply
that cmd->data is not null. Nevertheless checking cmd->data
before using it improves readability.

Signed-off-by: Jan Glauber <jglauber@cavium.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
  • Loading branch information
Jan Glauber authored and Ulf Hansson committed Apr 24, 2017
1 parent c34d157 commit fe79018
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/mmc/host/cavium.c
Original file line number Diff line number Diff line change
Expand Up @@ -799,7 +799,7 @@ static void cvm_mmc_request(struct mmc_host *mmc, struct mmc_request *mrq)
FIELD_PREP(MIO_EMM_CMD_IDX, cmd->opcode) |
FIELD_PREP(MIO_EMM_CMD_ARG, cmd->arg);
set_bus_id(&emm_cmd, slot->bus_id);
if (mmc_cmd_type(cmd) == MMC_CMD_ADTC)
if (cmd->data && mmc_cmd_type(cmd) == MMC_CMD_ADTC)
emm_cmd |= FIELD_PREP(MIO_EMM_CMD_OFFSET,
64 - ((cmd->data->blocks * cmd->data->blksz) / 8));

Expand Down

0 comments on commit fe79018

Please sign in to comment.