summaryrefslogtreecommitdiff
path: root/drivers/tee/qcomtee
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/tee/qcomtee
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/tee/qcomtee')
-rw-r--r--drivers/tee/qcomtee/call.c11
-rw-r--r--drivers/tee/qcomtee/core.c2
-rw-r--r--drivers/tee/qcomtee/mem_obj.c4
-rw-r--r--drivers/tee/qcomtee/qcomtee_object.h2
-rw-r--r--drivers/tee/qcomtee/shm.c2
-rw-r--r--drivers/tee/qcomtee/user_obj.c4
6 files changed, 13 insertions, 12 deletions
diff --git a/drivers/tee/qcomtee/call.c b/drivers/tee/qcomtee/call.c
index 8f8830f0df26..cd138adb5e17 100644
--- a/drivers/tee/qcomtee/call.c
+++ b/drivers/tee/qcomtee/call.c
@@ -416,8 +416,9 @@ static int qcomtee_object_invoke(struct tee_context *ctx,
return -ENOMEM;
/* +1 for ending QCOMTEE_ARG_TYPE_INV. */
- struct qcomtee_arg *u __free(kfree) = kcalloc(arg->num_params + 1, sizeof(*u),
- GFP_KERNEL);
+ struct qcomtee_arg *u __free(kfree) = kzalloc_objs(*u,
+ arg->num_params + 1,
+ GFP_KERNEL);
if (!u)
return -ENOMEM;
@@ -562,8 +563,8 @@ static int qcomtee_supp_send(struct tee_context *ctx, u32 errno, u32 num_params,
static int qcomtee_open(struct tee_context *ctx)
{
- struct qcomtee_context_data *ctxdata __free(kfree) = kzalloc(sizeof(*ctxdata),
- GFP_KERNEL);
+ struct qcomtee_context_data *ctxdata __free(kfree) = kzalloc_obj(*ctxdata,
+ GFP_KERNEL);
if (!ctxdata)
return -ENOMEM;
@@ -706,7 +707,7 @@ static int qcomtee_probe(struct platform_device *pdev)
struct qcomtee *qcomtee;
int err;
- qcomtee = kzalloc(sizeof(*qcomtee), GFP_KERNEL);
+ qcomtee = kzalloc_obj(*qcomtee, GFP_KERNEL);
if (!qcomtee)
return -ENOMEM;
diff --git a/drivers/tee/qcomtee/core.c b/drivers/tee/qcomtee/core.c
index ecd04403591c..ab477bbc8439 100644
--- a/drivers/tee/qcomtee/core.c
+++ b/drivers/tee/qcomtee/core.c
@@ -54,7 +54,7 @@ qcomtee_qtee_object_alloc(struct qcomtee_object_invoke_ctx *oic,
struct qcomtee *qcomtee = tee_get_drvdata(oic->ctx->teedev);
struct qcomtee_object *object;
- object = kzalloc(sizeof(*object), GFP_KERNEL);
+ object = kzalloc_obj(*object, GFP_KERNEL);
if (!object)
return NULL_QCOMTEE_OBJECT;
diff --git a/drivers/tee/qcomtee/mem_obj.c b/drivers/tee/qcomtee/mem_obj.c
index a16f8fc39b8d..01bc8dcc22e7 100644
--- a/drivers/tee/qcomtee/mem_obj.c
+++ b/drivers/tee/qcomtee/mem_obj.c
@@ -91,8 +91,8 @@ int qcomtee_memobj_param_to_object(struct qcomtee_object **object,
struct tee_shm *shm;
int err;
- struct qcomtee_mem_object *mem_object __free(kfree) = kzalloc(sizeof(*mem_object),
- GFP_KERNEL);
+ struct qcomtee_mem_object *mem_object __free(kfree) = kzalloc_obj(*mem_object,
+ GFP_KERNEL);
if (!mem_object)
return -ENOMEM;
diff --git a/drivers/tee/qcomtee/qcomtee_object.h b/drivers/tee/qcomtee/qcomtee_object.h
index 5221449be7db..d763f90c62bb 100644
--- a/drivers/tee/qcomtee/qcomtee_object.h
+++ b/drivers/tee/qcomtee/qcomtee_object.h
@@ -176,7 +176,7 @@ qcomtee_object_invoke_ctx_alloc(struct tee_context *ctx)
{
struct qcomtee_object_invoke_ctx *oic;
- oic = kzalloc(sizeof(*oic), GFP_KERNEL);
+ oic = kzalloc_obj(*oic, GFP_KERNEL);
if (oic)
oic->ctx = ctx;
return oic;
diff --git a/drivers/tee/qcomtee/shm.c b/drivers/tee/qcomtee/shm.c
index 580bd25f98ed..7bef13767e25 100644
--- a/drivers/tee/qcomtee/shm.c
+++ b/drivers/tee/qcomtee/shm.c
@@ -140,7 +140,7 @@ struct tee_shm_pool *qcomtee_shm_pool_alloc(void)
{
struct tee_shm_pool *pool;
- pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+ pool = kzalloc_obj(*pool, GFP_KERNEL);
if (!pool)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/tee/qcomtee/user_obj.c b/drivers/tee/qcomtee/user_obj.c
index 6aa3aefd67f0..d19c6589574a 100644
--- a/drivers/tee/qcomtee/user_obj.c
+++ b/drivers/tee/qcomtee/user_obj.c
@@ -326,7 +326,7 @@ static void qcomtee_user_object_release(struct qcomtee_object *object)
if (!uo->notify)
goto out_no_notify;
- ureq = kzalloc(sizeof(*ureq), GFP_KERNEL);
+ ureq = kzalloc_obj(*ureq, GFP_KERNEL);
if (!ureq)
goto out_no_notify;
@@ -370,7 +370,7 @@ int qcomtee_user_param_to_object(struct qcomtee_object **object,
int err;
struct qcomtee_user_object *user_object __free(kfree) =
- kzalloc(sizeof(*user_object), GFP_KERNEL);
+ kzalloc_obj(*user_object, GFP_KERNEL);
if (!user_object)
return -ENOMEM;