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)
committerDom Cobley <popcornmix@gmail.com>
Mon, 21 Mar 2022 16:04:14 +0000 (16:04 +0000)
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 cdb6c37..33de2b7 100644 (file)
@@ -2515,10 +2515,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();