Commit 03869ae0 authored by Stefan Wahren's avatar Stefan Wahren Committed by Jialin Zhang
Browse files

clk: bcm: rpi: Prevent out-of-bounds access

stable inclusion
from stable-v5.10.142
commit fcae47b2d23c81603b01f56cf8db63ed64599d34
category: bugfix
bugzilla: https://gitee.com/openeuler/kernel/issues/I6CSFH

Reference: https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git/commit/?id=fcae47b2d23c81603b01f56cf8db63ed64599d34

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

[ Upstream commit bc163555 ]

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: 93d2725a ("clk: bcm: rpi: Discover the firmware clocks")
Link: https://github.com/raspberrypi/firmware/issues/1688


Suggested-by: default avatarPhil Elwell <phil@raspberrypi.com>
Signed-off-by: default avatarStefan Wahren <stefan.wahren@i2se.com>
Link: https://lore.kernel.org/r/20220713154953.3336-2-stefan.wahren@i2se.com


Acked-by: default avatarFlorian Fainelli <f.fainelli@gmail.com>
Reviewed-by: default avatarIvan T. Ivanov <iivanov@suse.de>
Signed-off-by: default avatarStephen Boyd <sboyd@kernel.org>
Signed-off-by: default avatarSasha Levin <sashal@kernel.org>
Signed-off-by: default avatarJialin Zhang <zhangjialin11@huawei.com>
Reviewed-by: default avatarZheng Zengkai <zhengzengkai@huawei.com>
parent d28c9fc9
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment