Commit b846cb81 authored by Dave Jones's avatar Dave Jones

[CPUFREQ] Properly set memory allocated by x86 cpufreq drivers to zero.

From Dominik Brodowski
parent fcb96784
...@@ -242,6 +242,8 @@ static int __init elanfreq_init(void) ...@@ -242,6 +242,8 @@ static int __init elanfreq_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -260,8 +262,6 @@ static int __init elanfreq_init(void) ...@@ -260,8 +262,6 @@ static int __init elanfreq_init(void)
driver->verify = &elanfreq_verify; driver->verify = &elanfreq_verify;
driver->setpolicy = &elanfreq_setpolicy; driver->setpolicy = &elanfreq_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "elanfreq", CPUFREQ_NAME_LEN); strncpy(driver->name, "elanfreq", CPUFREQ_NAME_LEN);
driver->policy[0].cpu = 0; driver->policy[0].cpu = 0;
......
...@@ -431,11 +431,15 @@ static int __init cpufreq_gx_init(void) ...@@ -431,11 +431,15 @@ static int __init cpufreq_gx_init(void)
driver = kmalloc(sizeof(struct cpufreq_driver) + NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); driver = kmalloc(sizeof(struct cpufreq_driver) + NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (driver == NULL) if (driver == NULL)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
params = kmalloc(sizeof(struct gxfreq_params), GFP_KERNEL); params = kmalloc(sizeof(struct gxfreq_params), GFP_KERNEL);
if (params == NULL) { if (params == NULL) {
kfree(driver); kfree(driver);
return -ENOMEM; return -ENOMEM;
} }
memset(params, 0, sizeof(struct gxfreq_params));
driver->policy = (struct cpufreq_policy *)(driver + 1); driver->policy = (struct cpufreq_policy *)(driver + 1);
params->cs55x0 = gx_pci; params->cs55x0 = gx_pci;
......
...@@ -762,6 +762,8 @@ static int __init longhaul_init (void) ...@@ -762,6 +762,8 @@ static int __init longhaul_init (void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -771,8 +773,7 @@ static int __init longhaul_init (void) ...@@ -771,8 +773,7 @@ static int __init longhaul_init (void)
driver->verify = &longhaul_verify; driver->verify = &longhaul_verify;
driver->setpolicy = &longhaul_setpolicy; driver->setpolicy = &longhaul_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "longhaul", CPUFREQ_NAME_LEN); strncpy(driver->name, "longhaul", CPUFREQ_NAME_LEN);
driver->policy[0].cpu = 0; driver->policy[0].cpu = 0;
......
...@@ -241,6 +241,8 @@ static int __init longrun_init(void) ...@@ -241,6 +241,8 @@ static int __init longrun_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -251,8 +253,7 @@ static int __init longrun_init(void) ...@@ -251,8 +253,7 @@ static int __init longrun_init(void)
driver->policy[0].cpuinfo.min_freq = longrun_low_freq; driver->policy[0].cpuinfo.min_freq = longrun_low_freq;
driver->policy[0].cpuinfo.max_freq = longrun_high_freq; driver->policy[0].cpuinfo.max_freq = longrun_high_freq;
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL; driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "longrun", CPUFREQ_NAME_LEN); strncpy(driver->name, "longrun", CPUFREQ_NAME_LEN);
longrun_get_policy(&driver->policy[0]); longrun_get_policy(&driver->policy[0]);
......
...@@ -220,6 +220,8 @@ static int __init cpufreq_p4_init(void) ...@@ -220,6 +220,8 @@ static int __init cpufreq_p4_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -240,8 +242,6 @@ static int __init cpufreq_p4_init(void) ...@@ -240,8 +242,6 @@ static int __init cpufreq_p4_init(void)
driver->verify = &cpufreq_p4_verify; driver->verify = &cpufreq_p4_verify;
driver->setpolicy = &cpufreq_p4_setpolicy; driver->setpolicy = &cpufreq_p4_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "p4-clockmod", CPUFREQ_NAME_LEN); strncpy(driver->name, "p4-clockmod", CPUFREQ_NAME_LEN);
for (i=0;i<NR_CPUS;i++) { for (i=0;i<NR_CPUS;i++) {
......
...@@ -172,6 +172,8 @@ static int __init powernow_k6_init(void) ...@@ -172,6 +172,8 @@ static int __init powernow_k6_init(void)
release_region (POWERNOW_IOPORT, 16); release_region (POWERNOW_IOPORT, 16);
return -ENOMEM; return -ENOMEM;
} }
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
/* table init */ /* table init */
...@@ -184,8 +186,6 @@ static int __init powernow_k6_init(void) ...@@ -184,8 +186,6 @@ static int __init powernow_k6_init(void)
driver->verify = &powernow_k6_verify; driver->verify = &powernow_k6_verify;
driver->setpolicy = &powernow_k6_setpolicy; driver->setpolicy = &powernow_k6_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "powernow-k6", CPUFREQ_NAME_LEN); strncpy(driver->name, "powernow-k6", CPUFREQ_NAME_LEN);
/* cpuinfo and default policy values */ /* cpuinfo and default policy values */
......
...@@ -674,6 +674,8 @@ static int __init speedstep_init(void) ...@@ -674,6 +674,8 @@ static int __init speedstep_init(void)
NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL); NR_CPUS * sizeof(struct cpufreq_policy), GFP_KERNEL);
if (!driver) if (!driver)
return -ENOMEM; return -ENOMEM;
memset(driver, 0, sizeof(struct cpufreq_driver) +
NR_CPUS * sizeof(struct cpufreq_policy));
driver->policy = (struct cpufreq_policy *) (driver + 1); driver->policy = (struct cpufreq_policy *) (driver + 1);
...@@ -690,8 +692,6 @@ static int __init speedstep_init(void) ...@@ -690,8 +692,6 @@ static int __init speedstep_init(void)
driver->verify = &speedstep_verify; driver->verify = &speedstep_verify;
driver->setpolicy = &speedstep_setpolicy; driver->setpolicy = &speedstep_setpolicy;
driver->init = NULL;
driver->exit = NULL;
strncpy(driver->name, "speedstep", CPUFREQ_NAME_LEN); strncpy(driver->name, "speedstep", CPUFREQ_NAME_LEN);
driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL; driver->policy[0].cpuinfo.transition_latency = CPUFREQ_ETERNAL;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment