Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752833Ab2EMRKH (ORCPT ); Sun, 13 May 2012 13:10:07 -0400 Received: from acsinet15.oracle.com ([141.146.126.227]:46312 "EHLO acsinet15.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751499Ab2EMRKF (ORCPT ); Sun, 13 May 2012 13:10:05 -0400 Date: Sun, 13 May 2012 20:09:38 +0300 From: Dan Carpenter To: Suresh Siddha Cc: Ingo Molnar , Joerg Roedel , Thomas Gleixner , Youquan Song , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org, walter harms Subject: [patch v2] iommu: off by one in dmar_get_fault_reason() Message-ID: <20120513170938.GA4280@elgon.mountain> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <4FAE595A.6010605@bfs.de> User-Agent: Mutt/1.5.21 (2010-09-15) X-Source-IP: ucsinet22.oracle.com [156.151.31.94] Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1080 Lines: 27 fault_reason - 0x20 == ARRAY_SIZE(irq_remap_fault_reasons) is one past the end of the array. Signed-off-by: Dan Carpenter --- v2: re-arranged slightly for readability diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 5ef65cf..3a74e44 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c @@ -1057,8 +1057,8 @@ static const char *irq_remap_fault_reasons[] = const char *dmar_get_fault_reason(u8 fault_reason, int *fault_type) { - if (fault_reason >= 0x20 && (fault_reason <= 0x20 + - ARRAY_SIZE(irq_remap_fault_reasons))) { + if (fault_reason >= 0x20 && (fault_reason - 0x20 < + ARRAY_SIZE(irq_remap_fault_reasons))) { *fault_type = INTR_REMAP; return irq_remap_fault_reasons[fault_reason - 0x20]; } else if (fault_reason < ARRAY_SIZE(dma_remap_fault_reasons)) { -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/