All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] drm/amd/display: fix NULL deref when opening a closed DDC
@ 2026-10-07 17:47 Arthur Liberman
  2026-10-07 17:55 ` sashiko-bot
  0 siblings, 1 reply; 2+ messages in thread
From: Arthur Liberman @ 2026-10-07 17:47 UTC (permalink / raw)
  To: amd-gfx@lists.freedesktop.org
  Cc: dri-devel@lists.freedesktop.org, linux-kernel@vger.kernel.org,
	harry.wentland@amd.com, sunpeng.li@amd.com, siqueira@igalia.com,
	alexander.deucher@amd.com, christian.koenig@amd.com,
	airlied@gmail.com, simona@ffwll.ch

dal_ddc_open() uses gpio->pin after dal_gpio_service_open() installs
it. Close clears that pointer. HPD sink detection and a KWin atomic
check can both open the same DDC: the check reads DPCD for DSC while
the HPD worker closes the pin. The load of hw_gpio.store.en then
oopses at offset 0x28 and kwin_wayland exits with IRQs disabled.

If either pin is gone after open, close what this call holds and
return GPIO_RESULT_NULL_HANDLE so the AUX transfer fails instead.
This does not serialize the two threads.

Cc: stable@vger.kernel.org
Assisted-by: Cursor:xai-grok-4.7
Signed-off-by: Arthur Liberman <arthur_liberman@hotmail.com>
---
 drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
index 95f8b7c7d657..a3145cd82d8b 100644
--- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
+++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
@@ -577,6 +577,17 @@ enum gpio_result dal_ddc_open(
 		goto failure;
 	}
 
+	/*
+	 * dal_gpio_service_open() installs gpio->pin, and close clears it.
+	 * MST bring-up can AUX-read for DSC while HPD teardown closes the
+	 * same DDC. pin is NULL again in that window; do not dereference it.
+	 */
+	if (!ddc->pin_data->pin || !ddc->pin_clock->pin) {
+		dal_gpio_close(ddc->pin_clock);
+		dal_gpio_close(ddc->pin_data);
+		return GPIO_RESULT_NULL_HANDLE;
+	}
+
 	/* DDC clock and data pins should belong
 	 * to the same DDC block id,
 	 * we use the data pin to set the pad mode. */

base-commit: 41505ac433cc4c5179deee8860d197b04f6d1c1d
-- 
2.55.0


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

end of thread, other threads:[~2026-10-07 17:55 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-10-07 17:47 [PATCH] drm/amd/display: fix NULL deref when opening a closed DDC Arthur Liberman
2026-10-07 17:55 ` sashiko-bot

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.