[<prev] [next>] [day] [month] [year] [list]
Message-Id: <20211130111518.112374-1-zhou1615@umn.edu>
Date: Tue, 30 Nov 2021 19:15:17 +0800
From: Zhou Qingyang <zhou1615@....edu>
To: zhou1615@....edu
Cc: kjlu@....edu, Michael Turquette <mturquette@...libre.com>,
Stephen Boyd <sboyd@...nel.org>,
Akshu Agrawal <akshu.agrawal@....com>,
"Rafael J. Wysocki" <rafael.j.wysocki@...el.com>,
linux-clk@...r.kernel.org, linux-kernel@...r.kernel.org
Subject: [PATCH] clk: x86: Fix a wild pointer dereference in fch_clk_probe()
In fch_clk_probe(), the return value of clk_hw_register_mux() is
assigned to hws[ST_CLK_MUX] and there is a dereference of it in
fch_clk_probe(), which could lead to a wild pointer dereference on
failure of clk_hw_register_mux().
Fix this bug by adding a check of hws[ST_CLK_MUX].
This bug was found by a static analyzer. The analysis employs
differential checking to identify inconsistent security operations
(e.g., checks or kfrees) between two code paths and confirms that the
inconsistent operations are not recovered in the current function or
the callers, so they constitute bugs.
Note that, as a bug found by static analysis, it can be a false
positive or hard to trigger. Multiple researchers have cross-reviewed
the bug.
Builds with CONFIG_X86_AMD_PLATFORM_DEVICE=y show no new warnings, and
our static analyzer no longer warns about this code.
Fixes: 19fe87fd854a ("clk: x86: Support RV architecture")
Signed-off-by: Zhou Qingyang <zhou1615@....edu>
---
drivers/clk/x86/clk-fch.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/clk/x86/clk-fch.c b/drivers/clk/x86/clk-fch.c
index 8f7c5142b0f0..1539ee59c04a 100644
--- a/drivers/clk/x86/clk-fch.c
+++ b/drivers/clk/x86/clk-fch.c
@@ -51,6 +51,8 @@ static int fch_clk_probe(struct platform_device *pdev)
clk_oscout1_parents, ARRAY_SIZE(clk_oscout1_parents),
0, fch_data->base + CLKDRVSTR2, OSCOUT1CLK25MHZ, 3, 0,
NULL);
+ if (IS_ERR(hws[ST_CLK_MUX]))
+ return PTR_ERR(hws[ST_CLK_MUX]);
clk_set_parent(hws[ST_CLK_MUX]->clk, hws[ST_CLK_48M]->clk);
--
2.25.1
Powered by blists - more mailing lists