FAILED: patch "[PATCH] iommu/mediatek-v1: fix device leaks on probe()" failed to apply to 6.1-stable tree
Subsystems (4)
[email protected]
maintainerThe patch below does not apply to the 6.1-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-6.1.y
git checkout FETCH_HEAD
git cherry-pick -x 46207625c9f33da0e43bb4ae1e91f0791b6ed633
# <resolve conflicts, build, test, etc.>
git commit -s
git send-email --to '<[email protected]>' --in-reply-to '2026010545-bleak-stingily-e2a3@gregkh' --subject-prefix 'PATCH 6.1.y' HEAD^..
Possible dependencies:
thanks,
greg k-h
------------------ original commit in Linus's tree ------------------
From 46207625c9f33da0e43bb4ae1e91f0791b6ed633 Mon Sep 17 00:00:00 2001
From: Johan Hovold <[email protected]>
Date: Mon, 20 Oct 2025 06:53:13 +0200
Subject: [PATCH] iommu/mediatek-v1: fix device leaks on probe()
Make sure to drop the references taken to the larb devices during probe on probe failure (e.g. probe deferral) and on driver unbind.
drivers/iommu/mtk_iommu_v1.c +18 -5
@@ -651,8 +651,10 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)struct platform_device *plarbdev; larbnode =of_parse_phandle (dev->of_node,"mediatek,larbs" , i); -if (!larbnode) -return -EINVAL ; +if (!larbnode) { + ret = -EINVAL ; + goto out_put_larbs; + }if (!of_device_is_available (larbnode)) {of_node_put (larbnode);
@@ -662,11 +664,14 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) plarbdev =of_find_device_by_node (larbnode);if (!plarbdev) {of_node_put (larbnode); -return -ENODEV ; + ret = -ENODEV ; + goto out_put_larbs; }if (!plarbdev->dev.driver) {of_node_put (larbnode); -return -EPROBE_DEFER ; +put_device (&plarbdev->dev); + ret = -EPROBE_DEFER ; + goto out_put_larbs; } data->larb_imu[i].dev = &plarbdev->dev;
@@ -678,7 +683,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) ret =mtk_iommu_v1_hw_init (data);if (ret) -return ret; + goto out_put_larbs; ret =iommu_device_sysfs_add (&data->iommu, &pdev->dev,NULL ,dev_name (&pdev->dev));
@@ -700,12 +705,17 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)iommu_device_sysfs_remove (&data->iommu); out_clk_unprepare:clk_disable_unprepare (data->bclk); +out_put_larbs: +for (i =0 ; i <MTK_LARB_NR_MAX ; i++) +put_device (data->larb_imu[i].dev); +return ret; }static void mtk_iommu_v1_remove (struct platform_device *pdev) {struct mtk_iommu_v1_data *data =platform_get_drvdata (pdev); +int i;iommu_device_sysfs_remove (&data->iommu);iommu_device_unregister (&data->iommu);
@@ -713,6 +723,9 @@ static void mtk_iommu_v1_remove(struct platform_device *pdev)clk_disable_unprepare (data->bclk);devm_free_irq (&pdev->dev, data->irq, data);component_master_del (&pdev->dev, &mtk_iommu_v1_com_ops); + +for (i =0 ; i <MTK_LARB_NR_MAX ; i++) +put_device (data->larb_imu[i].dev); }static int __maybe_unused mtk_iommu_v1_suspend (struct device *dev)
Sasha Levin
maintainerPATCH 1/2 iommu/mtk_iommu_v1: Convert to platform remove callback returning void
From: Uwe Kleine-König <[email protected]>
[ Upstream commit 85e1049e50da9409678fc247ebad4c019d68041f ]
The .remove() callback for a platform driver returns an int which makes many driver authors wrongly assume it's possible to do error handling by returning an error code. However the value returned is (mostly) ignored and this typically results in resource leaks. To improve here there is a quest to make the remove callback return void. In the first step of this quest all drivers are converted to .remove_new() which already returns void.
Trivially convert this driver from always returning zero in the remove callback to the void returning variant.
Stable-dep-of: 46207625c9f3 ("iommu/mediatek-v1: fix device leaks on probe()")
--- drivers/iommu/mtk_iommu_v1.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-)
drivers/iommu/mtk_iommu_v1.c +2 -3
@@ -706,7 +706,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)return ret; } -static int mtk_iommu_v1_remove (struct platform_device *pdev) +static void mtk_iommu_v1_remove (struct platform_device *pdev) {struct mtk_iommu_v1_data *data =platform_get_drvdata (pdev);
@@ -716,7 +716,6 @@ static int mtk_iommu_v1_remove(struct platform_device *pdev)clk_disable_unprepare (data->bclk);devm_free_irq (&pdev->dev, data->irq, data);component_master_del (&pdev->dev, &mtk_iommu_v1_com_ops); -return 0 ; }static int __maybe_unused mtk_iommu_v1_suspend (struct device *dev)
@@ -755,7 +754,7 @@ static const struct dev_pm_ops mtk_iommu_v1_pm_ops = {static struct platform_driver mtk_iommu_v1_driver = { .probe = mtk_iommu_v1_probe, - .remove = mtk_iommu_v1_remove, + .remove_new = mtk_iommu_v1_remove, .driver = { .name ="mtk-iommu-v1" , .of_match_table = mtk_iommu_v1_of_ids,
Signature · 1 line
2.51.0
Sasha Levin
maintainerPATCH 2/2 iommu/mediatek-v1: fix device leaks on probe()
From: Johan Hovold <[email protected]>
[ Upstream commit 46207625c9f33da0e43bb4ae1e91f0791b6ed633 ]
Make sure to drop the references taken to the larb devices during probe on probe failure (e.g. probe deferral) and on driver unbind.
--- drivers/iommu/mtk_iommu_v1.c | 23 ++++++++++++++++++----- 1 file changed, 18 insertions(+), 5 deletions(-)
drivers/iommu/mtk_iommu_v1.c +18 -5
@@ -654,8 +654,10 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)struct platform_device *plarbdev; larbnode =of_parse_phandle (dev->of_node,"mediatek,larbs" , i); -if (!larbnode) -return -EINVAL ; +if (!larbnode) { + ret = -EINVAL ; + goto out_put_larbs; + }if (!of_device_is_available (larbnode)) {of_node_put (larbnode);
@@ -665,11 +667,14 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) plarbdev =of_find_device_by_node (larbnode);if (!plarbdev) {of_node_put (larbnode); -return -ENODEV ; + ret = -ENODEV ; + goto out_put_larbs; }if (!plarbdev->dev.driver) {of_node_put (larbnode); -return -EPROBE_DEFER ; +put_device (&plarbdev->dev); + ret = -EPROBE_DEFER ; + goto out_put_larbs; } data->larb_imu[i].dev = &plarbdev->dev;
@@ -681,7 +686,7 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev) ret =mtk_iommu_v1_hw_init (data);if (ret) -return ret; + goto out_put_larbs; ret =iommu_device_sysfs_add (&data->iommu, &pdev->dev,NULL ,dev_name (&pdev->dev));
@@ -703,12 +708,17 @@ static int mtk_iommu_v1_probe(struct platform_device *pdev)iommu_device_sysfs_remove (&data->iommu); out_clk_unprepare:clk_disable_unprepare (data->bclk); +out_put_larbs: +for (i =0 ; i <MTK_LARB_NR_MAX ; i++) +put_device (data->larb_imu[i].dev); +return ret; }static void mtk_iommu_v1_remove (struct platform_device *pdev) {struct mtk_iommu_v1_data *data =platform_get_drvdata (pdev); +int i;iommu_device_sysfs_remove (&data->iommu);iommu_device_unregister (&data->iommu);
@@ -716,6 +726,9 @@ static void mtk_iommu_v1_remove(struct platform_device *pdev)clk_disable_unprepare (data->bclk);devm_free_irq (&pdev->dev, data->irq, data);component_master_del (&pdev->dev, &mtk_iommu_v1_com_ops); + +for (i =0 ; i <MTK_LARB_NR_MAX ; i++) +put_device (data->larb_imu[i].dev); }static int __maybe_unused mtk_iommu_v1_suspend (struct device *dev)
Signature · 1 line
2.51.0