* [PATCH net-next] net: airoha: Fix a copy and paste bug in probe()
@ 2025-10-24 11:23 Dan Carpenter
2025-10-24 12:22 ` Lorenzo Bianconi
2025-10-28 1:20 ` patchwork-bot+netdevbpf
0 siblings, 2 replies; 3+ messages in thread
From: Dan Carpenter @ 2025-10-24 11:23 UTC (permalink / raw)
To: Lorenzo Bianconi
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Christian Marangi, linux-arm-kernel,
linux-mediatek, netdev, linux-kernel, kernel-janitors
This code has a copy and paste bug where it accidentally checks "if (err)"
instead of checking if "xsi_rsts" is NULL. Also, as a free bonus, I
changed the allocation from kzalloc() to kcalloc() which is a kernel
hardening measure to protect against integer overflows.
Fixes: 5863b4e065e2 ("net: airoha: Add airoha_eth_soc_data struct")
Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
---
drivers/net/ethernet/airoha/airoha_eth.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
index 8483ea02603e..d0ef64a87396 100644
--- a/drivers/net/ethernet/airoha/airoha_eth.c
+++ b/drivers/net/ethernet/airoha/airoha_eth.c
@@ -2985,11 +2985,11 @@ static int airoha_probe(struct platform_device *pdev)
return err;
}
- xsi_rsts = devm_kzalloc(eth->dev,
- eth->soc->num_xsi_rsts * sizeof(*xsi_rsts),
+ xsi_rsts = devm_kcalloc(eth->dev,
+ eth->soc->num_xsi_rsts, sizeof(*xsi_rsts),
GFP_KERNEL);
- if (err)
- return err;
+ if (!xsi_rsts)
+ return -ENOMEM;
eth->xsi_rsts = xsi_rsts;
for (i = 0; i < eth->soc->num_xsi_rsts; i++)
--
2.51.0
^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: Fix a copy and paste bug in probe()
2025-10-24 11:23 [PATCH net-next] net: airoha: Fix a copy and paste bug in probe() Dan Carpenter
@ 2025-10-24 12:22 ` Lorenzo Bianconi
2025-10-28 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: Lorenzo Bianconi @ 2025-10-24 12:22 UTC (permalink / raw)
To: Dan Carpenter
Cc: Andrew Lunn, David S. Miller, Eric Dumazet, Jakub Kicinski,
Paolo Abeni, Simon Horman, Christian Marangi, linux-arm-kernel,
linux-mediatek, netdev, linux-kernel, kernel-janitors
[-- Attachment #1: Type: text/plain, Size: 1327 bytes --]
> This code has a copy and paste bug where it accidentally checks "if (err)"
> instead of checking if "xsi_rsts" is NULL. Also, as a free bonus, I
> changed the allocation from kzalloc() to kcalloc() which is a kernel
> hardening measure to protect against integer overflows.
>
> Fixes: 5863b4e065e2 ("net: airoha: Add airoha_eth_soc_data struct")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
Acked-by: Lorenzo Bianconi <lorenzo@kernel.org>
> ---
> drivers/net/ethernet/airoha/airoha_eth.c | 8 ++++----
> 1 file changed, 4 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c
> index 8483ea02603e..d0ef64a87396 100644
> --- a/drivers/net/ethernet/airoha/airoha_eth.c
> +++ b/drivers/net/ethernet/airoha/airoha_eth.c
> @@ -2985,11 +2985,11 @@ static int airoha_probe(struct platform_device *pdev)
> return err;
> }
>
> - xsi_rsts = devm_kzalloc(eth->dev,
> - eth->soc->num_xsi_rsts * sizeof(*xsi_rsts),
> + xsi_rsts = devm_kcalloc(eth->dev,
> + eth->soc->num_xsi_rsts, sizeof(*xsi_rsts),
> GFP_KERNEL);
> - if (err)
> - return err;
> + if (!xsi_rsts)
> + return -ENOMEM;
>
> eth->xsi_rsts = xsi_rsts;
> for (i = 0; i < eth->soc->num_xsi_rsts; i++)
> --
> 2.51.0
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 228 bytes --]
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH net-next] net: airoha: Fix a copy and paste bug in probe()
2025-10-24 11:23 [PATCH net-next] net: airoha: Fix a copy and paste bug in probe() Dan Carpenter
2025-10-24 12:22 ` Lorenzo Bianconi
@ 2025-10-28 1:20 ` patchwork-bot+netdevbpf
1 sibling, 0 replies; 3+ messages in thread
From: patchwork-bot+netdevbpf @ 2025-10-28 1:20 UTC (permalink / raw)
To: Dan Carpenter
Cc: lorenzo, andrew+netdev, davem, edumazet, kuba, pabeni, horms,
ansuelsmth, linux-arm-kernel, linux-mediatek, netdev,
linux-kernel, kernel-janitors
Hello:
This patch was applied to netdev/net-next.git (main)
by Jakub Kicinski <kuba@kernel.org>:
On Fri, 24 Oct 2025 14:23:35 +0300 you wrote:
> This code has a copy and paste bug where it accidentally checks "if (err)"
> instead of checking if "xsi_rsts" is NULL. Also, as a free bonus, I
> changed the allocation from kzalloc() to kcalloc() which is a kernel
> hardening measure to protect against integer overflows.
>
> Fixes: 5863b4e065e2 ("net: airoha: Add airoha_eth_soc_data struct")
> Signed-off-by: Dan Carpenter <dan.carpenter@linaro.org>
>
> [...]
Here is the summary with links:
- [net-next] net: airoha: Fix a copy and paste bug in probe()
https://git.kernel.org/netdev/net-next/c/05e090620bac
You are awesome, thank you!
--
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2025-10-28 1:21 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-10-24 11:23 [PATCH net-next] net: airoha: Fix a copy and paste bug in probe() Dan Carpenter
2025-10-24 12:22 ` Lorenzo Bianconi
2025-10-28 1:20 ` patchwork-bot+netdevbpf
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).