linux/drivers/bus
Sumit Kumar f5225a34bd bus: mhi: ep: Fix chained transfer handling in read path
The mhi_ep_read_channel function incorrectly assumes the End of Transfer
(EOT) bit is present for each packet in a chained transactions, causing
it to advance mhi_chan->rd_offset beyond wr_offset during host-to-device
transfers when EOT has not yet arrived. This leads to access of unmapped
host memory, causing IOMMU faults and processing of stale TREs.

Modify the loop condition to ensure mhi_queue is not empty, allowing the
function to process only valid TREs up to the current write pointer to
prevent premature reads and ensure safe traversal of chained TREs.

Due to this change, buf_left needs to be removed from the while loop
condition to avoid exiting prematurely before reading the ring completely,
and also remove write_offset since it will always be zero because the new
cache buffer is allocated every time.

Fixes: 5301258899 ("bus: mhi: ep: Add support for reading from the host")
Co-developed-by: Akhil Vinod <akhil.vinod@oss.qualcomm.com>
Signed-off-by: Akhil Vinod <akhil.vinod@oss.qualcomm.com>
Signed-off-by: Sumit Kumar <sumit.kumar@oss.qualcomm.com>
[mani: reworded description slightly]
Signed-off-by: Manivannan Sadhasivam <manivannan.sadhasivam@oss.qualcomm.com>
Reviewed-by: Krishna Chaitanya Chundru <krishna.chundru@oss.qualcomm.com>
Cc: stable@vger.kernel.org
Link: https://patch.msgid.link/20250910-final_chained-v3-1-ec77c9d88ace@oss.qualcomm.com
2025-09-12 16:08:41 +05:30
..
fsl-mc bus: fsl-mc: Fix potential double device reference in fsl_mc_get_endpoint() 2025-07-18 17:13:50 -07:00
mhi bus: mhi: ep: Fix chained transfer handling in read path 2025-09-12 16:08:41 +05:30
arm-cci.c bus: arm-cci: remove unnecessary unreachable() 2018-05-14 01:22:49 -07:00
arm-integrator-lm.c bus: integrator-lm: fix OF node leak in probe() 2024-09-02 10:18:43 +02:00
brcmstb_gisb.c bus: brcmstb_gisb: use dev_groups to register attribute groups 2025-04-07 10:35:43 -07:00
bt1-apb.c bus: bt1-apb: change to use devm_clk_get_enabled() helper 2024-08-29 10:45:13 +02:00
bt1-axi.c bus: bt1-axi: change to use devm_clk_get_enabled() helper 2024-08-29 10:44:53 +02:00
da8xx-mstpri.c treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 500 2019-06-19 17:09:55 +02:00
hisi_lpc.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
imx-aipstz.c bus: imx-aipstz: allow creating pdevs for child buses 2025-07-11 16:32:08 +08:00
imx-weim.c bus: imx-weim: change to use devm_clk_get_enabled() helper 2024-09-01 17:06:33 +08:00
intel-ixp4xx-eb.c bus: ixp4xx: fix IXP4XX_EXP_T1_MASK 2023-07-05 22:22:55 +02:00
Kconfig bus: add driver for IMX AIPSTZ bridge 2025-07-01 22:23:21 +08:00
Makefile bus: add driver for IMX AIPSTZ bridge 2025-07-01 22:23:21 +08:00
mips_cdmm.c driver core: have match() callback in struct bus_type take a const * 2024-07-03 15:16:54 +02:00
moxtet.c bus: moxtet: Use dev_fwnode() 2025-07-24 11:42:22 +02:00
mvebu-mbus.c bus: mvebu-mbus: Remove open coded "ranges" parsing 2023-04-18 11:18:24 -05:00
omap-ocp2scp.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
omap_l3_noc.c treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_320.RULE 2022-06-10 14:51:36 +02:00
omap_l3_noc.h treewide: Replace GPLv2 boilerplate/reference with SPDX - gpl-2.0_320.RULE 2022-06-10 14:51:36 +02:00
omap_l3_smx.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
omap_l3_smx.h treewide: Replace GPLv2 boilerplate/reference with SPDX - rule 156 2019-05-30 11:26:35 -07:00
qcom-ebi2.c bus: qcom: remove MODULE_LICENSE in non-modules 2023-04-13 13:13:50 -07:00
qcom-ssc-block-bus.c bus: qcom-ssc-block-bus: Fix the error handling path of qcom_ssc_block_bus_probe() 2025-03-13 17:11:56 -05:00
simple-pm-bus.c bus: simple-pm-bus: fix forced runtime PM use 2025-02-20 15:22:02 +01:00
stm32_etzpc.c bus: etzpc: introduce ETZPC firewall controller driver 2024-04-25 14:44:39 +02:00
stm32_firewall.c bus: stm32_firewall: fix off by one in stm32_firewall_get_firewall() 2024-04-25 14:44:39 +02:00
stm32_firewall.h firewall: introduce stm32_firewall framework 2024-04-05 16:49:14 +02:00
stm32_rifsc.c bus: rifsc: introduce RIFSC firewall controller driver 2024-04-24 14:30:35 +02:00
sun50i-de2.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
sunxi-rsb.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
tegra-aconnect.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
tegra-gmi.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
ti-pwmss.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
ti-sysc.c bus: del unnecessary init var 2025-07-22 22:23:07 +02:00
ts-nbus.c bus: Switch back to struct platform_driver::remove() 2024-11-12 15:53:37 +01:00
uniphier-system-bus.c bus: uniphier-system-bus: Remove open coded "ranges" parsing 2023-03-30 13:37:21 -05:00
vexpress-config.c bus: vexpress-config: Add missing MODULE_DESCRIPTION() macro 2024-06-20 09:43:33 +01:00