drm/vmwgfx_kms: Fix potential NULL pointer dereference
Subsystems (3)
PATCH 1/1 drm/vmwgfx_kms: Fix potential NULL pointer dereference
crtc_state is being null checked in a previous code block, which implies that such pointer might be null.
crtc_state is dereferenced in drm_atomic_helper_check_plane_state, hence there is a potential null pointer dereference.
Fix this by warning-on and returning -EINVAL in case crtc_state is null.
Addresses-Coverity-ID: 1462412 ("Dereference after null check")
--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +3 -0
@@ -454,6 +454,9 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, clip.y2 = crtc_state->adjusted_mode.vdisplay; } +if (WARN_ON (!crtc_state)) +return -EINVAL ; + ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,
Signature · 1 line
2.7.4
Quoted 5 lines · Gustavo A. R. Silva
crtc_stateis being null checked in a previous code block, which implies that such pointer might be null.
crtc_stateis dereferenced indrm_atomic_helper_check_plane_state, hence there is a potential null pointer dereference.
This is a false positive. drm_atomic_helper_check_plane_state() will not dereference crtc_state when plane_state->crtc is NULL.
Quoted 15 lines
Fix this by warning-on and returning
-EINVALin casecrtc_stateis null.Addresses-Coverity-ID: 1462412 ("Dereference after null check")
Fixes a01cb8ba3f62 ("drm: Move drm_plane_helper_check_state() into drm_atomic_helper.c")Signed-off-by Gustavo A. R. Silva <[email protected]>--- drivers/gpu/drm/vmwgfx/vmwgfx_kms.c | 3 +++ 1 file changed, 3 insertions(+)drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +0
-0
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, · line 458
Quoted 5 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +2
-0@@ -454,6 +454,9 @@ int vmw_du_primary_plane_atomic_check(struct drm_plane *plane, clip.y2 = crtc_state->adjusted_mode.vdisplay; } +if (WARN_ON (!crtc_state)) +return -EINVAL ;
This would in fact break the driver because it would flag an error whenever the plane is disabled.
Quoted 11 lines
drivers/gpu/drm/vmwgfx/vmwgfx_kms.c +1
-0+ ret = drm_atomic_helper_check_plane_state(state, crtc_state, &clip, DRM_PLANE_HELPER_NO_SCALING, DRM_PLANE_HELPER_NO_SCALING,Signature · 6 lines
2.7.4 _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Signature · 6 lines
Ville Syrjälä Intel OTC _______________________________________________ dri-devel mailing list [email protected] https://lists.freedesktop.org/mailman/listinfo/dri-devel
Hi Ville,
Quoting Ville Syrjälä <[email protected]>:
Quoted 10 lines · Gustavo A. R. Silva
Quoted 5 lines
crtc_stateis being null checked in a previous code block, which implies that such pointer might be null.
crtc_stateis dereferenced indrm_atomic_helper_check_plane_state, hence there is a potential null pointer dereference.This is a false positive.
drm_atomic_helper_check_plane_state()will not dereferencecrtc_statewhenplane_state->crtcis NULL.
You are right.
Thank you for clarifying.
--
Gustavo A. R. Silva