summaryrefslogtreecommitdiff
path: root/drivers/net/ppp
diff options
context:
space:
mode:
authorKees Cook <kees@kernel.org>2026-02-20 23:49:23 -0800
committerKees Cook <kees@kernel.org>2026-02-21 01:02:28 -0800
commit69050f8d6d075dc01af7a5f2f550a8067510366f (patch)
treebb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/net/ppp
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (diff)
downloadlwn-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/net/ppp')
-rw-r--r--drivers/net/ppp/bsd_comp.c3
-rw-r--r--drivers/net/ppp/ppp_async.c2
-rw-r--r--drivers/net/ppp/ppp_deflate.c5
-rw-r--r--drivers/net/ppp/ppp_generic.c4
-rw-r--r--drivers/net/ppp/ppp_mppe.c2
-rw-r--r--drivers/net/ppp/ppp_synctty.c2
6 files changed, 8 insertions, 10 deletions
diff --git a/drivers/net/ppp/bsd_comp.c b/drivers/net/ppp/bsd_comp.c
index f385b759d5cf..26bfa0feb7f5 100644
--- a/drivers/net/ppp/bsd_comp.c
+++ b/drivers/net/ppp/bsd_comp.c
@@ -395,8 +395,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
* Allocate the main control structure for this instance.
*/
maxmaxcode = MAXCODE(bits);
- db = kzalloc(sizeof (struct bsd_db),
- GFP_KERNEL);
+ db = kzalloc_obj(struct bsd_db, GFP_KERNEL);
if (!db)
{
return NULL;
diff --git a/drivers/net/ppp/ppp_async.c b/drivers/net/ppp/ppp_async.c
index c97406c6004d..ead937d95cd8 100644
--- a/drivers/net/ppp/ppp_async.c
+++ b/drivers/net/ppp/ppp_async.c
@@ -163,7 +163,7 @@ ppp_asynctty_open(struct tty_struct *tty)
return -EOPNOTSUPP;
err = -ENOMEM;
- ap = kzalloc(sizeof(*ap), GFP_KERNEL);
+ ap = kzalloc_obj(*ap, GFP_KERNEL);
if (!ap)
goto out;
diff --git a/drivers/net/ppp/ppp_deflate.c b/drivers/net/ppp/ppp_deflate.c
index d93aeacc0dba..1d8370d2f098 100644
--- a/drivers/net/ppp/ppp_deflate.c
+++ b/drivers/net/ppp/ppp_deflate.c
@@ -97,8 +97,7 @@ static void *z_comp_alloc(unsigned char *options, int opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL;
- state = kzalloc(sizeof(*state),
- GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (state == NULL)
return NULL;
@@ -313,7 +312,7 @@ static void *z_decomp_alloc(unsigned char *options, int opt_len)
if (w_size < DEFLATE_MIN_SIZE || w_size > DEFLATE_MAX_SIZE)
return NULL;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (state == NULL)
return NULL;
diff --git a/drivers/net/ppp/ppp_generic.c b/drivers/net/ppp/ppp_generic.c
index f8814d7be6f1..fdf96999ba18 100644
--- a/drivers/net/ppp/ppp_generic.c
+++ b/drivers/net/ppp/ppp_generic.c
@@ -2926,7 +2926,7 @@ int ppp_register_net_channel(struct net *net, struct ppp_channel *chan)
struct channel *pch;
struct ppp_net *pn;
- pch = kzalloc(sizeof(struct channel), GFP_KERNEL);
+ pch = kzalloc_obj(struct channel, GFP_KERNEL);
if (!pch)
return -ENOMEM;
@@ -3277,7 +3277,7 @@ ppp_register_compressor(struct compressor *cp)
if (find_comp_entry(cp->compress_proto))
goto out;
ret = -ENOMEM;
- ce = kmalloc(sizeof(struct compressor_entry), GFP_ATOMIC);
+ ce = kmalloc_obj(struct compressor_entry, GFP_ATOMIC);
if (!ce)
goto out;
ret = 0;
diff --git a/drivers/net/ppp/ppp_mppe.c b/drivers/net/ppp/ppp_mppe.c
index 630cbf71c147..eacfe50b6955 100644
--- a/drivers/net/ppp/ppp_mppe.c
+++ b/drivers/net/ppp/ppp_mppe.c
@@ -158,7 +158,7 @@ static void *mppe_alloc(unsigned char *options, int optlen)
fips_enabled)
return NULL;
- state = kzalloc(sizeof(*state), GFP_KERNEL);
+ state = kzalloc_obj(*state, GFP_KERNEL);
if (state == NULL)
return NULL;
diff --git a/drivers/net/ppp/ppp_synctty.c b/drivers/net/ppp/ppp_synctty.c
index 9c4932198931..f49e60985171 100644
--- a/drivers/net/ppp/ppp_synctty.c
+++ b/drivers/net/ppp/ppp_synctty.c
@@ -162,7 +162,7 @@ ppp_sync_open(struct tty_struct *tty)
if (tty->ops->write == NULL)
return -EOPNOTSUPP;
- ap = kzalloc(sizeof(*ap), GFP_KERNEL);
+ ap = kzalloc_obj(*ap, GFP_KERNEL);
err = -ENOMEM;
if (!ap)
goto out;