Skip to contentSkip to conversation

macintosh/windfarm: Fix fan ID bounds check in smu_set_fan()

PATCH New Thorsten Blum 1 participant 1 message Nov 25 Linux for power macintosh

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 macintosh/windfarm: Fix fan ID bounds check in smu_set_fan()

The 14-byte legacy fan payload contains 2 control bytes followed by 6 16-bit fan values. However, the existing check also accepts IDs 6 and 7.

ID 6 stores its value in the last 2 bytes of the buffer, but outside the transmitted payload, while ID 7 writes beyond the 16-byte buffer.

Reject IDs greater than 5 for legacy fan commands.

Fixes 75722d3992f5 ("[PATCH] ppc64: Thermal control for SMU based machines")
---
 drivers/macintosh/windfarm_smu_controls.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/macintosh/windfarm_smu_controls.c +1 -1
index 9adceae74345..f430f160f246 100644
@@ -74,7 +74,7 @@ static int smu_set_fan(int pwm, u8 id, u16 value)
 		*((u16 *)(&buffer[2])) = value;
 		cmd.data_len = 4;
 	} else {
-		if (id > 7)
+		if (id > 5)
 			return -EINVAL;
 		/* Fill argument buffer */
 		memset(buffer, 0, 16);