[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <1396013356.31134.27.camel@joe-AO722>
Date: Fri, 28 Mar 2014 06:29:16 -0700
From: Joe Perches <joe@...ches.com>
To: Viresh Kumar <viresh.kumar@...aro.org>
Cc: rjw@...ysocki.net, linaro-kernel@...ts.linaro.org,
cpufreq@...r.kernel.org, linux-pm@...r.kernel.org,
linux-kernel@...r.kernel.org, srivatsa.bhat@...ux.vnet.ibm.com,
ego@...ux.vnet.ibm.com, svaidy@...ux.vnet.ibm.com
Subject: Re: [PATCH] cpufreq: use kzalloc() to allocate memory for
cpufreq_frequency_table
On Fri, 2014-03-28 at 15:44 +0530, Viresh Kumar wrote:
> Few drivers are using kmalloc() to allocate memory for frequency tables and once
> we have an additional field '.flags' in 'struct cpufreq_frequency_table', these
> might become unstable. Better get these fixed by replacing kmalloc() by
> kzalloc() instead.
There seems to be some sort of bug fix in the
patch at the very end too?
Perhaps a better fix would be to use kcalloc for
all the allocs with a multiply.
> diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c
[]
> @@ -754,7 +754,7 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
[]
> - data->freq_table = kmalloc(sizeof(*data->freq_table) *
> + data->freq_table = kzalloc(sizeof(*data->freq_table) *
> (perf->state_count+1), GFP_KERNEL);
> diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c
[]
> @@ -254,7 +254,7 @@ acpi_cpufreq_cpu_init (
[]
> - data->freq_table = kmalloc(sizeof(*data->freq_table) *
> + data->freq_table = kzalloc(sizeof(*data->freq_table) *
> (data->acpi_data.state_count + 1),
> GFP_KERNEL);
> diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c
[]
> @@ -475,7 +475,7 @@ static int longhaul_get_ranges(void)
[]
> - longhaul_table = kmalloc((numscales + 1) * sizeof(*longhaul_table),
> diff --git a/drivers/cpufreq/powernow-k8.c b/drivers/cpufreq/powernow-k8.c
[]
> @@ -623,7 +623,7 @@ static int fill_powernow_table(struct powernow_k8_data *data,
[]
> - powernow_table = kmalloc((sizeof(*powernow_table)
> + powernow_table = kzalloc((sizeof(*powernow_table)
> * (data->numps + 1)), GFP_KERNEL);
> diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c
[]
> @@ -586,7 +586,7 @@ static int s3c_cpufreq_build_freq(void)
[]
> - ftab = kmalloc(sizeof(*ftab) * size, GFP_KERNEL);
> + ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL);
> diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c
[]
> @@ -195,18 +195,15 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
[]
> - freq_tbl = kmalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
> + freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
> if (!freq_tbl) {
> ret = -ENOMEM;
> goto out_put_node;
> }
>
> - for (i = 0; i < cnt; i++) {
> - freq_tbl[i].driver_data = i;
> + for (i = 0; i < cnt; i++)
> freq_tbl[i].frequency = be32_to_cpup(val++);
> - }
>
> - freq_tbl[i].driver_data = i;
> freq_tbl[i].frequency = CPUFREQ_TABLE_END;
Is this some bug fix?
--
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in
the body of a message to majordomo@...r.kernel.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Powered by blists - more mailing lists