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 <[email protected]>
---
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;