public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: mark gross <mgross@linux.intel.com>
To: Andrew Morton <akpm@linux-foundation.org>,
	Linus Torvalds <torvalds@linux-foundation.org>
Cc: lkml <linux-kernel@vger.kernel.org>
Subject: [PATCH] intel-iommu-fault_reason_index_cleanup.patch
Date: Tue, 20 Nov 2007 10:22:20 -0800	[thread overview]
Message-ID: <20071120182220.GC18038@linux.intel.com> (raw)

The following patch fixes an off by one bug in the fault reason string
reporting function, and cleans up some of the code around this buglet.


please apply.

--mgross

Signed-off-by: mark gross <mgross@linux.intel.com>


Index: linux-2.6.23-rc2-iommu/drivers/pci/intel-iommu.c
===================================================================
--- linux-2.6.23-rc2-iommu.orig/drivers/pci/intel-iommu.c	2007-11-20 10:04:39.000000000 -0800
+++ linux-2.6.23-rc2-iommu/drivers/pci/intel-iommu.c	2007-11-20 10:10:48.000000000 -0800
@@ -745,7 +745,7 @@
 
 /* iommu interrupt handling. Most stuff are MSI-like. */
 
-static char *fault_reason_strings[] =
+static const char *fault_reason_strings[] =
 {
 	"Software",
 	"Present bit in root entry is clear",
@@ -759,15 +759,14 @@
 	"Context table ptr is invalid",
 	"non-zero reserved fields in RTP",
 	"non-zero reserved fields in CTP",
-	"non-zero reserved fields in PTE",
-	"Unknown"
+	"non-zero reserved fields in PTE"
 };
 #define MAX_FAULT_REASON_IDX 	(ARRAY_SIZE(fault_reason_strings) - 1)
 
-char *dmar_get_fault_reason(u8 fault_reason)
+const char *dmar_get_fault_reason(u8 fault_reason)
 {
-	if (fault_reason >= MAX_FAULT_REASON_IDX)
-		return fault_reason_strings[MAX_FAULT_REASON_IDX - 1];
+	if (fault_reason > MAX_FAULT_REASON_IDX)
+		return "Unknown";
 	else
 		return fault_reason_strings[fault_reason];
 }
@@ -825,7 +824,7 @@
 static int iommu_page_fault_do_one(struct intel_iommu *iommu, int type,
 		u8 fault_reason, u16 source_id, u64 addr)
 {
-	char *reason;
+	const char *reason;
 
 	reason = dmar_get_fault_reason(fault_reason);
 
Index: linux-2.6.23-rc2-iommu/include/linux/dmar.h
===================================================================
--- linux-2.6.23-rc2-iommu.orig/include/linux/dmar.h	2007-11-20 10:12:06.000000000 -0800
+++ linux-2.6.23-rc2-iommu/include/linux/dmar.h	2007-11-20 10:13:43.000000000 -0800
@@ -28,7 +28,7 @@
 #ifdef CONFIG_DMAR
 struct intel_iommu;
 
-extern char *dmar_get_fault_reason(u8 fault_reason);
+extern const char *dmar_get_fault_reason(u8 fault_reason);
 
 /* Can't use the common MSI interrupt functions
  * since DMAR is not a pci device

                 reply	other threads:[~2007-11-20 18:22 UTC|newest]

Thread overview: [no followups] expand[flat|nested]  mbox.gz  Atom feed

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=20071120182220.GC18038@linux.intel.com \
    --to=mgross@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=torvalds@linux-foundation.org \
    /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