Re: [PATCH] drm/i915: Fix NULL ptr deref by checking new_crtc_state

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Fri, May 05, 2023 at 11:29:22AM +0200, Andrzej Hajda wrote:
> On 05.05.2023 10:22, Stanislav Lisovskiy wrote:
> > intel_atomic_get_new_crtc_state can return NULL, unless crtc state wasn't
> > obtained previously with intel_atomic_get_crtc_state, so we must check it
> > for NULLness here, just as in many other places, where we can't guarantee
> > that intel_atomic_get_crtc_state was called.
> > We are currently getting NULL ptr deref because of that, so this fix was
> > confirmed to help.
> > 
> > Fixes: 74a75dc90869 ("drm/i915/display: move plane prepare/cleanup to intel_atomic_plane.c")
> > Signed-off-by: Stanislav Lisovskiy <stanislav.lisovskiy@xxxxxxxxx>
> 
> I wonder if it wouldn't be safer to move the check to
> intel_crtc_needs_modeset, up to you.
> 
> Reviewed-by: Andrzej Hajda <andrzej.hajda@xxxxxxxxx>

Hi Andrzej,

Thank you for the review, I would probably still prefer to leave that check
to the calling site, because depending on new_crtc_state availability
calling site might need to do different actions, so it anyway has to be dealt
with.

Stan

> 
> Regards
> Andrzej
> 
> > ---
> >   drivers/gpu/drm/i915/display/intel_atomic_plane.c | 4 ++--
> >   1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic_plane.c b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > index 9f670dcfe76e..4125ee07a271 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic_plane.c
> > @@ -1029,7 +1029,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
> >   	int ret;
> >   	if (old_obj) {
> > -		const struct intel_crtc_state *crtc_state =
> > +		const struct intel_crtc_state *new_crtc_state =
> >   			intel_atomic_get_new_crtc_state(state,
> >   							to_intel_crtc(old_plane_state->hw.crtc));
> > @@ -1044,7 +1044,7 @@ intel_prepare_plane_fb(struct drm_plane *_plane,
> >   		 * This should only fail upon a hung GPU, in which case we
> >   		 * can safely continue.
> >   		 */
> > -		if (intel_crtc_needs_modeset(crtc_state)) {
> > +		if (new_crtc_state && intel_crtc_needs_modeset(new_crtc_state)) {
> >   			ret = i915_sw_fence_await_reservation(&state->commit_ready,
> >   							      old_obj->base.resv,
> >   							      false, 0,
> 



[Index of Archives]     [AMD Graphics]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]

  Powered by Linux