From: Masami Hiramatsu (Google) <mhiramat@kernel.org>
To: Sergey Senozhatsky <senozhatsky@chromium.org>
Cc: Ulf Hansson <ulf.hansson@linaro.org>,
Chaotian Jing <chaotian.jing@mediatek.com>,
Matthias Brugger <matthias.bgg@gmail.com>,
AngeloGioacchino Del Regno
<angelogioacchino.delregno@collabora.com>,
Tomasz Figa <tfiga@chromium.org>,
linux-mmc@vger.kernel.org, linux-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org
Subject: Re: [PATCH] mtk-sd: Prevent memory corruption from DMA map failure
Date: Wed, 25 Jun 2025 13:42:54 +0900 [thread overview]
Message-ID: <20250625134254.7cbd72feb80d8d050f2f005d@kernel.org> (raw)
In-Reply-To: <cifhvofebjuanprzcs2duv6r22r5reibzm7nub4xfya3h3rmwe@ujpf5wadwh3c>
On Wed, 25 Jun 2025 13:13:18 +0900
Sergey Senozhatsky <senozhatsky@chromium.org> wrote:
> On (25/06/25 12:56), Sergey Senozhatsky wrote:
> > On (25/06/12 20:26), Masami Hiramatsu (Google) wrote:
> > [..]
> > > @@ -1466,8 +1471,18 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq)
> > > WARN_ON(!host->hsq_en && host->mrq);
> > > host->mrq = mrq;
> > >
> > > - if (mrq->data)
> > > + if (mrq->data) {
> > > msdc_prepare_data(host, mrq->data);
> > > + if (!msdc_data_prepared(mrq->data)) {
> > > + /*
> > > + * Failed to prepare DMA area, fail fast before
> > > + * starting any commands.
> > > + */
> > > + mrq->cmd->error = -ENOSPC;
> > > + mmc_request_done(mmc_from_priv(host), mrq);
> >
> > Do we end up having a stale/dangling host->mrq pointer here?
>
> Something like this maybe?
Good catch! I thought it is cleared in mmc_request_done(), but not.
I agree we need to clean it up since it is set in msdc_ops_request().
Reviewed-by: Masami Hiramatsu (Google) <mhiramat@kernel.org>
Thanks,
>
> ---
>
> diff --git a/drivers/mmc/host/mtk-sd.c b/drivers/mmc/host/mtk-sd.c
> index b12cfb9a5e5f..46bb770ace41 100644
> --- a/drivers/mmc/host/mtk-sd.c
> +++ b/drivers/mmc/host/mtk-sd.c
> @@ -1498,6 +1498,7 @@ static void msdc_ops_request(struct mmc_host *mmc, struct mmc_request *mrq)
> */
> mrq->cmd->error = -ENOSPC;
> mmc_request_done(mmc_from_priv(host), mrq);
> + host->mrq = NULL;
> return;
> }
> }
--
Masami Hiramatsu (Google) <mhiramat@kernel.org>
next prev parent reply other threads:[~2025-06-25 4:45 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-06-12 11:26 [PATCH] mtk-sd: Prevent memory corruption from DMA map failure Masami Hiramatsu (Google)
2025-06-19 2:05 ` Masami Hiramatsu
2025-06-19 11:20 ` Ulf Hansson
2025-06-25 3:56 ` Sergey Senozhatsky
2025-06-25 4:13 ` Sergey Senozhatsky
2025-06-25 4:42 ` Masami Hiramatsu [this message]
2025-06-25 5:20 ` [PATCH] mtk-sd: reset host->mrq on prepare_data() error Sergey Senozhatsky
2025-06-25 8:22 ` Masami Hiramatsu
2025-06-25 12:45 ` Ulf Hansson
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=20250625134254.7cbd72feb80d8d050f2f005d@kernel.org \
--to=mhiramat@kernel.org \
--cc=angelogioacchino.delregno@collabora.com \
--cc=chaotian.jing@mediatek.com \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=linux-mmc@vger.kernel.org \
--cc=matthias.bgg@gmail.com \
--cc=senozhatsky@chromium.org \
--cc=tfiga@chromium.org \
--cc=ulf.hansson@linaro.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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.