mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Muli Ben-Yehuda <muli@il.ibm.com>
To: ak@suse.de
Cc: jdmason@us.ibm.com, discuss@x86-64.org,
	linux-kernel@vger.kernel.org, konradr@redhat.com
Subject: [PATCH 1 of 2] x86_64: Calgary IOMMU - fix off by one error
Date: Tue, 18 Jul 2006 18:11:17 +0300	[thread overview]
Message-ID: <81635ec2e677165285c2.1153235477@rhun.haifa.ibm.com> (raw)
In-Reply-To: <patchbomb.1153235476@rhun.haifa.ibm.com>

# HG changeset patch
# User Muli Ben-Yehuda <muli@il.ibm.com>
# Date 1153234988 -10800
# Node ID 81635ec2e677165285c2a483958899217f9631d8
# Parent  1b8d63e34819bac5b6aac0048ef79004fb243db9
x86_64: Calgary IOMMU - fix off by one error

Fixed off-by-one error in detect_calgary and calgary_init which will
cause arrays to overflow.  Also, removed impossible to hit BUG_ON.

Signed-Off-By: Jon Mason <jdmason@us.ibm.com>
Signed-Off-By: Muli Ben-Yehuda <muli@il.ibm.com>

diff -r 1b8d63e34819 -r 81635ec2e677 arch/x86_64/kernel/pci-calgary.c
--- a/arch/x86_64/kernel/pci-calgary.c	Sat Jul 15 22:03:19 2006 +0000
+++ b/arch/x86_64/kernel/pci-calgary.c	Tue Jul 18 18:03:08 2006 +0300
@@ -812,7 +812,7 @@ static int __init calgary_init(void)
 	int i, ret = -ENODEV;
 	struct pci_dev *dev = NULL;
 
-	for (i = 0; i <= num_online_nodes() * MAX_NUM_OF_PHBS; i++) {
+	for (i = 0; i < num_online_nodes() * MAX_NUM_OF_PHBS; i++) {
 		dev = pci_get_device(PCI_VENDOR_ID_IBM,
 				     PCI_DEVICE_ID_IBM_CALGARY,
 				     dev);
@@ -890,9 +890,8 @@ void __init detect_calgary(void)
 	specified_table_size = determine_tce_table_size(end_pfn * PAGE_SIZE);
 
 	for (bus = 0, table_idx = 0;
-	     bus <= num_online_nodes() * MAX_PHB_BUS_NUM;
+	     bus < num_online_nodes() * MAX_PHB_BUS_NUM;
 	     bus++) {
-		BUG_ON(bus > MAX_NUMNODES * MAX_PHB_BUS_NUM);
 		if (read_pci_config(bus, 0, 0, 0) != PCI_VENDOR_DEVICE_ID_CALGARY)
 			continue;
 		if (test_bit(bus, translation_disabled)) {
@@ -1002,7 +1001,7 @@ static int __init calgary_parse_options(
 			if (p == endp)
 				break;
 
-			if (bridge <= (num_online_nodes() * MAX_PHB_BUS_NUM)) {
+			if (bridge < (num_online_nodes() * MAX_PHB_BUS_NUM)) {
 				printk(KERN_INFO "Calgary: disabling "
 				       "translation for PHB 0x%x\n", bridge);
 				set_bit(bridge, translation_disabled);

  reply	other threads:[~2006-07-18 15:12 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-07-18 15:11 [PATCH 0 of 2] Resend: x86-64: Calgary IOMMU updates Muli Ben-Yehuda
2006-07-18 15:11 ` Muli Ben-Yehuda [this message]
2006-07-18 15:11 ` [PATCH 2 of 2] x86-64: Calgary IOMMU - Multi-Node NULL pointer dereference fix Muli Ben-Yehuda

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=81635ec2e677165285c2.1153235477@rhun.haifa.ibm.com \
    --to=muli@il.ibm.com \
    --cc=ak@suse.de \
    --cc=discuss@x86-64.org \
    --cc=jdmason@us.ibm.com \
    --cc=konradr@redhat.com \
    --cc=linux-kernel@vger.kernel.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

all inboxes | Powered by JetHome®