bcm27xx: add support for linux v5.15
[openwrt/staging/chunkeey.git] / target / linux / bcm27xx / patches-5.15 / 950-0857-clk-Test-the-clock-pointer-in-clk_hw_get_name.patch
1 From f8740e21bb2a6eb11da683901e22fbb6fea80dc8 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Tue, 5 Apr 2022 15:20:27 +0200
4 Subject: [PATCH] clk: Test the clock pointer in clk_hw_get_name()
5
6 Unlike __clk_get_name(), clk_hw_get_name() doesn't test wether passed
7 clk_hw pointer is NULL or not and dereferences it directly. This can
8 then lead to NULL pointer dereference.
9
10 Let's make sure the pointer isn't NULL before dereferencing it.
11
12 Tested-by: Alexander Stein <alexander.stein@ew.tq-group.com> # imx8mp
13 Tested-by: Marek Szyprowski <m.szyprowski@samsung.com> # exynos4210, meson g12b
14 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
15 ---
16 drivers/clk/clk.c | 2 +-
17 1 file changed, 1 insertion(+), 1 deletion(-)
18
19 --- a/drivers/clk/clk.c
20 +++ b/drivers/clk/clk.c
21 @@ -269,7 +269,7 @@ EXPORT_SYMBOL_GPL(__clk_get_name);
22
23 const char *clk_hw_get_name(const struct clk_hw *hw)
24 {
25 - return hw->core->name;
26 + return !hw ? NULL : hw->core->name;
27 }
28 EXPORT_SYMBOL_GPL(clk_hw_get_name);
29