The PXP component bind callback publishes the component pointer and may
create a stateless device link before loading HuC firmware. If HuC
loading fails and the device is active, the callback returns that error
without clearing either resource. The component framework does not call
unbind for a component whose bind callback failed, leaving a stale
component pointer and an unreleased device link.

Clear the published pointer under tee_mutex and delete the link before
returning the firmware error. Check the error before the suspended-device
shortcut too, so binding failure does not depend on runtime PM state and
PXP hardware initialization is skipped on failure.

Fixes: 087b681805f1 ("drm/i915/dg2: setup HuC loading via GSC")
Cc: [email protected]
Assisted-by: DeepSeek-V4.1-Flash and OpenAI Codex
Signed-off-by: Wentao Liang <[email protected]>
---
 drivers/gpu/drm/i915/pxp/intel_pxp_tee.c | 12 ++++++++++++
 1 file changed, 12 insertions(+)

diff --git a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c 
b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
index 1784153f0cf8..97169ae51d3c 100644
--- a/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
+++ b/drivers/gpu/drm/i915/pxp/intel_pxp_tee.c
@@ -186,6 +186,18 @@ static int i915_pxp_tee_component_bind(struct device 
*i915_kdev,
                }
        }
 
+       if (ret < 0) {
+               mutex_lock(&pxp->tee_mutex);
+               pxp->pxp_component = NULL;
+               mutex_unlock(&pxp->tee_mutex);
+
+               if (pxp->dev_link) {
+                       device_link_del(pxp->dev_link);
+                       pxp->dev_link = NULL;
+               }
+               return ret;
+       }
+
        /* if we are suspended, the HW will be re-initialized on resume */
        wakeref = intel_runtime_pm_get_if_in_use(&i915->runtime_pm);
        if (!wakeref)
-- 
2.34.1

Reply via email to