aboutsummaryrefslogtreecommitdiffstats
path: root/drivers
diff options
context:
space:
mode:
authorGustavo A. R. Silva <gustavoars@kernel.org>2020-06-16 18:03:28 -0500
committerDavid S. Miller <davem@davemloft.net>2020-06-18 20:19:20 -0700
commit4e638025f25652b052ec54cf75e4cfe4f4663ce7 (patch)
tree9c3adb9752b29a79750c56843de08f07174246fd /drivers
parentethtool: ioctl: Use array_size() in copy_to_user() (diff)
downloadlinux-dev-4e638025f25652b052ec54cf75e4cfe4f4663ce7.tar.xz
linux-dev-4e638025f25652b052ec54cf75e4cfe4f4663ce7.zip
net: stmmac: selftests: Use struct_size() helper in kzalloc()
Make use of the struct_size() helper instead of an open-coded version in order to avoid any potential type mistakes. This code was detected with the help of Coccinelle and, audited and fixed manually. Signed-off-by: Gustavo A. R. Silva <gustavoars@kernel.org> Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers')
-rw-r--r--drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c2
1 files changed, 1 insertions, 1 deletions
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
index e6696495f126..e113b1376fdd 100644
--- a/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
+++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c
@@ -1094,7 +1094,7 @@ static int stmmac_test_rxp(struct stmmac_priv *priv)
if (!priv->dma_cap.frpsel)
return -EOPNOTSUPP;
- sel = kzalloc(sizeof(*sel) + nk * sizeof(struct tc_u32_key), GFP_KERNEL);
+ sel = kzalloc(struct_size(sel, keys, nk), GFP_KERNEL);
if (!sel)
return -ENOMEM;