summaryrefslogtreecommitdiff
path: root/drivers/xen/evtchn.c
diff options
context:
space:
mode:
authorKees Cook2026-02-20 23:49:23 -0800
committerKees Cook2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/xen/evtchn.c
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 'drivers/xen/evtchn.c')
-rw-r--r--drivers/xen/evtchn.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c
index 7e4a13e632dc..568f1830f3a3 100644
--- a/drivers/xen/evtchn.c
+++ b/drivers/xen/evtchn.c
@@ -332,7 +332,7 @@ static int evtchn_resize_ring(struct per_user_data *u)
else
new_size = 2 * u->ring_size;
- new_ring = kvmalloc_array(new_size, sizeof(*new_ring), GFP_KERNEL);
+ new_ring = kvmalloc_objs(*new_ring, new_size, GFP_KERNEL);
if (!new_ring)
return -ENOMEM;
@@ -386,7 +386,7 @@ static int evtchn_bind_to_user(struct per_user_data *u, evtchn_port_t port,
* serialized bind operations.)
*/
- evtchn = kzalloc(sizeof(*evtchn), GFP_KERNEL);
+ evtchn = kzalloc_obj(*evtchn, GFP_KERNEL);
if (!evtchn)
return -ENOMEM;
@@ -642,7 +642,7 @@ static int evtchn_open(struct inode *inode, struct file *filp)
{
struct per_user_data *u;
- u = kzalloc(sizeof(*u), GFP_KERNEL);
+ u = kzalloc_obj(*u, GFP_KERNEL);
if (u == NULL)
return -ENOMEM;