From: Jani Nikula <jani.nikula@linux.intel.com>
To: Mallesh Koujalagi <mallesh.koujalagi@intel.com>,
intel-xe@lists.freedesktop.org, rodrigo.vivi@intel.com,
matthew.brost@intel.com
Cc: anshuman.gupta@intel.com, badal.nilawar@intel.com,
vinay.belgaumkar@intel.com, riana.tauro@intel.com,
karthik.poosa@intel.com, sk.anirban@intel.com,
raag.jadav@intel.com, aravind.iddamsetty@linux.intel.com,
Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Subject: Re: [PATCH v2] drm/xe/hwmon: Use overflows_type() for temperature range check
Date: Tue, 27 Oct 2026 18:08:38 +0200 [thread overview]
Message-ID: <06bca621edbbf5fae4b83a4f5a84535204df9db1@intel.com> (raw)
In-Reply-To: <20261023143632.461084-2-mallesh.koujalagi@intel.com>
On Fri, 23 Oct 2026, Mallesh Koujalagi <mallesh.koujalagi@intel.com> wrote:
> The temperature value is calculated as an s64 before being stored
> in a long. Check whether the value fits in the target type using
> overflows_type() instead of comparing against LONG_MAX directly.
>
> This keeps the overflow check correct on both 32-bit and 64-bit
> systems and avoids architecture-specific handling.
>
> Fixes: 24ec15d64617 ("drm/xe/hwmon: Decode CRI temperature registers as IEEE-754")
> Signed-off-by: Mallesh Koujalagi <mallesh.koujalagi@intel.com>
Reviewed-by: Jani Nikula <jani.nikula@intel.com>
> ---
> v2:
> - Use overflows_type(), instead of #ifdef. (Jani)
> ---
> drivers/gpu/drm/xe/xe_hwmon.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/gpu/drm/xe/xe_hwmon.c b/drivers/gpu/drm/xe/xe_hwmon.c
> index 42acfeb8818c..515b288f18e5 100644
> --- a/drivers/gpu/drm/xe/xe_hwmon.c
> +++ b/drivers/gpu/drm/xe/xe_hwmon.c
> @@ -6,6 +6,7 @@
> #include <linux/hwmon-sysfs.h>
> #include <linux/hwmon.h>
> #include <linux/jiffies.h>
> +#include <linux/overflow.h>
> #include <linux/types.h>
> #include <linux/units.h>
>
> @@ -1322,8 +1323,8 @@ static int xe_hwmon_temperature_decode(u32 reg_val, long *temperature)
> value = 0;
> }
>
> - /* Ensure the magnitude fits in long, which is 32-bit on some arches. */
> - if (value > LONG_MAX)
> + /* Ensure the decoded value fits in a long. */
> + if (overflows_type(value, *temperature))
> return -ERANGE;
>
> if (reg_val & IEEE754_SIGN)
--
Jani Nikula, Intel
prev parent reply other threads:[~2026-10-27 16:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-23 14:36 [PATCH v2] drm/xe/hwmon: Use overflows_type() for temperature range check Mallesh Koujalagi
2026-10-23 14:45 ` ✓ CI.KUnit: success for " Patchwork
2026-10-23 15:26 ` ✓ Xe.CI.BAT: " Patchwork
2026-10-23 21:40 ` ✓ Xe.CI.FULL: " Patchwork
2026-10-26 11:34 ` [PATCH v2] " Poosa, Karthik
2026-10-26 12:36 ` Mallesh, Koujalagi
2026-10-28 5:26 ` Poosa, Karthik
2026-10-27 16:08 ` Jani Nikula [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=06bca621edbbf5fae4b83a4f5a84535204df9db1@intel.com \
--to=jani.nikula@linux.intel.com \
--cc=anshuman.gupta@intel.com \
--cc=aravind.iddamsetty@linux.intel.com \
--cc=badal.nilawar@intel.com \
--cc=intel-xe@lists.freedesktop.org \
--cc=karthik.poosa@intel.com \
--cc=mallesh.koujalagi@intel.com \
--cc=matthew.brost@intel.com \
--cc=raag.jadav@intel.com \
--cc=riana.tauro@intel.com \
--cc=rodrigo.vivi@intel.com \
--cc=sk.anirban@intel.com \
--cc=vinay.belgaumkar@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.