Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

f05c7b7d9ea9 thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe #211

Closed
r-c-n opened this issue May 25, 2023 · 4 comments

Comments

@r-c-n
Copy link

r-c-n commented May 25, 2023

Summary:
  Start:      1fe619a7d252 Linux 5.15.113
  Plain log:  https://storage.kernelci.org/stable/linux-5.15.y/v5.15.113/arm64/defconfig+arm64-chromebook+kselftest/gcc-10/lab-collabora/baseline-mt8183-kukui-jacuzzi-juniper-sku16.txt
  HTML log:   https://storage.kernelci.org/stable/linux-5.15.y/v5.15.113/arm64/defconfig+arm64-chromebook+kselftest/gcc-10/lab-collabora/baseline-mt8183-kukui-jacuzzi-juniper-sku16.html
  Result:     388d2578c7d7 thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe

Checks:
  revert:     PASS
  verify:     PASS

Parameters:
  Tree:       stable
  URL:        https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable.git
  Branch:     linux-5.15.y
  Target:     mt8183-kukui-jacuzzi-juniper-sku16
  CPU arch:   arm64
  Lab:        lab-collabora
  Compiler:   gcc-10
  Config:     defconfig+arm64-chromebook+kselftest
  Test case:  baseline.bootrr.generic-adc-thermal-probed

Breaking commit found:

-------------------------------------------------------------------------------
commit 388d2578c7d7165c1aeca76a0b5ae38e6d74b176
Author: Kang Chen <void0red@...>
Date:   Wed Apr 19 10:07:48 2023 +0800

    thermal/drivers/mediatek: Use devm_of_iomap to avoid resource leak in mtk_thermal_probe
    
    [ Upstream commit f05c7b7d9ea9477fcc388476c6f4ade8c66d2d26 ]
    
    Smatch reports:
    1. mtk_thermal_probe() warn: 'apmixed_base' from of_iomap() not released.
    2. mtk_thermal_probe() warn: 'auxadc_base' from of_iomap() not released.
    
    The original code forgets to release iomap resource when handling errors,
    fix it by switch to devm_of_iomap.
    
    Fixes: 89945047b166 ("thermal: mediatek: Add tsensor support for V2 thermal system")
    Signed-off-by: Kang Chen <void0red@...>
    Reviewed-by: Dongliang Mu <dzm91@...>
    Reviewed-by: AngeloGioacchino Del Regno <angelogioacchino.delregno@...>
    Signed-off-by: Daniel Lezcano <daniel.lezcano@...>
    Link: https://lore.kernel.org/r/[email protected]
    Signed-off-by: Sasha Levin <sashal@...>

diff --git a/drivers/thermal/mtk_thermal.c b/drivers/thermal/mtk_thermal.c
index ede94eadddda..9c857fb5d968 100644
--- a/drivers/thermal/mtk_thermal.c
+++ b/drivers/thermal/mtk_thermal.c
@@ -1028,7 +1028,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	auxadc_base = of_iomap(auxadc, 0);
+	auxadc_base = devm_of_iomap(&pdev->dev, auxadc, 0, NULL);
+	if (IS_ERR(auxadc_base)) {
+		of_node_put(auxadc);
+		return PTR_ERR(auxadc_base);
+	}
+
 	auxadc_phys_base = of_get_phys_base(auxadc);
 
 	of_node_put(auxadc);
@@ -1044,7 +1049,12 @@ static int mtk_thermal_probe(struct platform_device *pdev)
 		return -ENODEV;
 	}
 
-	apmixed_base = of_iomap(apmixedsys, 0);
+	apmixed_base = devm_of_iomap(&pdev->dev, apmixedsys, 0, NULL);
+	if (IS_ERR(apmixed_base)) {
+		of_node_put(apmixedsys);
+		return PTR_ERR(apmixed_base);
+	}
+
 	apmixed_phys_base = of_get_phys_base(apmixedsys);
 
 	of_node_put(apmixedsys);
@r-c-n
Copy link
Author

r-c-n commented May 25, 2023

@gctucker
Copy link
Contributor

@hardboprobot How about adding Reported-by: "kernelci.org bot" <[email protected]>?

@r-c-n
Copy link
Author

r-c-n commented Jun 14, 2023

Merged in next: https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/?id=427f64d9f7ea28320cd3ef7159b9909403bbe527

Sorry @gctucker, I just saw the message. I'll make sure to add the tag in all the next reports.

@padovan
Copy link
Contributor

padovan commented Jul 9, 2024

Old issue. (also we are not tracking kernel test failure/issues through GitHub anymore)

@padovan padovan closed this as completed Jul 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants