]> git.ipfire.org Git - thirdparty/kernel/stable.git/commit
spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware
authorDevyn Liu <liudingyuan@huawei.com>
Tue, 30 Jul 2024 03:20:40 +0000 (11:20 +0800)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 12 Sep 2024 09:11:38 +0000 (11:11 +0200)
commit16ccaf581da4fcf1e4d66086cf37263f9a656d43
tree97cff009b482b1d3990c72af48670a8f909721fc
parentd43fde5ebfe7ea1b8189c67dcf37ceb5371158b8
spi: hisi-kunpeng: Add verification for the max_frequency provided by the firmware

[ Upstream commit 5127c42c77de18651aa9e8e0a3ced190103b449c ]

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@huawei.com>
Reviewed-by: Jay Fang <f.fangjian@huawei.com>
Link: https://patch.msgid.link/20240730032040.3156393-3-liudingyuan@huawei.com
Signed-off-by: Mark Brown <broonie@kernel.org>
Signed-off-by: Sasha Levin <sashal@kernel.org>
drivers/spi/spi-hisi-kunpeng.c