From: xkernel.wang@foxmail.com
To: narmstrong@baylibre.com, jbrunet@baylibre.com,
mturquette@baylibre.com, sboyd@kernel.org, khilman@baylibre.com
Cc: martin.blumenstingl@googlemail.com, p.zabel@pengutronix.de,
linux-amlogic@lists.infradead.org, linux-clk@vger.kernel.org,
linux-arm-kernel@lists.infradead.org,
linux-kernel@vger.kernel.org,
Xiaoke Wang <xkernel.wang@foxmail.com>
Subject: [PATCH] clk: meson: meson8b: fix a memory leak in meson8b_clkc_init_common()
Date: Thu, 7 Apr 2022 17:28:23 +0800 [thread overview]
Message-ID: <tencent_FE734C50BC851F2AB5FE1380F833A7E67A0A@qq.com> (raw)
From: Xiaoke Wang <xkernel.wang@foxmail.com>
`rstc` is allocated by kzalloc() for resetting the controller register,
however, if reset_controller_register() fails, `rstc` is not properly
released before returning, which can lead to memory leak.
Therefore, this patch adds kfree(rstc) on the above error path.
Signed-off-by: Xiaoke Wang <xkernel.wang@foxmail.com>
---
drivers/clk/meson/meson8b.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/clk/meson/meson8b.c b/drivers/clk/meson/meson8b.c
index a844d35..823eacc 100644
--- a/drivers/clk/meson/meson8b.c
+++ b/drivers/clk/meson/meson8b.c
@@ -3741,6 +3741,7 @@ static void __init meson8b_clkc_init_common(struct device_node *np,
if (ret) {
pr_err("%s: Failed to register clkc reset controller: %d\n",
__func__, ret);
+ kfree(rstc);
return;
}
--
_______________________________________________
linux-amlogic mailing list
linux-amlogic@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-amlogic
next reply other threads:[~2022-04-07 9:51 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-04-07 9:28 xkernel.wang [this message]
2022-04-07 10:05 ` Philipp Zabel
2022-04-18 16:39 ` Martin Blumenstingl
2022-04-23 2:25 ` Stephen Boyd
2022-04-24 19:36 ` Martin Blumenstingl
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=tencent_FE734C50BC851F2AB5FE1380F833A7E67A0A@qq.com \
--to=xkernel.wang@foxmail.com \
--cc=jbrunet@baylibre.com \
--cc=khilman@baylibre.com \
--cc=linux-amlogic@lists.infradead.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-clk@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=martin.blumenstingl@googlemail.com \
--cc=mturquette@baylibre.com \
--cc=narmstrong@baylibre.com \
--cc=p.zabel@pengutronix.de \
--cc=sboyd@kernel.org \
/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
all inboxes | Powered by JetHome®