intel-iommu: Fix array overflow
authorTakashi Iwai <tiwai@suse.de>
Mon, 29 Oct 2007 21:37:22 +0000 (14:37 -0700)
committerLinus Torvalds <torvalds@woody.linux-foundation.org>
Tue, 30 Oct 2007 15:06:55 +0000 (08:06 -0700)
Fix possible array overflow:

drivers/pci/intel-iommu.c: In function ¡dmar_get_fault_reason¢:
drivers/pci/intel-iommu.c:753: warning: array subscript is above array bounds
drivers/pci/intel-iommu.c: In function ¡iommu_page_fault¢:
drivers/pci/intel-iommu.c:753: warning: array subscript is above array bounds

Signed-off-by: Takashi Iwai <tiwai@suse.de>
Cc: Mark Gross <mgross@linux.intel.com>
Acked-by: "Keshavamurthy, Anil S" <anil.s.keshavamurthy@intel.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
drivers/pci/intel-iommu.c

index 8af1d9a261e50e9fd42c6e28854a85bb57e48102..e079a5237c9424e7064e1c0892377f2d9b78536b 100644 (file)
@@ -749,8 +749,8 @@ static char *fault_reason_strings[] =
 
 char *dmar_get_fault_reason(u8 fault_reason)
 {
-       if (fault_reason > MAX_FAULT_REASON_IDX)
-               return fault_reason_strings[MAX_FAULT_REASON_IDX];
+       if (fault_reason >= MAX_FAULT_REASON_IDX)
+               return fault_reason_strings[MAX_FAULT_REASON_IDX - 1];
        else
                return fault_reason_strings[fault_reason];
 }