[PATCH V2 2/3] x86/ioapic: Fix wrong pointers in ioapic_setup_resources()

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.

Fix it by assigning the correct pointers to ioapics[i].iomem_res in
ioapic_setup_resources().

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].

Signed-off-by: Rui Wang <rui.y.wang@xxxxxxxxx>
---
 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;
-- 
1.8.3.1

--
To unsubscribe from this list: send the line "unsubscribe linux-pci" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [DMA Engine]     [Linux Coverity]     [Linux USB]     [Video for Linux]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [Greybus]

  Powered by Linux