ARM: OMAP2+: Fix memleak in omap2xxx_clkt_vps_init
authorYouling Tang <tangyouling@loongson.cn>
Sat, 14 Nov 2020 04:06:58 +0000 (12:06 +0800)
committerTony Lindgren <tony@atomide.com>
Thu, 19 Nov 2020 09:44:46 +0000 (11:44 +0200)
If the clk_register fails, we should free hw before function returns to
prevent memleak.

Signed-off-by: Youling Tang <tangyouling@loongson.cn>
Signed-off-by: Tony Lindgren <tony@atomide.com>
arch/arm/mach-omap2/clkt2xxx_virt_prcm_set.c

index 2a3e72286d3ab2c1235028caabd9a0a62b39eef5..70892b3da28d3221963712a0ffffd844d2bfd2c3 100644 (file)
@@ -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: