intel-gfx.lists.freedesktop.org archive mirror
 help / color / mirror / Atom feed
From: Ville Syrjala <ville.syrjala@linux.intel.com>
To: dri-devel@lists.freedesktop.org
Cc: intel-gfx@lists.freedesktop.org
Subject: [Intel-gfx] [PATCH 8/9] drm/edid: Clarify validate_displayid()
Date: Fri, 13 Mar 2020 18:20:53 +0200	[thread overview]
Message-ID: <20200313162054.16009-9-ville.syrjala@linux.intel.com> (raw)
In-Reply-To: <20200313162054.16009-1-ville.syrjala@linux.intel.com>

From: Ville Syrjälä <ville.syrjala@linux.intel.com>

Throw out the magic '5' from validate_displayid() and replace with
the actual thing we mean sizeof(header)+checksum. Also rewrite the
checksum loop to be less hard to parse for mere mortals.

Signed-off-by: Ville Syrjälä <ville.syrjala@linux.intel.com>
---
 drivers/gpu/drm/drm_edid.c | 13 ++++++++-----
 1 file changed, 8 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
index f1ba06396c0a..185027f751f6 100644
--- a/drivers/gpu/drm/drm_edid.c
+++ b/drivers/gpu/drm/drm_edid.c
@@ -5098,7 +5098,7 @@ u32 drm_add_display_info(struct drm_connector *connector, const struct edid *edi
 
 static int validate_displayid(u8 *displayid, int length, int idx)
 {
-	int i;
+	int i, dispid_length;
 	u8 csum = 0;
 	struct displayid_hdr *base;
 
@@ -5107,15 +5107,18 @@ static int validate_displayid(u8 *displayid, int length, int idx)
 	DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
 		      base->rev, base->bytes, base->prod_id, base->ext_count);
 
-	if (base->bytes + 5 > length - idx)
+	/* +1 for DispID checksum */
+	dispid_length = sizeof(*base) + base->bytes + 1;
+	if (dispid_length > length - idx)
 		return -EINVAL;
-	for (i = idx; i <= base->bytes + 5; i++) {
-		csum += displayid[i];
-	}
+
+	for (i = 0; i < dispid_length; i++)
+		csum += displayid[idx + i];
 	if (csum) {
 		DRM_NOTE("DisplayID checksum invalid, remainder is %d\n", csum);
 		return -EINVAL;
 	}
+
 	return 0;
 }
 
-- 
2.24.1

_______________________________________________
Intel-gfx mailing list
Intel-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/intel-gfx

  parent reply	other threads:[~2020-03-13 16:21 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-03-13 16:20 [Intel-gfx] [PATCH 0/9] drm/edid: DisplayID parser fixes Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 1/9] drm: Constify topology id Ville Syrjala
2020-03-13 20:05   ` Alex Deucher
2020-03-18 15:56     ` Ville Syrjälä
2020-03-13 16:20 ` [Intel-gfx] [PATCH 2/9] drm/edid: Swap some operands in for_each_displayid_db() Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 3/9] drm/edid: Remove idx==1 assumptions from all over the DispID parsing Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 4/9] drm/edid: Return DispID length from drm_find_displayid_extension() Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 5/9] drm/edid: Move validate_displayid() drm_find_displayid_extension() Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 6/9] drm/edid: Don't parse garbage as DispID blocks Ville Syrjala
2020-03-13 16:20 ` [Intel-gfx] [PATCH 7/9] drm/edid: Don't include ext block csum in DispID size Ville Syrjala
2020-03-13 16:20 ` Ville Syrjala [this message]
2020-03-13 16:20 ` [Intel-gfx] [PATCH 9/9] drm/edid: Fix DispID tile parsing for override EDID Ville Syrjala
2020-03-16 14:44 ` [Intel-gfx] ✓ Fi.CI.BAT: success for drm/edid: DisplayID parser fixes Patchwork
2020-03-16 21:44 ` [Intel-gfx] ✗ Fi.CI.IGT: failure " Patchwork

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20200313162054.16009-9-ville.syrjala@linux.intel.com \
    --to=ville.syrjala@linux.intel.com \
    --cc=dri-devel@lists.freedesktop.org \
    --cc=intel-gfx@lists.freedesktop.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).