drm/msm/dpu: Add a null ptr check for dpu_encoder_needs_modeset
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.
--- 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
@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_streturn 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
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 usingconn_state.Signed-off-by Chenyuan Yang <[email protected]>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
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_streturn 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
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 usingconn_state.Signed-off-by Chenyuan Yang <[email protected]>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@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_streturn 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
-0conn_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
Dmitry Baryshkov
Reviewed-byQuoted 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 usingconn_state.Signed-off-by Chenyuan Yang <[email protected]>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@@ -729,6 +729,8 @@ bool dpu_encoder_needs_modeset(struct drm_encoder *drm_enc, struct drm_atomic_streturn 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
-0conn_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