summaryrefslogtreecommitdiff
path: root/drivers/net/macsec.c
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/net/macsec.c
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
This is the result of running the Coccinelle script from scripts/coccinelle/api/kmalloc_objs.cocci. The script is designed to avoid scalar types (which need careful case-by-case checking), and instead replace kmalloc-family calls that allocate struct or union object instances: Single allocations: kmalloc(sizeof(TYPE), ...) are replaced with: kmalloc_obj(TYPE, ...) Array allocations: kmalloc_array(COUNT, sizeof(TYPE), ...) are replaced with: kmalloc_objs(TYPE, COUNT, ...) Flex array allocations: kmalloc(struct_size(PTR, FAM, COUNT), ...) are replaced with: kmalloc_flex(*PTR, FAM, COUNT, ...) (where TYPE may also be *VAR) The resulting allocations no longer return "void *", instead returning "TYPE *". Signed-off-by: Kees Cook <kees@kernel.org>
Diffstat (limited to 'drivers/net/macsec.c')
-rw-r--r--drivers/net/macsec.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/net/macsec.c b/drivers/net/macsec.c
index c2cb2d20976b..1b523a56e7da 100644
--- a/drivers/net/macsec.c
+++ b/drivers/net/macsec.c
@@ -1465,7 +1465,7 @@ static struct macsec_rx_sc *create_rx_sc(struct net_device *dev, sci_t sci,
return ERR_PTR(-EEXIST);
}
- rx_sc = kzalloc(sizeof(*rx_sc), GFP_KERNEL);
+ rx_sc = kzalloc_obj(*rx_sc, GFP_KERNEL);
if (!rx_sc)
return ERR_PTR(-ENOMEM);
@@ -1797,7 +1797,7 @@ static int macsec_add_rxsa(struct sk_buff *skb, struct genl_info *info)
return -EBUSY;
}
- rx_sa = kmalloc(sizeof(*rx_sa), GFP_KERNEL);
+ rx_sa = kmalloc_obj(*rx_sa, GFP_KERNEL);
if (!rx_sa) {
rtnl_unlock();
return -ENOMEM;
@@ -2005,7 +2005,7 @@ static int macsec_add_txsa(struct sk_buff *skb, struct genl_info *info)
return -EBUSY;
}
- tx_sa = kmalloc(sizeof(*tx_sa), GFP_KERNEL);
+ tx_sa = kmalloc_obj(*tx_sa, GFP_KERNEL);
if (!tx_sa) {
rtnl_unlock();
return -ENOMEM;
@@ -4013,7 +4013,7 @@ static int register_macsec_dev(struct net_device *real_dev,
if (!rxd) {
int err;
- rxd = kmalloc(sizeof(*rxd), GFP_KERNEL);
+ rxd = kmalloc_obj(*rxd, GFP_KERNEL);
if (!rxd)
return -ENOMEM;