9f87aadc177f803b4da78a8f344d430132820993
[openwrt/staging/pepe2k.git] /
1 From 491c6fbbe8fadead32fbe316fd5d0f21e9aa01f2 Mon Sep 17 00:00:00 2001
2 From: Maxime Ripard <maxime@cerno.tech>
3 Date: Thu, 22 Apr 2021 10:45:37 +0200
4 Subject: [PATCH] clk: requests: Dereference the request pointer after
5 the check
6
7 The current code will first dereference the req pointer and then test if
8 it's NULL, resulting in a NULL pointer dereference if req is indeed
9 NULL. Reorder the test and derefence to avoid the issue
10
11 Signed-off-by: Maxime Ripard <maxime@cerno.tech>
12 ---
13 drivers/clk/clk.c | 3 ++-
14 1 file changed, 2 insertions(+), 1 deletion(-)
15
16 --- a/drivers/clk/clk.c
17 +++ b/drivers/clk/clk.c
18 @@ -2496,10 +2496,11 @@ EXPORT_SYMBOL_GPL(clk_request_start);
19 */
20 void clk_request_done(struct clk_request *req)
21 {
22 - struct clk_core *core = req->clk->core;
23 + struct clk_core *core;
24
25 if (!req)
26 return;
27 + core = req->clk->core;
28
29 clk_prepare_lock();
30