From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-wm0-f71.google.com (mail-wm0-f71.google.com [74.125.82.71]) by kanga.kvack.org (Postfix) with ESMTP id CA87E28024B for ; Fri, 23 Sep 2016 20:06:38 -0400 (EDT) Received: by mail-wm0-f71.google.com with SMTP id b130so31162727wmc.2 for ; Fri, 23 Sep 2016 17:06:38 -0700 (PDT) Received: from mail-wm0-x235.google.com (mail-wm0-x235.google.com. [2a00:1450:400c:c09::235]) by mx.google.com with ESMTPS id mh12si9580249wjb.128.2016.09.23.17.06.37 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 23 Sep 2016 17:06:37 -0700 (PDT) Received: by mail-wm0-x235.google.com with SMTP id b130so55797391wmc.0 for ; Fri, 23 Sep 2016 17:06:37 -0700 (PDT) MIME-Version: 1.0 In-Reply-To: References: From: "Rafael J. Wysocki" Date: Sat, 24 Sep 2016 02:06:36 +0200 Message-ID: Subject: Re: acpi: Fix broken error check in map_processor() Content-Type: text/plain; charset=UTF-8 Sender: owner-linux-mm@kvack.org List-ID: To: Thomas Gleixner Cc: Dou Liyang , cl@linux.com, Tejun Heo , mika.j.penttila@gmail.com, Ingo Molnar , Andrew Morton , "Rafael J. Wysocki" , "H. Peter Anvin" , yasu.isimatu@gmail.com, isimatu.yasuaki@jp.fujitsu.com, kamezawa.hiroyu@jp.fujitsu.com, izumi.taku@jp.fujitsu.com, gongzhaogang@inspur.com, Len Brown , Len Brown , chen.tang@easystack.cn, "Rafael J. Wysocki" , the arch/x86 maintainers , ACPI Devel Maling List , Linux Kernel Mailing List , Linux Memory Management List , Gu Zheng , Tang Chen , Zhu Guihua On Fri, Sep 23, 2016 at 5:08 PM, Thomas Gleixner wrote: > map_processor() checks the cpuid value returned by acpi_map_cpuid() for -1 > but acpi_map_cpuid() returns -EINVAL in case of error. > > As a consequence the error is ignored and the following access into percpu > data with that negative cpuid results in a boot crash. > > This happens always when NR_CPUS/nr_cpu_ids is smaller than the number of > processors listed in the ACPI tables. > > Use a proper error check for id < 0 so the function returns instead of > trying to map CPU#(-EINVAL). > > Reported-by: Ingo Molnar > Fixes: dc6db24d2476 ("x86/acpi: Set persistent cpuid <-> nodeid mapping when booting") > Signed-off-by: Thomas Gleixner It looks like the commit in the Fixes tag is in the tip tree now, so the fix should better go in via tip as well IMO. Acked-by: Rafael J. Wysocki > --- > drivers/acpi/processor_core.c | 9 +++++---- > 1 file changed, 5 insertions(+), 4 deletions(-) > > --- a/drivers/acpi/processor_core.c > +++ b/drivers/acpi/processor_core.c > @@ -284,7 +284,7 @@ EXPORT_SYMBOL_GPL(acpi_get_cpuid); > static bool __init > map_processor(acpi_handle handle, phys_cpuid_t *phys_id, int *cpuid) > { > - int type; > + int type, id; > u32 acpi_id; > acpi_status status; > acpi_object_type acpi_type; > @@ -320,10 +320,11 @@ map_processor(acpi_handle handle, phys_c > type = (acpi_type == ACPI_TYPE_DEVICE) ? 1 : 0; > > *phys_id = __acpi_get_phys_id(handle, type, acpi_id, false); > - *cpuid = acpi_map_cpuid(*phys_id, acpi_id); > - if (*cpuid == -1) > - return false; > + id = acpi_map_cpuid(*phys_id, acpi_id); > > + if (id < 0) > + return false; > + *cpuid = id; > return true; > } > -- To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to majordomo@kvack.org. For more info on Linux MM, see: http://www.linux-mm.org/ . Don't email: email@kvack.org