[PATCH 5/7] platform/x86: asus-wmi: reject short fan curve replies

From: Bartu Alev

Date: Sun Nov 01 2026 - 05:49:11 EST


fan_curve_get_factory_default() passes a 32-byte stack buffer to
asus_wmi_evaluate_method_buf() and copies the first 16 bytes into the
curve without checking the returned length. Because the helper only
copies obj->buffer.length bytes, a shorter firmware reply leaves the
tail of the buffer uninitialized, populating the curve with stack
garbage.

Zero-initialize the buffer and reject replies shorter than the 16
bytes required for the curve. Known curve getters return 32 bytes,
well above this threshold.

Signed-off-by: Bartu Alev <bartualev@xxxxxxxxx>
---
drivers/platform/x86/asus-wmi.c | 11 +++++++++--
1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/drivers/platform/x86/asus-wmi.c b/drivers/platform/x86/asus-wmi.c
index b6541183d4568..dc1e69b964c99 100644
--- a/drivers/platform/x86/asus-wmi.c
+++ b/drivers/platform/x86/asus-wmi.c
@@ -3631,7 +3631,8 @@ static void fan_curve_copy_from_buf(struct fan_curve_data *data, u8 *buf)
static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
{
struct fan_curve_data *curves;
- u8 buf[FAN_CURVE_BUF_LEN];
+ u8 buf[FAN_CURVE_BUF_LEN] = {};
+ size_t len;
int err, fan_idx;
u8 mode = 0;

@@ -3644,12 +3645,18 @@ static int fan_curve_get_factory_default(struct asus_wmi *asus, u32 fan_dev)
mode = 2;

err = asus_wmi_evaluate_method_buf(asus->dsts_id, fan_dev, mode, buf,
- FAN_CURVE_BUF_LEN, NULL);
+ FAN_CURVE_BUF_LEN, &len);
if (err) {
pr_warn("%s (0x%08x) failed: %d\n", __func__, fan_dev, err);
return err;
}

+ if (len < 2 * FAN_CURVE_POINTS) {
+ pr_debug("%s (0x%08x): short reply of %zu bytes\n",
+ __func__, fan_dev, len);
+ return -ENODATA;
+ }
+
fan_idx = FAN_CURVE_DEV_CPU;
if (fan_dev == ASUS_WMI_DEVID_GPU_FAN_CURVE)
fan_idx = FAN_CURVE_DEV_GPU;

--
2.56.0