Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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 <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>

authored by

Dan Carpenter and committed by
Jakub Kicinski
05e09062 bbfa5e7c

+4 -4
+4 -4
drivers/net/ethernet/airoha/airoha_eth.c
··· 2985 2985 return err; 2986 2986 } 2987 2987 2988 - xsi_rsts = devm_kzalloc(eth->dev, 2989 - eth->soc->num_xsi_rsts * sizeof(*xsi_rsts), 2988 + xsi_rsts = devm_kcalloc(eth->dev, 2989 + eth->soc->num_xsi_rsts, sizeof(*xsi_rsts), 2990 2990 GFP_KERNEL); 2991 - if (err) 2992 - return err; 2991 + if (!xsi_rsts) 2992 + return -ENOMEM; 2993 2993 2994 2994 eth->xsi_rsts = xsi_rsts; 2995 2995 for (i = 0; i < eth->soc->num_xsi_rsts; i++)