Skip to content

Commit

Permalink
bus: ti-sysc: Fix sysc_unprepare() when no clocks have been allocated
Browse files Browse the repository at this point in the history
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: 0eecc63 ("bus: ti-sysc: Add minimal TI sysc interconnect target driver")
Signed-off-by: Tony Lindgren <tony@atomide.com>
  • Loading branch information
Tony Lindgren committed Apr 1, 2019
1 parent 8b30919 commit aaa29bb
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions drivers/bus/ti-sysc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
Expand Down

0 comments on commit aaa29bb

Please sign in to comment.