Skip to contentSkip to conversation

drm/i915: Fix comparison bug

PATCH New Rasmus Villemoes 1 participant 1 message Dec 7, 2014

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/i915: Fix comparison bug

->stolen->start has type unsigned long; relying on the difference (effectively cast to int) for sorting is wrong.

---
 drivers/gpu/drm/i915/i915_debugfs.c | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)
drivers/gpu/drm/i915/i915_debugfs.c +5 -1
index 063b44817e08..adfb863bb580 100644
@@ -236,7 +236,11 @@ static int obj_rank_by_stolen(void *priv,
 	struct drm_i915_gem_object *b =
 		container_of(B, struct drm_i915_gem_object, obj_exec_link);
 
-	return a->stolen->start - b->stolen->start;
+	if (a->stolen->start < b->stolen->start)
+		return -1;
+	if (a->stolen->start > b->stolen->start)
+		return 1;
+	return 0;
 }
 
 static int i915_gem_stolen_list_info(struct seq_file *m, void *data)
Signature · 1 line
2.1.3