summaryrefslogtreecommitdiff
path: root/drivers/platform/raspberrypi
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/platform/raspberrypi
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/platform/raspberrypi')
-rw-r--r--drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c7
-rw-r--r--drivers/platform/raspberrypi/vchiq-interface/vchiq_bus.c2
-rw-r--r--drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c2
-rw-r--r--drivers/platform/raspberrypi/vchiq-interface/vchiq_dev.c6
-rw-r--r--drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c4
5 files changed, 10 insertions, 11 deletions
diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
index 6a7b96d3dae6..1e72dc819e2a 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_arm.c
@@ -358,7 +358,7 @@ int vchiq_initialise(struct vchiq_state *state, struct vchiq_instance **instance
__func__, i);
}
- instance = kzalloc(sizeof(*instance), GFP_KERNEL);
+ instance = kzalloc_obj(*instance, GFP_KERNEL);
if (!instance) {
ret = -ENOMEM;
goto failed;
@@ -618,7 +618,7 @@ vchiq_blocking_bulk_transfer(struct vchiq_instance *instance, unsigned int handl
}
}
} else {
- waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
+ waiter = kzalloc_obj(*waiter, GFP_KERNEL);
if (!waiter)
return -ENOMEM;
}
@@ -1249,8 +1249,7 @@ vchiq_dump_service_use_state(struct vchiq_state *state)
if (!arm_state)
return;
- service_data = kmalloc_array(MAX_SERVICES, sizeof(*service_data),
- GFP_KERNEL);
+ service_data = kmalloc_objs(*service_data, MAX_SERVICES, GFP_KERNEL);
if (!service_data)
return;
diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_bus.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_bus.c
index f50e637d505c..616e05a36918 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_bus.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_bus.c
@@ -68,7 +68,7 @@ vchiq_device_register(struct device *parent, const char *name)
struct vchiq_device *device;
int ret;
- device = kzalloc(sizeof(*device), GFP_KERNEL);
+ device = kzalloc_obj(*device, GFP_KERNEL);
if (!device)
return NULL;
diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
index 83de27cfd469..1dac7d1ffaa2 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_core.c
@@ -2723,7 +2723,7 @@ vchiq_add_service_internal(struct vchiq_state *state,
if (ret)
return NULL;
- service = kzalloc(sizeof(*service), GFP_KERNEL);
+ service = kzalloc_obj(*service, GFP_KERNEL);
if (!service)
return service;
diff --git a/drivers/platform/raspberrypi/vchiq-interface/vchiq_dev.c b/drivers/platform/raspberrypi/vchiq-interface/vchiq_dev.c
index 0f3dde2657d6..18bcb8c133d1 100644
--- a/drivers/platform/raspberrypi/vchiq-interface/vchiq_dev.c
+++ b/drivers/platform/raspberrypi/vchiq-interface/vchiq_dev.c
@@ -149,7 +149,7 @@ static int vchiq_ioc_create_service(struct vchiq_instance *instance,
if (args->is_open && !instance->connected)
return -ENOTCONN;
- user_service = kmalloc(sizeof(*user_service), GFP_KERNEL);
+ user_service = kmalloc_obj(*user_service, GFP_KERNEL);
if (!user_service)
return -ENOMEM;
@@ -298,7 +298,7 @@ static int vchiq_irq_queue_bulk_tx_rx(struct vchiq_instance *instance,
return -EINVAL;
if (args->mode == VCHIQ_BULK_MODE_BLOCKING) {
- waiter = kzalloc(sizeof(*waiter), GFP_KERNEL);
+ waiter = kzalloc_obj(*waiter, GFP_KERNEL);
if (!waiter) {
ret = -ENOMEM;
goto out;
@@ -1185,7 +1185,7 @@ static int vchiq_open(struct inode *inode, struct file *file)
return -ENOTCONN;
}
- instance = kzalloc(sizeof(*instance), GFP_KERNEL);
+ instance = kzalloc_obj(*instance, GFP_KERNEL);
if (!instance)
return -ENOMEM;
diff --git a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
index cd073ed3ea2d..79790867c45c 100644
--- a/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
+++ b/drivers/platform/raspberrypi/vchiq-mmal/mmal-vchiq.c
@@ -190,7 +190,7 @@ get_msg_context(struct vchiq_mmal_instance *instance)
int handle;
/* todo: should this be allocated from a pool to avoid kzalloc */
- msg_context = kzalloc(sizeof(*msg_context), GFP_KERNEL);
+ msg_context = kzalloc_obj(*msg_context, GFP_KERNEL);
if (!msg_context)
return ERR_PTR(-ENOMEM);
@@ -1898,7 +1898,7 @@ int vchiq_mmal_init(struct device *dev, struct vchiq_mmal_instance **out_instanc
goto err_shutdown_vchiq;
}
- instance = kzalloc(sizeof(*instance), GFP_KERNEL);
+ instance = kzalloc_obj(*instance, GFP_KERNEL);
if (!instance) {
err = -ENOMEM;