linux-omap.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/2] arm: Fix memleak in omap2xxx_clkt_vps_init
@ 2020-11-14  4:06 Youling Tang
  2020-11-19  9:54 ` Tony Lindgren
  0 siblings, 1 reply; 2+ messages in thread
From: Youling Tang @ 2020-11-14  4:06 UTC (permalink / raw)
  To: Tony Lindgren, Russell King; +Cc: linux-omap, linux-arm-kernel, linux-kernel

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


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

* Re: [PATCH 1/2] arm: Fix memleak in omap2xxx_clkt_vps_init
  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
  0 siblings, 0 replies; 2+ messages in thread
From: Tony Lindgren @ 2020-11-19  9:54 UTC (permalink / raw)
  To: Youling Tang; +Cc: Russell King, linux-omap, linux-arm-kernel, linux-kernel

* Youling Tang <tangyouling@loongson.cn> [201114 04:07]:
> If the clk_register fails, we should free hw before function returns to
> prevent memleak.

Thanks applying both into omap-for-v5.11/soc.

Tony

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

end of thread, other threads:[~2020-11-19  9:54 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
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

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).