summaryrefslogtreecommitdiff
path: root/drivers/uio
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 /drivers/uio
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlinux-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 'drivers/uio')
-rw-r--r--drivers/uio/uio.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/drivers/uio/uio.c b/drivers/uio/uio.c
index fa0d4e6aee16..14d14389164e 100644
--- a/drivers/uio/uio.c
+++ b/drivers/uio/uio.c
@@ -306,7 +306,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_map;
}
}
- map = kzalloc(sizeof(*map), GFP_KERNEL);
+ map = kzalloc_obj(*map, GFP_KERNEL);
if (!map) {
ret = -ENOMEM;
goto err_map;
@@ -335,7 +335,7 @@ static int uio_dev_add_attributes(struct uio_device *idev)
goto err_portio;
}
}
- portio = kzalloc(sizeof(*portio), GFP_KERNEL);
+ portio = kzalloc_obj(*portio, GFP_KERNEL);
if (!portio) {
ret = -ENOMEM;
goto err_portio;
@@ -494,7 +494,7 @@ static int uio_open(struct inode *inode, struct file *filep)
goto err_module_get;
}
- listener = kmalloc(sizeof(*listener), GFP_KERNEL);
+ listener = kmalloc_obj(*listener, GFP_KERNEL);
if (!listener) {
ret = -ENOMEM;
goto err_alloc_listener;
@@ -991,7 +991,7 @@ int __uio_register_device(struct module *owner,
info->uio_dev = NULL;
- idev = kzalloc(sizeof(*idev), GFP_KERNEL);
+ idev = kzalloc_obj(*idev, GFP_KERNEL);
if (!idev) {
return -ENOMEM;
}