From: Lorenzo Bianconi <lorenzo@kernel.org>
To: Dan Carpenter <dan.carpenter@linaro.org>
Cc: Andrew Lunn <andrew+netdev@lunn.ch>,
"David S. Miller" <davem@davemloft.net>,
Eric Dumazet <edumazet@google.com>,
Jakub Kicinski <kuba@kernel.org>, Paolo Abeni <pabeni@redhat.com>,
Simon Horman <horms@kernel.org>,
Christian Marangi <ansuelsmth@gmail.com>,
linux-arm-kernel@lists.infradead.org,
linux-mediatek@lists.infradead.org, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, kernel-janitors@vger.kernel.org
Subject: Re: [PATCH net-next] net: airoha: Fix a copy and paste bug in probe()
Date: Fri, 24 Oct 2025 14:22:35 +0200 [thread overview]
Message-ID: <aPtvi1hwDKOZH3vB@lore-desk> (raw)
In-Reply-To: <aPtht6y5DRokn9zv@stanley.mountain>
[-- 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 --]
next prev parent reply other threads:[~2025-10-24 12:22 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
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 [this message]
2025-10-28 1:20 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aPtvi1hwDKOZH3vB@lore-desk \
--to=lorenzo@kernel.org \
--cc=andrew+netdev@lunn.ch \
--cc=ansuelsmth@gmail.com \
--cc=dan.carpenter@linaro.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=horms@kernel.org \
--cc=kernel-janitors@vger.kernel.org \
--cc=kuba@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mediatek@lists.infradead.org \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).