[lvc-project] [PATCH 6.1] spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware
Maxim Boykov
meboykov at yandex.ru
Thu Dec 11 08:26:34 MSK 2025
From: Devyn Liu <liudingyuan at huawei.com>
commit 5127c42c77de18651aa9e8e0a3ced190103b449c upstream.
If the value of max_speed_hz is 0, it may cause a division by zero
error in hisi_calc_effective_speed().
The value of max_speed_hz is provided by firmware.
Firmware is generally considered as a trusted domain. However, as
division by zero errors can cause system failure, for defense measure,
the value of max_speed is validated here. So 0 is regarded as invalid
and an error code is returned.
Signed-off-by: Devyn Liu <liudingyuan at huawei.com>
Reviewed-by: Jay Fang <f.fangjian at huawei.com>
Link: https://patch.msgid.link/20240730032040.3156393-3-liudingyuan@huawei.com
Signed-off-by: Mark Brown <broonie at kernel.org>
Signed-off-by: Maxim Boykov <meboykov at yandex.ru>
---
Backport fix for BDU:2025-04641 (CVE-2024-47664)
drivers/spi/spi-hisi-kunpeng.c | 3 +++
1 file changed, 3 insertions(+)
diff --git a/drivers/spi/spi-hisi-kunpeng.c b/drivers/spi/spi-hisi-kunpeng.c
index 54730e93fba4..18a17427ad3b 100644
--- a/drivers/spi/spi-hisi-kunpeng.c
+++ b/drivers/spi/spi-hisi-kunpeng.c
@@ -481,6 +481,9 @@ static int hisi_spi_probe(struct platform_device *pdev)
return -EINVAL;
}
+ if (master->max_speed_hz == 0)
+ return dev_err_probe(dev, -EINVAL, "spi-max-frequency can't be 0\n");
+
ret = device_property_read_u16(dev, "num-cs",
&master->num_chipselect);
if (ret)
--
2.47.3
More information about the lvc-project
mailing list