drm/i915/hdcp: fix connector refcounting
authorjsg <jsg@openbsd.org>
Fri, 18 Oct 2024 00:08:23 +0000 (00:08 +0000)
committerjsg <jsg@openbsd.org>
Fri, 18 Oct 2024 00:08:23 +0000 (00:08 +0000)
From Jani Nikula
55f2bd90b9fba95e929d4c407ffc422597152323 in linux-6.6.y/6.6.57
4cc2718f621a6a57a02581125bb6d914ce74d23b in mainline linux

sys/dev/pci/drm/i915/display/intel_hdcp.c

index 197c83f..a42e133 100644 (file)
@@ -1005,7 +1005,8 @@ static void intel_hdcp_update_value(struct intel_connector *connector,
        hdcp->value = value;
        if (update_property) {
                drm_connector_get(&connector->base);
-               queue_work(i915->unordered_wq, &hdcp->prop_work);
+               if (!queue_work(i915->unordered_wq, &hdcp->prop_work))
+                       drm_connector_put(&connector->base);
        }
 }
 
@@ -2491,7 +2492,8 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
                mutex_lock(&hdcp->mutex);
                hdcp->value = DRM_MODE_CONTENT_PROTECTION_DESIRED;
                drm_connector_get(&connector->base);
-               queue_work(i915->unordered_wq, &hdcp->prop_work);
+               if (!queue_work(i915->unordered_wq, &hdcp->prop_work))
+                       drm_connector_put(&connector->base);
                mutex_unlock(&hdcp->mutex);
        }
 
@@ -2508,7 +2510,9 @@ void intel_hdcp_update_pipe(struct intel_atomic_state *state,
                 */
                if (!desired_and_not_enabled && !content_protection_type_changed) {
                        drm_connector_get(&connector->base);
-                       queue_work(i915->unordered_wq, &hdcp->prop_work);
+                       if (!queue_work(i915->unordered_wq, &hdcp->prop_work))
+                               drm_connector_put(&connector->base);
+
                }
        }