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/tty/ipwireless | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz lwn-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/tty/ipwireless')
| -rw-r--r-- | drivers/tty/ipwireless/hardware.c | 2 | ||||
| -rw-r--r-- | drivers/tty/ipwireless/main.c | 2 | ||||
| -rw-r--r-- | drivers/tty/ipwireless/network.c | 4 | ||||
| -rw-r--r-- | drivers/tty/ipwireless/tty.c | 2 |
4 files changed, 5 insertions, 5 deletions
diff --git a/drivers/tty/ipwireless/hardware.c b/drivers/tty/ipwireless/hardware.c index e18848267be4..6e6aa90b33ba 100644 --- a/drivers/tty/ipwireless/hardware.c +++ b/drivers/tty/ipwireless/hardware.c @@ -1618,7 +1618,7 @@ struct ipw_hardware *ipwireless_hardware_create(void) { int i; struct ipw_hardware *hw = - kzalloc(sizeof(struct ipw_hardware), GFP_KERNEL); + kzalloc_obj(struct ipw_hardware, GFP_KERNEL); if (!hw) return NULL; diff --git a/drivers/tty/ipwireless/main.c b/drivers/tty/ipwireless/main.c index 4c18bbfe1a92..3bf160d62a1e 100644 --- a/drivers/tty/ipwireless/main.c +++ b/drivers/tty/ipwireless/main.c @@ -267,7 +267,7 @@ static int ipwireless_attach(struct pcmcia_device *link) struct ipw_dev *ipw; int ret; - ipw = kzalloc(sizeof(struct ipw_dev), GFP_KERNEL); + ipw = kzalloc_obj(struct ipw_dev, GFP_KERNEL); if (!ipw) return -ENOMEM; diff --git a/drivers/tty/ipwireless/network.c b/drivers/tty/ipwireless/network.c index fe569f6294a2..cb864142be09 100644 --- a/drivers/tty/ipwireless/network.c +++ b/drivers/tty/ipwireless/network.c @@ -257,7 +257,7 @@ static void do_go_online(struct work_struct *work_go_online) struct ppp_channel *channel; spin_unlock_irqrestore(&network->lock, flags); - channel = kzalloc(sizeof(struct ppp_channel), GFP_KERNEL); + channel = kzalloc_obj(struct ppp_channel, GFP_KERNEL); if (!channel) { printk(KERN_ERR IPWIRELESS_PCCARD_NAME ": unable to allocate PPP channel\n"); @@ -416,7 +416,7 @@ void ipwireless_network_packet_received(struct ipw_network *network, struct ipw_network *ipwireless_network_create(struct ipw_hardware *hw) { struct ipw_network *network = - kzalloc(sizeof(struct ipw_network), GFP_KERNEL); + kzalloc_obj(struct ipw_network, GFP_KERNEL); if (!network) return NULL; diff --git a/drivers/tty/ipwireless/tty.c b/drivers/tty/ipwireless/tty.c index b6de40815fb9..79c01ff49c65 100644 --- a/drivers/tty/ipwireless/tty.c +++ b/drivers/tty/ipwireless/tty.c @@ -437,7 +437,7 @@ static int add_tty(int j, struct ipw_network *network, int channel_idx, int secondary_channel_idx, int tty_type) { - ttys[j] = kzalloc(sizeof(struct ipw_tty), GFP_KERNEL); + ttys[j] = kzalloc_obj(struct ipw_tty, GFP_KERNEL); if (!ttys[j]) return -ENOMEM; ttys[j]->index = j; |
