]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
net: airoha: Fix a copy and paste bug in probe()
authorDan Carpenter <dan.carpenter@linaro.org>
Fri, 24 Oct 2025 11:23:35 +0000 (14:23 +0300)
committerJakub Kicinski <kuba@kernel.org>
Tue, 28 Oct 2025 01:03:30 +0000 (18:03 -0700)
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>
Link: https://patch.msgid.link/aPtht6y5DRokn9zv@stanley.mountain
Signed-off-by: Jakub Kicinski <kuba@kernel.org>
drivers/net/ethernet/airoha/airoha_eth.c

index e17a285a9e8fa7b4b4c1433240f2bb82401bcb9b..688faf999e4c0a30d53a25877b4a81a33ec7fca2 100644 (file)
@@ -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++)