clk: requests: Dereference the request pointer after the check
authorMaxime Ripard <maxime@cerno.tech>
Thu, 22 Apr 2021 08:45:37 +0000 (10:45 +0200)
committerPhil Elwell <8911409+pelwell@users.noreply.github.com>
Thu, 22 Apr 2021 10:07:05 +0000 (11:07 +0100)
The current code will first dereference the req pointer and then test if
it's NULL, resulting in a NULL pointer dereference if req is indeed
NULL. Reorder the test and derefence to avoid the issue

Signed-off-by: Maxime Ripard <maxime@cerno.tech>
drivers/clk/clk.c

index af0f638..1b9a76c 100644 (file)
@@ -2496,10 +2496,11 @@ EXPORT_SYMBOL_GPL(clk_request_start);
  */
 void clk_request_done(struct clk_request *req)
 {
-       struct clk_core *core = req->clk->core;
+       struct clk_core *core;
 
        if (!req)
                return;
+       core = req->clk->core;
 
        clk_prepare_lock();