提交 f77ebdda 编写于 作者: D Dmitry Baryshkov 提交者: Georgi Djakov

interconnect: qcom: osm-l3: fix icc_onecell_data allocation

This is a struct with a trailing zero-length array of icc_node pointers
but it's allocated as if it were a single array of icc_nodes instead.

Fortunately this overallocates memory rather then allocating less memory
than required.

Fix by replacing devm_kcalloc() with devm_kzalloc() and struct_size()
macro.

Fixes: 5bc9900a ("interconnect: qcom: Add OSM L3 interconnect provider support")
Signed-off-by: NDmitry Baryshkov <dmitry.baryshkov@linaro.org>
Link: https://lore.kernel.org/r/20230105002221.1416479-2-dmitry.baryshkov@linaro.orgSigned-off-by: NGeorgi Djakov <djakov@kernel.org>
上级 fe15c26e
...@@ -236,7 +236,7 @@ static int qcom_osm_l3_probe(struct platform_device *pdev) ...@@ -236,7 +236,7 @@ static int qcom_osm_l3_probe(struct platform_device *pdev)
qnodes = desc->nodes; qnodes = desc->nodes;
num_nodes = desc->num_nodes; num_nodes = desc->num_nodes;
data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL); data = devm_kzalloc(&pdev->dev, struct_size(data, nodes, num_nodes), GFP_KERNEL);
if (!data) if (!data)
return -ENOMEM; return -ENOMEM;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册