diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-21 11:02:58 -0800 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2026-02-21 11:02:58 -0800 |
| commit | 8934827db5403eae57d4537114a9ff88b0a8460f (patch) | |
| tree | 5167aa7e16b786b9135e19d508b234054fa6e8ce /drivers/tee | |
| parent | c7decec2f2d2ab0366567f9e30c0e1418cece43f (diff) | |
| parent | 7a70c15bd1449f1eb30991772edce37b41e496fb (diff) | |
Merge tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linuxHEADmaster
Pull kmalloc_obj conversion from Kees Cook:
"This does the tree-wide conversion to kmalloc_obj() and friends using
coccinelle, with a subsequent small manual cleanup of whitespace
alignment that coccinelle does not handle.
This uncovered a clang bug in __builtin_counted_by_ref(), so the
conversion is preceded by disabling that for current versions of
clang. The imminent clang 22.1 release has the fix.
I've done allmodconfig build tests for x86_64, arm64, i386, and arm. I
did defconfig builds for alpha, m68k, mips, parisc, powerpc, riscv,
s390, sparc, sh, arc, csky, xtensa, hexagon, and openrisc"
* tag 'kmalloc_obj-treewide-v7.0-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux:
kmalloc_obj: Clean up after treewide replacements
treewide: Replace kmalloc with kmalloc_obj for non-scalar types
compiler_types: Disable __builtin_counted_by_ref for Clang
Diffstat (limited to 'drivers/tee')
| -rw-r--r-- | drivers/tee/amdtee/call.c | 4 | ||||
| -rw-r--r-- | drivers/tee/amdtee/core.c | 10 | ||||
| -rw-r--r-- | drivers/tee/amdtee/shm_pool.c | 2 | ||||
| -rw-r--r-- | drivers/tee/optee/call.c | 4 | ||||
| -rw-r--r-- | drivers/tee/optee/core.c | 2 | ||||
| -rw-r--r-- | drivers/tee/optee/device.c | 2 | ||||
| -rw-r--r-- | drivers/tee/optee/ffa_abi.c | 8 | ||||
| -rw-r--r-- | drivers/tee/optee/notif.c | 2 | ||||
| -rw-r--r-- | drivers/tee/optee/protmem.c | 2 | ||||
| -rw-r--r-- | drivers/tee/optee/rpc.c | 6 | ||||
| -rw-r--r-- | drivers/tee/optee/smc_abi.c | 4 | ||||
| -rw-r--r-- | drivers/tee/optee/supp.c | 2 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/call.c | 11 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/core.c | 2 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/mem_obj.c | 4 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/qcomtee_object.h | 2 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/shm.c | 2 | ||||
| -rw-r--r-- | drivers/tee/qcomtee/user_obj.c | 4 | ||||
| -rw-r--r-- | drivers/tee/tee_core.c | 20 | ||||
| -rw-r--r-- | drivers/tee/tee_heap.c | 8 | ||||
| -rw-r--r-- | drivers/tee/tee_shm.c | 12 | ||||
| -rw-r--r-- | drivers/tee/tee_shm_pool.c | 2 | ||||
| -rw-r--r-- | drivers/tee/tstee/core.c | 8 |
23 files changed, 61 insertions, 62 deletions
diff --git a/drivers/tee/amdtee/call.c b/drivers/tee/amdtee/call.c index 460b0c9e511f..3d25cee5c7d0 100644 --- a/drivers/tee/amdtee/call.c +++ b/drivers/tee/amdtee/call.c @@ -134,7 +134,7 @@ static u32 get_ta_refcount(u32 ta_handle) if (ta_data->ta_handle == ta_handle) return ++ta_data->refcount; - ta_data = kzalloc(sizeof(*ta_data), GFP_KERNEL); + ta_data = kzalloc_obj(*ta_data, GFP_KERNEL); if (ta_data) { ta_data->ta_handle = ta_handle; ta_data->refcount = 1; @@ -293,7 +293,7 @@ int handle_map_shmem(u32 count, struct shmem_desc *start, u32 *buf_id) if (!count || !start || !buf_id) return -EINVAL; - cmd = kzalloc(sizeof(*cmd), GFP_KERNEL); + cmd = kzalloc_obj(*cmd, GFP_KERNEL); if (!cmd) return -ENOMEM; diff --git a/drivers/tee/amdtee/core.c b/drivers/tee/amdtee/core.c index fb39d9a19c69..1ff4834722f7 100644 --- a/drivers/tee/amdtee/core.c +++ b/drivers/tee/amdtee/core.c @@ -38,7 +38,7 @@ static int amdtee_open(struct tee_context *ctx) { struct amdtee_context_data *ctxdata; - ctxdata = kzalloc(sizeof(*ctxdata), GFP_KERNEL); + ctxdata = kzalloc_obj(*ctxdata, GFP_KERNEL); if (!ctxdata) return -ENOMEM; @@ -122,7 +122,7 @@ static struct amdtee_session *alloc_session(struct amdtee_context_data *ctxdata, } /* Allocate a new session and add to list */ - sess = kzalloc(sizeof(*sess), GFP_KERNEL); + sess = kzalloc_obj(*sess, GFP_KERNEL); if (sess) { sess->ta_handle = ta_handle; kref_init(&sess->refcount); @@ -351,7 +351,7 @@ int amdtee_map_shmem(struct tee_shm *shm) if (!shm) return -EINVAL; - shmnode = kmalloc(sizeof(*shmnode), GFP_KERNEL); + shmnode = kmalloc_obj(*shmnode, GFP_KERNEL); if (!shmnode) return -ENOMEM; @@ -465,11 +465,11 @@ static int __init amdtee_driver_init(void) return rc; } - drv_data = kzalloc(sizeof(*drv_data), GFP_KERNEL); + drv_data = kzalloc_obj(*drv_data, GFP_KERNEL); if (!drv_data) return -ENOMEM; - amdtee = kzalloc(sizeof(*amdtee), GFP_KERNEL); + amdtee = kzalloc_obj(*amdtee, GFP_KERNEL); if (!amdtee) { rc = -ENOMEM; goto err_kfree_drv_data; diff --git a/drivers/tee/amdtee/shm_pool.c b/drivers/tee/amdtee/shm_pool.c index 6346e0bc8a64..fcb0d5da4bfd 100644 --- a/drivers/tee/amdtee/shm_pool.c +++ b/drivers/tee/amdtee/shm_pool.c @@ -59,7 +59,7 @@ static const struct tee_shm_pool_ops pool_ops = { struct tee_shm_pool *amdtee_config_shm(void) { - struct tee_shm_pool *pool = kzalloc(sizeof(*pool), GFP_KERNEL); + struct tee_shm_pool *pool = kzalloc_obj(*pool, GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); diff --git a/drivers/tee/optee/call.c b/drivers/tee/optee/call.c index 16eb953e14bb..5fa3edd9b233 100644 --- a/drivers/tee/optee/call.c +++ b/drivers/tee/optee/call.c @@ -293,7 +293,7 @@ struct optee_msg_arg *optee_get_msg_arg(struct tee_context *ctx, /* * No entry was found, let's allocate a new. */ - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) { res = ERR_PTR(-ENOMEM); goto out; @@ -404,7 +404,7 @@ int optee_open_session(struct tee_context *ctx, if (rc) goto out; - sess = kzalloc(sizeof(*sess), GFP_KERNEL); + sess = kzalloc_obj(*sess, GFP_KERNEL); if (!sess) { rc = -ENOMEM; goto out; diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 2d807bc748bc..ec07a8e1a585 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -125,7 +125,7 @@ int optee_open(struct tee_context *ctx, bool cap_memref_null) struct tee_device *teedev = ctx->teedev; struct optee *optee = tee_get_drvdata(teedev); - ctxdata = kzalloc(sizeof(*ctxdata), GFP_KERNEL); + ctxdata = kzalloc_obj(*ctxdata, GFP_KERNEL); if (!ctxdata) return -ENOMEM; diff --git a/drivers/tee/optee/device.c b/drivers/tee/optee/device.c index 950b4661d5df..3f272c356ce4 100644 --- a/drivers/tee/optee/device.c +++ b/drivers/tee/optee/device.c @@ -81,7 +81,7 @@ static int optee_register_device(const uuid_t *device_uuid, u32 func) struct tee_client_device *optee_device = NULL; int rc; - optee_device = kzalloc(sizeof(*optee_device), GFP_KERNEL); + optee_device = kzalloc_obj(*optee_device, GFP_KERNEL); if (!optee_device) return -ENOMEM; diff --git a/drivers/tee/optee/ffa_abi.c b/drivers/tee/optee/ffa_abi.c index 8fc72aa95722..53ec3204b075 100644 --- a/drivers/tee/optee/ffa_abi.c +++ b/drivers/tee/optee/ffa_abi.c @@ -78,7 +78,7 @@ static int optee_shm_add_ffa_handle(struct optee *optee, struct tee_shm *shm, struct shm_rhash *r; int rc; - r = kmalloc(sizeof(*r), GFP_KERNEL); + r = kmalloc_obj(*r, GFP_KERNEL); if (!r) return -ENOMEM; r->shm = shm; @@ -404,7 +404,7 @@ static const struct tee_shm_pool_ops pool_ffa_ops = { */ static struct tee_shm_pool *optee_ffa_shm_pool_alloc_pages(void) { - struct tee_shm_pool *pool = kzalloc(sizeof(*pool), GFP_KERNEL); + struct tee_shm_pool *pool = kzalloc_obj(*pool, GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); @@ -697,7 +697,7 @@ static int optee_ffa_lend_protmem(struct optee *optee, struct tee_shm *protmem, unsigned int n; int rc; - mem_attr = kcalloc(ma_count, sizeof(*mem_attr), GFP_KERNEL); + mem_attr = kzalloc_objs(*mem_attr, ma_count, GFP_KERNEL); for (n = 0; n < ma_count; n++) { mem_attr[n].receiver = mem_attrs[n] & U16_MAX; mem_attr[n].attrs = mem_attrs[n] >> 16; @@ -1077,7 +1077,7 @@ static int optee_ffa_probe(struct ffa_device *ffa_dev) if (sec_caps & OPTEE_FFA_SEC_CAP_ARG_OFFSET) arg_cache_flags |= OPTEE_SHM_ARG_SHARED; - optee = kzalloc(sizeof(*optee), GFP_KERNEL); + optee = kzalloc_obj(*optee, GFP_KERNEL); if (!optee) return -ENOMEM; diff --git a/drivers/tee/optee/notif.c b/drivers/tee/optee/notif.c index 1970880c796f..7ce65c8a07cf 100644 --- a/drivers/tee/optee/notif.c +++ b/drivers/tee/optee/notif.c @@ -38,7 +38,7 @@ int optee_notif_wait(struct optee *optee, u_int key, u32 timeout) if (key > optee->notif.max_key) return -EINVAL; - entry = kmalloc(sizeof(*entry), GFP_KERNEL); + entry = kmalloc_obj(*entry, GFP_KERNEL); if (!entry) return -ENOMEM; init_completion(&entry->c); diff --git a/drivers/tee/optee/protmem.c b/drivers/tee/optee/protmem.c index 2eba48d5ac73..086df220f758 100644 --- a/drivers/tee/optee/protmem.c +++ b/drivers/tee/optee/protmem.c @@ -294,7 +294,7 @@ struct tee_protmem_pool *optee_protmem_alloc_dyn_pool(struct optee *optee, u_int pa_width; int rc; - rp = kzalloc(sizeof(*rp), GFP_KERNEL); + rp = kzalloc_obj(*rp, GFP_KERNEL); if (!rp) return ERR_PTR(-ENOMEM); rp->use_case = id; diff --git a/drivers/tee/optee/rpc.c b/drivers/tee/optee/rpc.c index 1758eb7e6e8b..ef80f668a6bc 100644 --- a/drivers/tee/optee/rpc.c +++ b/drivers/tee/optee/rpc.c @@ -55,8 +55,7 @@ static void handle_rpc_func_cmd_i2c_transfer(struct tee_context *ctx, return; } - params = kmalloc_array(arg->num_params, sizeof(struct tee_param), - GFP_KERNEL); + params = kmalloc_objs(struct tee_param, arg->num_params, GFP_KERNEL); if (!params) { arg->ret = TEEC_ERROR_OUT_OF_MEMORY; return; @@ -192,8 +191,7 @@ static void handle_rpc_supp_cmd(struct tee_context *ctx, struct optee *optee, arg->ret_origin = TEEC_ORIGIN_COMMS; - params = kmalloc_array(arg->num_params, sizeof(struct tee_param), - GFP_KERNEL); + params = kmalloc_objs(struct tee_param, arg->num_params, GFP_KERNEL); if (!params) { arg->ret = TEEC_ERROR_OUT_OF_MEMORY; return; diff --git a/drivers/tee/optee/smc_abi.c b/drivers/tee/optee/smc_abi.c index 51fae1ab8ef8..3d33b8d6af37 100644 --- a/drivers/tee/optee/smc_abi.c +++ b/drivers/tee/optee/smc_abi.c @@ -626,7 +626,7 @@ static const struct tee_shm_pool_ops pool_ops = { */ static struct tee_shm_pool *optee_shm_pool_alloc_pages(void) { - struct tee_shm_pool *pool = kzalloc(sizeof(*pool), GFP_KERNEL); + struct tee_shm_pool *pool = kzalloc_obj(*pool, GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); @@ -1816,7 +1816,7 @@ static int optee_probe(struct platform_device *pdev) if (IS_ERR(pool)) return PTR_ERR(pool); - optee = kzalloc(sizeof(*optee), GFP_KERNEL); + optee = kzalloc_obj(*optee, GFP_KERNEL); if (!optee) { rc = -ENOMEM; goto err_free_shm_pool; diff --git a/drivers/tee/optee/supp.c b/drivers/tee/optee/supp.c index d0f397c90242..3562cb80a95a 100644 --- a/drivers/tee/optee/supp.c +++ b/drivers/tee/optee/supp.c @@ -89,7 +89,7 @@ u32 optee_supp_thrd_req(struct tee_context *ctx, u32 func, size_t num_params, if (!supp->ctx && ctx->supp_nowait) return TEEC_ERROR_COMMUNICATION; - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = kzalloc_obj(*req, GFP_KERNEL); if (!req) return TEEC_ERROR_OUT_OF_MEMORY; 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; diff --git a/drivers/tee/tee_core.c b/drivers/tee/tee_core.c index 6c49e2e383c6..29df8cd1efd2 100644 --- a/drivers/tee/tee_core.c +++ b/drivers/tee/tee_core.c @@ -51,7 +51,7 @@ struct tee_context *teedev_open(struct tee_device *teedev) if (!tee_device_get(teedev)) return ERR_PTR(-EINVAL); - ctx = kzalloc(sizeof(*ctx), GFP_KERNEL); + ctx = kzalloc_obj(*ctx, GFP_KERNEL); if (!ctx) { rc = -ENOMEM; goto err; @@ -560,8 +560,8 @@ static int tee_ioctl_open_session(struct tee_context *ctx, return -EINVAL; if (arg.num_params) { - params = kcalloc(arg.num_params, sizeof(struct tee_param), - GFP_KERNEL); + params = kzalloc_objs(struct tee_param, arg.num_params, + GFP_KERNEL); if (!params) return -ENOMEM; uparams = uarg->params; @@ -638,8 +638,8 @@ static int tee_ioctl_invoke(struct tee_context *ctx, return -EINVAL; if (arg.num_params) { - params = kcalloc(arg.num_params, sizeof(struct tee_param), - GFP_KERNEL); + params = kzalloc_objs(struct tee_param, arg.num_params, + GFP_KERNEL); if (!params) return -ENOMEM; uparams = uarg->params; @@ -699,8 +699,8 @@ static int tee_ioctl_object_invoke(struct tee_context *ctx, return -EINVAL; if (arg.num_params) { - params = kcalloc(arg.num_params, sizeof(struct tee_param), - GFP_KERNEL); + params = kzalloc_objs(struct tee_param, arg.num_params, + GFP_KERNEL); if (!params) return -ENOMEM; uparams = uarg->params; @@ -844,7 +844,7 @@ static int tee_ioctl_supp_recv(struct tee_context *ctx, if (size_add(sizeof(*uarg), TEE_IOCTL_PARAM_SIZE(num_params)) != buf.buf_len) return -EINVAL; - params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL); + params = kzalloc_objs(struct tee_param, num_params, GFP_KERNEL); if (!params) return -ENOMEM; @@ -958,7 +958,7 @@ static int tee_ioctl_supp_send(struct tee_context *ctx, if (size_add(sizeof(*uarg), TEE_IOCTL_PARAM_SIZE(num_params)) > buf.buf_len) return -EINVAL; - params = kcalloc(num_params, sizeof(struct tee_param), GFP_KERNEL); + params = kzalloc_objs(struct tee_param, num_params, GFP_KERNEL); if (!params) return -ENOMEM; @@ -1052,7 +1052,7 @@ struct tee_device *tee_device_alloc(const struct tee_desc *teedesc, !teedesc->ops->release) return ERR_PTR(-EINVAL); - teedev = kzalloc(sizeof(*teedev), GFP_KERNEL); + teedev = kzalloc_obj(*teedev, GFP_KERNEL); if (!teedev) { ret = ERR_PTR(-ENOMEM); goto err; diff --git a/drivers/tee/tee_heap.c b/drivers/tee/tee_heap.c index d8d7735cdffb..71e50d9573c7 100644 --- a/drivers/tee/tee_heap.c +++ b/drivers/tee/tee_heap.c @@ -94,7 +94,7 @@ static int tee_heap_attach(struct dma_buf *dmabuf, struct tee_heap_attachment *a; int ret; - a = kzalloc(sizeof(*a), GFP_KERNEL); + a = kzalloc_obj(*a, GFP_KERNEL); if (!a) return -ENOMEM; @@ -188,7 +188,7 @@ static struct dma_buf *tee_dma_heap_alloc(struct dma_heap *heap, if (!teedev) return ERR_PTR(-EINVAL); - buf = kzalloc(sizeof(*buf), GFP_KERNEL); + buf = kzalloc_obj(*buf, GFP_KERNEL); if (!buf) { dmabuf = ERR_PTR(-ENOMEM); goto err; @@ -260,7 +260,7 @@ static int alloc_dma_heap(struct tee_device *teedev, enum tee_dma_heap_id id, return -ENOMEM; } - h = kzalloc(sizeof(*h), GFP_KERNEL); + h = kzalloc_obj(*h, GFP_KERNEL); if (!h) return -ENOMEM; h->id = id; @@ -472,7 +472,7 @@ struct tee_protmem_pool *tee_protmem_static_pool_alloc(phys_addr_t paddr, if (!pfn_valid(PHYS_PFN(paddr))) return ERR_PTR(-EINVAL); - stp = kzalloc(sizeof(*stp), GFP_KERNEL); + stp = kzalloc_obj(*stp, GFP_KERNEL); if (!stp) return ERR_PTR(-ENOMEM); diff --git a/drivers/tee/tee_shm.c b/drivers/tee/tee_shm.c index 4a47de4bb2e5..1ed278fc9e4a 100644 --- a/drivers/tee/tee_shm.c +++ b/drivers/tee/tee_shm.c @@ -106,7 +106,7 @@ static struct tee_shm *shm_alloc_helper(struct tee_context *ctx, size_t size, goto err_dev_put; } - shm = kzalloc(sizeof(*shm), GFP_KERNEL); + shm = kzalloc_obj(*shm, GFP_KERNEL); if (!shm) { ret = ERR_PTR(-ENOMEM); goto err_dev_put; @@ -214,7 +214,7 @@ struct tee_shm *tee_shm_register_fd(struct tee_context *ctx, int fd) teedev_ctx_get(ctx); - ref = kzalloc(sizeof(*ref), GFP_KERNEL); + ref = kzalloc_obj(*ref, GFP_KERNEL); if (!ref) { rc = -ENOMEM; goto err_put_tee; @@ -315,7 +315,7 @@ struct tee_shm *tee_shm_alloc_dma_mem(struct tee_context *ctx, if (!page) goto err_put_teedev; - dma_mem = kzalloc(sizeof(*dma_mem), GFP_KERNEL); + dma_mem = kzalloc_obj(*dma_mem, GFP_KERNEL); if (!dma_mem) goto err_free_pages; @@ -373,7 +373,7 @@ int tee_dyn_shm_alloc_helper(struct tee_shm *shm, size_t size, size_t align, shm->paddr = virt_to_phys(shm->kaddr); shm->size = nr_pages * PAGE_SIZE; - pages = kcalloc(nr_pages, sizeof(*pages), GFP_KERNEL); + pages = kzalloc_objs(*pages, nr_pages, GFP_KERNEL); if (!pages) { rc = -ENOMEM; goto err_pages; @@ -438,7 +438,7 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, teedev_ctx_get(ctx); - shm = kzalloc(sizeof(*shm), GFP_KERNEL); + shm = kzalloc_obj(*shm, GFP_KERNEL); if (!shm) { ret = ERR_PTR(-ENOMEM); goto err_ctx_put; @@ -456,7 +456,7 @@ register_shm_helper(struct tee_context *ctx, struct iov_iter *iter, u32 flags, goto err_ctx_put; } - shm->pages = kcalloc(num_pages, sizeof(*shm->pages), GFP_KERNEL); + shm->pages = kzalloc_objs(*shm->pages, num_pages, GFP_KERNEL); if (!shm->pages) { ret = ERR_PTR(-ENOMEM); goto err_free_shm; diff --git a/drivers/tee/tee_shm_pool.c b/drivers/tee/tee_shm_pool.c index 80004b55628d..fc82c689c29e 100644 --- a/drivers/tee/tee_shm_pool.c +++ b/drivers/tee/tee_shm_pool.c @@ -65,7 +65,7 @@ struct tee_shm_pool *tee_shm_pool_alloc_res_mem(unsigned long vaddr, if (vaddr & page_mask || paddr & page_mask || size & page_mask) return ERR_PTR(-EINVAL); - pool = kzalloc(sizeof(*pool), GFP_KERNEL); + pool = kzalloc_obj(*pool, GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); diff --git a/drivers/tee/tstee/core.c b/drivers/tee/tstee/core.c index 533425e9e9e7..4a4aa2bc5ab6 100644 --- a/drivers/tee/tstee/core.c +++ b/drivers/tee/tstee/core.c @@ -59,7 +59,7 @@ static int tstee_open(struct tee_context *ctx) { struct ts_context_data *ctxdata; - ctxdata = kzalloc(sizeof(*ctxdata), GFP_KERNEL); + ctxdata = kzalloc_obj(*ctxdata, GFP_KERNEL); if (!ctxdata) return -ENOMEM; @@ -122,7 +122,7 @@ static int tstee_open_session(struct tee_context *ctx, if (ffa_args[TS_RPC_SERVICE_INFO_IFACE] > U8_MAX) return -EINVAL; - sess = kzalloc(sizeof(*sess), GFP_KERNEL); + sess = kzalloc_obj(*sess, GFP_KERNEL); if (!sess) return -ENOMEM; @@ -376,7 +376,7 @@ static const struct tee_shm_pool_ops pool_ops = { static struct tee_shm_pool *tstee_create_shm_pool(void) { - struct tee_shm_pool *pool = kzalloc(sizeof(*pool), GFP_KERNEL); + struct tee_shm_pool *pool = kzalloc_obj(*pool, GFP_KERNEL); if (!pool) return ERR_PTR(-ENOMEM); @@ -414,7 +414,7 @@ static int tstee_probe(struct ffa_device *ffa_dev) if (!tstee_check_rpc_compatible(ffa_dev)) return -EINVAL; - tstee = kzalloc(sizeof(*tstee), GFP_KERNEL); + tstee = kzalloc_obj(*tstee, GFP_KERNEL); if (!tstee) return -ENOMEM; |
