public inbox for linux-mediatek@lists.infradead.org
 help / color / mirror / Atom feed
From: Haotian Zhang <vulab@iscas.ac.cn>
To: Matthias Brugger <matthias.bgg@gmail.com>,
	AngeloGioacchino Del Regno
	<angelogioacchino.delregno@collabora.com>
Cc: linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org,
	linux-mediatek@lists.infradead.org,
	Haotian Zhang <vulab@iscas.ac.cn>
Subject: [PATCH] clk: mediatek: Use devm_alloc for clk_data allocation to fix memory leak on probe error
Date: Mon, 29 Sep 2025 10:36:20 +0800	[thread overview]
Message-ID: <20250929023621.1968-1-vulab@iscas.ac.cn> (raw)

The probe functions for the mt6765 apmixed, top, and infrasys clocks
use mtk_alloc_clk_data() to allocate memory. This requires manual
freeing of the memory in all error handling paths and in the driver's
remove function.

Switch to mtk_devm_alloc_clk_data() in order to fix the memory leak in the
probe function.

Fixes: 1aca9939bf72 ("clk: mediatek: Add MT6765 clock support")
Signed-off-by: Haotian Zhang <vulab@iscas.ac.cn>
---
 drivers/clk/mediatek/clk-mt6765.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/clk/mediatek/clk-mt6765.c b/drivers/clk/mediatek/clk-mt6765.c
index d53731e7933f..5cfb9a3a5ee3 100644
--- a/drivers/clk/mediatek/clk-mt6765.c
+++ b/drivers/clk/mediatek/clk-mt6765.c
@@ -736,7 +736,7 @@ static int clk_mt6765_apmixed_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	clk_data = mtk_alloc_clk_data(CLK_APMIXED_NR_CLK);
+	clk_data = mtk_devm_alloc_clk_data(CLK_APMIXED_NR_CLK);
 	if (!clk_data)
 		return -ENOMEM;
 
@@ -770,7 +770,7 @@ static int clk_mt6765_top_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	clk_data = mtk_alloc_clk_data(CLK_TOP_NR_CLK);
+	clk_data = mtk_devm_alloc_clk_data(CLK_TOP_NR_CLK);
 	if (!clk_data)
 		return -ENOMEM;
 
@@ -810,7 +810,7 @@ static int clk_mt6765_ifr_probe(struct platform_device *pdev)
 	if (IS_ERR(base))
 		return PTR_ERR(base);
 
-	clk_data = mtk_alloc_clk_data(CLK_IFR_NR_CLK);
+	clk_data = mtk_devm_alloc_clk_data(CLK_IFR_NR_CLK);
 	if (!clk_data)
 		return -ENOMEM;
 
-- 
2.50.1.windows.1



             reply	other threads:[~2025-09-29  2:36 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-29  2:36 Haotian Zhang [this message]
2025-09-29  6:54 ` [PATCH] clk: mediatek: Use devm_alloc for clk_data allocation to fix memory leak on probe error kernel test robot
2025-09-29  9:48 ` kernel test robot
2025-09-29 10:47 ` AngeloGioacchino Del Regno

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20250929023621.1968-1-vulab@iscas.ac.cn \
    --to=vulab@iscas.ac.cn \
    --cc=angelogioacchino.delregno@collabora.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-mediatek@lists.infradead.org \
    --cc=matthias.bgg@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox