diff mbox

[3/3] drm: Avoid dereferencing a NULL mstb in drm_dp_mst_handle_up_req()

Message ID 1463058040-31828-4-git-send-email-imre.deak@intel.com (mailing list archive)
State New, archived
Headers show

Commit Message

Imre Deak May 12, 2016, 1 p.m. UTC
In case of an unknown broadcast message is sent mstb will remain unset,
so check for this.

CC: Dave Airlie <airlied@redhat.com>
Signed-off-by: Imre Deak <imre.deak@intel.com>
---
 drivers/gpu/drm/drm_dp_mst_topology.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

Comments

Imre Deak July 17, 2017, 12:10 p.m. UTC | #1
On Thu, May 12, 2016 at 04:00:40PM +0300, Imre Deak wrote:
> In case of an unknown broadcast message is sent mstb will remain unset,
> so check for this.
> 
> CC: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>

Could someone review 2/3 and 3/3 in this patchset? 1/3 was NAK'd and
otherwise isn't needed anymore.

Thanks,
Imre

> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
> index 12c0ab3..412b9ca 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -2334,7 +2334,9 @@ static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
>  			DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn);
>  		}
>  
> -		drm_dp_put_mst_branch_device(mstb);
> +		if (mstb)
> +			drm_dp_put_mst_branch_device(mstb);
> +
>  		memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
>  	}
>  	return ret;
> -- 
> 2.5.0
> 
> _______________________________________________
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
Lyude Paul July 17, 2017, 3:33 p.m. UTC | #2
Looks good to me.

Reviewed-by: Lyude <lyude@redhat.com>

On Mon, 2017-07-17 at 15:10 +0300, Imre Deak wrote:
> On Thu, May 12, 2016 at 04:00:40PM +0300, Imre Deak wrote:
> > In case of an unknown broadcast message is sent mstb will remain
> > unset,
> > so check for this.
> > 
> > CC: Dave Airlie <airlied@redhat.com>
> > Signed-off-by: Imre Deak <imre.deak@intel.com>
> 
> Could someone review 2/3 and 3/3 in this patchset? 1/3 was NAK'd and
> otherwise isn't needed anymore.
> 
> Thanks,
> Imre
> 
> > ---
> >  drivers/gpu/drm/drm_dp_mst_topology.c | 4 +++-
> >  1 file changed, 3 insertions(+), 1 deletion(-)
> > 
> > diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> > b/drivers/gpu/drm/drm_dp_mst_topology.c
> > index 12c0ab3..412b9ca 100644
> > --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> > +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> > @@ -2334,7 +2334,9 @@ static int drm_dp_mst_handle_up_req(struct
> > drm_dp_mst_topology_mgr *mgr)
> >  			DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn
> > %d\n", msg.u.resource_stat.port_number,
> > msg.u.resource_stat.available_pbn);
> >  		}
> >  
> > -		drm_dp_put_mst_branch_device(mstb);
> > +		if (mstb)
> > +			drm_dp_put_mst_branch_device(mstb);
> > +
> >  		memset(&mgr->up_req_recv, 0, sizeof(struct
> > drm_dp_sideband_msg_rx));
> >  	}
> >  	return ret;
> > -- 
> > 2.5.0
> > 
> > _______________________________________________
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index 12c0ab3..412b9ca 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2334,7 +2334,9 @@  static int drm_dp_mst_handle_up_req(struct drm_dp_mst_topology_mgr *mgr)
 			DRM_DEBUG_KMS("Got RSN: pn: %d avail_pbn %d\n", msg.u.resource_stat.port_number, msg.u.resource_stat.available_pbn);
 		}
 
-		drm_dp_put_mst_branch_device(mstb);
+		if (mstb)
+			drm_dp_put_mst_branch_device(mstb);
+
 		memset(&mgr->up_req_recv, 0, sizeof(struct drm_dp_sideband_msg_rx));
 	}
 	return ret;