Skip to contentSkip to conversation

drm/amd/display: Fix null pointer on analog detection

PATCH In review Harry Wentland 2 participants 4 messages Oct 29, 2025

Subsystems (3)
lore
Share & tools
lore

Harry Wentland

author maintainer
#0 lore raw

PATCH 1/1 drm/amd/display: Fix null pointer on analog detection

Check if we have an amdgpu_dm_connector->dc_sink first before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.

Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analog displays without EDID")
Cc Timur Kristóf <[email protected]>
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -1
index c621e50f636a..bc5a8b8442a2 100644
@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct drm_connector *connector)
 			amdgpu_dm_connector->num_modes +=
 				drm_add_modes_noedid(connector, 1920, 1080);
 
-		if (amdgpu_dm_connector->dc_sink->edid_caps.analog) {
+		if (amdgpu_dm_connector->dc_sink && amdgpu_dm_connector->dc_sink->edid_caps.analog) {
 			/* Analog monitor connected by DAC load detection.
 			 * Add common modes. It will be up to the user to select one that works.
 			 */
Signature · 1 line
2.51.2
Reviewed-by on v1 1/1
#1 lore raw
Quoted 3 lines · Harry Wentland

Check if we have an amdgpu_dm_connector->dc_sink first before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.

Hi Harry, nice catch!

Out of curiosity, how is it possible to reach this code when the dc_sink is NULL?

The patch is:

Quoted 29 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analog

displays without EDID")

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index c621e50f636a..bc5a8b8442a2 100644
@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct
 drm_connector *connector)

  amdgpu_dm_connector->num_modes += drm_add_modes_noedid(connector, 1920, 1080);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
-		if (amdgpu_dm_connector->dc_sink->edid_caps.analog)

{

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+		if (amdgpu_dm_connector->dc_sink &&

amdgpu_dm_connector->dc_sink->edid_caps.analog) {
  /* Analog monitor connected by DAC load detection.
  * Add common modes. It will be up to the user to select one that works.
  */

author maintainer
#2 lore raw
Quoted 10 lines · Timur Kristóf
Quoted 3 lines · Harry Wentland

Check if we have an amdgpu_dm_connector->dc_sink first before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.

Hi Harry, nice catch!

Out of curiosity, how is it possible to reach this code when the dc_sink is NULL?

Huh, that was a bit of a goose chase.

amdgpu_dm_init

Quoted 3 lines

amdgpu_dm_initialize_drm_device
amdgpu_set_panel_orientation
amdgpu_dm_connector_get_modes

This will run even on disconnected (i.e., without dc_sink) connectors.

Maybe amdgpu_set_panel_orientation had better move into this hunk after the amdgpu_dm_update_connector_after_detect:

	ret = dc_link_detect(link, DETECT_REASON_BOOT);
	mutex_unlock(&dm->dc_lock);
	printk("hwhw: %s %d\n", __func__, __LINE__);

	if (ret) {
		amdgpu_dm_update_connector_after_detect(aconnector);
		printk("hwhw: %s %d\n", __func__, __LINE__);

Either way, the NULL check is still prudent.

Harry

Quoted 32 lines

The patch is:

Quoted 29 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analog

displays without EDID")

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index c621e50f636a..bc5a8b8442a2 100644
@@ -8669,7 +8669,7 @@ static int amdgpu_dm_connector_get_modes(struct
 drm_connector *connector)

  amdgpu_dm_connector->num_modes += drm_add_modes_noedid(connector, 1920, 1080);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
-		if (amdgpu_dm_connector->dc_sink->edid_caps.analog)

{

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+		if (amdgpu_dm_connector->dc_sink &&

amdgpu_dm_connector->dc_sink->edid_caps.analog) {
  /* Analog monitor connected by DAC load detection.
  * Add common modes. It will be up to the user to select one that works.
  */

#3 lore raw
Quoted 16 lines · Harry Wentland
Quoted 10 lines · Timur Kristóf
Quoted 3 lines · Harry Wentland

Check if we have an amdgpu_dm_connector->dc_sink first before adding common modes for analog outputs. If we don't have a sink yet we can safely skip this.

Hi Harry, nice catch!

Out of curiosity, how is it possible to reach this code when the dc_sink is NULL?

Huh, that was a bit of a goose chase.

Quoted 7 lines

amdgpu_dm_init

Quoted 3 lines

amdgpu_dm_initialize_drm_device
amdgpu_set_panel_orientation
amdgpu_dm_connector_get_modes

This will run even on disconnected (i.e., without dc_sink) connectors.

Interesting. I hadn't encountered this code path during my testing, so I'm a bit baffled how you could trigger that.

I'm sorry for the goose chase, but glad you found a solution.

Quoted 12 lines

Maybe amdgpu_set_panel_orientation had better move into this hunk after the amdgpu_dm_update_connector_after_detect:

	ret = dc_link_detect(link, DETECT_REASON_BOOT);
	mutex_unlock(&dm->dc_lock);
	printk("hwhw: %s %d\n", __func__, __LINE__);

	if (ret) {
		amdgpu_dm_update_connector_after_detect(aconnector);
		printk("hwhw: %s %d\n", __func__, __LINE__);
Quoted 1 line

Either way, the NULL check is still prudent.

Yes, I agree with the NULL check. No argument there. Also agree with the suggestion above.

Thanks & best regards,
Timur

Quoted 35 lines
Quoted 35 lines

The patch is:

Quoted 32 lines
Fixes 0c9f9ca99238 ("drm/amd/display: Add common modes to analog

displays without EDID")

---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 2 +-

 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -0
index c621e50f636a..bc5a8b8442a2 100644
@@ -8669,7 +8669,7 @@ static int

amdgpu_dm_connector_get_modes(struct
drm_connector *connector) amdgpu_dm_connector->num_modes += drm_add_modes_noedid(connector, 1920, 1080);

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +0 -1
-		if (amdgpu_dm_connector->dc_sink-
Quoted 1 line

edid_caps.analog)

{

drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c +1 -0
+		if (amdgpu_dm_connector->dc_sink &&

amdgpu_dm_connector->dc_sink->edid_caps.analog) {
  /* Analog monitor connected by DAC load detection.
  * Add common modes. It will be up to the
user to select one that works.
  */