public inbox for stable@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/dmc: fix an unlikely NULL pointer deference at probe
@ 2025-12-02 18:39 Jani Nikula
  2025-12-02 21:24 ` Imre Deak
  2026-03-02 17:48 ` [PATCH v2] " Imre Deak
  0 siblings, 2 replies; 12+ messages in thread
From: Jani Nikula @ 2025-12-02 18:39 UTC (permalink / raw)
  To: intel-gfx, intel-xe; +Cc: jani.nikula, Mohammed Thasleem, Imre Deak, stable

intel_dmc_update_dc6_allowed_count() oopses when DMC hasn't been
initialized, and dmc is thus NULL.

That would be the case when the call path is
intel_power_domains_init_hw() -> {skl,bxt,icl}_display_core_init() ->
gen9_set_dc_state() -> intel_dmc_update_dc6_allowed_count(), as
intel_power_domains_init_hw() is called *before* intel_dmc_init().

However, gen9_set_dc_state() calls intel_dmc_update_dc6_allowed_count()
conditionally, depending on the current and target DC states. At probe,
the target is disabled, but if DC6 is enabled, the function is called,
and an oops follows. Apparently it's quite unlikely that DC6 is enabled
at probe, as we haven't seen this failure mode before.

Add NULL checks and switch the dmc->display references to just display.

Fixes: 88c1f9a4d36d ("drm/i915/dmc: Create debugfs entry for dc6 counter")
Cc: Mohammed Thasleem <mohammed.thasleem@intel.com>
Cc: Imre Deak <imre.deak@intel.com>
Cc: <stable@vger.kernel.org> # v6.16+
Signed-off-by: Jani Nikula <jani.nikula@intel.com>

---

Rare case, but this may also throw off the rc6 counting in debugfs when
it does happen.
---
 drivers/gpu/drm/i915/display/intel_dmc.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/i915/display/intel_dmc.c b/drivers/gpu/drm/i915/display/intel_dmc.c
index 2fb6fec6dc99..169bbbc91f6d 100644
--- a/drivers/gpu/drm/i915/display/intel_dmc.c
+++ b/drivers/gpu/drm/i915/display/intel_dmc.c
@@ -1570,10 +1570,10 @@ void intel_dmc_update_dc6_allowed_count(struct intel_display *display,
 	struct intel_dmc *dmc = display_to_dmc(display);
 	u32 dc5_cur_count;
 
-	if (DISPLAY_VER(dmc->display) < 14)
+	if (!dmc || DISPLAY_VER(display) < 14)
 		return;
 
-	dc5_cur_count = intel_de_read(dmc->display, DG1_DMC_DEBUG_DC5_COUNT);
+	dc5_cur_count = intel_de_read(display, DG1_DMC_DEBUG_DC5_COUNT);
 
 	if (!start_tracking)
 		dmc->dc6_allowed.count += dc5_cur_count - dmc->dc6_allowed.dc5_start;
@@ -1587,7 +1587,7 @@ static bool intel_dmc_get_dc6_allowed_count(struct intel_display *display, u32 *
 	struct intel_dmc *dmc = display_to_dmc(display);
 	bool dc6_enabled;
 
-	if (DISPLAY_VER(display) < 14)
+	if (!dmc || DISPLAY_VER(display) < 14)
 		return false;
 
 	mutex_lock(&power_domains->lock);
-- 
2.47.3


^ permalink raw reply related	[flat|nested] 12+ messages in thread

end of thread, other threads:[~2026-03-06 14:58 UTC | newest]

Thread overview: 12+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-12-02 18:39 [PATCH] drm/i915/dmc: fix an unlikely NULL pointer deference at probe Jani Nikula
2025-12-02 21:24 ` Imre Deak
2025-12-02 21:35   ` Imre Deak
2025-12-03  8:13     ` Jani Nikula
2025-12-03 10:38       ` Imre Deak
2025-12-04 11:30         ` Jani Nikula
2025-12-04 13:02           ` Imre Deak
2026-01-07 11:16             ` Jani Nikula
2026-03-02 17:48 ` [PATCH v2] " Imre Deak
2026-03-03  2:44   ` Tao Liu
2026-03-06 10:12   ` Jani Nikula
2026-03-06 14:57     ` Imre Deak

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox