From: Jani Nikula <jani.nikula@linux.intel.com>
To: Dave Airlie <airlied@gmail.com>, dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 3/4] drm/edid: move displayid validation to it's own function.
Date: Tue, 10 May 2016 12:14:52 +0300 [thread overview]
Message-ID: <87ziry9svn.fsf@intel.com> (raw)
In-Reply-To: <1462843220-15092-3-git-send-email-airlied@gmail.com>
On Tue, 10 May 2016, Dave Airlie <airlied@gmail.com> wrote:
> From: Dave Airlie <airlied@redhat.com>
>
> We need to use this for validating modeline additions.
>
> Signed-off-by: Dave Airlie <airlied@redhat.com>
> ---
> drivers/gpu/drm/drm_edid.c | 44 ++++++++++++++++++++++++++------------------
> 1 file changed, 26 insertions(+), 18 deletions(-)
>
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index 3cf17a3..73d4218 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
> @@ -3901,6 +3901,29 @@ static void drm_add_display_info(struct edid *edid,
> info->color_formats |= DRM_COLOR_FORMAT_YCRCB422;
> }
>
> +static int validate_displayid(u8 *displayid, int length, int idx)
Bikeshed, (u8 *displayid, int idx, int length) would feel like a more
natural order to me.
> +{
> + int i;
> + u8 csum = 0;
> + struct displayid_hdr *base;
> +
> + base = (struct displayid_hdr *)&displayid[idx];
> +
> + DRM_DEBUG_KMS("base revision 0x%x, length %d, %d %d\n",
> + base->rev, base->bytes, base->prod_id, base->ext_count);
> +
I guess to be pedantic we should check idx + sizeof(struct
displayid_hdr) <= length before looking at base. This patch is about
abstracting the thing, so should be a separate patch anyway.
Other than the bikeshed,
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> + if (base->bytes + 5 > length - idx)
> + return -EINVAL;
> + for (i = idx; i <= base->bytes + 5; i++) {
> + csum += displayid[i];
> + }
> + if (csum) {
> + DRM_ERROR("DisplayID checksum invalid, remainder is %d\n", csum);
> + return -EINVAL;
> + }
> + return 0;
> +}
> +
> /**
> * drm_add_edid_modes - add modes from EDID data, if available
> * @connector: connector we're probing
> @@ -4212,30 +4235,15 @@ static int drm_parse_display_id(struct drm_connector *connector,
> {
> /* if this is an EDID extension the first byte will be 0x70 */
> int idx = 0;
> - struct displayid_hdr *base;
> struct displayid_block *block;
> - u8 csum = 0;
> - int i;
> int ret;
>
> if (is_edid_extension)
> idx = 1;
>
> - base = (struct displayid_hdr *)&displayid[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)
> - return -EINVAL;
> -
> - for (i = idx; i <= base->bytes + 5; i++) {
> - csum += displayid[i];
> - }
> - if (csum) {
> - DRM_ERROR("DisplayID checksum invalid, remainder is %d\n", csum);
> - return -EINVAL;
> - }
> + ret = validate_displayid(displayid, length, idx);
> + if (ret)
> + return ret;
>
> idx += sizeof(struct displayid_hdr);
> while (block = (struct displayid_block *)&displayid[idx],
--
Jani Nikula, Intel Open Source Technology Center
_______________________________________________
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel
next prev parent reply other threads:[~2016-05-10 9:14 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2016-05-10 1:20 [PATCH 1/4] drm/edid: move displayid tiled block parsing into separate function Dave Airlie
2016-05-10 1:20 ` [PATCH 2/4] drm/displayid: Iterate over all DisplayID blocks Dave Airlie
2016-05-10 9:02 ` Jani Nikula
2016-05-10 1:20 ` [PATCH 3/4] drm/edid: move displayid validation to it's own function Dave Airlie
2016-05-10 9:14 ` Jani Nikula [this message]
2016-05-10 1:20 ` [PATCH 4/4] drm/edid: add displayid detailed 1 timings to the modelist. (v1.1) Dave Airlie
2016-05-10 8:15 ` [PATCH 1/4] drm/edid: move displayid tiled block parsing into separate function Jani Nikula
2016-05-10 9:01 ` Jani Nikula
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=87ziry9svn.fsf@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=airlied@gmail.com \
--cc=dri-devel@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.