From: sashiko-bot@kernel.org
To: "Thomas Zimmermann" <tzimmermann@suse.de>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH 1/3] drm/edid: Add drm_edid_get_preferred_size()
Date: Thu, 27 Aug 2026 14:19:53 +0000 [thread overview]
Message-ID: <20260827141954.2AC011F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260827140726.420734-2-tzimmermann@suse.de>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [High] Pointer Dereference and Logic Error in drm_edid_get_preferred_size
- [High] Missing EDID Hardware Validation for Detailed Timing Descriptor
--
commit 2d529ec582fce7d82757afd45c986da44f50ceb6
Author: Thomas Zimmermann <tzimmermann@suse.de>
Subject: drm/edid: Add drm_edid_get_preferred_size()
This commit adds drm_edid_get_preferred_size() to extract the panel's
preferred display resolution from a given EDID. This is required for
DRM's panel orientation quirks.
> diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c
> index df3c25bac761d..650ccd05977be 100644
> --- a/drivers/gpu/drm/drm_edid.c
> +++ b/drivers/gpu/drm/drm_edid.c
[ ... ]
> @@ -2844,6 +2844,46 @@ u32 drm_edid_get_panel_id(const struct drm_edid *drm_edid)
> }
> EXPORT_SYMBOL(drm_edid_get_panel_id);
>
> +/**
> + * drm_edid_get_preferred_size - Get a panel's preferred size from EDID
> + * @drm_edid: EDID that contains panel ID.
> + * @width: Returns the panel's width in pixels per scanline, if given
> + * @height: Returns the panel's height in scanlines, if given
> + *
> + * This function detects the preferred size of a panel from the given
> + * EDID. There is no such information stored in the EDID block directly,
> + * but the preferred mode often corresponds to the panel's native geometry.
> + *
> + * Return: Zero on success, or a negative errno code otherwise.
> + */
> +int drm_edid_get_preferred_size(const struct drm_edid *drm_edid,
> + unsigned int *width, unsigned int *height)
> +{
> + const struct edid *edid = drm_edid->edid;
> + const struct detailed_pixel_timing *pt;
> +
> + if (drm_edid->size < EDID_LENGTH)
> + return -EINVAL;
> +
> + /*
> + * Use whatever the Preferred Timing Descriptor tells us. For old
> + * and obscure displays, we might need better heuristics.
> + */
> +
> + if (edid->revision < 4 && !(edid->features & DRM_EDID_FEATURE_PREFERRED_TIMING))
> + return -EINVAL; /* no Preferred Timing Descriptor */
> +
> + pt = &edid->detailed_timings[0].data.pixel_data;
[Severity: High]
Does this safely handle non-compliant or corrupted EDIDs where the first
detailed timing block might be a Display Descriptor rather than a pixel
timing descriptor?
In the EDID specification, a detailed timing block is only a Detailed Timing
Descriptor if its pixel clock is non-zero. If the pixel clock is 0, the block
is a Display Descriptor like an ASCII monitor name. By unconditionally
accessing it as pixel data without validating it, could we end up reading
overlapping union fields and returning garbage display geometry data to the
driver?
> +
> + if (*width)
> + *width = (pt->hactive_hblank_hi & 0xf0) << 4 | pt->hactive_lo;
> + if (*height)
> + *height = (pt->vactive_vblank_hi & 0xf0) << 4 | pt->vactive_lo;
[Severity: High]
Does this logic incorrectly dereference the pointers before checking if they
are valid?
The kernel doc mentions that width and height are optional, which implies
callers might pass a NULL pointer. If a caller passes NULL for width or
height, evaluating if (*width) will cause a NULL pointer dereference crash.
Additionally, if a caller passes a valid pointer to a 0-initialized variable,
evaluating if (*width) will result in false, skipping the assignment entirely
and leaving the output as 0. Should these conditions check if (width) and
if (height) instead?
> +
> + return 0;
> +}
> +EXPORT_SYMBOL(drm_edid_get_preferred_size);
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260827140726.420734-1-tzimmermann@suse.de?part=1
next prev parent reply other threads:[~2026-08-27 14:19 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-27 14:01 [PATCH 0/3] sysfb: Fix display output on Lenovo D330 (and others) Thomas Zimmermann
2026-08-27 14:01 ` [PATCH 1/3] drm/edid: Add drm_edid_get_preferred_size() Thomas Zimmermann
2026-08-27 14:19 ` sashiko-bot [this message]
2026-08-27 14:40 ` Thomas Zimmermann
2026-08-27 14:01 ` [PATCH 2/3] drm/sysfb: Use preferred panel size for panel orientation quirks Thomas Zimmermann
2026-08-27 14:21 ` sashiko-bot
2026-08-27 14:44 ` Thomas Zimmermann
2026-08-27 14:01 ` [PATCH 3/3] firmware/sysfb: Remove rotation quirk for Lenovo D330 Thomas Zimmermann
2026-08-27 16:56 ` [PATCH 0/3] sysfb: Fix display output on Lenovo D330 (and others) Ard Biesheuvel
2026-08-31 10:34 ` Thomas Zimmermann
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=20260827141954.2AC011F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=tzimmermann@suse.de \
/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).