summaryrefslogtreecommitdiff
path: root/net/rose
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/rose
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.zip
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/rose')
-rw-r--r--net/rose/af_rose.c3
-rw-r--r--net/rose/rose_route.c12
2 files changed, 7 insertions, 8 deletions
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c
index c0f5a515a8ce..83c62af80d7c 100644
--- a/net/rose/af_rose.c
+++ b/net/rose/af_rose.c
@@ -1571,8 +1571,7 @@ static int __init rose_proto_init(void)
rose_callsign = null_ax25_address;
- dev_rose = kcalloc(rose_ndevs, sizeof(struct net_device *),
- GFP_KERNEL);
+ dev_rose = kzalloc_objs(struct net_device *, rose_ndevs, GFP_KERNEL);
if (dev_rose == NULL) {
printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
rc = -ENOMEM;
diff --git a/net/rose/rose_route.c b/net/rose/rose_route.c
index a1e9b05ef6f5..4330df1b1b59 100644
--- a/net/rose/rose_route.c
+++ b/net/rose/rose_route.c
@@ -82,7 +82,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
}
if (rose_neigh == NULL) {
- rose_neigh = kmalloc(sizeof(*rose_neigh), GFP_ATOMIC);
+ rose_neigh = kmalloc_obj(*rose_neigh, GFP_ATOMIC);
if (rose_neigh == NULL) {
res = -ENOMEM;
goto out;
@@ -106,7 +106,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
if (rose_route->ndigis != 0) {
rose_neigh->digipeat =
- kmalloc(sizeof(ax25_digi), GFP_ATOMIC);
+ kmalloc_obj(ax25_digi, GFP_ATOMIC);
if (rose_neigh->digipeat == NULL) {
kfree(rose_neigh);
res = -ENOMEM;
@@ -148,7 +148,7 @@ static int __must_check rose_add_node(struct rose_route_struct *rose_route,
}
/* create new node */
- rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC);
+ rose_node = kmalloc_obj(*rose_node, GFP_ATOMIC);
if (rose_node == NULL) {
res = -ENOMEM;
goto out;
@@ -368,7 +368,7 @@ void rose_add_loopback_neigh(void)
{
struct rose_neigh *sn;
- rose_loopback_neigh = kmalloc(sizeof(struct rose_neigh), GFP_KERNEL);
+ rose_loopback_neigh = kmalloc_obj(struct rose_neigh, GFP_KERNEL);
if (!rose_loopback_neigh)
return;
sn = rose_loopback_neigh;
@@ -417,7 +417,7 @@ int rose_add_loopback_node(const rose_address *address)
if (rose_node != NULL)
goto out;
- if ((rose_node = kmalloc(sizeof(*rose_node), GFP_ATOMIC)) == NULL) {
+ if ((rose_node = kmalloc_obj(*rose_node, GFP_ATOMIC)) == NULL) {
err = -ENOMEM;
goto out;
}
@@ -1055,7 +1055,7 @@ int rose_route_frame(struct sk_buff *skb, ax25_cb *ax25)
goto put_neigh;
}
- if ((rose_route = kmalloc(sizeof(*rose_route), GFP_ATOMIC)) == NULL) {
+ if ((rose_route = kmalloc_obj(*rose_route, GFP_ATOMIC)) == NULL) {
rose_transmit_clear_request(rose_neigh, lci, ROSE_NETWORK_CONGESTION, 120);
goto put_neigh;
}