timers/migration: Ensure proper resource cleanup on error in tmigr_init
PATCH 1/1 timers/migration: Ensure proper resource cleanup on error in tmigr_init
Free resources allocated by zalloc_cpumask_var and kcalloc on failure.
--- kernel/time/timer_migration.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
kernel/time/timer_migration.c +9 -3
@@ -1994,7 +1994,7 @@ static int __init tmigr_init(void) tmigr_level_list =kcalloc (tmigr_hierarchy_levels,sizeof (struct list_head ),GFP_KERNEL );if (!tmigr_level_list) - goto err; + goto err_free_cpumask;for (i =0 ; i < tmigr_hierarchy_levels; i++)INIT_LIST_HEAD (&tmigr_level_list[i]);
@@ -2007,15 +2007,21 @@ static int __init tmigr_init(void) ret =cpuhp_setup_state (CPUHP_TMIGR_PREPARE ,"tmigr:prepare" , tmigr_cpu_prepare,NULL );if (ret) - goto err; + goto err_free_level_list; ret =cpuhp_setup_state (CPUHP_AP_TMIGR_ONLINE ,"tmigr:online" , tmigr_set_cpu_available, tmigr_clear_cpu_available);if (ret) - goto err; + goto err_free_level_list;return 0 ; +err_free_level_list: +kfree (tmigr_level_list); + +err_free_cpumask: +free_cpumask_var (tmigr_available_cpumask); + err:pr_err ("Timer migration setup failed\n" );return ret;
Signature · 1 line
2.43.0
Thomas Gleixner
maintainerQuoted 22 lines · Zhan Xusheng
Free resources allocated by
zalloc_cpumask_varand kcalloc on failure.Signed-off-by Zhan Xusheng <[email protected]>--- kernel/time/timer_migration.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)kernel/time/timer_migration.c +1
-1@@ -1994,7 +1994,7 @@ static int __init tmigr_init(void) tmigr_level_list =kcalloc (tmigr_hierarchy_levels,sizeof (struct list_head ),GFP_KERNEL );if (!tmigr_level_list) - goto err; + goto err_free_cpumask;for (i =0 ; i < tmigr_hierarchy_levels; i++)INIT_LIST_HEAD (&tmigr_level_list[i]);@@ -2007,15 +2007,21 @@ static int __init tmigr_init(void) ret = cpuhp_setup_state(CPUHP_TMIGR_PREPARE, "tmigr:prepare",
kernel/time/timer_migration.c static int __init tmigr_init(void) · line 2015
Quoted 10 lines
kernel/time/timer_migration.c +2
-2tmigr_cpu_prepare, NULL);if (ret) - goto err; + goto err_free_level_list; ret =cpuhp_setup_state (CPUHP_AP_TMIGR_ONLINE ,"tmigr:online" , tmigr_set_cpu_available, tmigr_clear_cpu_available);if (ret) - goto err; + goto err_free_level_list;
Which leaves the prepare hotplug state registered ....
Quoted 11 lines
kernel/time/timer_migration.c +6
-0return 0 ; +err_free_level_list: +kfree (tmigr_level_list); + +err_free_cpumask: +free_cpumask_var (tmigr_available_cpumask); + err:pr_err ("Timer migration setup failed\n" );return ret;
PATCH v2 1/1 timers/migration: Ensure proper resource cleanup on error in tmigr_init
Free resources allocated by zalloc_cpumask_var and kcalloc on failure.
--- kernel/time/timer_migration.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/time/timer_migration.c +12 -3
@@ -1994,7 +1994,7 @@ static int __init tmigr_init(void) tmigr_level_list =kcalloc (tmigr_hierarchy_levels,sizeof (struct list_head ),GFP_KERNEL );if (!tmigr_level_list) - goto err; + goto err_free_cpumask;for (i =0 ; i < tmigr_hierarchy_levels; i++)INIT_LIST_HEAD (&tmigr_level_list[i]);
@@ -2007,15 +2007,24 @@ static int __init tmigr_init(void) ret =cpuhp_setup_state (CPUHP_TMIGR_PREPARE ,"tmigr:prepare" , tmigr_cpu_prepare,NULL );if (ret) - goto err; + goto err_free_level_list; ret =cpuhp_setup_state (CPUHP_AP_TMIGR_ONLINE ,"tmigr:online" , tmigr_set_cpu_available, tmigr_clear_cpu_available);if (ret) - goto err; + goto err_remove_prepare_state;return 0 ; +err_remove_prepare_state: +cpuhp_remove_state (CPUHP_TMIGR_PREPARE ); + +err_free_level_list: +kfree (tmigr_level_list); + +err_free_cpumask: +free_cpumask_var (tmigr_available_cpumask); + err:pr_err ("Timer migration setup failed\n" );return ret;
Signature · 1 line
2.43.0
Thomas Gleixner
maintainerQuoted 3 lines · Zhan Xusheng
Free resources allocated by
zalloc_cpumask_varand kcalloc on failure.Reviewed-by Thomas Gleixner <[email protected]>
I surely did not give you a reviewed-by tag. The fact that I reviewed V1 does not mean you can slap such a tag on it.
PATCH v3 1/1 timers/migration: Ensure proper resource cleanup on error in tmigr_init
Free resources allocated by zalloc_cpumask_var and kcalloc on failure.
--- kernel/time/timer_migration.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-)
kernel/time/timer_migration.c +12 -3
@@ -1994,7 +1994,7 @@ static int __init tmigr_init(void) tmigr_level_list =kcalloc (tmigr_hierarchy_levels,sizeof (struct list_head ),GFP_KERNEL );if (!tmigr_level_list) - goto err; + goto err_free_cpumask;for (i =0 ; i < tmigr_hierarchy_levels; i++)INIT_LIST_HEAD (&tmigr_level_list[i]);
@@ -2007,15 +2007,24 @@ static int __init tmigr_init(void) ret =cpuhp_setup_state (CPUHP_TMIGR_PREPARE ,"tmigr:prepare" , tmigr_cpu_prepare,NULL );if (ret) - goto err; + goto err_free_level_list; ret =cpuhp_setup_state (CPUHP_AP_TMIGR_ONLINE ,"tmigr:online" , tmigr_set_cpu_available, tmigr_clear_cpu_available);if (ret) - goto err; + goto err_remove_prepare_state;return 0 ; +err_remove_prepare_state: +cpuhp_remove_state (CPUHP_TMIGR_PREPARE ); + +err_free_level_list: +kfree (tmigr_level_list); + +err_free_cpumask: +free_cpumask_var (tmigr_available_cpumask); + err:pr_err ("Timer migration setup failed\n" );return ret;
Signature · 1 line
2.43.0
Quoted 3 lines · Zhan Xusheng
Free resources allocated by
zalloc_cpumask_varand kcalloc on failure.Signed-off-by Zhan Xusheng <[email protected]>
Signature · 2 lines
Frederic Weisbecker SUSE Labs