dri-devel Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/i915/hdcp: Call drm_connector_list_iter_end() on early return
@ 2026-12-01  8:53 Tzung-Bi Shih
  2026-12-01  9:07 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Tzung-Bi Shih @ 2026-12-01  8:53 UTC (permalink / raw)
  To: Jani Nikula, Rodrigo Vivi, Joonas Lahtinen, Tvrtko Ursulin
  Cc: David Airlie, Simona Vetter, intel-gfx, intel-xe, dri-devel,
	tzungbi, linux-kernel, stable

Commit 9284ab3b6e77 ("drm/i915/hdcp: check streams[] bounds before
overflow") moved the data->k bounds check in
intel_hdcp_required_content_stream() into the loop, returning -EINVAL
directly without calling drm_connector_list_iter_end() to release held
resources.

Call drm_connector_list_iter_end() before returning -EINVAL.

Fixes: 9284ab3b6e77 ("drm/i915/hdcp: check streams[] bounds before overflow")
Cc: stable@vger.kernel.org
Signed-off-by: Tzung-Bi Shih <tzungbi@kernel.org>
---
 drivers/gpu/drm/i915/display/intel_hdcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
index dad0c854e4fa..2c1ce65e7f9a 100644
--- a/drivers/gpu/drm/i915/display/intel_hdcp.c
+++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
@@ -145,8 +145,10 @@ intel_hdcp_required_content_stream(struct intel_atomic_state *state,
 		if (!new_conn_state || !new_conn_state->crtc)
 			continue;
 
-		if (drm_WARN_ON(display->drm, data->k >= INTEL_NUM_PIPES(display)))
+		if (drm_WARN_ON(display->drm, data->k >= INTEL_NUM_PIPES(display))) {
+			drm_connector_list_iter_end(&conn_iter);
 			return -EINVAL;
+		}
 
 		data->streams[data->k].stream_id =
 			intel_conn_to_vcpi(state, connector);
-- 
2.56.1.839.g22a8290db9-goog


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

* Re: [PATCH] drm/i915/hdcp: Call drm_connector_list_iter_end() on early return
  2026-12-01  8:53 [PATCH] drm/i915/hdcp: Call drm_connector_list_iter_end() on early return Tzung-Bi Shih
@ 2026-12-01  9:07 ` sashiko-bot
  0 siblings, 0 replies; 2+ messages in thread
From: sashiko-bot @ 2026-12-01  9:07 UTC (permalink / raw)
  To: Tzung-Bi Shih; +Cc: intel-gfx, intel-xe, dri-devel

Thank you for your contribution! Sashiko AI review found no new issues
in this patch, but noticed 1 related pre-existing issue it does not
introduce:
- [Critical] drm/i915/display: null pointer deref in
  intel_hdcp_required_content_stream() [1]
--

commit dc9e0e29bf2443e79a6b1bc4bcb651f3727d0798
Author: Tzung-Bi Shih <tzungbi@kernel.org>

drm/i915/hdcp: Call drm_connector_list_iter_end() on early return

This commit ensures drm_connector_list_iter_end() is called before
returning -EINVAL when the streams[] bounds check triggers in
intel_hdcp_required_content_stream().

> diff --git a/drivers/gpu/drm/i915/display/intel_hdcp.c b/drivers/gpu/drm/i915/display/intel_hdcp.c
> index dad0c854e4fa6..2c1ce65e7f9ad 100644
> --- a/drivers/gpu/drm/i915/display/intel_hdcp.c
> +++ b/drivers/gpu/drm/i915/display/intel_hdcp.c
> @@ -145,8 +145,10 @@ intel_hdcp_required_content_stream(struct intel_atomic_state *state,
>  		if (!new_conn_state || !new_conn_state->crtc)
>  			continue;
>  
> -		if (drm_WARN_ON(display->drm, data->k >= INTEL_NUM_PIPES(display)))
> +		if (drm_WARN_ON(display->drm, data->k >= INTEL_NUM_PIPES(display))) {
> +			drm_connector_list_iter_end(&conn_iter);
>  			return -EINVAL;
> +		}
>  
>  		data->streams[data->k].stream_id =
>  			intel_conn_to_vcpi(state, connector);

[Severity: Critical]
This problem wasn't introduced by this patch, but earlier in this loop in
intel_hdcp_required_content_stream(), can intel_encoder_is_mst() trigger a
NULL pointer dereference [1] when evaluating a connected but inactive
MST connector?

drivers/gpu/drm/i915/display/intel_hdcp.c:intel_hdcp_required_content_stream() {
	...
	for_each_intel_connector_iter(connector, &conn_iter) {
		if (connector->base.status == connector_status_disconnected)
			continue;

		if (!intel_encoder_is_mst(intel_attached_encoder(connector)))
			continue;
	...
}

An inactive connector in an MST topology has no attached encoder, so
intel_attached_encoder() returns NULL and intel_encoder_is_mst()
unconditionally dereferences encoder->type.

[1] https://sashiko.dev/#/bug/linux-e7eb43c9-05b7-4152-87a3-a523da195086

-- 
Sashiko AI review · https://sashiko.dev/#/patchset/20261201085340.1471343-1-tzungbi@kernel.org?part=1

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

end of thread, other threads:[~2026-12-01  9:07 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  8:53 [PATCH] drm/i915/hdcp: Call drm_connector_list_iter_end() on early return Tzung-Bi Shih
2026-12-01  9:07 ` sashiko-bot

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