public inbox for kernel-janitors@vger.kernel.org
 help / color / mirror / Atom feed
From: Dan Carpenter <dan.carpenter@oracle.com>
To: Suresh Siddha <suresh.b.siddha@intel.com>
Cc: Ingo Molnar <mingo@elte.hu>, Joerg Roedel <joerg.roedel@amd.com>,
	Thomas Gleixner <tglx@linutronix.de>,
	Youquan Song <youquan.song@intel.com>,
	linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org,
	walter harms <wharms@bfs.de>
Subject: [patch v2] iommu: off by one in dmar_get_fault_reason()
Date: Sun, 13 May 2012 17:09:38 +0000	[thread overview]
Message-ID: <20120513170938.GA4280@elgon.mountain> (raw)
In-Reply-To: <4FAE595A.6010605@bfs.de>

fault_reason - 0x20 = ARRAY_SIZE(irq_remap_fault_reasons) is one past
the end of the array.

Signed-off-by: Dan Carpenter <dan.carpenter@oracle.com>
---
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)) {

  reply	other threads:[~2012-05-13 17:09 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-05-12 10:59 [patch] iommu: off by one in dmar_get_fault_reason() Dan Carpenter
2012-05-12 12:36 ` walter harms
2012-05-13 17:09   ` Dan Carpenter [this message]
2012-05-13 17:12   ` Dan Carpenter

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20120513170938.GA4280@elgon.mountain \
    --to=dan.carpenter@oracle.com \
    --cc=joerg.roedel@amd.com \
    --cc=kernel-janitors@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@elte.hu \
    --cc=suresh.b.siddha@intel.com \
    --cc=tglx@linutronix.de \
    --cc=wharms@bfs.de \
    --cc=youquan.song@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox