From: Tony Lindgren Date: Thu, 21 Mar 2019 18:00:21 +0000 (-0700) Subject: bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated X-Git-Tag: microblaze-v5.4-rc1~700^2~17^2~32 X-Git-Url: http://git.monstr.eu/?a=commitdiff_plain;h=aaa29bb01cc4bf5a87dbdb219efba3b09f259d8e;p=linux-2.6-microblaze.git bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated 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 --- diff --git a/drivers/bus/ti-sysc.c b/drivers/bus/ti-sysc.c index d299ec79e4c3..647caccacee6 100644 --- a/drivers/bus/ti-sysc.c +++ b/drivers/bus/ti-sysc.c @@ -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]);