thermal: intel: int340x platform temperature
v2 cover thermal: intel: int340x platform temperature
From: Aravind Anilraj <[email protected]>
This series fixes two issues in the Intel int340x platform temperature control driver.
Patch 1 fixes a potential shift overflow where a u32 value is shifted into a u64 register without casting, which may lead to incorrect hardware configuration.
Patch 2 checks the return value of ptc_create_groups() and ensures proper cleanup of previously created sysfs groups on error.
Changes in v2:
Patch 1: No changes.
Patch 2: Add missing sysfs cleanup loop in error path.
Aravind Anilraj (2):
thermal: intel: int340x: Fix potential shift overflow in
ptc_mmio_write
thermal: intel: int340x: Check return value of ptc_create_groups()
.../int340x_thermal/platform_temperature_control.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)
Signature · 1 line
2.47.3
PATCH v2 1/2 thermal: intel: int340x: Fix potential shift overflow in ptc_mmio_write
From: Aravind Anilraj <[email protected]>
The value parameter is u32 but is shifted into a u64 register value without casting first. If the shift amount pushes bits beyond 32, they are lost. Cast value to u64 before shifting to ensure all bits are preserved.
--- .../intel/int340x_thermal/platform_temperature_control.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c +1 -1
@@ -138,7 +138,7 @@ static void ptc_mmio_write(struct pci_dev *pdev, u32 offset, int index, u32 valu reg_val =readq ((void __iomem *) (proc_priv->mmio_base + offset)); reg_val &= ~mask; - reg_val |= (value << ptc_mmio_regs[index].shift); + reg_val |= ((u64 )value << ptc_mmio_regs[index].shift);writeq (reg_val, (void __iomem *) (proc_priv->mmio_base + offset)); }
Signature · 1 line
2.47.3
PATCH v2 2/2 thermal: intel: int340x: Check return value of ptc_create_groups()
In reply to [email protected]From: Aravind Anilraj <[email protected]>
proc_thermal_ptc_add() ignores the return value of ptc_create_groups(), causing the driver to silenty continue even if sysfs group creation fails. The thermal control interface would be unavailable with no indication of failure.
Check the return value and on failure clean up any sysfs groups that were successfully created before the error, then propagate the error to the caller which already handles it correctly via goto err_rem_rapl.
--- .../int340x_thermal/platform_temperature_control.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
drivers/thermal/intel/int340x_thermal/platform_temperature_control.c +8 -2
@@ -278,12 +278,18 @@ static void ptc_delete_debugfs(void)int proc_thermal_ptc_add (struct pci_dev *pdev,struct proc_thermal_device *proc_priv) {if (proc_priv->mmio_feature_mask &PROC_THERMAL_FEATURE_PTC ) { -int i; +int i, ret;for (i =0 ; i <PTC_MAX_INSTANCES ; i++) { ptc_instance[i].offset = ptc_offsets[i]; ptc_instance[i].pdev = pdev; -ptc_create_groups (pdev, i, &ptc_instance[i]); + ret =ptc_create_groups (pdev, i, &ptc_instance[i]); +if (ret) { +while (i--) +sysfs_remove_group (&pdev->dev.kobj, + &ptc_instance[i].ptc_attr_group); +return ret; + } }ptc_create_debugfs ();
Signature · 1 line
2.47.3
Rafael J. Wysocki
maintainerQuoted 22 lines · On Sun, Mar 29, 2026 at 9:06 AM <[email protected]> wrote:
From: Aravind Anilraj <[email protected]>
This series fixes two issues in the Intel int340x platform temperature control driver.
Patch 1 fixes a potential shift overflow where a u32 value is shifted into a u64 register without casting, which may lead to incorrect hardware configuration.
Patch 2 checks the return value of
ptc_create_groups()and ensures proper cleanup of previously created sysfs groups on error.Changes in v2:
Patch 1: No changes.
Patch 2: Add missing sysfs cleanup loop in error path.Aravind Anilraj (2):
thermal: intel: int340x: Fix potential shift overflow in
ptc_mmio_write
thermal: intel: int340x: Check return value ofptc_create_groups()
Quoted 4 lines
.../int340x_thermal/platform_temperature_control.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-)--
Both patches applied as 7.2 material, thanks!