Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1755853Ab2ELMhM (ORCPT ); Sat, 12 May 2012 08:37:12 -0400 Received: from mx01.sz.bfs.de ([194.94.69.103]:42874 "EHLO mx01.sz.bfs.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1755802Ab2ELMgq (ORCPT ); Sat, 12 May 2012 08:36:46 -0400 Message-ID: <4FAE595A.6010605@bfs.de> Date: Sat, 12 May 2012 14:36:42 +0200 From: walter harms Reply-To: wharms@bfs.de User-Agent: Mozilla/5.0 (X11; U; Linux x86_64; de; rv:1.9.1.16) Gecko/20101125 SUSE/3.0.11 Thunderbird/3.0.11 MIME-Version: 1.0 To: Dan Carpenter CC: Suresh Siddha , Ingo Molnar , Joerg Roedel , Thomas Gleixner , Youquan Song , linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org Subject: Re: [patch] iommu: off by one in dmar_get_fault_reason() References: <20120512105935.GA19472@elgon.mountain> In-Reply-To: <20120512105935.GA19472@elgon.mountain> Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Length: 1141 Lines: 32 Am 12.05.2012 12:59, schrieb Dan Carpenter: > fault_reason == ARRAY_SIZE(irq_remap_fault_reasons) + 0x20 - 0x20 is one > past the end of the array. > > Signed-off-by: Dan Carpenter > > diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c > index 5ef65cf..9390f3f 100644 > --- a/drivers/iommu/dmar.c > +++ b/drivers/iommu/dmar.c > @@ -1057,7 +1057,7 @@ 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 + > + 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]; perhaps this is more readable: if (fault_reason >= 0x20 && (fault_reason - 0x20 < ARRAY_SIZE(irq_remap_fault_reasons))) re, wh -- 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/