Commit 51291a22 authored by Devyn Liu's avatar Devyn Liu Committed by Hao Chen
Browse files

spi: hisi-kunpeng: Add validation for the minimum value of speed_hz

driver inclusion
category: cleanup
bugzilla: https://gitee.com/openeuler/kernel/issues/I9O7EH


CVE: NA

--------------------------------

We get the configuration of max_frequency from the firmware, which is
used to calculate the clk_div together with the set speed. If the
speed set by the user is too small, it may cause the clk_div to be too
large to exceed the variable range. Therefore, we limit the minimum
value of the speed configuration to the value obtained by
(master->max_speed_hz/CLK_DIV_MAX).

Signed-off-by: default avatarDevyn Liu <liudingyuan@huawei.com>
Signed-off-by: default avatarJunhua Lu <lujunhua7@h-partners.com>
parent 8c9aeaf8
Loading
Loading
Loading
Loading
+1 −0
Original line number Diff line number Diff line
@@ -501,6 +501,7 @@ static int hisi_spi_probe(struct platform_device *pdev)
	host->transfer_one = hisi_spi_transfer_one;
	host->handle_err = hisi_spi_handle_err;
	host->dev.fwnode = dev->fwnode;
	host->min_speed_hz = DIV_ROUND_UP(host->max_speed_hz, CLK_DIV_MAX);

	hisi_spi_hw_init(hs);