diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /net/qrtr | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-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/qrtr')
| -rw-r--r-- | net/qrtr/af_qrtr.c | 4 | ||||
| -rw-r--r-- | net/qrtr/ns.c | 6 | ||||
| -rw-r--r-- | net/qrtr/tun.c | 2 |
3 files changed, 6 insertions, 6 deletions
diff --git a/net/qrtr/af_qrtr.c b/net/qrtr/af_qrtr.c index dab839f61ee9..70e7a210fd42 100644 --- a/net/qrtr/af_qrtr.c +++ b/net/qrtr/af_qrtr.c @@ -271,7 +271,7 @@ static int qrtr_tx_wait(struct qrtr_node *node, int dest_node, int dest_port, mutex_lock(&node->qrtr_tx_lock); flow = radix_tree_lookup(&node->qrtr_tx_flow, key); if (!flow) { - flow = kzalloc(sizeof(*flow), GFP_KERNEL); + flow = kzalloc_obj(*flow, GFP_KERNEL); if (flow) { init_waitqueue_head(&flow->resume_tx); if (radix_tree_insert(&node->qrtr_tx_flow, key, flow)) { @@ -589,7 +589,7 @@ int qrtr_endpoint_register(struct qrtr_endpoint *ep, unsigned int nid) if (!ep || !ep->xmit) return -EINVAL; - node = kzalloc(sizeof(*node), GFP_KERNEL); + node = kzalloc_obj(*node, GFP_KERNEL); if (!node) return -ENOMEM; diff --git a/net/qrtr/ns.c b/net/qrtr/ns.c index bfcc1a453f23..36b5c1990bf5 100644 --- a/net/qrtr/ns.c +++ b/net/qrtr/ns.c @@ -78,7 +78,7 @@ static struct qrtr_node *node_get(unsigned int node_id) return node; /* If node didn't exist, allocate and insert it to the tree */ - node = kzalloc(sizeof(*node), GFP_KERNEL); + node = kzalloc_obj(*node, GFP_KERNEL); if (!node) return NULL; @@ -229,7 +229,7 @@ static struct qrtr_server *server_add(unsigned int service, if (!service || !port) return NULL; - srv = kzalloc(sizeof(*srv), GFP_KERNEL); + srv = kzalloc_obj(*srv, GFP_KERNEL); if (!srv) return NULL; @@ -534,7 +534,7 @@ static int ctrl_cmd_new_lookup(struct sockaddr_qrtr *from, if (from->sq_node != qrtr_ns.local_node) return -EINVAL; - lookup = kzalloc(sizeof(*lookup), GFP_KERNEL); + lookup = kzalloc_obj(*lookup, GFP_KERNEL); if (!lookup) return -ENOMEM; diff --git a/net/qrtr/tun.c b/net/qrtr/tun.c index 304b41fea5ab..9ad17a773593 100644 --- a/net/qrtr/tun.c +++ b/net/qrtr/tun.c @@ -33,7 +33,7 @@ static int qrtr_tun_open(struct inode *inode, struct file *filp) struct qrtr_tun *tun; int ret; - tun = kzalloc(sizeof(*tun), GFP_KERNEL); + tun = kzalloc_obj(*tun, GFP_KERNEL); if (!tun) return -ENOMEM; |
