* [PATCH 0/2] thermal: intel: int340x: Fix bugs in
@ 2026-03-28 19:18 aravindanilraj0702
2026-03-28 19:18 ` [PATCH 1/2] thermal: intel: int340x: Fix potential shift overflow in ptc_mmio_write aravindanilraj0702
2026-03-28 19:18 ` [PATCH 2/2] thermal: intel: int340x: Check return value of ptc_create_groups() aravindanilraj0702
0 siblings, 2 replies; 3+ messages in thread
From: aravindanilraj0702 @ 2026-03-28 19:18 UTC (permalink / raw)
To: rafael, linux-pm
Cc: daniel.lezcano, rui.zhang, lukasz.luba, srinivas.pandruvada,
linux-kernel, Aravind Anilraj
From: Aravind Anilraj <aravindanilraj0702@gmail.com>
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, leading to incorrect results.
Patch 2 checks and propagates the return value of ptc_create_groups() in
proc_thermal_ptc_add(). It also ensures proper cleanup of any previously
created sysfs groups on the 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()
.../intel/int340x_thermal/platform_temperature_control.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
--
2.47.3
^ permalink raw reply [flat|nested] 3+ messages in thread* [PATCH 1/2] thermal: intel: int340x: Fix potential shift overflow in ptc_mmio_write
2026-03-28 19:18 [PATCH 0/2] thermal: intel: int340x: Fix bugs in aravindanilraj0702
@ 2026-03-28 19:18 ` aravindanilraj0702
2026-03-28 19:18 ` [PATCH 2/2] thermal: intel: int340x: Check return value of ptc_create_groups() aravindanilraj0702
1 sibling, 0 replies; 3+ messages in thread
From: aravindanilraj0702 @ 2026-03-28 19:18 UTC (permalink / raw)
To: rafael, linux-pm
Cc: daniel.lezcano, rui.zhang, lukasz.luba, srinivas.pandruvada,
linux-kernel, Aravind Anilraj
From: Aravind Anilraj <aravindanilraj0702@gmail.com>
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.
Signed-off-by: Aravind Anilraj <aravindanilraj0702@gmail.com>
---
.../intel/int340x_thermal/platform_temperature_control.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c b/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
index 0ccc72c93499..18ac5014d8dc 100644
--- a/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
+++ b/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
@@ -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));
}
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH 2/2] thermal: intel: int340x: Check return value of ptc_create_groups()
2026-03-28 19:18 [PATCH 0/2] thermal: intel: int340x: Fix bugs in aravindanilraj0702
2026-03-28 19:18 ` [PATCH 1/2] thermal: intel: int340x: Fix potential shift overflow in ptc_mmio_write aravindanilraj0702
@ 2026-03-28 19:18 ` aravindanilraj0702
1 sibling, 0 replies; 3+ messages in thread
From: aravindanilraj0702 @ 2026-03-28 19:18 UTC (permalink / raw)
To: rafael, linux-pm
Cc: daniel.lezcano, rui.zhang, lukasz.luba, srinivas.pandruvada,
linux-kernel, Aravind Anilraj
From: Aravind Anilraj <aravindanilraj0702@gmail.com>
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.
Signed-off-by: Aravind Anilraj <aravindanilraj0702@gmail.com>
---
.../intel/int340x_thermal/platform_temperature_control.c | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c b/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
index 18ac5014d8dc..caed572c6061 100644
--- a/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
+++ b/drivers/thermal/intel/int340x_thermal/platform_temperature_control.c
@@ -278,12 +278,14 @@ 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)
+ return ret;
}
ptc_create_debugfs();
--
2.47.3
^ permalink raw reply related [flat|nested] 3+ messages in thread
end of thread, other threads:[~2026-03-28 19:18 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-03-28 19:18 [PATCH 0/2] thermal: intel: int340x: Fix bugs in aravindanilraj0702
2026-03-28 19:18 ` [PATCH 1/2] thermal: intel: int340x: Fix potential shift overflow in ptc_mmio_write aravindanilraj0702
2026-03-28 19:18 ` [PATCH 2/2] thermal: intel: int340x: Check return value of ptc_create_groups() aravindanilraj0702
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox