From: Andrew Morton <akpm@linux-foundation.org>
To: Fenghua Yu <fenghua.yu@intel.com>
Cc: linux-kernel@vger.kernel.org,
Linus Torvalds <torvalds@linux-foundation.org>,
venkatesh.pallipadi@intel.com
Subject: Re: [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver
Date: Thu, 26 Jul 2007 17:12:22 -0700 [thread overview]
Message-ID: <20070726171222.4459155a.akpm@linux-foundation.org> (raw)
In-Reply-To: <20070726234630.GA29288@linux-os.sc.intel.com>
On Thu, 26 Jul 2007 16:46:30 -0700 Fenghua Yu <fenghua.yu@intel.com> wrote:
> The local variable "covered" is used without initialization in i386 acpi-cpufreq
> driver. The initial value of covered should be 0. The bug will cause memory leak
> when hit. The following patch fixes this bug.
>
> Signed-off-by: Fenghua Yu <fenghua.yu@intel.com>
>
> ---
>
> arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c | 2 +-
> 1 files changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> index 6f846be..bfb4959 100644
> --- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> +++ b/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
> @@ -511,7 +511,7 @@ acpi_cpufreq_guess_freq(struct acpi_cpufreq_data *data, unsigned int cpu)
> static int acpi_cpufreq_early_init(void)
> {
> struct acpi_processor_performance *data;
> - cpumask_t covered;
> + cpumask_t covered=0;
> unsigned int i, j;
>
> dprintk("acpi_cpufreq_early_init\n");
- please put spaces around "="
- that should have been CPU_MASK_NONE
- that code's way overengineered. This:
--- a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c~a
+++ a/arch/i386/kernel/cpu/cpufreq/acpi-cpufreq.c
@@ -511,7 +511,6 @@ acpi_cpufreq_guess_freq(struct acpi_cpuf
static int acpi_cpufreq_early_init(void)
{
struct acpi_processor_performance *data;
- cpumask_t covered;
unsigned int i, j;
dprintk("acpi_cpufreq_early_init\n");
@@ -520,14 +519,13 @@ static int acpi_cpufreq_early_init(void)
data = kzalloc(sizeof(struct acpi_processor_performance),
GFP_KERNEL);
if (!data) {
- for_each_cpu_mask(j, covered) {
+ for_each_possible_cpu(j) {
kfree(acpi_perf_data[j]);
acpi_perf_data[j] = NULL;
}
return -ENOMEM;
}
acpi_perf_data[i] = data;
- cpu_set(i, covered);
}
/* Do initialization in ACPI core */
_
should do the trick (please check it)
- what we have here is an open-coded alloc_percpu(). Hows about
converting it to alloc_percpu()?
- that function should have been be __init.
How's that for a one-liner? ;)
next prev parent reply other threads:[~2007-07-27 0:12 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <1181754124.6148.37.camel@localhost>
2007-07-26 23:46 ` [PATCH] Fix uninitialized local variable "covered" in i386 acpi-cpufreq driver Fenghua Yu
2007-07-27 0:12 ` Andrew Morton [this message]
2007-07-27 0:16 ` Andrew Morton
2007-07-27 0:46 ` Yu, Fenghua
[not found] ` <20070613172106.GA3002@frankl.hpl.hp.com>
2007-07-27 0:01 ` Fenghua Yu
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20070726171222.4459155a.akpm@linux-foundation.org \
--to=akpm@linux-foundation.org \
--cc=fenghua.yu@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=torvalds@linux-foundation.org \
--cc=venkatesh.pallipadi@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox