diff mbox

[2/3] drm/mst: Fix error handling during MST sideband message reception

Message ID 1463058040-31828-3-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
Handle any error due to partial reads, timeouts etc. to avoid parsing
uninitialized data subsequently. Also bail out if the parsing itself
fails.

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

Comments

cpaul@redhat.com May 12, 2016, 10 p.m. UTC | #1
On Thu, 2016-05-12 at 16:00 +0300, Imre Deak wrote:
> Handle any error due to partial reads, timeouts etc. to avoid parsing
> uninitialized data subsequently. Also bail out if the parsing itself
> fails.
> 
> CC: Dave Airlie <airlied@redhat.com>
> Signed-off-by: Imre Deak <imre.deak@intel.com>
> ---
>  drivers/gpu/drm/drm_dp_mst_topology.c | 12 ++++++++++--
>  1 file changed, 10 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c
> b/drivers/gpu/drm/drm_dp_mst_topology.c
> index a13edf5..12c0ab3 100644
> --- a/drivers/gpu/drm/drm_dp_mst_topology.c
> +++ b/drivers/gpu/drm/drm_dp_mst_topology.c
> @@ -2204,11 +2204,19 @@ static void drm_dp_get_one_sb_msg(struct
> drm_dp_mst_topology_mgr *mgr, bool up)
>  		ret = drm_dp_dpcd_read(mgr->aux, basereg + curreply,
>  				    replyblock, len);
>  		if (ret != len) {
> -			DRM_DEBUG_KMS("failed to read a chunk\n");
> +			DRM_DEBUG_KMS("failed to read a chunk (len %d, ret
> %d)\n",
> +				      len, ret);
> +
I'd get rid of the whitespace here…
> +			return;
>  		}
> +
>  		ret = drm_dp_sideband_msg_build(msg, replyblock, len, false);
> -		if (ret == false)
> +		if (!ret) {
>  			DRM_DEBUG_KMS("failed to build sideband msg\n");
> +
And here, to match the rest of the file. Otherwise looks good to me;

Reviewed-by: Lyude <cpaul@redhat.com>
> +			return;
> +		}
> +
>  		curreply += len;
>  		replylen -= len;
>  	}
diff mbox

Patch

diff --git a/drivers/gpu/drm/drm_dp_mst_topology.c b/drivers/gpu/drm/drm_dp_mst_topology.c
index a13edf5..12c0ab3 100644
--- a/drivers/gpu/drm/drm_dp_mst_topology.c
+++ b/drivers/gpu/drm/drm_dp_mst_topology.c
@@ -2204,11 +2204,19 @@  static void drm_dp_get_one_sb_msg(struct drm_dp_mst_topology_mgr *mgr, bool up)
 		ret = drm_dp_dpcd_read(mgr->aux, basereg + curreply,
 				    replyblock, len);
 		if (ret != len) {
-			DRM_DEBUG_KMS("failed to read a chunk\n");
+			DRM_DEBUG_KMS("failed to read a chunk (len %d, ret %d)\n",
+				      len, ret);
+
+			return;
 		}
+
 		ret = drm_dp_sideband_msg_build(msg, replyblock, len, false);
-		if (ret == false)
+		if (!ret) {
 			DRM_DEBUG_KMS("failed to build sideband msg\n");
+
+			return;
+		}
+
 		curreply += len;
 		replylen -= len;
 	}