mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Alex Hung <alex.hung@amd.com>
To: Arthur Liberman <arthur_liberman@hotmail.com>,
	"amd-gfx@lists.freedesktop.org" <amd-gfx@lists.freedesktop.org>
Cc: "dri-devel@lists.freedesktop.org"
	<dri-devel@lists.freedesktop.org>,
	"linux-kernel@vger.kernel.org" <linux-kernel@vger.kernel.org>,
	"harry.wentland@amd.com" <harry.wentland@amd.com>,
	"sunpeng.li@amd.com" <sunpeng.li@amd.com>,
	"siqueira@igalia.com" <siqueira@igalia.com>,
	"alexander.deucher@amd.com" <alexander.deucher@amd.com>,
	"christian.koenig@amd.com" <christian.koenig@amd.com>,
	"airlied@gmail.com" <airlied@gmail.com>,
	"simona@ffwll.ch" <simona@ffwll.ch>
Subject: Re: [PATCH] drm/amd/display: fix NULL deref when opening a closed DDC
Date: Fri, 16 Oct 2026 10:39:00 -0600	[thread overview]
Message-ID: <38cc515d-ae4b-4031-a061-224d492826e1@amd.com> (raw)
In-Reply-To: <DB9PR03MB73881C96FE86D964037ABEDB8A942@DB9PR03MB7388.eurprd03.prod.outlook.com>

Hi Arthur,

When AUX already holds the DDC, dal_ddc_open() fails with
GPIO_RESULT_ALREADY_OPENED, and the HPD path then calls dal_ddc_close()
on pins it does not own.

Please try whether the following solution fix your KWin issue?


diff --git 
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c 
drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
index ad1a499b0d9d..1f53b33fc875 100644
--- drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
+++ drivers/gpu/drm/amd/display/dc/link/protocols/link_dp_capability.c
@@ -2604,8 +2604,6 @@ bool dp_is_sink_present(struct dc_link *link)

  	if (dal_ddc_open(ddc, GPIO_MODE_INPUT,
  			 GPIO_DDC_CONFIG_TYPE_MODE_I2C) != GPIO_RESULT_OK) {
-		dal_ddc_close(ddc);
-
  		return present;
  	}



On 10/7/26 11:47, Arthur Liberman wrote:
> 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


  reply	other threads:[~2026-10-16 16:39 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-10-07 17:47 Arthur Liberman
2026-10-16 16:39 ` Alex Hung [this message]
2026-10-16 17:42   ` Arthur Liberman

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=38cc515d-ae4b-4031-a061-224d492826e1@amd.com \
    --to=alex.hung@amd.com \
    --cc=airlied@gmail.com \
    --cc=alexander.deucher@amd.com \
    --cc=amd-gfx@lists.freedesktop.org \
    --cc=arthur_liberman@hotmail.com \
    --cc=christian.koenig@amd.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=harry.wentland@amd.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=simona@ffwll.ch \
    --cc=siqueira@igalia.com \
    --cc=sunpeng.li@amd.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®