summaryrefslogtreecommitdiff
path: root/drivers/gnss
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/gnss
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/gnss')
-rw-r--r--drivers/gnss/core.c2
-rw-r--r--drivers/gnss/usb.c2
2 files changed, 2 insertions, 2 deletions
diff --git a/drivers/gnss/core.c b/drivers/gnss/core.c
index 883ef86ad3fc..fb17b7811025 100644
--- a/drivers/gnss/core.c
+++ b/drivers/gnss/core.c
@@ -227,7 +227,7 @@ struct gnss_device *gnss_allocate_device(struct device *parent)
int id;
int ret;
- gdev = kzalloc(sizeof(*gdev), GFP_KERNEL);
+ gdev = kzalloc_obj(*gdev, GFP_KERNEL);
if (!gdev)
return NULL;
diff --git a/drivers/gnss/usb.c b/drivers/gnss/usb.c
index 028ce56b20ea..919ea2ab4572 100644
--- a/drivers/gnss/usb.c
+++ b/drivers/gnss/usb.c
@@ -131,7 +131,7 @@ static int gnss_usb_probe(struct usb_interface *intf, const struct usb_device_id
if (ret)
return ret;
- gusb = kzalloc(sizeof(*gusb), GFP_KERNEL);
+ gusb = kzalloc_obj(*gusb, GFP_KERNEL);
if (!gusb)
return -ENOMEM;