mirror of
https://github.com/torvalds/linux.git
synced 2026-07-28 18:21:24 +02:00
firmware: arm_scmi: Harden clock parents discovery
Fix clock parents enumeration to account only for effectively discovered parents during enumeration, avoiding to trust the total number of parents declared upfront by the platform. Reviewed-by: Peng Fan <peng.fan@nxp.com> Signed-off-by: Cristian Marussi <cristian.marussi@arm.com> Tested-by: Florian Fainelli <florian.fainelli@broadcom.com> Tested-by: Geert Uytterhoeven <geert+renesas@glider.be> Link: https://patch.msgid.link/20260508153300.2224715-9-cristian.marussi@arm.com Signed-off-by: Sudeep Holla <sudeep.holla@kernel.org>
This commit is contained in:
parent
62ba967595
commit
bda40491e0
|
|
@ -270,15 +270,15 @@ static int iter_clk_possible_parents_update_state(struct scmi_iterator_state *st
|
|||
* assume it's returned+remaining on first call.
|
||||
*/
|
||||
if (!st->max_resources) {
|
||||
p->clkd->info.num_parents = st->num_returned + st->num_remaining;
|
||||
p->clkd->info.parents = devm_kcalloc(p->dev,
|
||||
p->clkd->info.num_parents,
|
||||
int num_parents = st->num_returned + st->num_remaining;
|
||||
|
||||
p->clkd->info.parents = devm_kcalloc(p->dev, num_parents,
|
||||
sizeof(*p->clkd->info.parents),
|
||||
GFP_KERNEL);
|
||||
if (!p->clkd->info.parents) {
|
||||
p->clkd->info.num_parents = 0;
|
||||
if (!p->clkd->info.parents)
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
/* max_resources is used by the iterators to control bounds */
|
||||
st->max_resources = st->num_returned + st->num_remaining;
|
||||
}
|
||||
|
||||
|
|
@ -293,9 +293,11 @@ static int iter_clk_possible_parents_process_response(const struct scmi_protocol
|
|||
const struct scmi_msg_resp_clock_possible_parents *r = response;
|
||||
struct scmi_clk_ipriv *p = priv;
|
||||
|
||||
u32 *parent = &p->clkd->info.parents[st->desc_index + st->loop_idx];
|
||||
p->clkd->info.parents[st->desc_index + st->loop_idx] =
|
||||
le32_to_cpu(r->possible_parents[st->loop_idx]);
|
||||
|
||||
*parent = le32_to_cpu(r->possible_parents[st->loop_idx]);
|
||||
/* Count only effectively discovered parents */
|
||||
p->clkd->info.num_parents++;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user