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/cdx/controller | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-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/cdx/controller')
| -rw-r--r-- | drivers/cdx/controller/cdx_controller.c | 4 | ||||
| -rw-r--r-- | drivers/cdx/controller/mcdi.c | 6 |
2 files changed, 5 insertions, 5 deletions
diff --git a/drivers/cdx/controller/cdx_controller.c b/drivers/cdx/controller/cdx_controller.c index 280f207735da..abd8f9cdb0b5 100644 --- a/drivers/cdx/controller/cdx_controller.c +++ b/drivers/cdx/controller/cdx_controller.c @@ -168,7 +168,7 @@ static int xlnx_cdx_probe(struct platform_device *pdev) struct cdx_mcdi *cdx_mcdi; int ret; - cdx_mcdi = kzalloc(sizeof(*cdx_mcdi), GFP_KERNEL); + cdx_mcdi = kzalloc_obj(*cdx_mcdi, GFP_KERNEL); if (!cdx_mcdi) return -ENOMEM; @@ -181,7 +181,7 @@ static int xlnx_cdx_probe(struct platform_device *pdev) goto mcdi_init_fail; } - cdx = kzalloc(sizeof(*cdx), GFP_KERNEL); + cdx = kzalloc_obj(*cdx, GFP_KERNEL); if (!cdx) { ret = -ENOMEM; goto cdx_alloc_fail; diff --git a/drivers/cdx/controller/mcdi.c b/drivers/cdx/controller/mcdi.c index 2e82ffc18d89..4b3d8f1ef964 100644 --- a/drivers/cdx/controller/mcdi.c +++ b/drivers/cdx/controller/mcdi.c @@ -118,7 +118,7 @@ int cdx_mcdi_init(struct cdx_mcdi *cdx) struct cdx_mcdi_iface *mcdi; int rc = -ENOMEM; - cdx->mcdi = kzalloc(sizeof(*cdx->mcdi), GFP_KERNEL); + cdx->mcdi = kzalloc_obj(*cdx->mcdi, GFP_KERNEL); if (!cdx->mcdi) goto fail; @@ -456,11 +456,11 @@ static int cdx_mcdi_rpc_sync(struct cdx_mcdi *cdx, unsigned int cmd, if (outlen_actual) *outlen_actual = 0; - wait_data = kmalloc(sizeof(*wait_data), GFP_KERNEL); + wait_data = kmalloc_obj(*wait_data, GFP_KERNEL); if (!wait_data) return -ENOMEM; - cmd_item = kmalloc(sizeof(*cmd_item), GFP_KERNEL); + cmd_item = kmalloc_obj(*cmd_item, GFP_KERNEL); if (!cmd_item) { kfree(wait_data); return -ENOMEM; |
