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/gpu/host1x | |
| 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/gpu/host1x')
| -rw-r--r-- | drivers/gpu/host1x/bus.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/host1x/channel.c | 4 | ||||
| -rw-r--r-- | drivers/gpu/host1x/context.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/host1x/fence.c | 2 | ||||
| -rw-r--r-- | drivers/gpu/host1x/mipi.c | 2 |
5 files changed, 7 insertions, 7 deletions
diff --git a/drivers/gpu/host1x/bus.c b/drivers/gpu/host1x/bus.c index e2673bc7cb31..b0c12d63d7b4 100644 --- a/drivers/gpu/host1x/bus.c +++ b/drivers/gpu/host1x/bus.c @@ -43,7 +43,7 @@ static int host1x_subdev_add(struct host1x_device *device, struct host1x_subdev *subdev; int err; - subdev = kzalloc(sizeof(*subdev), GFP_KERNEL); + subdev = kzalloc_obj(*subdev, GFP_KERNEL); if (!subdev) return -ENOMEM; @@ -459,7 +459,7 @@ static int host1x_device_add(struct host1x *host1x, struct host1x_device *device; int err; - device = kzalloc(sizeof(*device), GFP_KERNEL); + device = kzalloc_obj(*device, GFP_KERNEL); if (!device) return -ENOMEM; diff --git a/drivers/gpu/host1x/channel.c b/drivers/gpu/host1x/channel.c index 08077afe4cde..b2d434746167 100644 --- a/drivers/gpu/host1x/channel.c +++ b/drivers/gpu/host1x/channel.c @@ -16,8 +16,8 @@ int host1x_channel_list_init(struct host1x_channel_list *chlist, unsigned int num_channels) { - chlist->channels = kcalloc(num_channels, sizeof(struct host1x_channel), - GFP_KERNEL); + chlist->channels = kzalloc_objs(struct host1x_channel, num_channels, + GFP_KERNEL); if (!chlist->channels) return -ENOMEM; diff --git a/drivers/gpu/host1x/context.c b/drivers/gpu/host1x/context.c index a6f6779662a3..8d7719dab510 100644 --- a/drivers/gpu/host1x/context.c +++ b/drivers/gpu/host1x/context.c @@ -35,7 +35,7 @@ int host1x_memory_context_list_init(struct host1x *host1x) return 0; cdl->len = err / 4; - cdl->devs = kcalloc(cdl->len, sizeof(*cdl->devs), GFP_KERNEL); + cdl->devs = kzalloc_objs(*cdl->devs, cdl->len, GFP_KERNEL); if (!cdl->devs) return -ENOMEM; diff --git a/drivers/gpu/host1x/fence.c b/drivers/gpu/host1x/fence.c index 139ad1afd935..d8f3aade9b2e 100644 --- a/drivers/gpu/host1x/fence.c +++ b/drivers/gpu/host1x/fence.c @@ -127,7 +127,7 @@ struct dma_fence *host1x_fence_create(struct host1x_syncpt *sp, u32 threshold, { struct host1x_syncpt_fence *fence; - fence = kzalloc(sizeof(*fence), GFP_KERNEL); + fence = kzalloc_obj(*fence, GFP_KERNEL); if (!fence) return ERR_PTR(-ENOMEM); diff --git a/drivers/gpu/host1x/mipi.c b/drivers/gpu/host1x/mipi.c index e51b43dd15a3..90108d695f63 100644 --- a/drivers/gpu/host1x/mipi.c +++ b/drivers/gpu/host1x/mipi.c @@ -219,7 +219,7 @@ struct tegra_mipi_device *tegra_mipi_request(struct device *device, if (err < 0) return ERR_PTR(err); - dev = kzalloc(sizeof(*dev), GFP_KERNEL); + dev = kzalloc_obj(*dev, GFP_KERNEL); if (!dev) { err = -ENOMEM; goto out; |
