From 93a99e8a105aeaec432995196c21ffedcd0c0cad Mon Sep 17 00:00:00 2001 From: Phong Tran Date: Fri, 26 Jun 2015 21:05:13 +0700 Subject: [PATCH] greybus: sdio: correct the usage of mmc request in work queues handler The mmc request should assigned before use. Then It should avoid freeing before using in mmc_request_done(). Signed-off-by: Phong Tran Reviewed-by: Rui Miguel Silva Reviewed-by: Mark Greer Signed-off-by: Greg Kroah-Hartman --- drivers/staging/greybus/sdio.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/drivers/staging/greybus/sdio.c b/drivers/staging/greybus/sdio.c index cf12592d3468..30ebd42da287 100644 --- a/drivers/staging/greybus/sdio.c +++ b/drivers/staging/greybus/sdio.c @@ -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); }