Skip to content

Commit ac3420d

Browse files
kpoosaanshuma1
authored andcommitted
drm/i915/hwmon: Fix static analysis tool reported issues
Updated i915 hwmon with fixes for issues reported by static analysis tool. Fixed integer overflow with upcasting. v2: - Added Fixes tag (Badal). - Updated commit message as per review comments (Anshuman). Fixes: 4c2572f ("drm/i915/hwmon: Expose power1_max_interval") Reviewed-by: Badal Nilawar <badal.nilawar@intel.com> Reviewed-by: Anshuman Gupta <anshuman.gupta@intel.com> Signed-off-by: Karthik Poosa <karthik.poosa@intel.com> Signed-off-by: Anshuman Gupta <anshuman.gupta@intel.com> Link: https://patchwork.freedesktop.org/patch/msgid/20231204144809.1518704-1-karthik.poosa@intel.com
1 parent 5169477 commit ac3420d

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

drivers/gpu/drm/i915/i915_hwmon.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ hwm_power1_max_interval_show(struct device *dev, struct device_attribute *attr,
175175
* tau4 = (4 | x) << y
176176
* but add 2 when doing the final right shift to account for units
177177
*/
178-
tau4 = ((1 << x_w) | x) << y;
178+
tau4 = (u64)((1 << x_w) | x) << y;
179179
/* val in hwmon interface units (millisec) */
180180
out = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w);
181181

@@ -211,7 +211,7 @@ hwm_power1_max_interval_store(struct device *dev,
211211
r = FIELD_PREP(PKG_MAX_WIN, PKG_MAX_WIN_DEFAULT);
212212
x = REG_FIELD_GET(PKG_MAX_WIN_X, r);
213213
y = REG_FIELD_GET(PKG_MAX_WIN_Y, r);
214-
tau4 = ((1 << x_w) | x) << y;
214+
tau4 = (u64)((1 << x_w) | x) << y;
215215
max_win = mul_u64_u32_shr(tau4, SF_TIME, hwmon->scl_shift_time + x_w);
216216

217217
if (val > max_win)

0 commit comments

Comments
 (0)