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/peci | |
| 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/peci')
| -rw-r--r-- | drivers/peci/core.c | 2 | ||||
| -rw-r--r-- | drivers/peci/cpu.c | 2 | ||||
| -rw-r--r-- | drivers/peci/device.c | 2 | ||||
| -rw-r--r-- | drivers/peci/request.c | 2 |
4 files changed, 4 insertions, 4 deletions
diff --git a/drivers/peci/core.c b/drivers/peci/core.c index 936c1fadefe5..f54341959769 100644 --- a/drivers/peci/core.c +++ b/drivers/peci/core.c @@ -52,7 +52,7 @@ static struct peci_controller *peci_controller_alloc(struct device *dev, if (!ops->xfer) return ERR_PTR(-EINVAL); - controller = kzalloc(sizeof(*controller), GFP_KERNEL); + controller = kzalloc_obj(*controller, GFP_KERNEL); if (!controller) return ERR_PTR(-ENOMEM); diff --git a/drivers/peci/cpu.c b/drivers/peci/cpu.c index fbccc1d1b637..050612e2d3ca 100644 --- a/drivers/peci/cpu.c +++ b/drivers/peci/cpu.c @@ -199,7 +199,7 @@ static struct auxiliary_device *adev_alloc(struct peci_cpu *priv, int idx) const char *name; int ret; - adev = kzalloc(sizeof(*adev), GFP_KERNEL); + adev = kzalloc_obj(*adev, GFP_KERNEL); if (!adev) return ERR_PTR(-ENOMEM); diff --git a/drivers/peci/device.c b/drivers/peci/device.c index 416635029f55..ed4177b72f0e 100644 --- a/drivers/peci/device.c +++ b/drivers/peci/device.c @@ -170,7 +170,7 @@ int peci_device_create(struct peci_controller *controller, u8 addr) return ret; } - device = kzalloc(sizeof(*device), GFP_KERNEL); + device = kzalloc_obj(*device, GFP_KERNEL); if (!device) return -ENOMEM; diff --git a/drivers/peci/request.c b/drivers/peci/request.c index e6327af45fc7..437a59146dff 100644 --- a/drivers/peci/request.c +++ b/drivers/peci/request.c @@ -203,7 +203,7 @@ struct peci_request *peci_request_alloc(struct peci_device *device, u8 tx_len, u * should be converted to DMA API once support for controllers that do * allow it is added to avoid an extra copy. */ - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = kzalloc_obj(*req, GFP_KERNEL); if (!req) return NULL; |
