summaryrefslogtreecommitdiff
path: root/drivers/ps3
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/ps3
parentd39a1d7486d98668dd34aaa6732aad7977c45f5a (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/ps3')
-rw-r--r--drivers/ps3/ps3-lpm.c2
-rw-r--r--drivers/ps3/ps3-vuart.c5
-rw-r--r--drivers/ps3/ps3av.c2
3 files changed, 4 insertions, 5 deletions
diff --git a/drivers/ps3/ps3-lpm.c b/drivers/ps3/ps3-lpm.c
index 188ae2572674..8f1ee4c748bf 100644
--- a/drivers/ps3/ps3-lpm.c
+++ b/drivers/ps3/ps3-lpm.c
@@ -1181,7 +1181,7 @@ static int ps3_lpm_probe(struct ps3_system_bus_device *dev)
return -EBUSY;
}
- lpm_priv = kzalloc(sizeof(*lpm_priv), GFP_KERNEL);
+ lpm_priv = kzalloc_obj(*lpm_priv, GFP_KERNEL);
if (!lpm_priv)
return -ENOMEM;
diff --git a/drivers/ps3/ps3-vuart.c b/drivers/ps3/ps3-vuart.c
index 5cb92535a4a1..3493a9ef05ce 100644
--- a/drivers/ps3/ps3-vuart.c
+++ b/drivers/ps3/ps3-vuart.c
@@ -914,7 +914,7 @@ static int ps3_vuart_bus_interrupt_get(void)
BUG_ON(vuart_bus_priv.bmp);
- vuart_bus_priv.bmp = kzalloc(sizeof(struct ports_bmp), GFP_KERNEL);
+ vuart_bus_priv.bmp = kzalloc_obj(struct ports_bmp, GFP_KERNEL);
if (!vuart_bus_priv.bmp) {
result = -ENOMEM;
@@ -1015,8 +1015,7 @@ static int ps3_vuart_probe(struct ps3_system_bus_device *dev)
/* Setup dev->driver_priv. */
- dev->driver_priv = kzalloc(sizeof(struct ps3_vuart_port_priv),
- GFP_KERNEL);
+ dev->driver_priv = kzalloc_obj(struct ps3_vuart_port_priv, GFP_KERNEL);
if (!dev->driver_priv) {
result = -ENOMEM;
diff --git a/drivers/ps3/ps3av.c b/drivers/ps3/ps3av.c
index f6c9e56bdba7..19f2c5b4f8f3 100644
--- a/drivers/ps3/ps3av.c
+++ b/drivers/ps3/ps3av.c
@@ -934,7 +934,7 @@ static int ps3av_probe(struct ps3_system_bus_device *dev)
return -EBUSY;
}
- ps3av = kzalloc(sizeof(*ps3av), GFP_KERNEL);
+ ps3av = kzalloc_obj(*ps3av, GFP_KERNEL);
if (!ps3av)
return -ENOMEM;