diff options
| author | Kees Cook <kees@kernel.org> | 2026-02-20 23:49:23 -0800 |
|---|---|---|
| committer | Kees Cook <kees@kernel.org> | 2026-02-21 01:02:28 -0800 |
| commit | 69050f8d6d075dc01af7a5f2f550a8067510366f (patch) | |
| tree | bb265f94d9dfa7876c06a5d9f88673d496a15341 /drivers/pmdomain | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | linux-next-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz linux-next-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/pmdomain')
| -rw-r--r-- | drivers/pmdomain/core.c | 16 | ||||
| -rw-r--r-- | drivers/pmdomain/renesas/rcar-gen4-sysc.c | 2 | ||||
| -rw-r--r-- | drivers/pmdomain/renesas/rcar-sysc.c | 2 | ||||
| -rw-r--r-- | drivers/pmdomain/renesas/rmobile-sysc.c | 2 | ||||
| -rw-r--r-- | drivers/pmdomain/st/ste-ux500-pm-domain.c | 2 | ||||
| -rw-r--r-- | drivers/pmdomain/tegra/powergate-bpmp.c | 4 |
6 files changed, 14 insertions, 14 deletions
diff --git a/drivers/pmdomain/core.c b/drivers/pmdomain/core.c index bf82775f6a67..a324740b248b 100644 --- a/drivers/pmdomain/core.c +++ b/drivers/pmdomain/core.c @@ -1811,7 +1811,7 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, if (ret) return ERR_PTR(ret); - gpd_data = kzalloc(sizeof(*gpd_data), GFP_KERNEL); + gpd_data = kzalloc_obj(*gpd_data, GFP_KERNEL); if (!gpd_data) { ret = -ENOMEM; goto err_put; @@ -1822,7 +1822,7 @@ static struct generic_pm_domain_data *genpd_alloc_dev_data(struct device *dev, /* Allocate data used by a governor. */ if (has_governor) { - td = kzalloc(sizeof(*td), GFP_KERNEL); + td = kzalloc_obj(*td, GFP_KERNEL); if (!td) { ret = -ENOMEM; goto err_free; @@ -2161,7 +2161,7 @@ static int genpd_add_subdomain(struct generic_pm_domain *genpd, return -EINVAL; } - link = kzalloc(sizeof(*link), GFP_KERNEL); + link = kzalloc_obj(*link, GFP_KERNEL); if (!link) return -ENOMEM; @@ -2269,7 +2269,7 @@ static int genpd_set_default_power_state(struct generic_pm_domain *genpd) { struct genpd_power_state *state; - state = kzalloc(sizeof(*state), GFP_KERNEL); + state = kzalloc_obj(*state, GFP_KERNEL); if (!state) return -ENOMEM; @@ -2295,7 +2295,7 @@ static int genpd_alloc_data(struct generic_pm_domain *genpd) return -ENOMEM; if (genpd->gov) { - gd = kzalloc(sizeof(*gd), GFP_KERNEL); + gd = kzalloc_obj(*gd, GFP_KERNEL); if (!gd) { ret = -ENOMEM; goto free; @@ -2623,7 +2623,7 @@ static int genpd_add_provider(struct device_node *np, genpd_xlate_t xlate, { struct of_genpd_provider *cp; - cp = kzalloc(sizeof(*cp), GFP_KERNEL); + cp = kzalloc_obj(*cp, GFP_KERNEL); if (!cp) return -ENOMEM; @@ -3316,7 +3316,7 @@ struct device *genpd_dev_pm_attach_by_id(struct device *dev, return ERR_PTR(-ENODEV); /* Allocate and register device on the genpd bus. */ - virt_dev = kzalloc(sizeof(*virt_dev), GFP_KERNEL); + virt_dev = kzalloc_obj(*virt_dev, GFP_KERNEL); if (!virt_dev) return ERR_PTR(-ENOMEM); @@ -3474,7 +3474,7 @@ int of_genpd_parse_idle_states(struct device_node *dn, return 0; } - st = kcalloc(ret, sizeof(*st), GFP_KERNEL); + st = kzalloc_objs(*st, ret, GFP_KERNEL); if (!st) return -ENOMEM; diff --git a/drivers/pmdomain/renesas/rcar-gen4-sysc.c b/drivers/pmdomain/renesas/rcar-gen4-sysc.c index 7434bf42d215..a62937a9a045 100644 --- a/drivers/pmdomain/renesas/rcar-gen4-sysc.c +++ b/drivers/pmdomain/renesas/rcar-gen4-sysc.c @@ -324,7 +324,7 @@ static int __init rcar_gen4_sysc_pd_init(void) rcar_gen4_sysc_base = base; - domains = kzalloc(sizeof(*domains), GFP_KERNEL); + domains = kzalloc_obj(*domains, GFP_KERNEL); if (!domains) { error = -ENOMEM; goto out_put; diff --git a/drivers/pmdomain/renesas/rcar-sysc.c b/drivers/pmdomain/renesas/rcar-sysc.c index d8a8ffcde38d..aa5485876e0a 100644 --- a/drivers/pmdomain/renesas/rcar-sysc.c +++ b/drivers/pmdomain/renesas/rcar-sysc.c @@ -383,7 +383,7 @@ static int __init rcar_sysc_pd_init(void) rcar_sysc_extmask_offs = info->extmask_offs; rcar_sysc_extmask_val = info->extmask_val; - domains = kzalloc(sizeof(*domains), GFP_KERNEL); + domains = kzalloc_obj(*domains, GFP_KERNEL); if (!domains) { error = -ENOMEM; goto out_put; diff --git a/drivers/pmdomain/renesas/rmobile-sysc.c b/drivers/pmdomain/renesas/rmobile-sysc.c index a6bf7295e909..541f5739c13a 100644 --- a/drivers/pmdomain/renesas/rmobile-sysc.c +++ b/drivers/pmdomain/renesas/rmobile-sysc.c @@ -277,7 +277,7 @@ static int __init rmobile_add_pm_domains(void __iomem *base, /* always-on domain */ } - pd = kzalloc(sizeof(*pd), GFP_KERNEL); + pd = kzalloc_obj(*pd, GFP_KERNEL); if (!pd) return -ENOMEM; diff --git a/drivers/pmdomain/st/ste-ux500-pm-domain.c b/drivers/pmdomain/st/ste-ux500-pm-domain.c index 3d4f111ed156..45ea76b9c7f8 100644 --- a/drivers/pmdomain/st/ste-ux500-pm-domain.c +++ b/drivers/pmdomain/st/ste-ux500-pm-domain.c @@ -65,7 +65,7 @@ static int ux500_pm_domains_probe(struct platform_device *pdev) if (!np) return -ENODEV; - genpd_data = kzalloc(sizeof(*genpd_data), GFP_KERNEL); + genpd_data = kzalloc_obj(*genpd_data, GFP_KERNEL); if (!genpd_data) return -ENOMEM; diff --git a/drivers/pmdomain/tegra/powergate-bpmp.c b/drivers/pmdomain/tegra/powergate-bpmp.c index 9f4366250bfd..43a46edd1ebc 100644 --- a/drivers/pmdomain/tegra/powergate-bpmp.c +++ b/drivers/pmdomain/tegra/powergate-bpmp.c @@ -226,7 +226,7 @@ tegra_bpmp_probe_powergates(struct tegra_bpmp *bpmp, dev_dbg(bpmp->dev, "maximum powergate ID: %u\n", max_id); - powergates = kcalloc(max_id + 1, sizeof(*powergates), GFP_KERNEL); + powergates = kzalloc_objs(*powergates, max_id + 1, GFP_KERNEL); if (!powergates) return -ENOMEM; @@ -260,7 +260,7 @@ static int tegra_bpmp_add_powergates(struct tegra_bpmp *bpmp, unsigned int i; int err; - domains = kcalloc(count, sizeof(*domains), GFP_KERNEL); + domains = kzalloc_objs(*domains, count, GFP_KERNEL); if (!domains) return -ENOMEM; |
