* [PATCH] macintosh/windfarm: Zero-initialize cached fan value
@ 2026-11-25 18:37 Thorsten Blum
0 siblings, 0 replies; only message in thread
From: Thorsten Blum @ 2026-11-25 18:37 UTC (permalink / raw)
To: Madhavan Srinivasan, Michael Ellerman, Nicholas Piggin,
Christophe Leroy (CS GROUP), Benjamin Herrenschmidt,
Paul Mackerras
Cc: Thorsten Blum, linuxppc-dev
smu_fan_create() allocates the control with kmalloc_obj(), which leaves
fct->value uninitialized. Once the control is registered, reading the
fan control via sysfs and smu_fan_get() before the first call to
smu_fan_set() can therefore expose uninitialized heap data.
Use kzalloc_obj() to zero-initialize the control instead.
Note that smu_fan_get() returns the cached value set by smu_fan_set()
without querying the SMU. The initial value of 0 is thus only a
placeholder and does not indicate that the fan is stopped.
Fixes: 75722d3992f5 ("[PATCH] ppc64: Thermal control for SMU based machines")
Signed-off-by: Thorsten Blum <blum@kernel.org>
---
drivers/macintosh/windfarm_smu_controls.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/macintosh/windfarm_smu_controls.c b/drivers/macintosh/windfarm_smu_controls.c
index 671ff959bf06..2f4dc0e2be40 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -149,7 +149,7 @@ static struct smu_fan_control *smu_fan_create(struct device_node *node,
const u32 *reg;
const char *l;
- fct = kmalloc_obj(struct smu_fan_control);
+ fct = kzalloc_obj(*fct);
if (fct == NULL)
return NULL;
fct->ctrl.ops = &smu_fan_ops;
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2026-11-25 18:37 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-25 18:37 [PATCH] macintosh/windfarm: Zero-initialize cached fan value Thorsten Blum
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.