summaryrefslogtreecommitdiffstats
path: root/drivers/gpu/drm/panthor
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/gpu/drm/panthor
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlinux-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz
linux-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/gpu/drm/panthor')
-rw-r--r--drivers/gpu/drm/panthor/panthor_drv.c8
-rw-r--r--drivers/gpu/drm/panthor/panthor_gem.c4
-rw-r--r--drivers/gpu/drm/panthor/panthor_heap.c6
-rw-r--r--drivers/gpu/drm/panthor/panthor_mmu.c19
-rw-r--r--drivers/gpu/drm/panthor/panthor_sched.c10
5 files changed, 23 insertions, 24 deletions
diff --git a/drivers/gpu/drm/panthor/panthor_drv.c b/drivers/gpu/drm/panthor/panthor_drv.c
index 165dddfde6ca..e1e51daba356 100644
--- a/drivers/gpu/drm/panthor/panthor_drv.c
+++ b/drivers/gpu/drm/panthor/panthor_drv.c
@@ -382,7 +382,7 @@ panthor_submit_ctx_add_sync_signal(struct panthor_submit_ctx *ctx, u32 handle, u
struct dma_fence *cur_fence;
int ret;
- sig_sync = kzalloc(sizeof(*sig_sync), GFP_KERNEL);
+ sig_sync = kzalloc_obj(*sig_sync, GFP_KERNEL);
if (!sig_sync)
return -ENOMEM;
@@ -723,8 +723,8 @@ panthor_submit_ctx_push_jobs(struct panthor_submit_ctx *ctx,
static int panthor_submit_ctx_init(struct panthor_submit_ctx *ctx,
struct drm_file *file, u32 job_count)
{
- ctx->jobs = kvmalloc_array(job_count, sizeof(*ctx->jobs),
- GFP_KERNEL | __GFP_ZERO);
+ ctx->jobs = kvmalloc_objs(*ctx->jobs, job_count,
+ GFP_KERNEL | __GFP_ZERO);
if (!ctx->jobs)
return -ENOMEM;
@@ -1471,7 +1471,7 @@ panthor_open(struct drm_device *ddev, struct drm_file *file)
struct panthor_file *pfile;
int ret;
- pfile = kzalloc(sizeof(*pfile), GFP_KERNEL);
+ pfile = kzalloc_obj(*pfile, GFP_KERNEL);
if (!pfile)
return -ENOMEM;
diff --git a/drivers/gpu/drm/panthor/panthor_gem.c b/drivers/gpu/drm/panthor/panthor_gem.c
index 2c215efb5320..3d94f9cc94d6 100644
--- a/drivers/gpu/drm/panthor/panthor_gem.c
+++ b/drivers/gpu/drm/panthor/panthor_gem.c
@@ -183,7 +183,7 @@ panthor_kernel_bo_create(struct panthor_device *ptdev, struct panthor_vm *vm,
if (drm_WARN_ON(&ptdev->base, !vm))
return ERR_PTR(-EINVAL);
- kbo = kzalloc(sizeof(*kbo), GFP_KERNEL);
+ kbo = kzalloc_obj(*kbo, GFP_KERNEL);
if (!kbo)
return ERR_PTR(-ENOMEM);
@@ -399,7 +399,7 @@ struct drm_gem_object *panthor_gem_create_object(struct drm_device *ddev, size_t
{
struct panthor_gem_object *obj;
- obj = kzalloc(sizeof(*obj), GFP_KERNEL);
+ obj = kzalloc_obj(*obj, GFP_KERNEL);
if (!obj)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/panthor/panthor_heap.c b/drivers/gpu/drm/panthor/panthor_heap.c
index 0b6ff4c0a11b..ded9cb83842c 100644
--- a/drivers/gpu/drm/panthor/panthor_heap.c
+++ b/drivers/gpu/drm/panthor/panthor_heap.c
@@ -145,7 +145,7 @@ static int panthor_alloc_heap_chunk(struct panthor_heap_pool *pool,
struct panthor_heap_chunk_header *hdr;
int ret;
- chunk = kmalloc(sizeof(*chunk), GFP_KERNEL);
+ chunk = kmalloc_obj(*chunk, GFP_KERNEL);
if (!chunk)
return -ENOMEM;
@@ -303,7 +303,7 @@ int panthor_heap_create(struct panthor_heap_pool *pool,
if (!vm)
return -EINVAL;
- heap = kzalloc(sizeof(*heap), GFP_KERNEL);
+ heap = kzalloc_obj(*heap, GFP_KERNEL);
if (!heap) {
ret = -ENOMEM;
goto err_put_vm;
@@ -541,7 +541,7 @@ panthor_heap_pool_create(struct panthor_device *ptdev, struct panthor_vm *vm)
struct panthor_heap_pool *pool;
int ret = 0;
- pool = kzalloc(sizeof(*pool), GFP_KERNEL);
+ pool = kzalloc_obj(*pool, GFP_KERNEL);
if (!pool)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/panthor/panthor_mmu.c b/drivers/gpu/drm/panthor/panthor_mmu.c
index 198d59f42578..c482bbe6fffd 100644
--- a/drivers/gpu/drm/panthor/panthor_mmu.c
+++ b/drivers/gpu/drm/panthor/panthor_mmu.c
@@ -1159,7 +1159,7 @@ panthor_vm_op_ctx_prealloc_vmas(struct panthor_vm_op_ctx *op_ctx)
}
for (u32 i = 0; i < vma_count; i++) {
- struct panthor_vma *vma = kzalloc(sizeof(*vma), GFP_KERNEL);
+ struct panthor_vma *vma = kzalloc_obj(*vma, GFP_KERNEL);
if (!vma)
return -ENOMEM;
@@ -1257,9 +1257,8 @@ static int panthor_vm_prepare_map_op_ctx(struct panthor_vm_op_ctx *op_ctx,
((ALIGN(va + size, 1ull << 30) - ALIGN_DOWN(va, 1ull << 30)) >> 30) +
((ALIGN(va + size, 1ull << 21) - ALIGN_DOWN(va, 1ull << 21)) >> 21);
- op_ctx->rsvd_page_tables.pages = kcalloc(pt_count,
- sizeof(*op_ctx->rsvd_page_tables.pages),
- GFP_KERNEL);
+ op_ctx->rsvd_page_tables.pages = kzalloc_objs(*op_ctx->rsvd_page_tables.pages,
+ pt_count, GFP_KERNEL);
if (!op_ctx->rsvd_page_tables.pages) {
ret = -ENOMEM;
goto err_cleanup;
@@ -1312,9 +1311,9 @@ static int panthor_vm_prepare_unmap_op_ctx(struct panthor_vm_op_ctx *op_ctx,
goto err_cleanup;
if (pt_count) {
- op_ctx->rsvd_page_tables.pages = kcalloc(pt_count,
- sizeof(*op_ctx->rsvd_page_tables.pages),
- GFP_KERNEL);
+ op_ctx->rsvd_page_tables.pages = kzalloc_objs(*op_ctx->rsvd_page_tables.pages,
+ pt_count,
+ GFP_KERNEL);
if (!op_ctx->rsvd_page_tables.pages) {
ret = -ENOMEM;
goto err_cleanup;
@@ -1587,7 +1586,7 @@ void panthor_vm_pool_destroy(struct panthor_file *pfile)
*/
int panthor_vm_pool_create(struct panthor_file *pfile)
{
- pfile->vms = kzalloc(sizeof(*pfile->vms), GFP_KERNEL);
+ pfile->vms = kzalloc_obj(*pfile->vms, GFP_KERNEL);
if (!pfile->vms)
return -ENOMEM;
@@ -2426,7 +2425,7 @@ panthor_vm_create(struct panthor_device *ptdev, bool for_mcu,
struct panthor_vm *vm;
int ret;
- vm = kzalloc(sizeof(*vm), GFP_KERNEL);
+ vm = kzalloc_obj(*vm, GFP_KERNEL);
if (!vm)
return ERR_PTR(-ENOMEM);
@@ -2609,7 +2608,7 @@ panthor_vm_bind_job_create(struct drm_file *file,
if (vm->destroyed || vm->unusable)
return ERR_PTR(-EINVAL);
- job = kzalloc(sizeof(*job), GFP_KERNEL);
+ job = kzalloc_obj(*job, GFP_KERNEL);
if (!job)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/gpu/drm/panthor/panthor_sched.c b/drivers/gpu/drm/panthor/panthor_sched.c
index ca272dbae14d..e40d7be90bb9 100644
--- a/drivers/gpu/drm/panthor/panthor_sched.c
+++ b/drivers/gpu/drm/panthor/panthor_sched.c
@@ -3512,7 +3512,7 @@ group_create_queue(struct panthor_group *group,
if (args->priority > CSF_MAX_QUEUE_PRIO)
return ERR_PTR(-EINVAL);
- queue = kzalloc(sizeof(*queue), GFP_KERNEL);
+ queue = kzalloc_obj(*queue, GFP_KERNEL);
if (!queue)
return ERR_PTR(-ENOMEM);
@@ -3659,7 +3659,7 @@ int panthor_group_create(struct panthor_file *pfile,
hweight64(group_args->tiler_core_mask) < group_args->max_tiler_cores)
return -EINVAL;
- group = kzalloc(sizeof(*group), GFP_KERNEL);
+ group = kzalloc_obj(*group, GFP_KERNEL);
if (!group)
return -ENOMEM;
@@ -3853,7 +3853,7 @@ int panthor_group_pool_create(struct panthor_file *pfile)
{
struct panthor_group_pool *gpool;
- gpool = kzalloc(sizeof(*gpool), GFP_KERNEL);
+ gpool = kzalloc_obj(*gpool, GFP_KERNEL);
if (!gpool)
return -ENOMEM;
@@ -3979,7 +3979,7 @@ panthor_job_create(struct panthor_file *pfile,
if (qsubmit->latest_flush & GENMASK(30, 24))
return ERR_PTR(-EINVAL);
- job = kzalloc(sizeof(*job), GFP_KERNEL);
+ job = kzalloc_obj(*job, GFP_KERNEL);
if (!job)
return ERR_PTR(-ENOMEM);
@@ -4011,7 +4011,7 @@ panthor_job_create(struct panthor_file *pfile,
* the previously submitted job.
*/
if (job->call_info.size) {
- job->done_fence = kzalloc(sizeof(*job->done_fence), GFP_KERNEL);
+ job->done_fence = kzalloc_obj(*job->done_fence, GFP_KERNEL);
if (!job->done_fence) {
ret = -ENOMEM;
goto err_put_job;