Skip to contentSkip to conversation

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

PATCH Applied Alex Elder 2 participants 2 messages Mar 11, 2022 – Mar 12, 2022

Subsystems (4)
lore
Share & tools
lore

Alex Elder

author
#0 lore raw

PATCH 1/1 net: ipa: use struct_size() for the interconnect array

In review for commit 8ee7ec4890e2b ("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.

---
 drivers/net/ipa/ipa_power.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/net/ipa/ipa_power.c +2 -2
index 16ece27d14d7e..db5ac7552286e 100644
@@ -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;
Signature · 1 line
2.32.0
#1 lore raw
This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Hello:

This patch was applied to netdev/net-next.git (master) by Jakub Kicinski <[email protected]>:

Quoted 8 lines · On Fri, 11 Mar 2022 10:24:23 -0600 you wrote:

In review for commit 8ee7ec4890e2b ("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.

[...]

Here is the summary with links:
- [net-next,1/1] net: ipa: use struct_size() for the interconnect array

    https://git.kernel.org/netdev/net-next/c/cb631a639819

You are awesome, thank you!

Signature · 2 lines
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html