summaryrefslogtreecommitdiff
path: root/drivers/bcma
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/bcma
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/bcma')
-rw-r--r--drivers/bcma/driver_pci_host.c2
-rw-r--r--drivers/bcma/host_pci.c2
-rw-r--r--drivers/bcma/scan.c2
3 files changed, 3 insertions, 3 deletions
diff --git a/drivers/bcma/driver_pci_host.c b/drivers/bcma/driver_pci_host.c
index 8540052d37c5..2acf87f8de9a 100644
--- a/drivers/bcma/driver_pci_host.c
+++ b/drivers/bcma/driver_pci_host.c
@@ -399,7 +399,7 @@ void bcma_core_pci_hostmode_init(struct bcma_drv_pci *pc)
return;
}
- pc_host = kzalloc(sizeof(*pc_host), GFP_KERNEL);
+ pc_host = kzalloc_obj(*pc_host, GFP_KERNEL);
if (!pc_host) {
bcma_err(bus, "can not allocate memory");
return;
diff --git a/drivers/bcma/host_pci.c b/drivers/bcma/host_pci.c
index 960632197b05..55a4ad2c704a 100644
--- a/drivers/bcma/host_pci.c
+++ b/drivers/bcma/host_pci.c
@@ -165,7 +165,7 @@ static int bcma_host_pci_probe(struct pci_dev *dev,
u32 val;
/* Alloc */
- bus = kzalloc(sizeof(*bus), GFP_KERNEL);
+ bus = kzalloc_obj(*bus, GFP_KERNEL);
if (!bus)
goto out;
diff --git a/drivers/bcma/scan.c b/drivers/bcma/scan.c
index 26d12a7e6ca0..5e77d570767c 100644
--- a/drivers/bcma/scan.c
+++ b/drivers/bcma/scan.c
@@ -479,7 +479,7 @@ int bcma_bus_scan(struct bcma_bus *bus)
while (eromptr < eromend) {
struct bcma_device *other_core;
- struct bcma_device *core = kzalloc(sizeof(*core), GFP_KERNEL);
+ struct bcma_device *core = kzalloc_obj(*core, GFP_KERNEL);
if (!core) {
err = -ENOMEM;
goto out;