Skip to contentSkip to conversation

drm/msm/dpu: Add a null ptr check for dpu_encoder_needs_modeset

PATCH In review Chenyuan Yang 2 participants 4 messages Jul 22, 2025 – Aug 13, 2025

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 drm/msm/dpu: Add a null ptr check for dpu_encoder_needs_modeset

The drm_atomic_get_new_connector_state() can return NULL if the connector is not part of the atomic state. Add a check to prevent a NULL pointer dereference.

This follows the same pattern used in dpu_encoder_update_topology() within the same file, which checks for NULL before using conn_state.

Fixes 1ce69c265a53 ("drm/msm/dpu: move resource allocation to CRTC")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -0
index c0ed110a7d30..4bddb9504796 100644
@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st
 		return false;
 
 	conn_state = drm_atomic_get_new_connector_state(state, connector);
+	if (!conn_state)
+		return false;
 
 	/**
 	 * These checks are duplicated from dpu_encoder_update_topology() since
Signature · 1 line
2.34.1
#1 lore raw
Quoted 18 lines · Chenyuan Yang

The drm_atomic_get_new_connector_state() can return NULL if the connector is not part of the atomic state. Add a check to prevent a NULL pointer dereference.

This follows the same pattern used in dpu_encoder_update_topology() within the same file, which checks for NULL before using conn_state.

Fixes 1ce69c265a53 ("drm/msm/dpu: move resource allocation to CRTC")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -0
index c0ed110a7d30..4bddb9504796 100644

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st · line 733

Quoted 5 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -0
@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st
 		return false;
 
 	conn_state = drm_atomic_get_new_connector_state(state, connector);
+	if (!conn_state)
+		return false;

Did this happen in a real case or is it just
yet-another-static-analysys?

Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -0
 	/**
 	 * These checks are duplicated from dpu_encoder_update_topology() since
Signature · 1 line
2.34.1
Signature · 2 lines
With best wishes
Dmitry
#2 lore raw
Quoted 22 lines · Dmitry Baryshkov
Quoted 20 lines · Chenyuan Yang

The drm_atomic_get_new_connector_state() can return NULL if the connector is not part of the atomic state. Add a check to prevent a NULL pointer dereference.

This follows the same pattern used in dpu_encoder_update_topology() within the same file, which checks for NULL before using conn_state.

Fixes 1ce69c265a53 ("drm/msm/dpu: move resource allocation to CRTC")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -0
index c0ed110a7d30..4bddb9504796 100644
@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st
              return false;
 
Quoted 6 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st · line 733

Quoted 3 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -0
      conn_state = drm_atomic_get_new_connector_state(state, connector);
+     if (!conn_state)
+             return false;

Did this happen in a real case or is it just
yet-another-static-analysys?

This is a static-analysis detected bug.

Quoted 10 lines
Quoted 6 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -1
      /**
       * These checks are duplicated from dpu_encoder_update_topology() since
--

2.34.1

--
With best wishes
Dmitry

Reviewed-by
#3 lore raw
Quoted 24 lines · Chenyuan Yang
Quoted 22 lines · Dmitry Baryshkov
Quoted 20 lines · Chenyuan Yang

The drm_atomic_get_new_connector_state() can return NULL if the connector is not part of the atomic state. Add a check to prevent a NULL pointer dereference.

This follows the same pattern used in dpu_encoder_update_topology() within the same file, which checks for NULL before using conn_state.

Fixes 1ce69c265a53 ("drm/msm/dpu: move resource allocation to CRTC")
---
 drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c | 2 ++
 1 file changed, 2 insertions(+)
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -0
index c0ed110a7d30..4bddb9504796 100644
@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st
              return false;
 
Quoted 8 lines
Quoted 6 lines

drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_st · line 733

Quoted 3 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +2 -0
      conn_state = drm_atomic_get_new_connector_state(state, connector);
+     if (!conn_state)
+             return false;

Did this happen in a real case or is it just
yet-another-static-analysys?

This is a static-analysis detected bug.

Quoted 11 lines
Quoted 11 lines
Quoted 7 lines
drivers/gpu/drm/msm/disp/dpu1/dpu_encoder.c +0 -1
      /**
       * These checks are duplicated from dpu_encoder_update_topology() since
--

2.34.1

--
With best wishes
Dmitry

Signature · 2 lines
With best wishes
Dmitry