summaryrefslogtreecommitdiffstats
path: root/drivers/interconnect
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2024-07-16 23:48:23 +0200
committerGeorgi Djakov <djakov@kernel.org>2024-08-23 17:40:00 +0200
commitc801ed86840ec38b2a9bcafeee3d7c9e14c743f3 (patch)
tree9d17ba5e340a869ed40e6ab25aec1d2763213daa /drivers/interconnect
parentdt-bindings: interconnect: qcom,rpmh: correct sm8150 camnoc (diff)
downloadlinux-c801ed86840ec38b2a9bcafeee3d7c9e14c743f3.tar.xz
linux-c801ed86840ec38b2a9bcafeee3d7c9e14c743f3.zip
interconnect: icc-clk: Add missed num_nodes initialization
With the new __counted_by annotation, the "num_nodes" struct member must be set before accessing the "nodes" array. This initialization was done in other places where a new struct icc_onecell_data is allocated, but this case in icc_clk_register() was missed. Set "num_nodes" after allocation. Fixes: dd4904f3b924 ("interconnect: qcom: Annotate struct icc_onecell_data with __counted_by") Signed-off-by: Kees Cook <kees@kernel.org> Reviewed-by: Gustavo A. R. Silva <gustavoars@kernel.org> Link: https://lore.kernel.org/r/20240716214819.work.328-kees@kernel.org Signed-off-by: Georgi Djakov <djakov@kernel.org>
Diffstat (limited to 'drivers/interconnect')
-rw-r--r--drivers/interconnect/icc-clk.c3
1 files changed, 1 insertions, 2 deletions
diff --git a/drivers/interconnect/icc-clk.c b/drivers/interconnect/icc-clk.c
index f788db15cd76..b956e4050f38 100644
--- a/drivers/interconnect/icc-clk.c
+++ b/drivers/interconnect/icc-clk.c
@@ -87,6 +87,7 @@ struct icc_provider *icc_clk_register(struct device *dev,
onecell = devm_kzalloc(dev, struct_size(onecell, nodes, 2 * num_clocks), GFP_KERNEL);
if (!onecell)
return ERR_PTR(-ENOMEM);
+ onecell->num_nodes = 2 * num_clocks;
qp = devm_kzalloc(dev, struct_size(qp, clocks, num_clocks), GFP_KERNEL);
if (!qp)
@@ -133,8 +134,6 @@ struct icc_provider *icc_clk_register(struct device *dev,
onecell->nodes[j++] = node;
}
- onecell->num_nodes = j;
-
ret = icc_provider_register(provider);
if (ret)
goto err;