Skip to contentSkip to conversation

Fix a panic with 1M of shared memory, no GTT entries

PATCH In review Lubomir Rintel 2 participants 2 messages Jan 28, 2009 Agpgart driver

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 Fix a panic with 1M of shared memory, no GTT entries

When GTT size is equal to amount of video memory, the amount of GTT entries is computed lower than zero, which is invalid and leads to off-by-one error in intel_i915_configure()

Originally posted here:
http://bugzilla.kernel.org/show_bug.cgi?id=12539
http://bugzilla.redhat.com/show_bug.cgi?id=445592

---
 drivers/char/agp/intel-agp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/agp/intel-agp.c +5 -3
index c771418..4373adb 100644
@@ -633,13 +633,15 @@ static void intel_i830_init_gtt_entries(void)
 			break;
 		}
 	}
-	if (gtt_entries > 0)
+	if (gtt_entries > 0) {
 		dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n",
 		       gtt_entries / KB(1), local ? "local" : "stolen");
-	else
+		gtt_entries /= KB(4);
+	} else {
 		dev_info(&agp_bridge->dev->dev,
 		       "no pre-allocated video memory detected\n");
-	gtt_entries /= KB(4);
+		gtt_entries = 0;
+	}
 
 	intel_private.gtt_entries = gtt_entries;
 }
Signature · 1 line
1.5.5.6
#1 lore raw
Quoted 8 lines

When GTT size is equal to amount of video memory, the amount of GTT entries is computed lower than zero, which is invalid and leads to off-by-one error in intel_i915_configure()

Originally posted here:
http://bugzilla.kernel.org/show_bug.cgi?id=12539
http://bugzilla.redhat.com/show_bug.cgi?id=445592

cc'ed Intel agp knowledge.

Dave.

Quoted 30 lines
---
 drivers/char/agp/intel-agp.c |    8 +++++---
 1 files changed, 5 insertions(+), 3 deletions(-)
drivers/char/agp/intel-agp.c +5 -3
index c771418..4373adb 100644
@@ -633,13 +633,15 @@ static void intel_i830_init_gtt_entries(void)
 			break;
 		}
 	}
-	if (gtt_entries > 0)
+	if (gtt_entries > 0) {
 		dev_info(&agp_bridge->dev->dev, "detected %dK %s memory\n",
 		       gtt_entries / KB(1), local ? "local" : "stolen");
-	else
+		gtt_entries /= KB(4);
+	} else {
 		dev_info(&agp_bridge->dev->dev,
 		       "no pre-allocated video memory detected\n");
-	gtt_entries /= KB(4);
+		gtt_entries = 0;
+	}
 
 	intel_private.gtt_entries = gtt_entries;
 }