From: Dan Carpenter Date: Fri, 24 Oct 2025 11:23:35 +0000 (+0300) Subject: net: airoha: Fix a copy and paste bug in probe() X-Git-Tag: v6.19-rc1~170^2~306 X-Git-Url: http://git.ipfire.org/?a=commitdiff_plain;h=05e090620bacf317020f9591cfff8926093380bd;p=thirdparty%2Fkernel%2Flinux.git net: airoha: Fix a copy and paste bug in probe() 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 Acked-by: Lorenzo Bianconi Link: https://patch.msgid.link/aPtht6y5DRokn9zv@stanley.mountain Signed-off-by: Jakub Kicinski --- diff --git a/drivers/net/ethernet/airoha/airoha_eth.c b/drivers/net/ethernet/airoha/airoha_eth.c index e17a285a9e8fa..688faf999e4c0 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++)