summaryrefslogtreecommitdiff
path: root/net
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-21 23:46:04 -0800
committerLinus Torvalds <torvalds@linux-foundation.org>2026-02-22 08:26:33 -0800
commit189f164e573e18d9f8876dbd3ad8fcbe11f93037 (patch)
tree733382723a15ea29b7c9f3dde3bcb281f0b3c287 /net
parent32a92f8c89326985e05dce8b22d3f0aa07a3e1bd (diff)
Convert remaining multi-line kmalloc_obj/flex GFP_KERNEL usesHEADtorvalds/mastertorvalds/HEADmaster
Conversion performed via this Coccinelle script: // SPDX-License-Identifier: GPL-2.0-only // Options: --include-headers-for-types --all-includes --include-headers --keep-comments virtual patch @gfp depends on patch && !(file in "tools") && !(file in "samples")@ identifier ALLOC = {kmalloc_obj,kmalloc_objs,kmalloc_flex, kzalloc_obj,kzalloc_objs,kzalloc_flex, kvmalloc_obj,kvmalloc_objs,kvmalloc_flex, kvzalloc_obj,kvzalloc_objs,kvzalloc_flex}; @@ ALLOC(... - , GFP_KERNEL ) $ make coccicheck MODE=patch COCCI=gfp.cocci Build and boot tested x86_64 with Fedora 42's GCC and Clang: Linux version 6.19.0+ (user@host) (gcc (GCC) 15.2.1 20260123 (Red Hat 15.2.1-7), GNU ld version 2.44-12.fc42) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Linux version 6.19.0+ (user@host) (clang version 20.1.8 (Fedora 20.1.8-4.fc42), LLD 20.1.8) #1 SMP PREEMPT_DYNAMIC 1970-01-01 Signed-off-by: Kees Cook <kees@kernel.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'net')
-rw-r--r--net/bridge/br_mdb.c2
-rw-r--r--net/core/devmem.c6
-rw-r--r--net/ipv4/cipso_ipv4.c2
-rw-r--r--net/ipv4/devinet.c2
-rw-r--r--net/ipv4/nexthop.c2
-rw-r--r--net/ipv4/udp_tunnel_nic.c3
-rw-r--r--net/ipv6/addrconf.c2
-rw-r--r--net/ipv6/calipso.c2
-rw-r--r--net/mac80211/cfg.c4
-rw-r--r--net/mac80211/main.c2
-rw-r--r--net/netfilter/ipvs/ip_vs_mh.c2
-rw-r--r--net/netfilter/nf_tables_api.c2
-rw-r--r--net/netfilter/nfnetlink_cthelper.c2
-rw-r--r--net/sched/sch_htb.c3
-rw-r--r--net/smc/smc_wr.c8
-rw-r--r--net/unix/af_unix.c2
-rw-r--r--net/wireless/core.c2
-rw-r--r--net/wireless/nl80211.c4
-rw-r--r--net/xdp/xsk_buff_pool.c2
-rw-r--r--net/xfrm/xfrm_iptfs.c5
20 files changed, 27 insertions, 32 deletions
diff --git a/net/bridge/br_mdb.c b/net/bridge/br_mdb.c
index a5f0b74b59f3..e0c7020b12f5 100644
--- a/net/bridge/br_mdb.c
+++ b/net/bridge/br_mdb.c
@@ -1134,7 +1134,7 @@ static int br_mdb_config_src_list_init(struct nlattr *src_list,
}
cfg->src_entries = kzalloc_objs(struct br_mdb_src_entry,
- cfg->num_src_entries, GFP_KERNEL);
+ cfg->num_src_entries);
if (!cfg->src_entries)
return -ENOMEM;
diff --git a/net/core/devmem.c b/net/core/devmem.c
index 16a1949dbed1..8c9aad776bf4 100644
--- a/net/core/devmem.c
+++ b/net/core/devmem.c
@@ -242,8 +242,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
if (direction == DMA_TO_DEVICE) {
binding->tx_vec = kvmalloc_objs(struct net_iov *,
- dmabuf->size / PAGE_SIZE,
- GFP_KERNEL);
+ dmabuf->size / PAGE_SIZE);
if (!binding->tx_vec) {
err = -ENOMEM;
goto err_unmap;
@@ -290,8 +289,7 @@ net_devmem_bind_dmabuf(struct net_device *dev,
}
owner->area.niovs = kvmalloc_objs(*owner->area.niovs,
- owner->area.num_niovs,
- GFP_KERNEL);
+ owner->area.num_niovs);
if (!owner->area.niovs) {
err = -ENOMEM;
goto err_free_chunks;
diff --git a/net/ipv4/cipso_ipv4.c b/net/ipv4/cipso_ipv4.c
index 3fb181a3f3c0..a05aa075de1a 100644
--- a/net/ipv4/cipso_ipv4.c
+++ b/net/ipv4/cipso_ipv4.c
@@ -169,7 +169,7 @@ static int __init cipso_v4_cache_init(void)
u32 iter;
cipso_v4_cache = kzalloc_objs(struct cipso_v4_map_cache_bkt,
- CIPSO_V4_CACHE_BUCKETS, GFP_KERNEL);
+ CIPSO_V4_CACHE_BUCKETS);
if (!cipso_v4_cache)
return -ENOMEM;
diff --git a/net/ipv4/devinet.c b/net/ipv4/devinet.c
index 8f4190c7c9ab..537bb6c315d2 100644
--- a/net/ipv4/devinet.c
+++ b/net/ipv4/devinet.c
@@ -2755,7 +2755,7 @@ static __net_init int devinet_init_net(struct net *net)
err = -ENOMEM;
net->ipv4.inet_addr_lst = kmalloc_objs(struct hlist_head,
- IN4_ADDR_HSIZE, GFP_KERNEL);
+ IN4_ADDR_HSIZE);
if (!net->ipv4.inet_addr_lst)
goto err_alloc_hash;
diff --git a/net/ipv4/nexthop.c b/net/ipv4/nexthop.c
index defe6b30f18f..1aa2b05ee8de 100644
--- a/net/ipv4/nexthop.c
+++ b/net/ipv4/nexthop.c
@@ -714,7 +714,7 @@ static int nh_notifier_grp_hw_stats_init(struct nh_notifier_info *info,
info->id = nh->id;
info->type = NH_NOTIFIER_INFO_TYPE_GRP_HW_STATS;
info->nh_grp_hw_stats = kzalloc_flex(*info->nh_grp_hw_stats, stats,
- nhg->num_nh, GFP_KERNEL);
+ nhg->num_nh);
if (!info->nh_grp_hw_stats)
return -ENOMEM;
diff --git a/net/ipv4/udp_tunnel_nic.c b/net/ipv4/udp_tunnel_nic.c
index 9716e98b9291..9944ed923ddf 100644
--- a/net/ipv4/udp_tunnel_nic.c
+++ b/net/ipv4/udp_tunnel_nic.c
@@ -762,8 +762,7 @@ udp_tunnel_nic_alloc(const struct udp_tunnel_nic_info *info,
for (i = 0; i < n_tables; i++) {
utn->entries[i] = kzalloc_objs(*utn->entries[i],
- info->tables[i].n_entries,
- GFP_KERNEL);
+ info->tables[i].n_entries);
if (!utn->entries[i])
goto err_free_prev_entries;
}
diff --git a/net/ipv6/addrconf.c b/net/ipv6/addrconf.c
index 9f48b0f210e6..0e55f139e05d 100644
--- a/net/ipv6/addrconf.c
+++ b/net/ipv6/addrconf.c
@@ -7398,7 +7398,7 @@ static int __net_init addrconf_init_net(struct net *net)
spin_lock_init(&net->ipv6.addrconf_hash_lock);
INIT_DEFERRABLE_WORK(&net->ipv6.addr_chk_work, addrconf_verify_work);
net->ipv6.inet6_addr_lst = kzalloc_objs(struct hlist_head,
- IN6_ADDR_HSIZE, GFP_KERNEL);
+ IN6_ADDR_HSIZE);
if (!net->ipv6.inet6_addr_lst)
goto err_alloc_addr;
diff --git a/net/ipv6/calipso.c b/net/ipv6/calipso.c
index ff39220fef8a..c6a34334e657 100644
--- a/net/ipv6/calipso.c
+++ b/net/ipv6/calipso.c
@@ -134,7 +134,7 @@ static int __init calipso_cache_init(void)
u32 iter;
calipso_cache = kzalloc_objs(struct calipso_map_cache_bkt,
- CALIPSO_CACHE_BUCKETS, GFP_KERNEL);
+ CALIPSO_CACHE_BUCKETS);
if (!calipso_cache)
return -ENOMEM;
diff --git a/net/mac80211/cfg.c b/net/mac80211/cfg.c
index 8b76525c56ee..b92b4a5c2636 100644
--- a/net/mac80211/cfg.c
+++ b/net/mac80211/cfg.c
@@ -3941,7 +3941,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
if (beacon->mbssid_ies && beacon->mbssid_ies->cnt) {
new_beacon->mbssid_ies =
kzalloc_flex(*new_beacon->mbssid_ies, elem,
- beacon->mbssid_ies->cnt, GFP_KERNEL);
+ beacon->mbssid_ies->cnt);
if (!new_beacon->mbssid_ies) {
kfree(new_beacon);
return NULL;
@@ -3950,7 +3950,7 @@ cfg80211_beacon_dup(struct cfg80211_beacon_data *beacon)
if (beacon->rnr_ies && beacon->rnr_ies->cnt) {
new_beacon->rnr_ies =
kzalloc_flex(*new_beacon->rnr_ies, elem,
- beacon->rnr_ies->cnt, GFP_KERNEL);
+ beacon->rnr_ies->cnt);
if (!new_beacon->rnr_ies) {
kfree(new_beacon->mbssid_ies);
kfree(new_beacon);
diff --git a/net/mac80211/main.c b/net/mac80211/main.c
index 9825d7c70cbc..616f86b1a7e4 100644
--- a/net/mac80211/main.c
+++ b/net/mac80211/main.c
@@ -1360,7 +1360,7 @@ int ieee80211_register_hw(struct ieee80211_hw *hw)
local->int_scan_req = kzalloc_flex(*local->int_scan_req, channels,
- channels, GFP_KERNEL);
+ channels);
if (!local->int_scan_req)
return -ENOMEM;
diff --git a/net/netfilter/ipvs/ip_vs_mh.c b/net/netfilter/ipvs/ip_vs_mh.c
index 06dece1fb9ee..020863047562 100644
--- a/net/netfilter/ipvs/ip_vs_mh.c
+++ b/net/netfilter/ipvs/ip_vs_mh.c
@@ -294,7 +294,7 @@ static int ip_vs_mh_reassign(struct ip_vs_mh_state *s,
if (svc->num_dests >= 1) {
s->dest_setup = kzalloc_objs(struct ip_vs_mh_dest_setup,
- svc->num_dests, GFP_KERNEL);
+ svc->num_dests);
if (!s->dest_setup)
return -ENOMEM;
}
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c
index 06bd4d6eefeb..fd7f7e4e2a43 100644
--- a/net/netfilter/nf_tables_api.c
+++ b/net/netfilter/nf_tables_api.c
@@ -4316,7 +4316,7 @@ static int nf_tables_newrule(struct sk_buff *skb, const struct nfnl_info *info,
size = 0;
if (nla[NFTA_RULE_EXPRESSIONS]) {
expr_info = kvmalloc_objs(struct nft_expr_info,
- NFT_RULE_MAXEXPRS, GFP_KERNEL);
+ NFT_RULE_MAXEXPRS);
if (!expr_info)
return -ENOMEM;
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c
index dbc54a3b7074..d658b1478fa0 100644
--- a/net/netfilter/nfnetlink_cthelper.c
+++ b/net/netfilter/nfnetlink_cthelper.c
@@ -193,7 +193,7 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper,
return -EOVERFLOW;
expect_policy = kzalloc_objs(struct nf_conntrack_expect_policy,
- class_max, GFP_KERNEL);
+ class_max);
if (expect_policy == NULL)
return -ENOMEM;
diff --git a/net/sched/sch_htb.c b/net/sched/sch_htb.c
index 0926a9ccfa2d..cf6cd4ccfa20 100644
--- a/net/sched/sch_htb.c
+++ b/net/sched/sch_htb.c
@@ -1096,8 +1096,7 @@ static int htb_init(struct Qdisc *sch, struct nlattr *opt,
q->num_direct_qdiscs = dev->real_num_tx_queues;
q->direct_qdiscs = kzalloc_objs(*q->direct_qdiscs,
- q->num_direct_qdiscs,
- GFP_KERNEL);
+ q->num_direct_qdiscs);
if (!q->direct_qdiscs)
return -ENOMEM;
}
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c
index c9f999ae10e0..59c92b46945c 100644
--- a/net/smc/smc_wr.c
+++ b/net/smc/smc_wr.c
@@ -756,11 +756,11 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
if (!link->wr_rx_ibs)
goto no_mem_wr_tx_ibs;
link->wr_tx_rdmas = kzalloc_objs(link->wr_tx_rdmas[0],
- link->max_send_wr, GFP_KERNEL);
+ link->max_send_wr);
if (!link->wr_tx_rdmas)
goto no_mem_wr_rx_ibs;
link->wr_tx_rdma_sges = kzalloc_objs(link->wr_tx_rdma_sges[0],
- link->max_send_wr, GFP_KERNEL);
+ link->max_send_wr);
if (!link->wr_tx_rdma_sges)
goto no_mem_wr_tx_rdmas;
link->wr_tx_sges = kzalloc_objs(link->wr_tx_sges[0], link->max_send_wr);
@@ -775,11 +775,11 @@ int smc_wr_alloc_link_mem(struct smc_link *link)
if (!link->wr_tx_mask)
goto no_mem_wr_rx_sges;
link->wr_tx_pends = kzalloc_objs(link->wr_tx_pends[0],
- link->max_send_wr, GFP_KERNEL);
+ link->max_send_wr);
if (!link->wr_tx_pends)
goto no_mem_wr_tx_mask;
link->wr_tx_compl = kzalloc_objs(link->wr_tx_compl[0],
- link->max_send_wr, GFP_KERNEL);
+ link->max_send_wr);
if (!link->wr_tx_compl)
goto no_mem_wr_tx_pends;
diff --git a/net/unix/af_unix.c b/net/unix/af_unix.c
index 5ea834414ed5..3756a93dc63a 100644
--- a/net/unix/af_unix.c
+++ b/net/unix/af_unix.c
@@ -3803,7 +3803,7 @@ static int __net_init unix_net_init(struct net *net)
goto err_proc;
net->unx.table.buckets = kvmalloc_objs(struct hlist_head,
- UNIX_HASH_SIZE, GFP_KERNEL);
+ UNIX_HASH_SIZE);
if (!net->unx.table.buckets)
goto free_locks;
diff --git a/net/wireless/core.c b/net/wireless/core.c
index bd53317e44ef..4b0645d56344 100644
--- a/net/wireless/core.c
+++ b/net/wireless/core.c
@@ -1001,7 +1001,7 @@ int wiphy_register(struct wiphy *wiphy)
int idx;
wiphy->radio_cfg = kzalloc_objs(*wiphy->radio_cfg,
- wiphy->n_radio, GFP_KERNEL);
+ wiphy->n_radio);
if (!wiphy->radio_cfg)
return -ENOMEM;
/*
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c
index 2ea72c64b405..b94231c8441c 100644
--- a/net/wireless/nl80211.c
+++ b/net/wireless/nl80211.c
@@ -14308,7 +14308,7 @@ static int nl80211_set_cqm_rssi(struct genl_info *info,
if (n_thresholds) {
cqm_config = kzalloc_flex(*cqm_config, rssi_thresholds,
- n_thresholds, GFP_KERNEL);
+ n_thresholds);
if (!cqm_config)
return -ENOMEM;
@@ -15051,7 +15051,7 @@ static int nl80211_set_wowlan(struct sk_buff *skb, struct genl_info *info)
return -EINVAL;
new_triggers.patterns = kzalloc_objs(new_triggers.patterns[0],
- n_patterns, GFP_KERNEL);
+ n_patterns);
if (!new_triggers.patterns)
return -ENOMEM;
diff --git a/net/xdp/xsk_buff_pool.c b/net/xdp/xsk_buff_pool.c
index 281e7af2c50b..37b7a68b89b3 100644
--- a/net/xdp/xsk_buff_pool.c
+++ b/net/xdp/xsk_buff_pool.c
@@ -420,7 +420,7 @@ static int xp_init_dma_info(struct xsk_buff_pool *pool, struct xsk_dma_map *dma_
}
pool->dma_pages = kvzalloc_objs(*pool->dma_pages,
- dma_map->dma_pages_cnt, GFP_KERNEL);
+ dma_map->dma_pages_cnt);
if (!pool->dma_pages)
return -ENOMEM;
diff --git a/net/xfrm/xfrm_iptfs.c b/net/xfrm/xfrm_iptfs.c
index 5c9e56e525f2..050a82101ca5 100644
--- a/net/xfrm/xfrm_iptfs.c
+++ b/net/xfrm/xfrm_iptfs.c
@@ -2527,7 +2527,7 @@ static int iptfs_user_init(struct net *net, struct xfrm_state *x,
/* saved array is for saving 1..N seq nums from wantseq */
if (xc->reorder_win_size) {
xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
- xc->reorder_win_size, GFP_KERNEL);
+ xc->reorder_win_size);
if (!xtfs->w_saved) {
NL_SET_ERR_MSG(extack, "Cannot alloc reorder window");
return -ENOMEM;
@@ -2659,8 +2659,7 @@ static int iptfs_clone_state(struct xfrm_state *x, struct xfrm_state *orig)
xtfs->ra_newskb = NULL;
if (xtfs->cfg.reorder_win_size) {
xtfs->w_saved = kzalloc_objs(*xtfs->w_saved,
- xtfs->cfg.reorder_win_size,
- GFP_KERNEL);
+ xtfs->cfg.reorder_win_size);
if (!xtfs->w_saved) {
kfree_sensitive(xtfs);
return -ENOMEM;