diff mbox series

[1/5] Fixing Possible Null Pointer Dereference

Message ID 20200824034556.26626-1-nischal.varide@intel.com (mailing list archive)
State New, archived
Headers show
Series [1/5] Fixing Possible Null Pointer Dereference | expand

Commit Message

Nischal Varide Aug. 24, 2020, 3:45 a.m. UTC
There is a possble Null Pointer dereference in intel_atomic.c and this
patch fixes the same by introducting a check to old_state, new_state
old_conn_state and new_conn_state variables.

Signed-off-by: Nischal Varide <nischal.varide@intel.com>
---
 drivers/gpu/drm/i915/display/intel_atomic.c | 5 +++++
 1 file changed, 5 insertions(+)

Comments

Ville Syrjala Aug. 24, 2020, 7:58 p.m. UTC | #1
On Mon, Aug 24, 2020 at 09:15:52AM +0530, Nischal Varide wrote:
> There is a possble Null Pointer dereference in intel_atomic.c and this
> patch fixes the same by introducting a check to old_state, new_state
> old_conn_state and new_conn_state variables.

Not possible. In fact none of the supposed null ptrs in the series
seem possible to me.

> 
> Signed-off-by: Nischal Varide <nischal.varide@intel.com>
> ---
>  drivers/gpu/drm/i915/display/intel_atomic.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c b/drivers/gpu/drm/i915/display/intel_atomic.c
> index 630f49b7aa01..ab58f061c8a7 100644
> --- a/drivers/gpu/drm/i915/display/intel_atomic.c
> +++ b/drivers/gpu/drm/i915/display/intel_atomic.c
> @@ -132,6 +132,9 @@ int intel_digital_connector_atomic_check(struct drm_connector *conn,
>  		to_intel_digital_connector_state(old_state);
>  	struct drm_crtc_state *crtc_state;
>  
> +	if (!(new_state && new_conn_state && old_state && old_conn_state))
> +		return 0;
> +
>  	intel_hdcp_atomic_check(conn, old_state, new_state);
>  	intel_psr_atomic_check(conn, old_state, new_state);
>  
> @@ -192,6 +195,8 @@ intel_connector_needs_modeset(struct intel_atomic_state *state,
>  
>  	old_conn_state = drm_atomic_get_old_connector_state(&state->base, connector);
>  	new_conn_state = drm_atomic_get_new_connector_state(&state->base, connector);
> +	if (!(old_conn_state && new_conn_state))
> +		return 0;
>  
>  	return old_conn_state->crtc != new_conn_state->crtc ||
>  	       (new_conn_state->crtc &&
> -- 
> 2.26.0
> 
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
Shankar, Uma Aug. 27, 2020, 6:49 a.m. UTC | #2
> -----Original Message-----
> From: Intel-gfx <intel-gfx-bounces@lists.freedesktop.org> On Behalf Of Ville
> Syrjälä
> Sent: Tuesday, August 25, 2020 1:29 AM
> To: Varide, Nischal <nischal.varide@intel.com>
> Cc: intel-gfx@lists.freedesktop.org
> Subject: Re: [Intel-gfx] [PATCH 1/5] Fixing Possible Null Pointer Dereference
> 
> On Mon, Aug 24, 2020 at 09:15:52AM +0530, Nischal Varide wrote:
> > There is a possble Null Pointer dereference in intel_atomic.c and this
> > patch fixes the same by introducting a check to old_state, new_state
> > old_conn_state and new_conn_state variables.
> 
> Not possible. In fact none of the supposed null ptrs in the series seem possible
> to me.

Hi Nischal,
Yeah I agree with Ville, these all seem to be false positives. We don't expect these to be NULL at this deep in the
call flow. You can drop these.

Regards,
Uma Shankar

> >
> > Signed-off-by: Nischal Varide <nischal.varide@intel.com>
> > ---
> >  drivers/gpu/drm/i915/display/intel_atomic.c | 5 +++++
> >  1 file changed, 5 insertions(+)
> >
> > diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c
> > b/drivers/gpu/drm/i915/display/intel_atomic.c
> > index 630f49b7aa01..ab58f061c8a7 100644
> > --- a/drivers/gpu/drm/i915/display/intel_atomic.c
> > +++ b/drivers/gpu/drm/i915/display/intel_atomic.c
> > @@ -132,6 +132,9 @@ int intel_digital_connector_atomic_check(struct
> drm_connector *conn,
> >  		to_intel_digital_connector_state(old_state);
> >  	struct drm_crtc_state *crtc_state;
> >
> > +	if (!(new_state && new_conn_state && old_state && old_conn_state))
> > +		return 0;
> > +
> >  	intel_hdcp_atomic_check(conn, old_state, new_state);
> >  	intel_psr_atomic_check(conn, old_state, new_state);
> >
> > @@ -192,6 +195,8 @@ intel_connector_needs_modeset(struct
> > intel_atomic_state *state,
> >
> >  	old_conn_state = drm_atomic_get_old_connector_state(&state->base,
> connector);
> >  	new_conn_state = drm_atomic_get_new_connector_state(&state->base,
> > connector);
> > +	if (!(old_conn_state && new_conn_state))
> > +		return 0;
> >
> >  	return old_conn_state->crtc != new_conn_state->crtc ||
> >  	       (new_conn_state->crtc &&
> > --
> > 2.26.0
> >
> > _______________________________________________
> > Intel-gfx mailing list
> > Intel-gfx@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/intel-gfx
> 
> --
> Ville Syrjälä
> Intel
> _______________________________________________
> Intel-gfx mailing list
> Intel-gfx@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/intel-gfx
diff mbox series

Patch

diff --git a/drivers/gpu/drm/i915/display/intel_atomic.c b/drivers/gpu/drm/i915/display/intel_atomic.c
index 630f49b7aa01..ab58f061c8a7 100644
--- a/drivers/gpu/drm/i915/display/intel_atomic.c
+++ b/drivers/gpu/drm/i915/display/intel_atomic.c
@@ -132,6 +132,9 @@  int intel_digital_connector_atomic_check(struct drm_connector *conn,
 		to_intel_digital_connector_state(old_state);
 	struct drm_crtc_state *crtc_state;
 
+	if (!(new_state && new_conn_state && old_state && old_conn_state))
+		return 0;
+
 	intel_hdcp_atomic_check(conn, old_state, new_state);
 	intel_psr_atomic_check(conn, old_state, new_state);
 
@@ -192,6 +195,8 @@  intel_connector_needs_modeset(struct intel_atomic_state *state,
 
 	old_conn_state = drm_atomic_get_old_connector_state(&state->base, connector);
 	new_conn_state = drm_atomic_get_new_connector_state(&state->base, connector);
+	if (!(old_conn_state && new_conn_state))
+		return 0;
 
 	return old_conn_state->crtc != new_conn_state->crtc ||
 	       (new_conn_state->crtc &&