drm/kmb: Fix dereference of pointer plane before a null check
Subsystems (3)
PATCH 1/1 drm/kmb: Fix dereference of pointer plane before a null check
Currently pointer plane is being dereferenced on the calls to drm_atomic_get_old_plane_state and drm_atomic_get_new_plane_state when assigning old_plane_state and new_plane_state, this could lead to a null pointer dereference. Fix this by first performing a null pointer check on plane, then assigning old_plane_state and new_plance_state and then null pointer checking these.
--- drivers/gpu/drm/kmb/kmb_plane.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-)
drivers/gpu/drm/kmb/kmb_plane.c +8 -5
@@ -341,10 +341,8 @@ static void kmb_plane_set_alpha(struct kmb_drm_private *kmb,static void kmb_plane_atomic_update (struct drm_plane *plane,struct drm_atomic_state *state) { -struct drm_plane_state *old_plane_state =drm_atomic_get_old_plane_state (state, - plane); -struct drm_plane_state *new_plane_state =drm_atomic_get_new_plane_state (state, - plane); +struct drm_plane_state *old_plane_state; +struct drm_plane_state *new_plane_state;struct drm_framebuffer *fb;struct kmb_drm_private *kmb;unsigned int width;
@@ -359,7 +357,12 @@ static void kmb_plane_atomic_update(struct drm_plane *plane,static dma_addr_t addr[MAX_SUB_PLANES ];struct disp_cfg *init_disp_cfg; -if (!plane || !new_plane_state || !old_plane_state) +if (!plane) +return ; + + old_plane_state =drm_atomic_get_old_plane_state (state, plane); + new_plane_state =drm_atomic_get_new_plane_state (state, plane); +if (!old_plane_state || !new_plane_state)return ; fb = new_plane_state->fb;
Signature · 1 line
2.50.0
Hi,
Quoted 6 lines · Colin Ian King
Currently pointer plane is being dereferenced on the calls to
drm_atomic_get_old_plane_stateanddrm_atomic_get_new_plane_statewhen assigningold_plane_stateandnew_plane_state, this could lead to a null pointer dereference. Fix this by first performing a null pointer check on plane, then assigningold_plane_stateandnew_plance_stateand then null pointer checking these.
plane cannot be NULL, so that check should just be deleted instead.
Cheers,
Daniel