[PATCH] x86_64: Calgary IOMMU - fix off by one error

Fixed off-by-one error in detect_calgary and calgary_init which will
cause arrays to overflow. Also, removed impossible to hit BUG_ON.

Signed-off-by: Jon Mason <jdmason@us.ibm.com>
Signed-off-by: Muli Ben-Yehuda <muli@il.ibm.com>
Signed-off-by: Andi Kleen <ak@suse.de>
Signed-off-by: Linus Torvalds <torvalds@osdl.org>

authored by Muli Ben-Yehuda and committed by Linus Torvalds 089bbbcb 0e5f61b0

+3 -4
+3 -4
arch/x86_64/kernel/pci-calgary.c
··· 812 812 int i, ret = -ENODEV; 813 813 struct pci_dev *dev = NULL; 814 814 815 - for (i = 0; i <= num_online_nodes() * MAX_NUM_OF_PHBS; i++) { 815 + for (i = 0; i < num_online_nodes() * MAX_NUM_OF_PHBS; i++) { 816 816 dev = pci_get_device(PCI_VENDOR_ID_IBM, 817 817 PCI_DEVICE_ID_IBM_CALGARY, 818 818 dev); ··· 890 890 specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE); 891 891 892 892 for (bus = 0, table_idx = 0; 893 - bus <= num_online_nodes() * MAX_PHB_BUS_NUM; 893 + bus < num_online_nodes() * MAX_PHB_BUS_NUM; 894 894 bus++) { 895 - BUG_ON(bus > MAX_NUMNODES * MAX_PHB_BUS_NUM); 896 895 if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY) 897 896 continue; 898 897 if (test_bit(bus, translation_disabled)) { ··· 1001 1002 if (p == endp) 1002 1003 break; 1003 1004 1004 - if (bridge <= (num_online_nodes() * MAX_PHB_BUS_NUM)) { 1005 + if (bridge < (num_online_nodes() * MAX_PHB_BUS_NUM)) { 1005 1006 printk(KERN_INFO "Calgary: disabling " 1006 1007 "translation for PHB 0x%x\n", bridge); 1007 1008 set_bit(bridge, translation_disabled);