Skip to content

Commit

Permalink
interconnect: qcom: icc-rpm: Set the count member before accessing th…
Browse files Browse the repository at this point in the history
…e flex array

The following UBSAN error is reported during boot on the db410c board on
a clang-19 build:

Internal error: UBSAN: array index out of bounds: 00000000f2005512 [#1] PREEMPT SMP
...
pc : qnoc_probe+0x5f8/0x5fc
...

The cause of the error is that the counter member was not set before
accessing the annotated flexible array member, but after that. Fix this
by initializing it earlier.

Reported-by: Linux Kernel Functional Testing <[email protected]>
Closes: https://lore.kernel.org/r/CA+G9fYs+2mBz1y2dAzxkj9-oiBJ2Acm1Sf1h2YQ3VmBqj_VX2g@mail.gmail.com
Fixes: dd4904f ("interconnect: qcom: Annotate struct icc_onecell_data with __counted_by")
Reviewed-by: Nathan Chancellor <[email protected]>
Link: https://lore.kernel.org/r/[email protected]
Signed-off-by: Georgi Djakov <[email protected]>
  • Loading branch information
Georgi Djakov committed Dec 17, 2024
1 parent 40384c8 commit 00a973e
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion drivers/interconnect/qcom/icc-rpm.c
Original file line number Diff line number Diff line change
Expand Up @@ -503,6 +503,7 @@ int qnoc_probe(struct platform_device *pdev)
GFP_KERNEL);
if (!data)
return -ENOMEM;
data->num_nodes = num_nodes;

qp->num_intf_clks = cd_num;
for (i = 0; i < cd_num; i++)
Expand Down Expand Up @@ -597,7 +598,6 @@ int qnoc_probe(struct platform_device *pdev)

data->nodes[i] = node;
}
data->num_nodes = num_nodes;

clk_bulk_disable_unprepare(qp->num_intf_clks, qp->intf_clks);

Expand Down

0 comments on commit 00a973e

Please sign in to comment.