Commit c801ed86 authored by Kees Cook's avatar Kees Cook Committed by Georgi Djakov
Browse files

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: dd4904f3 ("interconnect: qcom: Annotate struct icc_onecell_data with __counted_by")
Signed-off-by: default avatarKees Cook <kees@kernel.org>
Reviewed-by: default avatarGustavo A. R. Silva <gustavoars@kernel.org>
Link: https://lore.kernel.org/r/20240716214819.work.328-kees@kernel.org


Signed-off-by: default avatarGeorgi Djakov <djakov@kernel.org>
parent 7d59b1ff
Loading
Loading
Loading
Loading
+1 −2
Original line number Diff line number Diff line
@@ -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;