public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
* [PATCH 6.1.y] clk: mediatek: fix of_iomap memory leak
@ 2026-02-11  1:23 Li hongliang
  2026-02-17 12:33 ` Patch "clk: mediatek: fix of_iomap memory leak" has been added to the 6.1-stable tree gregkh
  0 siblings, 1 reply; 2+ messages in thread
From: Li hongliang @ 2026-02-11  1:23 UTC (permalink / raw)
  To: gregkh, stable, u201911157
  Cc: patches, linux-kernel, mturquette, sboyd, matthias.bgg,
	angelogioacchino.delregno, miles.chen, wenst, chun-jie.chen, ikjn,
	weiyi.lu, linux-clk, linux-arm-kernel, linux-mediatek, dzm91

From: Bosi Zhang <u201911157@hust.edu.cn>

[ Upstream commit 3db7285e044144fd88a356f5b641b9cd4b231a77 ]

Smatch reports:
drivers/clk/mediatek/clk-mtk.c:583 mtk_clk_simple_probe() warn:
    'base' from of_iomap() not released on lines: 496.

This problem was also found in linux-next. In mtk_clk_simple_probe(),
base is not released when handling errors
if clk_data is not existed, which may cause a leak.
So free_base should be added here to release base.

Fixes: c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers")
Signed-off-by: Bosi Zhang <u201911157@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230422084331.47198-1-u201911157@hust.edu.cn
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Li hongliang <1468888505@139.com>
---
 drivers/clk/mediatek/clk-mtk.c | 7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mtk.c b/drivers/clk/mediatek/clk-mtk.c
index 7b1ad73309b1..c2ca3d7576c2 100644
--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -505,8 +505,10 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
 	num_clks += mcd->num_mux_clks;
 
 	clk_data = mtk_alloc_clk_data(num_clks);
-	if (!clk_data)
-		return -ENOMEM;
+	if (!clk_data) {
+		r = -ENOMEM;
+		goto free_base;
+	}
 
 	if (mcd->fixed_clks) {
 		r = mtk_clk_register_fixed_clks(mcd->fixed_clks,
@@ -594,6 +596,7 @@ int mtk_clk_simple_probe(struct platform_device *pdev)
 					      mcd->num_fixed_clks, clk_data);
 free_data:
 	mtk_free_clk_data(clk_data);
+free_base:
 	if (mcd->shared_io && base)
 		iounmap(base);
 
-- 
2.34.1




^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Patch "clk: mediatek: fix of_iomap memory leak" has been added to the 6.1-stable tree
  2026-02-11  1:23 [PATCH 6.1.y] clk: mediatek: fix of_iomap memory leak Li hongliang
@ 2026-02-17 12:33 ` gregkh
  0 siblings, 0 replies; 2+ messages in thread
From: gregkh @ 2026-02-17 12:33 UTC (permalink / raw)
  To: 1468888505, angelogioacchino.delregno, chun-jie.chen, dzm91,
	gregkh, ikjn, linux-arm-kernel, linux-mediatek, matthias.bgg,
	miles.chen, mturquette, patches, sboyd, u201911157, weiyi.lu,
	wenst
  Cc: stable-commits


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

    clk: mediatek: fix of_iomap memory leak

to the 6.1-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:
     clk-mediatek-fix-of_iomap-memory-leak.patch
and it can be found in the queue-6.1 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-215733-greg=kroah.com@vger.kernel.org Wed Feb 11 02:24:25 2026
From: Li hongliang <1468888505@139.com>
Date: Wed, 11 Feb 2026 09:23:51 +0800
Subject: clk: mediatek: fix of_iomap memory leak
To: gregkh@linuxfoundation.org, stable@vger.kernel.org, u201911157@hust.edu.cn
Cc: patches@lists.linux.dev, linux-kernel@vger.kernel.org, mturquette@baylibre.com, sboyd@kernel.org, matthias.bgg@gmail.com, angelogioacchino.delregno@collabora.com, miles.chen@mediatek.com, wenst@chromium.org, chun-jie.chen@mediatek.com, ikjn@chromium.org, weiyi.lu@mediatek.com, linux-clk@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org, dzm91@hust.edu.cn
Message-ID: <20260211012351.2076922-1-1468888505@139.com>

From: Bosi Zhang <u201911157@hust.edu.cn>

[ Upstream commit 3db7285e044144fd88a356f5b641b9cd4b231a77 ]

Smatch reports:
drivers/clk/mediatek/clk-mtk.c:583 mtk_clk_simple_probe() warn:
    'base' from of_iomap() not released on lines: 496.

This problem was also found in linux-next. In mtk_clk_simple_probe(),
base is not released when handling errors
if clk_data is not existed, which may cause a leak.
So free_base should be added here to release base.

Fixes: c58cd0e40ffa ("clk: mediatek: Add mtk_clk_simple_probe() to simplify clock providers")
Signed-off-by: Bosi Zhang <u201911157@hust.edu.cn>
Reviewed-by: Dongliang Mu <dzm91@hust.edu.cn>
Link: https://lore.kernel.org/r/20230422084331.47198-1-u201911157@hust.edu.cn
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
Signed-off-by: Li hongliang <1468888505@139.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
 drivers/clk/mediatek/clk-mtk.c |    7 +++++--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/clk/mediatek/clk-mtk.c
+++ b/drivers/clk/mediatek/clk-mtk.c
@@ -505,8 +505,10 @@ int mtk_clk_simple_probe(struct platform
 	num_clks += mcd->num_mux_clks;
 
 	clk_data = mtk_alloc_clk_data(num_clks);
-	if (!clk_data)
-		return -ENOMEM;
+	if (!clk_data) {
+		r = -ENOMEM;
+		goto free_base;
+	}
 
 	if (mcd->fixed_clks) {
 		r = mtk_clk_register_fixed_clks(mcd->fixed_clks,
@@ -594,6 +596,7 @@ unregister_fixed_clks:
 					      mcd->num_fixed_clks, clk_data);
 free_data:
 	mtk_free_clk_data(clk_data);
+free_base:
 	if (mcd->shared_io && base)
 		iounmap(base);
 


Patches currently in stable-queue which might be from 1468888505@139.com are

queue-6.1/devlink-rate-unset-parent-pointer-in-devl_rate_nodes_destroy.patch
queue-6.1/ksmbd-set-attr_ctime-flags-when-setting-mtime.patch
queue-6.1/clk-mediatek-fix-of_iomap-memory-leak.patch


^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2026-02-17 12:34 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-02-11  1:23 [PATCH 6.1.y] clk: mediatek: fix of_iomap memory leak Li hongliang
2026-02-17 12:33 ` Patch "clk: mediatek: fix of_iomap memory leak" has been added to the 6.1-stable tree gregkh

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox