From: Pablo Neira Ayuso <pablo@netfilter.org>
To: netfilter-devel@vger.kernel.org
Cc: davem@davemloft.net, netdev@vger.kernel.org, kuba@kernel.org,
pabeni@redhat.com, edumazet@google.com, fw@strlen.de,
horms@kernel.org
Subject: [PATCH net-next 7/7] ipvs: use type-safe allocation helpers in ip_vs_rht_alloc
Date: Fri, 24 Jul 2026 12:49:32 +0200 [thread overview]
Message-ID: <20260724104932.437729-8-pablo@netfilter.org> (raw)
In-Reply-To: <20260724104932.437729-1-pablo@netfilter.org>
From: Subasri S <subasris1210@gmail.com>
As per Documentation/process/deprecated.rst, open-coded kmalloc
assignments for struct objects are deprecated. Replace
kzalloc(sizeof(*ptr), GFP_KERNEL) with kzalloc_obj() and
kvmalloc_array(n, sizeof(*ptr), GFP_KERNEL) with kvmalloc_objs()
in ip_vs_rht_alloc().
Compile tested with CONFIG_IP_VS=y and runtime tested using
tools/testing/selftests/net/netfilter/ipvs.sh on x86_64/QEMU.
Signed-off-by: Subasri S <subasris1210@gmail.com>
Reviewed-by: Phil Sutter <phil@nwl.cc>
Acked-by: Julian Anastasov <ja@ssi.bg>
Signed-off-by: Pablo Neira Ayuso <pablo@netfilter.org>
---
net/netfilter/ipvs/ip_vs_core.c | 9 ++++-----
1 file changed, 4 insertions(+), 5 deletions(-)
diff --git a/net/netfilter/ipvs/ip_vs_core.c b/net/netfilter/ipvs/ip_vs_core.c
index bafab93451d0..a896bfb53f07 100644
--- a/net/netfilter/ipvs/ip_vs_core.c
+++ b/net/netfilter/ipvs/ip_vs_core.c
@@ -176,7 +176,7 @@ void ip_vs_rht_rcu_free(struct rcu_head *head)
struct ip_vs_rht *ip_vs_rht_alloc(int buckets, int scounts, int locks)
{
- struct ip_vs_rht *t = kzalloc(sizeof(*t), GFP_KERNEL);
+ struct ip_vs_rht *t = kzalloc_obj(*t);
int i;
if (!t)
@@ -186,7 +186,7 @@ struct ip_vs_rht *ip_vs_rht_alloc(int buckets, int scounts, int locks)
scounts = min(scounts, buckets);
scounts = min(scounts, ml);
- t->seqc = kvmalloc_array(scounts, sizeof(*t->seqc), GFP_KERNEL);
+ t->seqc = kvmalloc_objs(*t->seqc, scounts);
if (!t->seqc)
goto err;
for (i = 0; i < scounts; i++)
@@ -194,8 +194,7 @@ struct ip_vs_rht *ip_vs_rht_alloc(int buckets, int scounts, int locks)
if (locks) {
locks = min(locks, scounts);
- t->lock = kvmalloc_array(locks, sizeof(*t->lock),
- GFP_KERNEL);
+ t->lock = kvmalloc_objs(*t->lock, locks);
if (!t->lock)
goto err;
for (i = 0; i < locks; i++)
@@ -203,7 +202,7 @@ struct ip_vs_rht *ip_vs_rht_alloc(int buckets, int scounts, int locks)
}
}
- t->buckets = kvmalloc_array(buckets, sizeof(*t->buckets), GFP_KERNEL);
+ t->buckets = kvmalloc_objs(*t->buckets, buckets);
if (!t->buckets)
goto err;
for (i = 0; i < buckets; i++)
--
2.47.3
prev parent reply other threads:[~2026-07-24 10:49 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-24 10:49 [PATCH net-next 0/7] Netfilter/IPVS updates for net-next Pablo Neira Ayuso
2026-07-24 10:49 ` [PATCH net-next 1/7] ipvs: Move defense_work and est_reload_work to system_dfl_long_wq Pablo Neira Ayuso
2026-07-28 1:10 ` patchwork-bot+netdevbpf
2026-07-24 10:49 ` [PATCH net-next 2/7] netfilter: xt_tcpmss: extend checkentry to ipv6 Pablo Neira Ayuso
2026-07-24 10:49 ` [PATCH net-next 3/7] netfilter: nf_nat_sip: rewind offset when NAT shrinks the packet Pablo Neira Ayuso
2026-07-24 10:49 ` [PATCH net-next 4/7] netfilter: flowtable: tear down flow entries with stale dst from GC Pablo Neira Ayuso
2026-07-24 10:49 ` [PATCH net-next 5/7] netfilter: conntrack_helper: pass master conntrack to helper functions Pablo Neira Ayuso
2026-07-24 10:49 ` [PATCH net-next 6/7] netfilter: nf_conntrack_expect: store event cache in expectation Pablo Neira Ayuso
2026-07-24 10:49 ` Pablo Neira Ayuso [this message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260724104932.437729-8-pablo@netfilter.org \
--to=pablo@netfilter.org \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=fw@strlen.de \
--cc=horms@kernel.org \
--cc=kuba@kernel.org \
--cc=netdev@vger.kernel.org \
--cc=netfilter-devel@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.