Patch "mtd: rawnand: stm32_fmc2: Fix dma_map_sg error check" has been added to the 5.15-stable tree

gregkh
2025-09-14T08:02:39Z

This is a note to let you know that I've just added the patch titled

mtd: rawnand: stm32_fmc2: Fix dma_map_sg error check

to the 5.15-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary

The filename of the patch is:
mtd-rawnand-stm32_fmc2-fix-dma_map_sg-error-check.patch
and it can be found in the queue-5.15 subdirectory.

If you, or anyone else, feels it should not be added to the stable tree,
please let <stable@vger.kernel.org> know about it.

From stable+bounces-179495-greg=kroah.com@vger.kernel.org Sat Sep 13 17:09:31 2025
From: Sasha Levin <sashal@kernel.org>
Date: Sat, 13 Sep 2025 11:09:16 -0400
Subject: mtd: rawnand: stm32_fmc2: Fix dma_map_sg error check
To: stable@vger.kernel.org
Cc: Jack Wang <jinpu.wang@ionos.com>, Miquel Raynal <miquel.raynal@bootlin.com>, Richard Weinberger <richard@nod.at>, Vignesh Raghavendra <vigneshr@ti.com>, Maxime Coquelin <mcoquelin.stm32@gmail.com>, Alexandre Torgue <alexandre.torgue@foss.st.com>, Philipp Zabel <p.zabel@pengutronix.de>, Christophe Kerello <christophe.kerello@foss.st.com>, Cai Huoqing <cai.huoqing@linux.dev>, linux-mtd@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, Sasha Levin <sashal@kernel.org>
Message-ID: <20250913150917.1408380-1-sashal@kernel.org>

From: Jack Wang <jinpu.wang@ionos.com>

[ Upstream commit 43b81c2a3e6e07915151045aa13a6e8a9bd64419 ]

dma_map_sg return 0 on error, in case of error return -EIO.

Cc: Miquel Raynal <miquel.raynal@bootlin.com>
Cc: Richard Weinberger <richard@nod.at>
Cc: Vignesh Raghavendra <vigneshr@ti.com>
Cc: Maxime Coquelin <mcoquelin.stm32@gmail.com>
Cc: Alexandre Torgue <alexandre.torgue@foss.st.com>
Cc: Philipp Zabel <p.zabel@pengutronix.de>
Cc: Christophe Kerello <christophe.kerello@foss.st.com>
Cc: Cai Huoqing <cai.huoqing@linux.dev>
Cc: linux-mtd@lists.infradead.org
Cc: linux-stm32@st-md-mailman.stormreply.com
Cc: linux-arm-kernel@lists.infradead.org
Cc: linux-kernel@vger.kernel.org
Signed-off-by: Jack Wang <jinpu.wang@ionos.com>
Reviewed-by: Christophe Kerello <christophe.kerello@foss.st.com>
Signed-off-by: Miquel Raynal <miquel.raynal@bootlin.com>
Link: https://lore.kernel.org/linux-mtd/20220819060801.10443-5-jinpu.wang@ionos.com
Stable-dep-of: 513c40e59d5a ("mtd: rawnand: stm32_fmc2: avoid overlapping mappings on ECC buffer")
Signed-off-by: Sasha Levin <sashal@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/mtd/nand/raw/stm32_fmc2_nand.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)

--- a/drivers/mtd/nand/raw/stm32_fmc2_nand.c
+++ b/drivers/mtd/nand/raw/stm32_fmc2_nand.c
@@ -860,8 +860,8 @@ static int stm32_fmc2_nfc_xfer(struct na

ret = dma_map_sg(nfc->dev, nfc->dma_data_sg.sgl,
eccsteps, dma_data_dir);
- if (ret < 0)
- return ret;
+ if (!ret)
+ return -EIO;

desc_data = dmaengine_prep_slave_sg(dma_ch, nfc->dma_data_sg.sgl,
eccsteps, dma_transfer_dir,
@@ -891,8 +891,10 @@ static int stm32_fmc2_nfc_xfer(struct na

ret = dma_map_sg(nfc->dev, nfc->dma_ecc_sg.sgl,
eccsteps, dma_data_dir);
- if (ret < 0)
+ if (!ret) {
+ ret = -EIO;
goto err_unmap_data;
+ }

desc_ecc = dmaengine_prep_slave_sg(nfc->dma_ecc_ch,
nfc->dma_ecc_sg.sgl,

Patches currently in stable-queue which might be from sashal@kernel.org are

queue-5.15/media-i2c-imx214-fix-link-frequency-validation.patch
queue-5.15/flexfiles-pnfs-fix-null-checks-on-result-of-ff_layou.patch
queue-5.15/kvm-svm-set-synthesized-tsa-cpuid-flags.patch
queue-5.15/tcp_bpf-call-sk_msg_free-when-tcp_bpf_send_verdict-f.patch
queue-5.15/mm-rmap-reject-hugetlb-folios-in-folio_make_device_exclusive.patch
queue-5.15/media-mtk-vcodec-venc-avoid-wenum-compare-conditional-warning.patch
queue-5.15/nfsv4-clear-the-nfs_cap_fs_locations-flag-if-it-is-n.patch
queue-5.15/revert-fbdev-disable-sysfb-device-registration-when-.patch
queue-5.15/tracing-do-not-add-length-to-print-format-in-synthetic-events.patch
queue-5.15/tracing-fix-tracing_marker-may-trigger-page-fault-du.patch
queue-5.15/kvm-svm-return-tsa_sq_no-and-tsa_l1_no-bits-in-__do_cpuid_func.patch
queue-5.15/nfsv4-don-t-clear-capabilities-that-won-t-be-reset.patch
queue-5.15/s390-cpum_cf-deny-all-sampling-events-by-counter-pmu.patch
queue-5.15/nfsv4-flexfiles-fix-layout-merge-mirror-check.patch
queue-5.15/mtd-nand-raw-atmel-respect-tar-tclr-in-read-setup-timing.patch
queue-5.15/mtd-nand-raw-atmel-fix-comment-in-timings-preparation.patch
queue-5.15/nfsv4-clear-the-nfs_cap_xattr-flag-if-not-supported-.patch
queue-5.15/net-fix-null-ptr-deref-by-sock_lock_init_class_and_name-and-rmmod.patch
queue-5.15/mtd-rawnand-stm32_fmc2-fix-dma_map_sg-error-check.patch
queue-5.15/mtd-rawnand-stm32_fmc2-avoid-overlapping-mappings-on-ecc-buffer.patch
queue-5.15/kvm-x86-move-open-coded-cpuid-leaf-0x80000021-eax-bit-propagation-code.patch
queue-5.15/xfs-short-circuit-xfs_growfs_data_private-if-delta-i.patch