diff mbox

[V2] ACPI/Processor: Fix failure of loading acpi-cpufreq driver

Message ID 1398843993-26942-1-git-send-email-tianyu.lan@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

lan,Tianyu April 30, 2014, 7:46 a.m. UTC
According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
always returns -1. For these cases, original code will pass apic_id with
vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
is equal to zero, ignores apic_id and return zero for CPU0.

Commit b981513(ACPI / scan: bail out early if failed to parse APIC
ID for CPU) changed the behavior. Return ENODEV when find apic_id is
less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
driver fails to be loaded on some machines. This patch is to fix it.

Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
Cc: stable@vger.kernel.org v3.14
Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
---
Change since V1:
	Add a check for pr->apic_id in the acpi_processor_hotadd_init()
to avoid invalid memory access.

 drivers/acpi/acpi_processor.c | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

Comments

Rafael J. Wysocki April 30, 2014, 9:22 p.m. UTC | #1
On Wednesday, April 30, 2014 03:46:33 PM Lan Tianyu wrote:
> According commit d640113fe(ACPI: processor: fix acpi_get_cpuid for UP
> processor),  Bios may not provide _MAT or MADT tables and acpi_get_apicid()
> always returns -1. For these cases, original code will pass apic_id with
> vaule of -1 to acpi_map_cpuid() and it will check the acpi_id. If acpi_id
> is equal to zero, ignores apic_id and return zero for CPU0.
> 
> Commit b981513(ACPI / scan: bail out early if failed to parse APIC
> ID for CPU) changed the behavior. Return ENODEV when find apic_id is
> less than zero after calling acpi_get_apicid(). This causes acpi-cpufreq
> driver fails to be loaded on some machines. This patch is to fix it.
> 
> Reference:https://bugzilla.kernel.org/show_bug.cgi?id=73781
> Cc: stable@vger.kernel.org v3.14
> Reported-and-tested-by: KATO Hiroshi <katoh@mikage.ne.jp>
> Reported-and-tested-by: Stuart Foster <smf.linux@ntlworld.com>
> Signed-off-by: Lan Tianyu <tianyu.lan@intel.com>
> ---
> Change since V1:
> 	Add a check for pr->apic_id in the acpi_processor_hotadd_init()
> to avoid invalid memory access.

Queued up for the next pull request, thanks!


>  drivers/acpi/acpi_processor.c | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
> index c29c2c3..b06f5f5 100644
> --- a/drivers/acpi/acpi_processor.c
> +++ b/drivers/acpi/acpi_processor.c
> @@ -170,6 +170,9 @@ static int acpi_processor_hotadd_init(struct acpi_processor *pr)
>  	acpi_status status;
>  	int ret;
>  
> +	if (pr->apic_id == -1)
> +		return -ENODEV;
> +
>  	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
>  	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
>  		return -ENODEV;
> @@ -260,10 +263,8 @@ static int acpi_processor_get_info(struct acpi_device *device)
>  	}
>  
>  	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
> -	if (apic_id < 0) {
> +	if (apic_id < 0)
>  		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
> -		return -ENODEV;
> -	}
>  	pr->apic_id = apic_id;
>  
>  	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);
>
diff mbox

Patch

diff --git a/drivers/acpi/acpi_processor.c b/drivers/acpi/acpi_processor.c
index c29c2c3..b06f5f5 100644
--- a/drivers/acpi/acpi_processor.c
+++ b/drivers/acpi/acpi_processor.c
@@ -170,6 +170,9 @@  static int acpi_processor_hotadd_init(struct acpi_processor *pr)
 	acpi_status status;
 	int ret;
 
+	if (pr->apic_id == -1)
+		return -ENODEV;
+
 	status = acpi_evaluate_integer(pr->handle, "_STA", NULL, &sta);
 	if (ACPI_FAILURE(status) || !(sta & ACPI_STA_DEVICE_PRESENT))
 		return -ENODEV;
@@ -260,10 +263,8 @@  static int acpi_processor_get_info(struct acpi_device *device)
 	}
 
 	apic_id = acpi_get_apicid(pr->handle, device_declaration, pr->acpi_id);
-	if (apic_id < 0) {
+	if (apic_id < 0)
 		acpi_handle_debug(pr->handle, "failed to get CPU APIC ID.\n");
-		return -ENODEV;
-	}
 	pr->apic_id = apic_id;
 
 	cpu_index = acpi_map_cpuid(pr->apic_id, pr->acpi_id);