cpufreq/intel_pstate: Fix intel_pstate_init() error path
Subsystems (2)
PATCH 2/2 cpufreq/intel_pstate: Fix intel_pstate_init() error path
From: Dirk Brandewie <[email protected]>
If cpufreq_register_driver() fails just free memory that has been allocated and return. intel_pstate_exit() function is removed since we are built-in only now there is no reason for a module exit procedure.
Reported-by Konrad Rzeszutek Wilk <[email protected]>
Signed-off-by Dirk Brandewie <[email protected]>
--- drivers/cpufreq/intel_pstate.c | 39 +++++++++++---------------------------- 1 files changed, 11 insertions(+), 28 deletions(-)
drivers/cpufreq/intel_pstate.c +11 -28
@@ -750,37 +750,11 @@ static struct cpufreq_driver intel_pstate_driver = { .owner = THIS_MODULE, }; -static void intel_pstate_exit (void ) -{ -int cpu; - -sysfs_remove_group (intel_pstate_kobject, - &intel_pstate_attr_group); -debugfs_remove_recursive (debugfs_parent); - -cpufreq_unregister_driver (&intel_pstate_driver); - -if (!all_cpu_data) -return ; - -get_online_cpus (); -for_each_online_cpu (cpu) { -if (all_cpu_data[cpu]) { -del_timer_sync (&all_cpu_data[cpu]->timer); -kfree (all_cpu_data[cpu]); - } - } - -put_online_cpus (); -vfree (all_cpu_data); -} -module_exit (intel_pstate_exit); -static int __initdata no_load;static int __init intel_pstate_init (void ) { -int rc =0 ; +int cpu, rc =0 ;const struct x86_cpu_id *id;if (no_load)
@@ -805,7 +779,16 @@ static int __init intel_pstate_init(void)intel_pstate_sysfs_expose_params ();return rc; out: -intel_pstate_exit (); +get_online_cpus (); +for_each_online_cpu (cpu) { +if (all_cpu_data[cpu]) { +del_timer_sync (&all_cpu_data[cpu]->timer); +kfree (all_cpu_data[cpu]); + } + } + +put_online_cpus (); +vfree (all_cpu_data);return -ENODEV ; }device_initcall (intel_pstate_init);
Signature · 1 line
1.7.7.6
Quoted 63 lines · On Thu, Mar 7, 2013 at 12:36 AM, <[email protected]> wrote:
From: Dirk Brandewie <[email protected]>
If
cpufreq_register_driver()fails just free memory that has been allocated and return.intel_pstate_exit()function is removed since we are built-in only now there is no reason for a module exit procedure.Reported-by Konrad Rzeszutek Wilk <[email protected]>Signed-off-by Dirk Brandewie <[email protected]>--- drivers/cpufreq/intel_pstate.c | 39 +++++++++++---------------------------- 1 files changed, 11 insertions(+), 28 deletions(-)drivers/cpufreq/intel_pstate.c +4
-28@@ -750,37 +750,11 @@ static struct cpufreq_driver intel_pstate_driver = { .owner = THIS_MODULE, }; -static void intel_pstate_exit (void ) -{ -int cpu; - -sysfs_remove_group (intel_pstate_kobject, - &intel_pstate_attr_group); -debugfs_remove_recursive (debugfs_parent); - -cpufreq_unregister_driver (&intel_pstate_driver); - -if (!all_cpu_data) -return ; - -get_online_cpus (); -for_each_online_cpu (cpu) { -if (all_cpu_data[cpu]) { -del_timer_sync (&all_cpu_data[cpu]->timer); -kfree (all_cpu_data[cpu]); - } - } - -put_online_cpus (); -vfree (all_cpu_data); -} -module_exit (intel_pstate_exit); -static int __initdata no_load;static int __init intel_pstate_init (void ) { -int rc =0 ; +int cpu, rc =0 ;const struct x86_cpu_id *id;if (no_load)@@ -805,7 +779,16 @@ static int __init intel_pstate_init(void)intel_pstate_sysfs_expose_params ();return rc; out: -intel_pstate_exit (); +get_online_cpus (); +for_each_online_cpu (cpu) { +if (all_cpu_data[cpu]) {
drivers/cpufreq/intel_pstate.c static int __init intel_pstate_init(void) · line 794
Quoted 10 lines
drivers/cpufreq/intel_pstate.c +7
-0+del_timer_sync (&all_cpu_data[cpu]->timer); +kfree (all_cpu_data[cpu]); + } + } + +put_online_cpus (); +vfree (all_cpu_data);return -ENODEV ; }device_initcall (intel_pstate_init);
Acked-by Viresh Kumar <[email protected]>