FAILED: patch "[PATCH] mtk-sd: Prevent memory corruption from DMA map failure" failed to apply to 5.10-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 5.10-stable tree.
If someone wants it applied there, or to any other stable or longterm tree, then please email the backport, including the original git commit id to <[email protected]>.
To reproduce the conflict and resubmit, you may use the following commands:
git fetch https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/ linux-5.10.y
git checkout FETCH_HEAD
git cherry-pick -x f5de469990f19569627ea0dd56536ff5a13beaa3
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2025070634-wrongness-claw-15a0@gregkh' --subject-prefix 'PATCH 5.10.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From f5de469990f19569627ea0dd56536ff5a13beaa3 Mon Sep 17 00:00:00 2001
From: "Masami Hiramatsu (Google)" <[email protected]>
Date: Thu, 12 Jun 2025 20:26:10 +0900
Subject: [PATCH] mtk-sd: Prevent memory corruption from DMA map failure
If msdc_prepare_data() fails to map the DMA region, the request is not prepared for data receiving, but msdc_start_data() proceeds the DMA with previous setting.
Since this will lead a memory corruption, we have to stop the request operation soon after the msdc_prepare_data() fails to prepare it.
drivers/mmc/host/mtk-sd.c +16 -1
@@ -853,6 +853,11 @@ static void msdc_prepare_data(struct msdc_host *host, struct mmc_data *data) } } +static bool msdc_data_prepared (struct mmc_data *data) +{ +return data->host_cookie &MSDC_PREPARE_FLAG ; +} +static void msdc_unprepare_data (struct msdc_host *host,struct mmc_data *data) {if (data->host_cookie &MSDC_ASYNC_FLAG )
@@ -1484,8 +1489,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); +return ; + } + }/* if SBC is required, we have HW option and SW option. * if HW option is enabled, and SBC does not have "special" flags,