]> git.baikalelectronics.ru Git - uboot.git/commit
clk: sunxi: Prevent out-of-bounds gate array access
authorSamuel Holland <samuel@sholland.org>
Mon, 9 May 2022 05:29:32 +0000 (00:29 -0500)
committerAndre Przywara <andre.przywara@arm.com>
Mon, 18 Jul 2022 08:37:49 +0000 (09:37 +0100)
commit1afa7bd64fe5c293439efb5821221867bc6a9f62
treec8e87a3d76f1f69ef2d1ca93d2106fbc402ca22c
parentf17e05deffa7d34e200cb268cded1665b93fbf8b
clk: sunxi: Prevent out-of-bounds gate array access

Because the gate arrays are not given explicit sizes, the arrays are
only as large as the highest-numbered gate described in the driver.
However, only a subset of the CCU clocks are needed by U-Boot. So there
are valid clock specifiers with indexes greater than the size of the
arrays. Referencing any of these clocks causes out-of-bounds access.
Fix this by checking the identifier against the size of the array.

Fixes: a0e78348a304 ("clk: Add Allwinner A64 CLK driver")
Signed-off-by: Samuel Holland <samuel@sholland.org>
Reviewed-by: Andre Przywara <andre.przywara@arm.com>
Signed-off-by: Andre Przywara <andre.przywara@arm.com>
drivers/clk/sunxi/clk_sunxi.c