Skip to content

Commit 19526d0

Browse files
MarijnS95vireshk
authored andcommitted
opp: core: Check for pending links before reading required_opp pointers
Commit 4fa82a8 ("opp: Allow required-opps to be used for non genpd use cases") dereferences the pointers in required_opp_tables but these might be set to an ERR_PTR if the list still has lazy links pending, resulting in segfaults. Prior to this patch IS_ERR was also checked on required_opp_tables[i] before reading ->is_genpd inside _opp_table_alloc_required_tables, which is at the same time the predicate to add this table to the lazy list. This segfault is solved by reordering the checks to bail on lazy pending tables before reading ->is_genpd. Fixes: 4fa82a8 ("opp: Allow required-opps to be used for non genpd use cases") Reviewed-by: AngeloGioacchino Del Regno <[email protected]> Signed-off-by: Marijn Suijten <[email protected]> Signed-off-by: Viresh Kumar <[email protected]>
1 parent c3ddfe6 commit 19526d0

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

drivers/opp/core.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -893,6 +893,10 @@ static int _set_required_opps(struct device *dev,
893893
if (!required_opp_tables)
894894
return 0;
895895

896+
/* required-opps not fully initialized yet */
897+
if (lazy_linking_pending(opp_table))
898+
return -EBUSY;
899+
896900
/*
897901
* We only support genpd's OPPs in the "required-opps" for now, as we
898902
* don't know much about other use cases. Error out if the required OPP
@@ -903,10 +907,6 @@ static int _set_required_opps(struct device *dev,
903907
return -ENOENT;
904908
}
905909

906-
/* required-opps not fully initialized yet */
907-
if (lazy_linking_pending(opp_table))
908-
return -EBUSY;
909-
910910
/* Single genpd case */
911911
if (!genpd_virt_devs)
912912
return _set_required_opp(dev, dev, opp, 0);

0 commit comments

Comments
 (0)