Skip to content

Commit 4e63802

Browse files
GustavoARSilvadavem330
authored andcommitted
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>
1 parent 3dd1499 commit 4e63802

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

drivers/net/ethernet/stmicro/stmmac/stmmac_selftests.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ static int stmmac_test_rxp(struct stmmac_priv *priv)
10941094
if (!priv->dma_cap.frpsel)
10951095
return -EOPNOTSUPP;
10961096

1097-
sel = kzalloc(sizeof(*sel) + nk * sizeof(struct tc_u32_key), GFP_KERNEL);
1097+
sel = kzalloc(struct_size(sel, keys, nk), GFP_KERNEL);
10981098
if (!sel)
10991099
return -ENOMEM;
11001100

0 commit comments

Comments
 (0)