⬢ DragonFlyBSD Kernel Audit
DF-4161 / fix.diff
← back to finding ↓ download raw
--- a/sys/dev/drm/i915/intel_panel.c
+++ b/sys/dev/drm/i915/intel_panel.c
@@ -578,9 +578,13 @@
 {
 	struct intel_connector *connector = to_intel_connector(conn_state->connector);
 	struct drm_i915_private *dev_priv = to_i915(connector->base.dev);
-	enum i915_pipe pipe = to_intel_crtc(conn_state->crtc)->pipe;
+	enum i915_pipe pipe;
 	u32 tmp;
 
+	if (WARN_ON(!conn_state->crtc))
+		return;
+	pipe = to_intel_crtc(conn_state->crtc)->pipe;
+
 	tmp = I915_READ(VLV_BLC_PWM_CTL(pipe)) & ~BACKLIGHT_DUTY_CYCLE_MASK;
 	I915_WRITE(VLV_BLC_PWM_CTL(pipe), tmp | level);
 }
@@ -1153,6 +1157,18 @@
 	struct intel_panel *panel = &connector->panel;
 	u32 hw_level;
 
+	/*
+	 * Lack of crtc may occur during driver init because
+	 * connection_mutex isn't held across the entire backlight
+	 * setup + modeset readout, and on DragonFly requests can
+	 * arrive at ANY time through hw.backlight_level
+	 * (CTLFLAG_ANYBODY). Mirror of the guard in
+	 * intel_panel_set_backlight_acpi(); without it
+	 * vlv_set_backlight() derefs to_intel_crtc(NULL)->pipe.
+	 */
+	if (!conn_state->crtc)
+		return;
+
 	if (!panel->backlight.present)
 		return;