From: "Ville Syrjälä" <ville.syrjala@linux.intel.com>
To: Krzysztof Karas <krzysztof.karas@intel.com>
Cc: intel-gfx@lists.freedesktop.org,
Andi Shyti <andi.shyti@linux.intel.com>,
Sebastian Brzezinka <sebastian.brzezinka@intel.com>,
Krzysztof Niemiec <krzysztof.niemiec@intel.com>,
Jani Nikula <jani.nikula@linux.intel.com>
Subject: Re: [PATCH v5 3/3] drm: Avoid undefined behavior on u16 multiplication in drm_crtc_vblank_helper_get_vblank_timestamp_internal()
Date: Tue, 9 Dec 2025 10:00:55 +0200 [thread overview]
Message-ID: <aTfXN-N8apskuGLE@intel.com> (raw)
In-Reply-To: <rn5ehfx4ujqwm3kbu3ryvtayinmmfbgdzaithxbkrrsg2onbco@nw4bkwywhrws>
On Tue, Dec 09, 2025 at 07:47:09AM +0000, Krzysztof Karas wrote:
> Hi Ville,
>
> On 2025-12-08 at 19:15:42 +0200, Ville Syrjälä wrote:
> > On Thu, Dec 04, 2025 at 02:38:27PM +0000, Krzysztof Karas wrote:
> > > vpos (int) field multiplied by crtc_htotal (u16) may cause
> > > implicit promotion of the latter and overflow the result causing
> > > undefined behavior.
> >
> > How is that undefined?
> Good question. It is well defined in C standard to wrap silently
> to fit in the new type, so operations may complete. I think this
> might have been caused by working with static analyzer at the
> time, which imprinted word "undefined" in my brain, so it made
> sense to use it here as well.
>
> I believe "unexpected" may better describe the problem.
> I'll change that in the v6 of this series.
If you really want it then at least make it a (int) to match the
other types in the expression. But personally I'd just drop the whole
thing since this is just normal C, and this does nothing to avoid any
overflows (which there won't be anyway unless some other code is super
buggy and returns nonsense hpos/vpos values).
--
Ville Syrjälä
Intel
next prev parent reply other threads:[~2025-12-09 8:01 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-12-04 14:38 [PATCH v5 0/3] drm: Miscellaneous fixes in drm code Krzysztof Karas
2025-12-04 14:38 ` [PATCH v5 1/3] drm: Warn and return before division by 0 Krzysztof Karas
2025-12-05 15:31 ` Krzysztof Niemiec
2025-12-16 14:12 ` Andi Shyti
2025-12-04 14:38 ` [PATCH v5 2/3] drm: Avoid suspicious operations in drm_fb_dma_get_gem_addr() Krzysztof Karas
2025-12-05 15:32 ` Krzysztof Niemiec
2025-12-16 14:11 ` Andi Shyti
2025-12-04 14:38 ` [PATCH v5 3/3] drm: Avoid undefined behavior on u16 multiplication in drm_crtc_vblank_helper_get_vblank_timestamp_internal() Krzysztof Karas
2025-12-05 15:32 ` Krzysztof Niemiec
2025-12-08 17:15 ` Ville Syrjälä
2025-12-09 7:47 ` Krzysztof Karas
2025-12-09 8:00 ` Ville Syrjälä [this message]
2025-12-05 8:50 ` ✓ i915.CI.BAT: success for drm: Miscellaneous fixes in drm code (rev5) Patchwork
2025-12-06 4:39 ` ✗ i915.CI.Full: 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=aTfXN-N8apskuGLE@intel.com \
--to=ville.syrjala@linux.intel.com \
--cc=andi.shyti@linux.intel.com \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=krzysztof.karas@intel.com \
--cc=krzysztof.niemiec@intel.com \
--cc=sebastian.brzezinka@intel.com \
/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.