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 /net/caif | |
| 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 'net/caif')
| -rw-r--r-- | net/caif/caif_dev.c | 2 | ||||
| -rw-r--r-- | net/caif/caif_usb.c | 2 | ||||
| -rw-r--r-- | net/caif/cfcnfg.c | 4 | ||||
| -rw-r--r-- | net/caif/cfctrl.c | 4 | ||||
| -rw-r--r-- | net/caif/cfdbgl.c | 2 | ||||
| -rw-r--r-- | net/caif/cfdgml.c | 2 | ||||
| -rw-r--r-- | net/caif/cffrml.c | 2 | ||||
| -rw-r--r-- | net/caif/cfmuxl.c | 2 | ||||
| -rw-r--r-- | net/caif/cfrfml.c | 2 | ||||
| -rw-r--r-- | net/caif/cfserl.c | 2 | ||||
| -rw-r--r-- | net/caif/cfutill.c | 2 | ||||
| -rw-r--r-- | net/caif/cfveil.c | 2 | ||||
| -rw-r--r-- | net/caif/cfvidl.c | 2 |
13 files changed, 15 insertions, 15 deletions
diff --git a/net/caif/caif_dev.c b/net/caif/caif_dev.c index 24e85c5487ef..18f7769405f9 100644 --- a/net/caif/caif_dev.c +++ b/net/caif/caif_dev.c @@ -94,7 +94,7 @@ static struct caif_device_entry *caif_device_alloc(struct net_device *dev) { struct caif_device_entry *caifd; - caifd = kzalloc(sizeof(*caifd), GFP_KERNEL); + caifd = kzalloc_obj(*caifd, GFP_KERNEL); if (!caifd) return NULL; caifd->pcpu_refcnt = alloc_percpu(int); diff --git a/net/caif/caif_usb.c b/net/caif/caif_usb.c index 5dc05a1e3178..4d44960d4c2f 100644 --- a/net/caif/caif_usb.c +++ b/net/caif/caif_usb.c @@ -85,7 +85,7 @@ static void cfusbl_ctrlcmd(struct cflayer *layr, enum caif_ctrlcmd ctrl, static struct cflayer *cfusbl_create(int phyid, const u8 ethaddr[ETH_ALEN], u8 braddr[ETH_ALEN]) { - struct cfusbl *this = kmalloc(sizeof(struct cfusbl), GFP_ATOMIC); + struct cfusbl *this = kmalloc_obj(struct cfusbl, GFP_ATOMIC); if (!this) return NULL; diff --git a/net/caif/cfcnfg.c b/net/caif/cfcnfg.c index 52509e185960..8a80914783e8 100644 --- a/net/caif/cfcnfg.c +++ b/net/caif/cfcnfg.c @@ -77,7 +77,7 @@ struct cfcnfg *cfcnfg_create(void) might_sleep(); /* Initiate this layer */ - this = kzalloc(sizeof(struct cfcnfg), GFP_ATOMIC); + this = kzalloc_obj(struct cfcnfg, GFP_ATOMIC); if (!this) return NULL; this->mux = cfmuxl_create(); @@ -477,7 +477,7 @@ cfcnfg_add_phy_layer(struct cfcnfg *cnfg, goto out; got_phyid: - phyinfo = kzalloc(sizeof(struct cfcnfg_phyinfo), GFP_ATOMIC); + phyinfo = kzalloc_obj(struct cfcnfg_phyinfo, GFP_ATOMIC); if (!phyinfo) { res = -ENOMEM; goto out; diff --git a/net/caif/cfctrl.c b/net/caif/cfctrl.c index 2aa1e7d46eb2..566546da4152 100644 --- a/net/caif/cfctrl.c +++ b/net/caif/cfctrl.c @@ -36,7 +36,7 @@ struct cflayer *cfctrl_create(void) { struct dev_info dev_info; struct cfctrl *this = - kzalloc(sizeof(struct cfctrl), GFP_ATOMIC); + kzalloc_obj(struct cfctrl, GFP_ATOMIC); if (!this) return NULL; caif_assert(offsetof(struct cfctrl, serv.layer) == 0); @@ -270,7 +270,7 @@ int cfctrl_linkup_request(struct cflayer *layer, cfpkt_destroy(pkt); return -EINVAL; } - req = kzalloc(sizeof(*req), GFP_KERNEL); + req = kzalloc_obj(*req, GFP_KERNEL); if (!req) { cfpkt_destroy(pkt); return -ENOMEM; diff --git a/net/caif/cfdbgl.c b/net/caif/cfdbgl.c index 77f428428b47..57ad3f82e004 100644 --- a/net/caif/cfdbgl.c +++ b/net/caif/cfdbgl.c @@ -19,7 +19,7 @@ static int cfdbgl_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfdbgl_create(u8 channel_id, struct dev_info *dev_info) { - struct cfsrvl *dbg = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); + struct cfsrvl *dbg = kzalloc_obj(struct cfsrvl, GFP_ATOMIC); if (!dbg) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); diff --git a/net/caif/cfdgml.c b/net/caif/cfdgml.c index eb6f8ef47a79..c451ddd155a7 100644 --- a/net/caif/cfdgml.c +++ b/net/caif/cfdgml.c @@ -26,7 +26,7 @@ static int cfdgml_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfdgml_create(u8 channel_id, struct dev_info *dev_info) { - struct cfsrvl *dgm = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); + struct cfsrvl *dgm = kzalloc_obj(struct cfsrvl, GFP_ATOMIC); if (!dgm) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); diff --git a/net/caif/cffrml.c b/net/caif/cffrml.c index d4d63586053a..0f4979d89fcb 100644 --- a/net/caif/cffrml.c +++ b/net/caif/cffrml.c @@ -34,7 +34,7 @@ static u32 cffrml_rcv_error; static u32 cffrml_rcv_checsum_error; struct cflayer *cffrml_create(u16 phyid, bool use_fcs) { - struct cffrml *this = kzalloc(sizeof(struct cffrml), GFP_ATOMIC); + struct cffrml *this = kzalloc_obj(struct cffrml, GFP_ATOMIC); if (!this) return NULL; this->pcpu_refcnt = alloc_percpu(int); diff --git a/net/caif/cfmuxl.c b/net/caif/cfmuxl.c index 4172b0d0db63..77a1f31639b7 100644 --- a/net/caif/cfmuxl.c +++ b/net/caif/cfmuxl.c @@ -47,7 +47,7 @@ static struct cflayer *get_up(struct cfmuxl *muxl, u16 id); struct cflayer *cfmuxl_create(void) { - struct cfmuxl *this = kzalloc(sizeof(struct cfmuxl), GFP_ATOMIC); + struct cfmuxl *this = kzalloc_obj(struct cfmuxl, GFP_ATOMIC); if (!this) return NULL; diff --git a/net/caif/cfrfml.c b/net/caif/cfrfml.c index 3c335057f255..93732ebbd1e2 100644 --- a/net/caif/cfrfml.c +++ b/net/caif/cfrfml.c @@ -46,7 +46,7 @@ struct cflayer *cfrfml_create(u8 channel_id, struct dev_info *dev_info, int mtu_size) { int tmp; - struct cfrfml *this = kzalloc(sizeof(struct cfrfml), GFP_ATOMIC); + struct cfrfml *this = kzalloc_obj(struct cfrfml, GFP_ATOMIC); if (!this) return NULL; diff --git a/net/caif/cfserl.c b/net/caif/cfserl.c index aee11c74d3c8..faf78fb754e2 100644 --- a/net/caif/cfserl.c +++ b/net/caif/cfserl.c @@ -38,7 +38,7 @@ void cfserl_release(struct cflayer *layer) struct cflayer *cfserl_create(int instance, bool use_stx) { - struct cfserl *this = kzalloc(sizeof(struct cfserl), GFP_ATOMIC); + struct cfserl *this = kzalloc_obj(struct cfserl, GFP_ATOMIC); if (!this) return NULL; caif_assert(offsetof(struct cfserl, layer) == 0); diff --git a/net/caif/cfutill.c b/net/caif/cfutill.c index b2e47ede912f..5111090bb2c0 100644 --- a/net/caif/cfutill.c +++ b/net/caif/cfutill.c @@ -26,7 +26,7 @@ static int cfutill_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfutill_create(u8 channel_id, struct dev_info *dev_info) { - struct cfsrvl *util = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); + struct cfsrvl *util = kzalloc_obj(struct cfsrvl, GFP_ATOMIC); if (!util) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); diff --git a/net/caif/cfveil.c b/net/caif/cfveil.c index db2274b94a5d..53f844c49bbb 100644 --- a/net/caif/cfveil.c +++ b/net/caif/cfveil.c @@ -25,7 +25,7 @@ static int cfvei_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfvei_create(u8 channel_id, struct dev_info *dev_info) { - struct cfsrvl *vei = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); + struct cfsrvl *vei = kzalloc_obj(struct cfsrvl, GFP_ATOMIC); if (!vei) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); diff --git a/net/caif/cfvidl.c b/net/caif/cfvidl.c index 134bad43196c..39e075b0a259 100644 --- a/net/caif/cfvidl.c +++ b/net/caif/cfvidl.c @@ -21,7 +21,7 @@ static int cfvidl_transmit(struct cflayer *layr, struct cfpkt *pkt); struct cflayer *cfvidl_create(u8 channel_id, struct dev_info *dev_info) { - struct cfsrvl *vid = kzalloc(sizeof(struct cfsrvl), GFP_ATOMIC); + struct cfsrvl *vid = kzalloc_obj(struct cfsrvl, GFP_ATOMIC); if (!vid) return NULL; caif_assert(offsetof(struct cfsrvl, layer) == 0); |
