[PATCH] drm/i915: add check for valid init_clock_gating-pointer

Wolfram Sang w.sang at pengutronix.de
Wed Jun 15 15:24:39 PDT 2011


Commit 6067aa (drm/i915: split clock gating init into per-chipset
functions) unconditionally calls the newly created
init_clock_gating-pointer. There is one case, however, where it does
not get set:

if (HAS_PCH_SPLIT(dev)) {
	...
	} else
		dev_priv->display.update_wm = NULL;
}

This can lead to a NULL-pointer exception as in
https://bugzilla.kernel.org/show_bug.cgi?id=37252

Fix it by checking if the pointer is valid before using it.

Signed-off-by: Wolfram Sang <w.sang at pengutronix.de>
Cc: Jesse Barnes <jbarnes at virtuousgeek.org>
Cc: Keith Packard <keithp at keithp.com>
---

Compile tested only, due to no hardware. I was going through the list of
regressions and had my take on this one. Exploring new subsystems here,
so hopefully it's the right direction. The other solution would be
initializing the pointer to a default value, but that one I don't know.

 drivers/gpu/drm/i915/intel_display.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/drivers/gpu/drm/i915/intel_display.c b/drivers/gpu/drm/i915/intel_display.c
index 81a9059..cf75856 100644
--- a/drivers/gpu/drm/i915/intel_display.c
+++ b/drivers/gpu/drm/i915/intel_display.c
@@ -7511,7 +7511,8 @@ void intel_init_clock_gating(struct drm_device *dev)
 {
 	struct drm_i915_private *dev_priv = dev->dev_private;
 
-	dev_priv->display.init_clock_gating(dev);
+	if (dev_priv->display.init_clock_gating)
+		dev_priv->display.init_clock_gating(dev);
 
 	if (dev_priv->display.init_pch_clock_gating)
 		dev_priv->display.init_pch_clock_gating(dev);
-- 
1.7.2.5



More information about the dri-devel mailing list