mmc: toshsd: move dereference below check for NULL
authorDan Carpenter <dan.carpenter@oracle.com>
Sat, 15 Nov 2014 18:56:41 +0000 (21:56 +0300)
committerUlf Hansson <ulf.hansson@linaro.org>
Wed, 26 Nov 2014 13:31:01 +0000 (14:31 +0100)
We check for NULL pointers after dereferencing so it's too late.  Oddly
enough, Smatch misses this code but complains about the caller passing
NULL pointers to this function:

drivers/mmc/host/toshsd.c:389 toshsd_irq()
error: we previously assumed 'host->cmd' could be null (see line 349)

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Ulf Hansson <ulf.hansson@linaro.org>
drivers/mmc/host/toshsd.c

index edb06d67c2f522b66718071177d68dcd8a227263..4666262edacaee792591bc801c0f34a50f2cc0d8 100644 (file)
@@ -206,14 +206,14 @@ static irqreturn_t toshsd_thread_irq(int irq, void *dev_id)
 static void toshsd_cmd_irq(struct toshsd_host *host)
 {
        struct mmc_command *cmd = host->cmd;
-       u8 *buf = (u8 *) cmd->resp;
+       u8 *buf;
        u16 data;
 
        if (!host->cmd) {
                dev_warn(&host->pdev->dev, "Spurious CMD irq\n");
                return;
        }
-
+       buf = (u8 *)cmd->resp;
        host->cmd = NULL;
 
        if (cmd->flags & MMC_RSP_PRESENT && cmd->flags & MMC_RSP_136) {