diff mbox series

[2/4] drm/i915: BUG() if we can't lookup_power_well()

Message ID 20180808221614.15486-2-paulo.r.zanoni@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/4] drm/i915: kill intel_display_power_well_is_enabled() | expand

Commit Message

Zanoni, Paulo R Aug. 8, 2018, 10:16 p.m. UTC
None of the current lookup_power_well() callers are actually checking
for NULL return values, they all just use the pointer right away.
Replacing these theoretical segfaults with BUG()s at least makes our
code a little more explicit to the reader.

We can only hit this NULL/BUG() condition if we try to lookup a power
well that isn't defined on a given platform. If that ever happens, we
have to fix our code, making it lookup the correct power well. Because
of this, I don't think it's worth trying to implement error checking
in every caller. Improving our CI system will be a better use of our
time once a bug is found in the wild.

Cc: Imre Deak <imre.deak@intel.com>
Signed-off-by: Paulo Zanoni <paulo.r.zanoni@intel.com>
---
 drivers/gpu/drm/i915/intel_runtime_pm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/intel_runtime_pm.c b/drivers/gpu/drm/i915/intel_runtime_pm.c
index e0947f662361..2fdb1f4125c2 100644
--- a/drivers/gpu/drm/i915/intel_runtime_pm.c
+++ b/drivers/gpu/drm/i915/intel_runtime_pm.c
@@ -1120,7 +1120,8 @@  lookup_power_well(struct drm_i915_private *dev_priv,
 			return power_well;
 	}
 
-	return NULL;
+	/* Tried to lookup a power well that doesn't exist for the platform. */
+	BUG();
 }
 
 #define BITS_SET(val, bits) (((val) & (bits)) == (bits))