bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated
authorTony Lindgren <tony@atomide.com>
Thu, 21 Mar 2019 18:00:21 +0000 (11:00 -0700)
committerTony Lindgren <tony@atomide.com>
Mon, 1 Apr 2019 14:38:37 +0000 (07:38 -0700)
If we return early before ddata->clocks have been allocated we will get a
NULL pointer dereference in sysc_unprepare(). Let's fix this by returning
early when no clocks are allocated.

Fixes: 0eecc636e5a2 ("bus: ti-sysc: Add minimal TI sysc interconnect target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
drivers/bus/ti-sysc.c

index d299ec79e4c38bd4b5117b87bd75d639fe596ea1..647caccacee684c374630784d5a50cb01b2bc68f 100644 (file)
@@ -1331,6 +1331,9 @@ static void sysc_unprepare(struct sysc *ddata)
 {
        int i;
 
+       if (!ddata->clocks)
+               return;
+
        for (i = 0; i < SYSC_MAX_CLOCKS; i++) {
                if (!IS_ERR_OR_NULL(ddata->clocks[i]))
                        clk_unprepare(ddata->clocks[i]);