Skip to content

Commit

Permalink
ACPI: pdc init related memory leak with physical CPU hotplug
Browse files Browse the repository at this point in the history
arch_acpi_processor_cleanup_pdc() in x86 and ia64 results in memory allocated
for _PDC objects that is never freed and will cause memory leak in case of
physical CPU remove and add. Patch fixes the memory leak by freeing the
objects soon after _PDC is evaluated.

Reported-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Venkatesh Pallipadi <venkatesh.pallipadi@intel.com>
Signed-off-by: Len Brown <len.brown@intel.com>
  • Loading branch information
Pallipadi, Venkatesh authored and Len Brown committed Jun 20, 2009
1 parent 07a2039 commit 7b768f0
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 0 deletions.
12 changes: 12 additions & 0 deletions arch/ia64/kernel/acpi-processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -71,3 +71,15 @@ void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
}

EXPORT_SYMBOL(arch_acpi_processor_init_pdc);

void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr)
{
if (pr->pdc) {
kfree(pr->pdc->pointer->buffer.pointer);
kfree(pr->pdc->pointer);
kfree(pr->pdc);
pr->pdc = NULL;
}
}

EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
13 changes: 13 additions & 0 deletions arch/x86/kernel/acpi/processor.c
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ static void init_intel_pdc(struct acpi_processor *pr, struct cpuinfo_x86 *c)
return;
}


/* Initialize _PDC data based on the CPU vendor */
void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
{
Expand All @@ -85,3 +86,15 @@ void arch_acpi_processor_init_pdc(struct acpi_processor *pr)
}

EXPORT_SYMBOL(arch_acpi_processor_init_pdc);

void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr)
{
if (pr->pdc) {
kfree(pr->pdc->pointer->buffer.pointer);
kfree(pr->pdc->pointer);
kfree(pr->pdc);
pr->pdc = NULL;
}
}

EXPORT_SYMBOL(arch_acpi_processor_cleanup_pdc);
2 changes: 2 additions & 0 deletions drivers/acpi/processor_core.c
Original file line number Diff line number Diff line change
Expand Up @@ -731,6 +731,8 @@ static int __cpuinit acpi_processor_start(struct acpi_device *device)
/* _PDC call should be done before doing anything else (if reqd.). */
arch_acpi_processor_init_pdc(pr);
acpi_processor_set_pdc(pr);
arch_acpi_processor_cleanup_pdc(pr);

#ifdef CONFIG_CPU_FREQ
acpi_processor_ppc_has_changed(pr);
#endif
Expand Down
1 change: 1 addition & 0 deletions include/acpi/processor.h
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,7 @@ DECLARE_PER_CPU(struct acpi_processor *, processors);
extern struct acpi_processor_errata errata;

void arch_acpi_processor_init_pdc(struct acpi_processor *pr);
void arch_acpi_processor_cleanup_pdc(struct acpi_processor *pr);

#ifdef ARCH_HAS_POWER_INIT
void acpi_processor_power_init_bm_check(struct acpi_processor_flags *flags,
Expand Down

0 comments on commit 7b768f0

Please sign in to comment.