mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Chris Ball <cjb@laptop.org>
To: Chuansheng Liu <chuansheng.liu@intel.com>
Cc: linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
	chuanxiao.dong@intel.com
Subject: Re: [PATCH] mmc: sdhci: Setting the host->mrq to NULL before executing tuning
Date: Tue, 26 Nov 2013 17:50:59 -0500	[thread overview]
Message-ID: <87r4a2eq0c.fsf@octavius.laptop.org> (raw)
In-Reply-To: <1383634365.26153.100.camel@cliu38-desktop-build> (Chuansheng Liu's message of "Tue, 05 Nov 2013 14:52:45 +0800")

Hi Chuansheng,

On Tue, Nov 05 2013, Chuansheng Liu wrote:
> In function sdhci_request(), it is possible to do the tuning execution
> like below:
>
> sdhci_request() {
> 	spin_lock_irqsave(&host->lock, flags);
> 	host->mrq = mrq;
> 	...
> 	spin_unlock_irqrestore(&host->lock, flags);
>
> <=== Here it is possible one pending finish_tasklet get running
>      and it will operate the original mrq, and notified the mrq
>      is done, and causes memory corruption.
>
> 	sdhci_execute_tuning(mmc, tuning_opcode);
> 	spin_lock_irqsave(&host->lock, flags);
> 	host->mrq = mrq;
> ...
> }
>
> In the above race place, the original mrq should not be finished wrongly,
> so here before unlock the spinlock, we need to set the host->mrq to NULL
> to avoid this case.
>
> Signed-off-by: Liu, Chuansheng <chuansheng.liu@intel.com>
> ---
>  drivers/mmc/host/sdhci.c |    7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c
> index 7a7fb4f..c7a001a 100644
> --- a/drivers/mmc/host/sdhci.c
> +++ b/drivers/mmc/host/sdhci.c
> @@ -1391,6 +1391,13 @@ static void sdhci_request(struct mmc_host *mmc, struct mmc_request *mrq)
>  					mmc->card->type == MMC_TYPE_MMC ?
>  					MMC_SEND_TUNING_BLOCK_HS200 :
>  					MMC_SEND_TUNING_BLOCK;
> +
> +				/* Here we need to set the host->mrq to NULL,
> +				 * in case the penging finish_tasklet
> +				 * operates it wrongly.
> +				 */
> +				host->mrq = NULL;
> +
>  				spin_unlock_irqrestore(&host->lock, flags);
>  				sdhci_execute_tuning(mmc, tuning_opcode);
>  				spin_lock_irqsave(&host->lock, flags);

Thanks, pushed to mmc-next for 3.14.

- Chris.
-- 
Chris Ball   <cjb@laptop.org>   <http://printf.net/>

      reply	other threads:[~2013-11-26 22:51 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2013-11-05  6:52 Chuansheng Liu
2013-11-26 22:50 ` Chris Ball [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=87r4a2eq0c.fsf@octavius.laptop.org \
    --to=cjb@laptop.org \
    --cc=chuansheng.liu@intel.com \
    --cc=chuanxiao.dong@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mmc@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®