net: stmmac: selftests: Use struct_size() in kzalloc()
Subsystems (4)
PATCH 1/1 net: stmmac: selftests: Use struct_size() 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.
Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by Gustavo A. R. Silva <[email protected]>
--- drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c +1 -1
@@ -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 ;
Signature · 1 line
2.27.0
David Miller
maintainerFrom: "Gustavo A. R. Silva" <[email protected]>
Date: Fri, 19 Jun 2020 12:41:54 -0500
Quoted 8 lines
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.
Addresses-KSPP-ID: https://github.com/KSPP/linux/issues/83
Signed-off-by Gustavo A. R. Silva <[email protected]>
This doesn't apply to net-next.