From: Youling Tang <tangyouling@loongson.cn> To: Tony Lindgren <tony@atomide.com>, Russell King <linux@armlinux.org.uk> Cc: linux-omap@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH 1/2] arm: Fix memleak in omap2xxx_clkt_vps_init Date: Sat, 14 Nov 2020 12:06:58 +0800 [thread overview] Message-ID: <1605326818-13823-1-git-send-email-tangyouling@loongson.cn> (raw) If the clk_register fails, we should free hw before function returns to prevent memleak. Signed-off-by: Youling Tang <tangyouling@loongson.cn> --- arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c index 2a3e722..70892b3 100644 --- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c +++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c @@ -244,6 +244,12 @@ void omap2xxx_clkt_vps_init(void) hw->hw.init = &init; clk = clk_register(NULL, &hw->hw); + if (IS_ERR(clk)) { + printk(KERN_ERR "Failed to register clock\n"); + kfree(hw); + return; + } + clkdev_create(clk, "cpufreq_ck", NULL); return; cleanup: -- 2.1.0
WARNING: multiple messages have this Message-ID (diff)
From: Youling Tang <tangyouling@loongson.cn> To: Tony Lindgren <tony@atomide.com>, Russell King <linux@armlinux.org.uk> Cc: linux-omap@vger.kernel.org, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [PATCH 1/2] arm: Fix memleak in omap2xxx_clkt_vps_init Date: Sat, 14 Nov 2020 12:06:58 +0800 [thread overview] Message-ID: <1605326818-13823-1-git-send-email-tangyouling@loongson.cn> (raw) If the clk_register fails, we should free hw before function returns to prevent memleak. Signed-off-by: Youling Tang <tangyouling@loongson.cn> --- arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c index 2a3e722..70892b3 100644 --- a/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c +++ b/arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c @@ -244,6 +244,12 @@ void omap2xxx_clkt_vps_init(void) hw->hw.init = &init; clk = clk_register(NULL, &hw->hw); + if (IS_ERR(clk)) { + printk(KERN_ERR "Failed to register clock\n"); + kfree(hw); + return; + } + clkdev_create(clk, "cpufreq_ck", NULL); return; cleanup: -- 2.1.0 _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
next reply other threads:[~2020-11-14 4:07 UTC|newest] Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top 2020-11-14 4:06 Youling Tang [this message] 2020-11-14 4:06 ` [PATCH 1/2] arm: Fix memleak in omap2xxx_clkt_vps_init Youling Tang 2020-11-19 9:54 ` Tony Lindgren 2020-11-19 9:54 ` Tony Lindgren
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=1605326818-13823-1-git-send-email-tangyouling@loongson.cn \ --to=tangyouling@loongson.cn \ --cc=linux-arm-kernel@lists.infradead.org \ --cc=linux-kernel@vger.kernel.org \ --cc=linux-omap@vger.kernel.org \ --cc=linux@armlinux.org.uk \ --cc=tony@atomide.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: linkBe sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.