提交 cb631a63 编写于 作者: A Alex Elder 提交者: Jakub Kicinski

net: ipa: use struct_size() for the interconnect array

In review for commit 8ee7ec48 ("net: ipa: embed interconnect
array in the power structure"), Jakub Kicinski suggested that a
follow-up patch use struct_size() when computing the size of the
IPA power structure, which ends with a flexible array member.

Do that.
Suggested-by: NJakub Kicinski <kuba@kernel.org>
Signed-off-by: NAlex Elder <elder@linaro.org>
Link: https://lore.kernel.org/r/20220311162423.872645-1-elder@linaro.orgSigned-off-by: NJakub Kicinski <kuba@kernel.org>
上级 0b366069
......@@ -374,8 +374,8 @@ ipa_power_init(struct device *dev, const struct ipa_power_data *data)
goto err_clk_put;
}
size = data->interconnect_count * sizeof(power->interconnect[0]);
power = kzalloc(sizeof(*power) + size, GFP_KERNEL);
size = struct_size(power, interconnect, data->interconnect_count);
power = kzalloc(size, GFP_KERNEL);
if (!power) {
ret = -ENOMEM;
goto err_clk_put;
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册