mmc: cavium: Check pointer before de-reference
authorJan Glauber <jglauber@cavium.com>
Thu, 13 Apr 2017 12:10:51 +0000 (14:10 +0200)
committerUlf Hansson <ulf.hansson@linaro.org>
Mon, 24 Apr 2017 19:42:23 +0000 (21:42 +0200)
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>
drivers/mmc/host/cavium.c

index ddf902c7f7e3c848166d8f7673686f52e1015913..d89c2ebcad90d773d1c94c2f3cfe15e87ee8c63f 100644 (file)
@@ -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));