From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932393AbcFJJqd (ORCPT ); Fri, 10 Jun 2016 05:46:33 -0400 Received: from terminus.zytor.com ([198.137.202.10]:48874 "EHLO terminus.zytor.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752168AbcFJJqI (ORCPT ); Fri, 10 Jun 2016 05:46:08 -0400 Date: Fri, 10 Jun 2016 02:45:45 -0700 From: tip-bot for Rui Wang Message-ID: Cc: tglx@linutronix.de, mingo@kernel.org, rui.y.wang@intel.com, linux-kernel@vger.kernel.org, hpa@zytor.com Reply-To: linux-kernel@vger.kernel.org, rui.y.wang@intel.com, mingo@kernel.org, tglx@linutronix.de, hpa@zytor.com In-Reply-To: <1465369193-4816-3-git-send-email-rui.y.wang@intel.com> References: <1465369193-4816-3-git-send-email-rui.y.wang@intel.com> To: linux-tip-commits@vger.kernel.org Subject: [tip:x86/urgent] x86/ioapic: Fix wrong pointers in ioapic_setup_resources() Git-Commit-ID: 0e1c672041819474181a41ce07e4734750789170 X-Mailer: tip-git-log-daemon Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain; charset=UTF-8 Content-Disposition: inline Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit-ID: 0e1c672041819474181a41ce07e4734750789170 Gitweb: http://git.kernel.org/tip/0e1c672041819474181a41ce07e4734750789170 Author: Rui Wang AuthorDate: Wed, 8 Jun 2016 14:59:52 +0800 Committer: Thomas Gleixner CommitDate: Fri, 10 Jun 2016 11:41:47 +0200 x86/ioapic: Fix wrong pointers in ioapic_setup_resources() On a 4-socket brickland, hot-removing one ioapic is fine. Hot-removing the 2nd one causes panic in mp_unregister_ioapic() while calling release_resource(). It is because the iomem_res pointer has already been released when removing the first ioapic. To explain the use of &res[num] here: res is assigned to ioapic_resources, and later in ioapic_insert_resources() we do struct resource *r = ioapic_resources; for_each_ioapic(i) { insert_resource(&iomem_resource, r); r++; } Here r is treated as an arry of struct resource, and the r++ ensures that each element of the array is inserted separately. Thus we should call release_resouce() on each element at &res[num]. Fix it by assigning the correct pointers to ioapics[i].iomem_res in ioapic_setup_resources(). Signed-off-by: Rui Wang Cc: tony.luck@intel.com Cc: linux-pci@vger.kernel.org Cc: rjw@rjwysocki.net Cc: linux-acpi@vger.kernel.org Cc: bhelgaas@google.com Link: http://lkml.kernel.org/r/1465369193-4816-3-git-send-email-rui.y.wang@intel.com Signed-off-by: Thomas Gleixner --- arch/x86/kernel/apic/io_apic.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/arch/x86/kernel/apic/io_apic.c b/arch/x86/kernel/apic/io_apic.c index 84e33ff..446702e 100644 --- a/arch/x86/kernel/apic/io_apic.c +++ b/arch/x86/kernel/apic/io_apic.c @@ -2588,8 +2588,8 @@ static struct resource * __init ioapic_setup_resources(void) res[num].flags = IORESOURCE_MEM | IORESOURCE_BUSY; snprintf(mem, IOAPIC_RESOURCE_NAME_SIZE, "IOAPIC %u", i); mem += IOAPIC_RESOURCE_NAME_SIZE; + ioapics[i].iomem_res = &res[num]; num++; - ioapics[i].iomem_res = res; } ioapic_resources = res;