summaryrefslogtreecommitdiff
path: root/drivers/reset
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/reset
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/reset')
-rw-r--r--drivers/reset/core.c8
-rw-r--r--drivers/reset/reset-npcm.c2
-rw-r--r--drivers/reset/reset-socfpga.c2
-rw-r--r--drivers/reset/reset-sunxi.c2
4 files changed, 7 insertions, 7 deletions
diff --git a/drivers/reset/core.c b/drivers/reset/core.c
index 0666dfc41ca9..c224e42e0f6c 100644
--- a/drivers/reset/core.c
+++ b/drivers/reset/core.c
@@ -778,7 +778,7 @@ __reset_control_get_internal(struct reset_controller_dev *rcdev,
}
}
- rstc = kzalloc(sizeof(*rstc), GFP_KERNEL);
+ rstc = kzalloc_obj(*rstc, GFP_KERNEL);
if (!rstc)
return ERR_PTR(-ENOMEM);
@@ -836,7 +836,7 @@ static int reset_add_gpio_aux_device(struct device *parent,
struct auxiliary_device *adev;
int ret;
- adev = kzalloc(sizeof(*adev), GFP_KERNEL);
+ adev = kzalloc_obj(*adev, GFP_KERNEL);
if (!adev)
return -ENOMEM;
@@ -931,7 +931,7 @@ static int __reset_add_reset_gpio_device(const struct of_phandle_args *args)
return id;
/* Not freed on success, because it is persisent subsystem data. */
- rgpio_dev = kzalloc(sizeof(*rgpio_dev), GFP_KERNEL);
+ rgpio_dev = kzalloc_obj(*rgpio_dev, GFP_KERNEL);
if (!rgpio_dev) {
ret = -ENOMEM;
goto err_ida_free;
@@ -1360,7 +1360,7 @@ of_reset_control_array_get(struct device_node *np, enum reset_control_flags flag
if (num < 0)
return optional ? NULL : ERR_PTR(num);
- resets = kzalloc(struct_size(resets, rstc, num), GFP_KERNEL);
+ resets = kzalloc_flex(*resets, rstc, num, GFP_KERNEL);
if (!resets)
return ERR_PTR(-ENOMEM);
resets->num_rstcs = num;
diff --git a/drivers/reset/reset-npcm.c b/drivers/reset/reset-npcm.c
index e5b6127783a7..c28cb4632883 100644
--- a/drivers/reset/reset-npcm.c
+++ b/drivers/reset/reset-npcm.c
@@ -399,7 +399,7 @@ static struct auxiliary_device *npcm_clock_adev_alloc(struct npcm_rc_data *rst_d
struct auxiliary_device *adev;
int ret;
- rdev = kzalloc(sizeof(*rdev), GFP_KERNEL);
+ rdev = kzalloc_obj(*rdev, GFP_KERNEL);
if (!rdev)
return ERR_PTR(-ENOMEM);
diff --git a/drivers/reset/reset-socfpga.c b/drivers/reset/reset-socfpga.c
index 8c6492e5693c..a18cc81e0efa 100644
--- a/drivers/reset/reset-socfpga.c
+++ b/drivers/reset/reset-socfpga.c
@@ -27,7 +27,7 @@ static int a10_reset_init(struct device_node *np)
int ret;
u32 reg_offset = 0x10;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;
diff --git a/drivers/reset/reset-sunxi.c b/drivers/reset/reset-sunxi.c
index e752594b6971..b88d1d001ec3 100644
--- a/drivers/reset/reset-sunxi.c
+++ b/drivers/reset/reset-sunxi.c
@@ -27,7 +27,7 @@ static int sunxi_reset_init(struct device_node *np)
resource_size_t size;
int ret;
- data = kzalloc(sizeof(*data), GFP_KERNEL);
+ data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;