From: sashiko-bot@kernel.org
To: "Xiang Mei" <xmei5@asu.edu>
Cc: dri-devel@lists.freedesktop.org
Subject: Re: [PATCH] drm/modes: reject out-of-range GTF blanking duty cycle
Date: Sat, 11 Jul 2026 23:20:12 +0000 [thread overview]
Message-ID: <20260711232012.E57081F000E9@smtp.kernel.org> (raw)
In-Reply-To: <20260711230728.2250485-1-xmei5@asu.edu>
Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
Pre-existing issues:
- [Medium] Unchecked `vrefresh` parameter from kernel command line can cause multiple divide-by-zero panics.
--
--- Patch [1]: [PATCH] drm/modes: reject out-of-range GTF blanking duty cycle ---
commit c78fc29b3d453bf33d5cd88746572b5f1e9a5c60
Author: Xiang Mei <xmei5@asu.edu>
drm/modes: reject out-of-range GTF blanking duty cycle
This commit rejects GTF blanking duty cycles of 100% or more to prevent a
divide-by-zero error that occurs when the divisor (100000 - ideal_duty_cycle)
evaluates to 0.
> diff --git a/drivers/gpu/drm/drm_modes.c b/drivers/gpu/drm/drm_modes.c
> index e1eed13a8e94f..291037706b587 100644
> --- a/drivers/gpu/drm/drm_modes.c
> +++ b/drivers/gpu/drm/drm_modes.c
> @@ -966,6 +966,10 @@ drm_gtf_mode_complex(struct drm_device *dev, int hdisplay, int vdisplay,
> /* 18.Find the ideal blanking duty cycle from blanking duty cycle */
> ideal_duty_cycle = GTF_C_PRIME * 1000 -
> (GTF_M_PRIME * 1000000 / hfreq_est);
[Severity: Medium]
This is a pre-existing issue, but while fixing divide-by-zero crashes here,
could an unvalidated vrefresh parameter cause other divide-by-zero panics
in this function?
For example, if an administrator provides a kernel command line parameter
with a refresh rate of @0 (e.g., video=1024x768@0), vfieldrate_rqd
evaluates to 0. This would cause a panic earlier in drm_gtf_mode_complex():
hperiod = 1000000 / (vfieldrate_rqd * vtotal_lines);
Also, if the refresh rate is @1818, tmp1 evaluates to 0:
tmp1 = (1000000 - MIN_VSYNC_PLUS_BP * vfieldrate_rqd) / 500;
// (1000000 - 550 * 1818) / 500 = 0
This leads to another direct division by zero:
hfreq_est = (tmp2 * 1000 * vfieldrate_rqd) / tmp1;
And if hfreq_est evaluates to 0, it causes a third divide-by-zero on the
ideal_duty_cycle assignment above.
Should drm_gtf_mode_complex() validate the vrefresh parameter before
performing these calculations?
> + if (ideal_duty_cycle >= 100000) {
> + drm_mode_destroy(dev, drm_mode);
> + return NULL;
> + }
> /* 19.Find the number of pixels in the blanking time to the nearest
> * double character cell: */
> hblank = total_active_pixels * ideal_duty_cycle /
--
Sashiko AI review · https://sashiko.dev/#/patchset/20260711230728.2250485-1-xmei5@asu.edu?part=1
prev parent reply other threads:[~2026-07-11 23:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-11 23:07 [PATCH] drm/modes: reject out-of-range GTF blanking duty cycle Xiang Mei
2026-07-11 23:20 ` sashiko-bot [this message]
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=20260711232012.E57081F000E9@smtp.kernel.org \
--to=sashiko-bot@kernel.org \
--cc=dri-devel@lists.freedesktop.org \
--cc=sashiko-reviews@lists.linux.dev \
--cc=xmei5@asu.edu \
/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