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/ipack | |
| 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/ipack')
| -rw-r--r-- | drivers/ipack/carriers/tpci200.c | 12 | ||||
| -rw-r--r-- | drivers/ipack/devices/ipoctal.c | 2 | ||||
| -rw-r--r-- | drivers/ipack/ipack.c | 2 |
3 files changed, 8 insertions, 8 deletions
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index cbfdadecb23b..6d1058dc8faa 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c @@ -209,7 +209,7 @@ static int tpci200_request_irq(struct ipack_device *dev, goto out_unlock; } - slot_irq = kzalloc(sizeof(struct slot_irq), GFP_KERNEL); + slot_irq = kzalloc_obj(struct slot_irq, GFP_KERNEL); if (slot_irq == NULL) { dev_err(&dev->dev, "Slot [%d:%d] unable to allocate memory for IRQ !\n", @@ -461,8 +461,8 @@ static int tpci200_install(struct tpci200_board *tpci200) { int res; - tpci200->slots = kcalloc(TPCI200_NB_SLOT, sizeof(struct tpci200_slot), - GFP_KERNEL); + tpci200->slots = kzalloc_objs(struct tpci200_slot, TPCI200_NB_SLOT, + GFP_KERNEL); if (tpci200->slots == NULL) return -ENOMEM; @@ -487,7 +487,7 @@ static int tpci200_create_device(struct tpci200_board *tpci200, int i) int ret; enum ipack_space space; struct ipack_device *dev = - kzalloc(sizeof(struct ipack_device), GFP_KERNEL); + kzalloc_obj(struct ipack_device, GFP_KERNEL); if (!dev) return -ENOMEM; dev->slot = i; @@ -521,11 +521,11 @@ static int tpci200_pci_probe(struct pci_dev *pdev, struct tpci200_board *tpci200; u32 reg32; - tpci200 = kzalloc(sizeof(struct tpci200_board), GFP_KERNEL); + tpci200 = kzalloc_obj(struct tpci200_board, GFP_KERNEL); if (!tpci200) return -ENOMEM; - tpci200->info = kzalloc(sizeof(struct tpci200_infos), GFP_KERNEL); + tpci200->info = kzalloc_obj(struct tpci200_infos, GFP_KERNEL); if (!tpci200->info) { ret = -ENOMEM; goto err_tpci200; diff --git a/drivers/ipack/devices/ipoctal.c b/drivers/ipack/devices/ipoctal.c index ba2e9e52d72b..563fdf197101 100644 --- a/drivers/ipack/devices/ipoctal.c +++ b/drivers/ipack/devices/ipoctal.c @@ -688,7 +688,7 @@ static int ipoctal_probe(struct ipack_device *dev) int res; struct ipoctal *ipoctal; - ipoctal = kzalloc(sizeof(struct ipoctal), GFP_KERNEL); + ipoctal = kzalloc_obj(struct ipoctal, GFP_KERNEL); if (ipoctal == NULL) return -ENOMEM; diff --git a/drivers/ipack/ipack.c b/drivers/ipack/ipack.c index 57d232c909f9..d4ec786bf98d 100644 --- a/drivers/ipack/ipack.c +++ b/drivers/ipack/ipack.c @@ -203,7 +203,7 @@ struct ipack_bus_device *ipack_bus_register(struct device *parent, int slots, int bus_nr; struct ipack_bus_device *bus; - bus = kzalloc(sizeof(*bus), GFP_KERNEL); + bus = kzalloc_obj(*bus, GFP_KERNEL); if (!bus) return NULL; |
