rtc: sun6i: fix error handling in sun6i_rtc_clk_init()
Subsystems (2)
PATCH 1/1 rtc: sun6i: fix error handling in sun6i_rtc_clk_init()
Set sun6i_rtc only once all clocks are registered, and unwind fully on error.
Signed-off-by Pablo Mazzini <[email protected]>
--- drivers/rtc/rtc-sun6i.c | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-)
drivers/rtc/rtc-sun6i.c +13 -5
@@ -231,6 +231,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node,const char *iosc_name ="rtc-int-osc" ;const char *clkout_name ="osc32k-out" ;const char *parents[2 ]; +struct resource res;u32 reg; rtc =kzalloc_obj (*rtc);
@@ -267,9 +268,6 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, }writel (reg, rtc->base +SUN6I_LOSC_CTRL ); -/* Yes, I know, this is ugly. */ - sun6i_rtc = rtc; -of_property_read_string_index (node,"clock-output-names" ,2 , &iosc_name);
@@ -280,7 +278,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, 300000000);if (IS_ERR (rtc->int_osc)) {pr_crit ("Couldn't register the internal oscillator\n" ); - goto err; + goto err_unmap; } parents[0 ] =clk_hw_get_name (rtc->int_osc);
@@ -309,7 +307,7 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, &rtc->lock);if (IS_ERR (rtc->ext_losc)) {pr_crit ("Couldn't register the LOSC external gate\n" ); - goto err_register; + goto err_losc; } clk_data->num =3 ;
@@ -317,12 +315,22 @@ static void __init sun6i_rtc_clk_init(struct device_node *node, clk_data->hws[1 ] =__clk_get_hw (rtc->ext_losc); clk_data->hws[2 ] = rtc->int_osc;of_clk_add_hw_provider (node, of_clk_hw_onecell_get, clk_data); + +/* Yes, I know, this is ugly. */ + sun6i_rtc = rtc;return ; +err_losc: +clk_unregister (rtc->losc); err_register:clk_hw_unregister_fixed_rate (rtc->int_osc); +err_unmap: +iounmap (rtc->base); +of_address_to_resource (node,0 , &res); +release_mem_region (res.start,resource_size (&res)); err:kfree (clk_data); +kfree (rtc); }static const struct sun6i_rtc_clk_data sun6i_a31_rtc_data = {
Signature · 1 line
2.52.0
[email protected]
AI reviewSashiko has reviewed this patch and found no issues. It looks great!
Quoted 4 lines
Set
sun6i_rtconly once all clocks are registered, and unwind fully on error.Signed-off-by Pablo Mazzini <[email protected]>
Sashiko has reviewed this patch and found no issues. It looks great!
Signature · 1 line
Sashiko AI review · https://sashiko.dev/#/patchset/[email protected]?part=1
Quoted 2 lines · Pablo Mazzini
Set
sun6i_rtconly once all clocks are registered, and unwind fully on error.
Applied, thanks!
[1/1] rtc: sun6i: fix error handling in sun6i_rtc_clk_init()
https://git.kernel.org/abelloni/c/2d6f97296143
Best regards,
Signature · 3 lines
Alexandre Belloni, co-owner and COO, Bootlin Embedded Linux and Kernel engineering https://bootlin.com