Skip to contentSkip to conversation

clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()

PATCH Superseded Jing Xiangfeng 2 participants 3 messages Jul 20, 2020 – Jul 28, 2020

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 clk: ti: clkctrl: add the missed kfree() for _ti_omap4_clkctrl_setup()

_ti_omap4_clkctrl_setup() misses to call kfree() in an error path. Add the missed function call to fix it.

Fixes 6c3090520554 ("clk: ti: clkctrl: Fix hidden dependency to node name")
---
 drivers/clk/ti/clkctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/ti/clkctrl.c +3 -1
index 864c484bde1b..868e50132c21 100644
@@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
 		}
 
 		hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-		if (!hw)
+		if (!hw) {
+			kfree(clkctrl_name);
 			return;
+		}
 
 		hw->enable_reg.ptr = provider->base + reg_data->offset;
 
Signature · 1 line
2.17.1
maintainer
#1 lore raw

Quoting Jing Xiangfeng (2020-07-20 05:23:43)

Quoted 14 lines

_ti_omap4_clkctrl_setup() misses to call kfree() in an error path. Add the missed function call to fix it.

Fixes 6c3090520554 ("clk: ti: clkctrl: Fix hidden dependency to node name")
---
 drivers/clk/ti/clkctrl.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/ti/clkctrl.c +0 -0
index 864c484bde1b..868e50132c21 100644

drivers/clk/ti/clkctrl.c static void __init _ti_omap4_clkctrl_setup(struct device_node *node) · line 661

Quoted 8 lines
drivers/clk/ti/clkctrl.c +3 -1
@@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
                }
 
                hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-               if (!hw)
+               if (!hw) {
+                       kfree(clkctrl_name);
                        return;
+               }

Why not goto cleanup?

Quoted 6 lines
drivers/clk/ti/clkctrl.c +0 -0
                hw->enable_reg.ptr = provider->base + reg_data->offset;
 
Signature · 1 line
2.17.1
#2 lore raw
Quoted 17 lines · Stephen Boyd

Quoting Jing Xiangfeng (2020-07-20 05:23:43)

Quoted 16 lines

_ti_omap4_clkctrl_setup() misses to call kfree() in an error path. Add the missed function call to fix it.

Fixes 6c3090520554 ("clk: ti: clkctrl: Fix hidden dependency to node name")
---
  drivers/clk/ti/clkctrl.c | 4 +++-
  1 file changed, 3 insertions(+), 1 deletion(-)
drivers/clk/ti/clkctrl.c +0 -0
index 864c484bde1b..868e50132c21 100644
@@ -655,8 +655,10 @@ static void __init _ti_omap4_clkctrl_setup(struct device_node *node)
                 }
 
Quoted 8 lines

drivers/clk/ti/clkctrl.c static void __init _ti_omap4_clkctrl_setup(struct device_node *node) · line 661

Quoted 6 lines
drivers/clk/ti/clkctrl.c +3 -1
                 hw = kzalloc(sizeof(*hw), GFP_KERNEL);
-               if (!hw)
+               if (!hw) {
+                       kfree(clkctrl_name);
                         return;
+               }

Why not goto cleanup?

Thanks, I will change it as you suggested.

Quoted 9 lines
Quoted 7 lines
drivers/clk/ti/clkctrl.c +0 -1
                 hw->enable_reg.ptr = provider->base + reg_data->offset;
 
--

2.17.1

.