diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/crypto/marvell | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (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/crypto/marvell')
5 files changed, 9 insertions, 9 deletions
diff --git a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c index 417a48f41350..b35c57a868e7 100644 --- a/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx/otx_cptpf_ucode.c @@ -318,7 +318,7 @@ static int process_tar_file(struct device *dev, return -EINVAL; } - tar_info = kzalloc(sizeof(struct tar_ucode_info_t), GFP_KERNEL); + tar_info = kzalloc_obj(struct tar_ucode_info_t, GFP_KERNEL); if (!tar_info) return -ENOMEM; @@ -412,7 +412,7 @@ static struct tar_arch_info_t *load_tar_archive(struct device *dev, size_t tar_size; int ret; - tar_arch = kzalloc(sizeof(struct tar_arch_info_t), GFP_KERNEL); + tar_arch = kzalloc_obj(struct tar_arch_info_t, GFP_KERNEL); if (!tar_arch) return NULL; diff --git a/drivers/crypto/marvell/octeontx/otx_cptvf_main.c b/drivers/crypto/marvell/octeontx/otx_cptvf_main.c index 6c0bfb3ea1c9..32f6616a60eb 100644 --- a/drivers/crypto/marvell/octeontx/otx_cptvf_main.c +++ b/drivers/crypto/marvell/octeontx/otx_cptvf_main.c @@ -31,7 +31,7 @@ static int init_worker_threads(struct otx_cptvf *cptvf) struct otx_cptvf_wqe_info *cwqe_info; int i; - cwqe_info = kzalloc(sizeof(*cwqe_info), GFP_KERNEL); + cwqe_info = kzalloc_obj(*cwqe_info, GFP_KERNEL); if (!cwqe_info) return -ENOMEM; @@ -100,7 +100,7 @@ static int alloc_pending_queues(struct otx_cpt_pending_qinfo *pqinfo, u32 qlen, pqinfo->num_queues = num_queues; for_each_pending_queue(pqinfo, queue, i) { - queue->head = kcalloc(qlen, sizeof(*queue->head), GFP_KERNEL); + queue->head = kzalloc_objs(*queue->head, qlen, GFP_KERNEL); if (!queue->head) { ret = -ENOMEM; goto pending_qfail; @@ -212,7 +212,7 @@ static int alloc_command_queues(struct otx_cptvf *cptvf, queue = &cqinfo->queue[i]; INIT_LIST_HEAD(&queue->chead); do { - curr = kzalloc(sizeof(*curr), GFP_KERNEL); + curr = kzalloc_obj(*curr, GFP_KERNEL); if (!curr) goto cmd_qfail; diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c index f54f90588d86..37eb56ab7832 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_main.c @@ -340,8 +340,8 @@ static int cptpf_flr_wq_init(struct otx2_cptpf_dev *cptpf, int num_vfs) if (!cptpf->flr_wq) return -ENOMEM; - cptpf->flr_work = kcalloc(num_vfs, sizeof(struct cptpf_flr_work), - GFP_KERNEL); + cptpf->flr_work = kzalloc_objs(struct cptpf_flr_work, num_vfs, + GFP_KERNEL); if (!cptpf->flr_work) goto destroy_wq; diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c index b5cc5401f704..97d948fbc4b3 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptpf_ucode.c @@ -372,7 +372,7 @@ static int load_fw(struct device *dev, struct fw_info_t *fw_info, int ucode_type, ucode_size; int ret; - uc_info = kzalloc(sizeof(*uc_info), GFP_KERNEL); + uc_info = kzalloc_obj(*uc_info, GFP_KERNEL); if (!uc_info) return -ENOMEM; diff --git a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c index c1c44a7b89fa..bec0a4cd2662 100644 --- a/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c +++ b/drivers/crypto/marvell/octeontx2/otx2_cptvf_main.c @@ -150,7 +150,7 @@ static int init_tasklet_work(struct otx2_cptlfs_info *lfs) int i, ret = 0; for (i = 0; i < lfs->lfs_num; i++) { - wqe = kzalloc(sizeof(struct otx2_cptlf_wqe), GFP_KERNEL); + wqe = kzalloc_obj(struct otx2_cptlf_wqe, GFP_KERNEL); if (!wqe) { ret = -ENOMEM; goto cleanup_tasklet; |
