]> git.baikalelectronics.ru Git - kernel.git/commit
clk: bcm: rpi: Prevent out-of-bounds access
authorStefan Wahren <stefan.wahren@i2se.com>
Wed, 13 Jul 2022 15:49:51 +0000 (17:49 +0200)
committerStephen Boyd <sboyd@kernel.org>
Tue, 23 Aug 2022 22:51:10 +0000 (15:51 -0700)
commit1ff99cc421d71c8f71a688b305e7d5c0a63abbc6
tree9d88acac9a328fd40681b39fa48f6243688df5f7
parentbb32ef870131b895a892a429939722f27a633701
clk: bcm: rpi: Prevent out-of-bounds access

The while loop in raspberrypi_discover_clocks() relies on the assumption
that the id of the last clock element is zero. Because this data comes
from the Videocore firmware and it doesn't guarantuee such a behavior
this could lead to out-of-bounds access. So fix this by providing
a sentinel element.

Fixes: cfcafa2c3e85 ("clk: bcm: rpi: Discover the firmware clocks")
Link: https://github.com/raspberrypi/firmware/issues/1688
Suggested-by: Phil Elwell <phil@raspberrypi.com>
Signed-off-by: Stefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20220713154953.3336-2-stefan.wahren@i2se.com
Acked-by: Florian Fainelli <f.fainelli@gmail.com>
Reviewed-by: Ivan T. Ivanov <iivanov@suse.de>
Signed-off-by: Stephen Boyd <sboyd@kernel.org>
drivers/clk/bcm/clk-raspberrypi.c