Skip to content

Commit 83c774f

Browse files
cdleonardGeorgi Djakov
authored andcommitted
interconnect: qcom: 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. This allocates too much memory at probe time but shouldn't have any noticeable effect. Both sdm845 and qcs404 are affected. Fix by replacing kcalloc with kzalloc and using the "struct_size" macro. Signed-off-by: Leonard Crestez <[email protected]> Fixes: 5e4e6c4 ("interconnect: qcom: Add QCS404 interconnect provider driver") Link: https://lore.kernel.org/linux-pm/a7360abb6561917e30bbfaa6084578449152bf1d.1569348056.git.leonard.crestez@nxp.com/ Signed-off-by: Georgi Djakov <[email protected]>
1 parent 4f5cafb commit 83c774f

File tree

2 files changed

+4
-2
lines changed

2 files changed

+4
-2
lines changed

drivers/interconnect/qcom/qcs404.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -433,7 +433,8 @@ static int qnoc_probe(struct platform_device *pdev)
433433
if (!qp)
434434
return -ENOMEM;
435435

436-
data = devm_kcalloc(dev, num_nodes, sizeof(*node), GFP_KERNEL);
436+
data = devm_kzalloc(dev, struct_size(data, nodes, num_nodes),
437+
GFP_KERNEL);
437438
if (!data)
438439
return -ENOMEM;
439440

drivers/interconnect/qcom/sdm845.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -790,7 +790,8 @@ static int qnoc_probe(struct platform_device *pdev)
790790
if (!qp)
791791
return -ENOMEM;
792792

793-
data = devm_kcalloc(&pdev->dev, num_nodes, sizeof(*node), GFP_KERNEL);
793+
data = devm_kzalloc(&pdev->dev, struct_size(data, nodes, num_nodes),
794+
GFP_KERNEL);
794795
if (!data)
795796
return -ENOMEM;
796797

0 commit comments

Comments
 (0)