summaryrefslogtreecommitdiff
path: root/net/rxrpc
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 /net/rxrpc
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 'net/rxrpc')
-rw-r--r--net/rxrpc/call_accept.c2
-rw-r--r--net/rxrpc/conn_client.c2
-rw-r--r--net/rxrpc/conn_object.c2
-rw-r--r--net/rxrpc/key.c6
-rw-r--r--net/rxrpc/local_object.c2
-rw-r--r--net/rxrpc/peer_object.c2
-rw-r--r--net/rxrpc/rxgk.c4
-rw-r--r--net/rxrpc/rxgk_kdf.c2
-rw-r--r--net/rxrpc/rxkad.c4
-rw-r--r--net/rxrpc/rxperf.c2
-rw-r--r--net/rxrpc/sendmsg.c2
-rw-r--r--net/rxrpc/txbuf.c2
12 files changed, 16 insertions, 16 deletions
diff --git a/net/rxrpc/call_accept.c b/net/rxrpc/call_accept.c
index 00982a030744..ee2d1319e69a 100644
--- a/net/rxrpc/call_accept.c
+++ b/net/rxrpc/call_accept.c
@@ -164,7 +164,7 @@ int rxrpc_service_prealloc(struct rxrpc_sock *rx, gfp_t gfp)
struct rxrpc_backlog *b = rx->backlog;
if (!b) {
- b = kzalloc(sizeof(struct rxrpc_backlog), gfp);
+ b = kzalloc_obj(struct rxrpc_backlog, gfp);
if (!b)
return -ENOMEM;
rx->backlog = b;
diff --git a/net/rxrpc/conn_client.c b/net/rxrpc/conn_client.c
index 63bbcc567f59..9b757798dedd 100644
--- a/net/rxrpc/conn_client.c
+++ b/net/rxrpc/conn_client.c
@@ -76,7 +76,7 @@ static struct rxrpc_bundle *rxrpc_alloc_bundle(struct rxrpc_call *call,
static atomic_t rxrpc_bundle_id;
struct rxrpc_bundle *bundle;
- bundle = kzalloc(sizeof(*bundle), gfp);
+ bundle = kzalloc_obj(*bundle, gfp);
if (bundle) {
bundle->local = call->local;
bundle->peer = rxrpc_get_peer(call->peer, rxrpc_peer_get_bundle);
diff --git a/net/rxrpc/conn_object.c b/net/rxrpc/conn_object.c
index 37340becb224..0ece717db0f8 100644
--- a/net/rxrpc/conn_object.c
+++ b/net/rxrpc/conn_object.c
@@ -59,7 +59,7 @@ struct rxrpc_connection *rxrpc_alloc_connection(struct rxrpc_net *rxnet,
_enter("");
- conn = kzalloc(sizeof(struct rxrpc_connection), gfp);
+ conn = kzalloc_obj(struct rxrpc_connection, gfp);
if (conn) {
INIT_LIST_HEAD(&conn->cache_link);
timer_setup(&conn->timer, &rxrpc_connection_timer, 0);
diff --git a/net/rxrpc/key.c b/net/rxrpc/key.c
index 9fdc1f031c9d..cd65bff97a8e 100644
--- a/net/rxrpc/key.c
+++ b/net/rxrpc/key.c
@@ -75,7 +75,7 @@ static int rxrpc_preparse_xdr_rxkad(struct key_preparsed_payload *prep,
prep->quotalen = datalen + plen;
plen -= sizeof(*token);
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
return -ENOMEM;
@@ -202,7 +202,7 @@ static int rxrpc_preparse_xdr_yfs_rxgk(struct key_preparsed_payload *prep,
prep->quotalen = datalen + plen;
plen -= sizeof(*token);
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
goto nomem;
@@ -500,7 +500,7 @@ static int rxrpc_preparse(struct key_preparsed_payload *prep)
prep->quotalen = plen + sizeof(*token);
ret = -ENOMEM;
- token = kzalloc(sizeof(*token), GFP_KERNEL);
+ token = kzalloc_obj(*token, GFP_KERNEL);
if (!token)
goto error;
token->kad = kzalloc(plen, GFP_KERNEL);
diff --git a/net/rxrpc/local_object.c b/net/rxrpc/local_object.c
index a74a4b43904f..6f799b26d4d5 100644
--- a/net/rxrpc/local_object.c
+++ b/net/rxrpc/local_object.c
@@ -112,7 +112,7 @@ static struct rxrpc_local *rxrpc_alloc_local(struct net *net,
struct rxrpc_local *local;
u32 tmp;
- local = kzalloc(sizeof(struct rxrpc_local), GFP_KERNEL);
+ local = kzalloc_obj(struct rxrpc_local, GFP_KERNEL);
if (local) {
refcount_set(&local->ref, 1);
atomic_set(&local->active_users, 1);
diff --git a/net/rxrpc/peer_object.c b/net/rxrpc/peer_object.c
index 366431b0736c..fa9a406e1168 100644
--- a/net/rxrpc/peer_object.c
+++ b/net/rxrpc/peer_object.c
@@ -226,7 +226,7 @@ struct rxrpc_peer *rxrpc_alloc_peer(struct rxrpc_local *local, gfp_t gfp,
_enter("");
- peer = kzalloc(sizeof(struct rxrpc_peer), gfp);
+ peer = kzalloc_obj(struct rxrpc_peer, gfp);
if (peer) {
refcount_set(&peer->ref, 1);
peer->local = rxrpc_get_local(local, rxrpc_local_get_peer);
diff --git a/net/rxrpc/rxgk.c b/net/rxrpc/rxgk.c
index 43cbf9efd89f..f9f5a2dc62ed 100644
--- a/net/rxrpc/rxgk.c
+++ b/net/rxrpc/rxgk.c
@@ -351,7 +351,7 @@ static int rxgk_secure_packet_integrity(const struct rxrpc_call *call,
_enter("");
- hdr = kzalloc(sizeof(*hdr), GFP_NOFS);
+ hdr = kzalloc_obj(*hdr, GFP_NOFS);
if (!hdr)
goto error_gk;
@@ -483,7 +483,7 @@ static int rxgk_verify_packet_integrity(struct rxrpc_call *call,
crypto_krb5_where_is_the_data(gk->krb5, KRB5_CHECKSUM_MODE,
&data_offset, &data_len);
- hdr = kzalloc(sizeof(*hdr), GFP_NOFS);
+ hdr = kzalloc_obj(*hdr, GFP_NOFS);
if (!hdr)
goto put_gk;
diff --git a/net/rxrpc/rxgk_kdf.c b/net/rxrpc/rxgk_kdf.c
index b4db5aa30e5b..6011fa7cf221 100644
--- a/net/rxrpc/rxgk_kdf.c
+++ b/net/rxrpc/rxgk_kdf.c
@@ -213,7 +213,7 @@ struct rxgk_context *rxgk_generate_transport_key(struct rxrpc_connection *conn,
_enter("");
- gk = kzalloc(sizeof(*gk), GFP_KERNEL);
+ gk = kzalloc_obj(*gk, GFP_KERNEL);
if (!gk)
return ERR_PTR(-ENOMEM);
refcount_set(&gk->usage, 1);
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c
index a756855a0a62..e923d6829008 100644
--- a/net/rxrpc/rxkad.c
+++ b/net/rxrpc/rxkad.c
@@ -511,7 +511,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb,
if (nsg <= 4) {
nsg = 4;
} else {
- sg = kmalloc_array(nsg, sizeof(*sg), GFP_NOIO);
+ sg = kmalloc_objs(*sg, nsg, GFP_NOIO);
if (!sg)
return -ENOMEM;
}
@@ -1139,7 +1139,7 @@ static int rxkad_verify_response(struct rxrpc_connection *conn,
}
ret = -ENOMEM;
- response = kzalloc(sizeof(struct rxkad_response), GFP_NOFS);
+ response = kzalloc_obj(struct rxkad_response, GFP_NOFS);
if (!response)
goto temporary_error;
diff --git a/net/rxrpc/rxperf.c b/net/rxrpc/rxperf.c
index 98ea76fae70f..1345ffffb109 100644
--- a/net/rxrpc/rxperf.c
+++ b/net/rxrpc/rxperf.c
@@ -151,7 +151,7 @@ static void rxperf_charge_preallocation(struct work_struct *work)
struct rxperf_call *call;
for (;;) {
- call = kzalloc(sizeof(*call), GFP_KERNEL);
+ call = kzalloc_obj(*call, GFP_KERNEL);
if (!call)
break;
diff --git a/net/rxrpc/sendmsg.c b/net/rxrpc/sendmsg.c
index ebbb78b842de..04f9c5f2dc24 100644
--- a/net/rxrpc/sendmsg.c
+++ b/net/rxrpc/sendmsg.c
@@ -282,7 +282,7 @@ static int rxrpc_alloc_txqueue(struct sock *sk, struct rxrpc_call *call)
{
struct rxrpc_txqueue *tq;
- tq = kzalloc(sizeof(*tq), sk->sk_allocation);
+ tq = kzalloc_obj(*tq, sk->sk_allocation);
if (!tq)
return -ENOMEM;
diff --git a/net/rxrpc/txbuf.c b/net/rxrpc/txbuf.c
index 29767038691a..55ef7a04852e 100644
--- a/net/rxrpc/txbuf.c
+++ b/net/rxrpc/txbuf.c
@@ -23,7 +23,7 @@ struct rxrpc_txbuf *rxrpc_alloc_data_txbuf(struct rxrpc_call *call, size_t data_
size_t total, doff, jsize = sizeof(struct rxrpc_jumbo_header);
void *buf;
- txb = kzalloc(sizeof(*txb), gfp);
+ txb = kzalloc_obj(*txb, gfp);
if (!txb)
return NULL;