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/platform/surface/aggregator | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-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/platform/surface/aggregator')
| -rw-r--r-- | drivers/platform/surface/aggregator/bus.c | 2 | ||||
| -rw-r--r-- | drivers/platform/surface/aggregator/controller.c | 4 | ||||
| -rw-r--r-- | drivers/platform/surface/aggregator/core.c | 2 |
3 files changed, 4 insertions, 4 deletions
diff --git a/drivers/platform/surface/aggregator/bus.c b/drivers/platform/surface/aggregator/bus.c index d68d231e716e..dba8ca379385 100644 --- a/drivers/platform/surface/aggregator/bus.c +++ b/drivers/platform/surface/aggregator/bus.c @@ -83,7 +83,7 @@ struct ssam_device *ssam_device_alloc(struct ssam_controller *ctrl, { struct ssam_device *sdev; - sdev = kzalloc(sizeof(*sdev), GFP_KERNEL); + sdev = kzalloc_obj(*sdev, GFP_KERNEL); if (!sdev) return NULL; diff --git a/drivers/platform/surface/aggregator/controller.c b/drivers/platform/surface/aggregator/controller.c index a265e667538c..5f1940a186a1 100644 --- a/drivers/platform/surface/aggregator/controller.c +++ b/drivers/platform/surface/aggregator/controller.c @@ -344,7 +344,7 @@ ssam_nf_refcount_inc(struct ssam_nf *nf, struct ssam_event_registry reg, } } - entry = kzalloc(sizeof(*entry), GFP_KERNEL); + entry = kzalloc_obj(*entry, GFP_KERNEL); if (!entry) return ERR_PTR(-ENOMEM); @@ -623,7 +623,7 @@ static struct ssam_event_item *ssam_event_item_alloc(size_t len, gfp_t flags) item->ops.free = __ssam_event_item_free_cached; } else { - item = kzalloc(struct_size(item, event.data, len), flags); + item = kzalloc_flex(*item, event.data, len, flags); if (!item) return NULL; diff --git a/drivers/platform/surface/aggregator/core.c b/drivers/platform/surface/aggregator/core.c index 82e531023911..9349a1b14ab7 100644 --- a/drivers/platform/surface/aggregator/core.c +++ b/drivers/platform/surface/aggregator/core.c @@ -652,7 +652,7 @@ static int ssam_serial_hub_probe(struct serdev_device *serdev) } /* Allocate controller. */ - ctrl = kzalloc(sizeof(*ctrl), GFP_KERNEL); + ctrl = kzalloc_obj(*ctrl, GFP_KERNEL); if (!ctrl) return -ENOMEM; |
