]> git.karo-electronics.de Git - karo-tx-linux.git/commitdiff
greybus: sdio: correct the usage of mmc request in work queues handler
authorPhong Tran <tranmanphong@gmail.com>
Fri, 26 Jun 2015 14:05:13 +0000 (21:05 +0700)
committerGreg Kroah-Hartman <gregkh@google.com>
Tue, 30 Jun 2015 01:06:08 +0000 (18:06 -0700)
The mmc request should assigned before use. Then
It should avoid freeing before using in mmc_request_done().

Signed-off-by: Phong Tran <tranmanphong@gmail.com>
Reviewed-by: Rui Miguel Silva <rui.silva@linaro.org>
Reviewed-by: Mark Greer <mgreer@animalcreek.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
drivers/staging/greybus/sdio.c

index cf12592d34680dc6747b7e62177bf1973998b16e..30ebd42da2879f3e9e02b405bb993a329da13c23 100644 (file)
@@ -387,13 +387,18 @@ static void gb_sdio_mrq_work(struct work_struct *work)
        host = container_of(work, struct gb_sdio_host, mrqwork);
 
        mutex_lock(&host->lock);
+       mrq = host->mrq;
+       if (!mrq) {
+               mutex_unlock(&host->lock);
+               dev_err(mmc_dev(host->mmc), "mmc request is NULL");
+               return;
+       }
+
        if (host->removed) {
                mrq->cmd->error = -ESHUTDOWN;
                goto done;
        }
 
-       mrq = host->mrq;
-
        if (mrq->sbc) {
                ret = gb_sdio_command(host, mrq->sbc);
                if (ret < 0)
@@ -417,7 +422,7 @@ static void gb_sdio_mrq_work(struct work_struct *work)
        }
 
 done:
-       mrq = NULL;
+       host->mrq = NULL;
        mutex_unlock(&host->lock);
        mmc_request_done(host->mmc, mrq);
 }