summaryrefslogtreecommitdiff
path: root/arch/powerpc/sysdev
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 /arch/powerpc/sysdev
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 'arch/powerpc/sysdev')
-rw-r--r--arch/powerpc/sysdev/ehv_pic.c2
-rw-r--r--arch/powerpc/sysdev/fsl_gtm.c2
-rw-r--r--arch/powerpc/sysdev/fsl_lbc.c4
-rw-r--r--arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c2
-rw-r--r--arch/powerpc/sysdev/fsl_msi.c4
-rw-r--r--arch/powerpc/sysdev/fsl_pci.c2
-rw-r--r--arch/powerpc/sysdev/fsl_rio.c10
-rw-r--r--arch/powerpc/sysdev/fsl_rmu.c2
-rw-r--r--arch/powerpc/sysdev/ipic.c2
-rw-r--r--arch/powerpc/sysdev/mpic.c9
-rw-r--r--arch/powerpc/sysdev/mpic_msgr.c6
-rw-r--r--arch/powerpc/sysdev/mpic_timer.c2
-rw-r--r--arch/powerpc/sysdev/of_rtc.c2
-rw-r--r--arch/powerpc/sysdev/xics/ics-native.c2
-rw-r--r--arch/powerpc/sysdev/xive/common.c5
-rw-r--r--arch/powerpc/sysdev/xive/spapr.c2
16 files changed, 29 insertions, 29 deletions
diff --git a/arch/powerpc/sysdev/ehv_pic.c b/arch/powerpc/sysdev/ehv_pic.c
index b6f9774038e1..c4c61216b96a 100644
--- a/arch/powerpc/sysdev/ehv_pic.c
+++ b/arch/powerpc/sysdev/ehv_pic.c
@@ -263,7 +263,7 @@ void __init ehv_pic_init(void)
return;
}
- ehv_pic = kzalloc(sizeof(struct ehv_pic), GFP_KERNEL);
+ ehv_pic = kzalloc_obj(struct ehv_pic, GFP_KERNEL);
if (!ehv_pic) {
of_node_put(np);
return;
diff --git a/arch/powerpc/sysdev/fsl_gtm.c b/arch/powerpc/sysdev/fsl_gtm.c
index 3dabc9621810..fabf39586eba 100644
--- a/arch/powerpc/sysdev/fsl_gtm.c
+++ b/arch/powerpc/sysdev/fsl_gtm.c
@@ -382,7 +382,7 @@ static int __init fsl_gtm_init(void)
const u32 *clock;
int size;
- gtm = kzalloc(sizeof(*gtm), GFP_KERNEL);
+ gtm = kzalloc_obj(*gtm, GFP_KERNEL);
if (!gtm) {
pr_err("%pOF: unable to allocate memory\n",
np);
diff --git a/arch/powerpc/sysdev/fsl_lbc.c b/arch/powerpc/sysdev/fsl_lbc.c
index 7ed07232a69a..01ddc6ac8277 100644
--- a/arch/powerpc/sysdev/fsl_lbc.c
+++ b/arch/powerpc/sysdev/fsl_lbc.c
@@ -283,7 +283,7 @@ static int fsl_lbc_ctrl_probe(struct platform_device *dev)
return -EFAULT;
}
- fsl_lbc_ctrl_dev = kzalloc(sizeof(*fsl_lbc_ctrl_dev), GFP_KERNEL);
+ fsl_lbc_ctrl_dev = kzalloc_obj(*fsl_lbc_ctrl_dev, GFP_KERNEL);
if (!fsl_lbc_ctrl_dev)
return -ENOMEM;
@@ -363,7 +363,7 @@ static int fsl_lbc_syscore_suspend(void *data)
if (!lbc)
goto out;
- ctrl->saved_regs = kmalloc(sizeof(struct fsl_lbc_regs), GFP_KERNEL);
+ ctrl->saved_regs = kmalloc_obj(struct fsl_lbc_regs, GFP_KERNEL);
if (!ctrl->saved_regs)
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
index 06d9101a5d49..43d6fba2bd42 100644
--- a/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
+++ b/arch/powerpc/sysdev/fsl_mpic_timer_wakeup.c
@@ -111,7 +111,7 @@ static int __init fsl_wakeup_sys_init(void)
struct device *dev_root;
int ret = -EINVAL;
- fsl_wakeup = kzalloc(sizeof(struct fsl_mpic_timer_wakeup), GFP_KERNEL);
+ fsl_wakeup = kzalloc_obj(struct fsl_mpic_timer_wakeup, GFP_KERNEL);
if (!fsl_wakeup)
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/fsl_msi.c b/arch/powerpc/sysdev/fsl_msi.c
index 2a007bfb038d..525ea894c14a 100644
--- a/arch/powerpc/sysdev/fsl_msi.c
+++ b/arch/powerpc/sysdev/fsl_msi.c
@@ -361,7 +361,7 @@ static int fsl_msi_setup_hwirq(struct fsl_msi *msi, struct platform_device *dev,
return 0;
}
- cascade_data = kzalloc(sizeof(struct fsl_msi_cascade_data), GFP_KERNEL);
+ cascade_data = kzalloc_obj(struct fsl_msi_cascade_data, GFP_KERNEL);
if (!cascade_data) {
dev_err(&dev->dev, "No memory for MSI cascade data\n");
return -ENOMEM;
@@ -405,7 +405,7 @@ static int fsl_of_msi_probe(struct platform_device *dev)
printk(KERN_DEBUG "Setting up Freescale MSI support\n");
- msi = kzalloc(sizeof(struct fsl_msi), GFP_KERNEL);
+ msi = kzalloc_obj(struct fsl_msi, GFP_KERNEL);
if (!msi) {
dev_err(&dev->dev, "No memory for MSI structure\n");
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c
index 4e501654cb41..0952b5ff8a16 100644
--- a/arch/powerpc/sysdev/fsl_pci.c
+++ b/arch/powerpc/sysdev/fsl_pci.c
@@ -767,7 +767,7 @@ static int __init mpc83xx_pcie_setup(struct pci_controller *hose,
u32 cfg_bar;
int ret = -ENOMEM;
- pcie = kzalloc(sizeof(*pcie), GFP_KERNEL);
+ pcie = kzalloc_obj(*pcie, GFP_KERNEL);
if (!pcie)
return ret;
diff --git a/arch/powerpc/sysdev/fsl_rio.c b/arch/powerpc/sysdev/fsl_rio.c
index f9b214b299e7..249b876daaee 100644
--- a/arch/powerpc/sysdev/fsl_rio.c
+++ b/arch/powerpc/sysdev/fsl_rio.c
@@ -470,7 +470,7 @@ static int fsl_rio_setup(struct platform_device *dev)
goto err_rio_regs;
}
- ops = kzalloc(sizeof(struct rio_ops), GFP_KERNEL);
+ ops = kzalloc_obj(struct rio_ops, GFP_KERNEL);
if (!ops) {
rc = -ENOMEM;
goto err_ops;
@@ -517,7 +517,7 @@ static int fsl_rio_setup(struct platform_device *dev)
rc = -ENODEV;
goto err_dbell;
}
- dbell = kzalloc(sizeof(struct fsl_rio_dbell), GFP_KERNEL);
+ dbell = kzalloc_obj(struct fsl_rio_dbell, GFP_KERNEL);
if (!(dbell)) {
dev_err(&dev->dev, "Can't alloc memory for 'fsl_rio_dbell'\n");
rc = -ENOMEM;
@@ -543,7 +543,7 @@ static int fsl_rio_setup(struct platform_device *dev)
rc = -ENODEV;
goto err_pw;
}
- pw = kzalloc(sizeof(struct fsl_rio_pw), GFP_KERNEL);
+ pw = kzalloc_obj(struct fsl_rio_pw, GFP_KERNEL);
if (!(pw)) {
dev_err(&dev->dev, "Can't alloc memory for 'fsl_rio_pw'\n");
rc = -ENOMEM;
@@ -580,7 +580,7 @@ static int fsl_rio_setup(struct platform_device *dev)
dev_info(&dev->dev, "%pOF: LAW %pR\n",
np, &res);
- port = kzalloc(sizeof(struct rio_mport), GFP_KERNEL);
+ port = kzalloc_obj(struct rio_mport, GFP_KERNEL);
if (!port)
continue;
@@ -593,7 +593,7 @@ static int fsl_rio_setup(struct platform_device *dev)
i = *port_index - 1;
port->index = (unsigned char)i;
- priv = kzalloc(sizeof(struct rio_priv), GFP_KERNEL);
+ priv = kzalloc_obj(struct rio_priv, GFP_KERNEL);
if (!priv) {
dev_err(&dev->dev, "Can't alloc memory for 'priv'\n");
kfree(port);
diff --git a/arch/powerpc/sysdev/fsl_rmu.c b/arch/powerpc/sysdev/fsl_rmu.c
index f956591cb64e..c0e358cf7822 100644
--- a/arch/powerpc/sysdev/fsl_rmu.c
+++ b/arch/powerpc/sysdev/fsl_rmu.c
@@ -1079,7 +1079,7 @@ int fsl_rio_setup_rmu(struct rio_mport *mport, struct device_node *node)
return -EINVAL;
}
- rmu = kzalloc(sizeof(struct fsl_rmu), GFP_KERNEL);
+ rmu = kzalloc_obj(struct fsl_rmu, GFP_KERNEL);
if (!rmu)
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 290ba8427239..2351604cc24a 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -707,7 +707,7 @@ struct ipic * __init ipic_init(struct device_node *node, unsigned int flags)
if (ret)
return NULL;
- ipic = kzalloc(sizeof(*ipic), GFP_KERNEL);
+ ipic = kzalloc_obj(*ipic, GFP_KERNEL);
if (ipic == NULL)
return NULL;
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c
index 67e51998d1ae..cb4cdd853cc8 100644
--- a/arch/powerpc/sysdev/mpic.c
+++ b/arch/powerpc/sysdev/mpic.c
@@ -547,7 +547,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
/* Allocate fixups array */
- mpic->fixups = kcalloc(128, sizeof(*mpic->fixups), GFP_KERNEL);
+ mpic->fixups = kzalloc_objs(*mpic->fixups, 128, GFP_KERNEL);
BUG_ON(mpic->fixups == NULL);
/* Init spinlock */
@@ -1273,7 +1273,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
mpic_tm_chip.flags |= IRQCHIP_SKIP_SET_WAKE;
}
- mpic = kzalloc(sizeof(struct mpic), GFP_KERNEL);
+ mpic = kzalloc_obj(struct mpic, GFP_KERNEL);
if (mpic == NULL)
goto err_of_node_put;
@@ -1639,9 +1639,8 @@ void __init mpic_init(struct mpic *mpic)
#ifdef CONFIG_PM
/* allocate memory to save mpic state */
- mpic->save_data = kmalloc_array(mpic->num_sources,
- sizeof(*mpic->save_data),
- GFP_KERNEL);
+ mpic->save_data = kmalloc_objs(*mpic->save_data, mpic->num_sources,
+ GFP_KERNEL);
BUG_ON(mpic->save_data == NULL);
#endif
diff --git a/arch/powerpc/sysdev/mpic_msgr.c b/arch/powerpc/sysdev/mpic_msgr.c
index 7b449cc51aef..8b1c02f5b1b3 100644
--- a/arch/powerpc/sysdev/mpic_msgr.c
+++ b/arch/powerpc/sysdev/mpic_msgr.c
@@ -188,8 +188,8 @@ static int mpic_msgr_probe(struct platform_device *dev)
dev_info(&dev->dev, "Found %d message registers\n",
mpic_msgr_count);
- mpic_msgrs = kcalloc(mpic_msgr_count, sizeof(*mpic_msgrs),
- GFP_KERNEL);
+ mpic_msgrs = kzalloc_objs(*mpic_msgrs, mpic_msgr_count,
+ GFP_KERNEL);
if (!mpic_msgrs) {
dev_err(&dev->dev,
"No memory for message register blocks\n");
@@ -227,7 +227,7 @@ static int mpic_msgr_probe(struct platform_device *dev)
struct mpic_msgr *msgr;
unsigned int reg_number;
- msgr = kzalloc(sizeof(struct mpic_msgr), GFP_KERNEL);
+ msgr = kzalloc_obj(struct mpic_msgr, GFP_KERNEL);
if (!msgr) {
dev_err(&dev->dev, "No memory for message register\n");
return -ENOMEM;
diff --git a/arch/powerpc/sysdev/mpic_timer.c b/arch/powerpc/sysdev/mpic_timer.c
index 60f5b3934b51..7b237b6f7151 100644
--- a/arch/powerpc/sysdev/mpic_timer.c
+++ b/arch/powerpc/sysdev/mpic_timer.c
@@ -464,7 +464,7 @@ static void __init timer_group_init(struct device_node *np)
unsigned int i = 0;
int ret;
- priv = kzalloc(sizeof(struct timer_group_priv), GFP_KERNEL);
+ priv = kzalloc_obj(struct timer_group_priv, GFP_KERNEL);
if (!priv) {
pr_err("%pOF: cannot allocate memory for group.\n", np);
return;
diff --git a/arch/powerpc/sysdev/of_rtc.c b/arch/powerpc/sysdev/of_rtc.c
index 2211937d3788..6c2ba4c44b11 100644
--- a/arch/powerpc/sysdev/of_rtc.c
+++ b/arch/powerpc/sysdev/of_rtc.c
@@ -33,7 +33,7 @@ void __init of_instantiate_rtc(void)
of_rtc_table[i].compatible) {
struct resource *res;
- res = kmalloc(sizeof(*res), GFP_KERNEL);
+ res = kmalloc_obj(*res, GFP_KERNEL);
if (!res) {
printk(KERN_ERR "OF RTC: Out of memory "
"allocating resource structure for %pOF\n",
diff --git a/arch/powerpc/sysdev/xics/ics-native.c b/arch/powerpc/sysdev/xics/ics-native.c
index 112c8a1e8159..50634a0ae478 100644
--- a/arch/powerpc/sysdev/xics/ics-native.c
+++ b/arch/powerpc/sysdev/xics/ics-native.c
@@ -186,7 +186,7 @@ static int __init ics_native_add_one(struct device_node *np)
u32 ranges[2];
int rc, count;
- ics = kzalloc(sizeof(struct ics_native), GFP_KERNEL);
+ ics = kzalloc_obj(struct ics_native, GFP_KERNEL);
if (!ics)
return -ENOMEM;
ics->node = of_node_get(np);
diff --git a/arch/powerpc/sysdev/xive/common.c b/arch/powerpc/sysdev/xive/common.c
index 8d0123b0ae84..f0fbee162f47 100644
--- a/arch/powerpc/sysdev/xive/common.c
+++ b/arch/powerpc/sysdev/xive/common.c
@@ -1016,7 +1016,7 @@ static struct xive_irq_data *xive_irq_alloc_data(unsigned int virq, irq_hw_numbe
struct xive_irq_data *xd;
int rc;
- xd = kzalloc(sizeof(struct xive_irq_data), GFP_KERNEL);
+ xd = kzalloc_obj(struct xive_irq_data, GFP_KERNEL);
if (!xd)
return ERR_PTR(-ENOMEM);
rc = xive_ops->populate_irq_data(hw, xd);
@@ -1144,7 +1144,8 @@ static int __init xive_init_ipis(void)
if (!ipi_domain)
goto out_free_fwnode;
- xive_ipis = kcalloc(nr_node_ids, sizeof(*xive_ipis), GFP_KERNEL | __GFP_NOFAIL);
+ xive_ipis = kzalloc_objs(*xive_ipis, nr_node_ids,
+ GFP_KERNEL | __GFP_NOFAIL);
if (!xive_ipis)
goto out_free_domain;
diff --git a/arch/powerpc/sysdev/xive/spapr.c b/arch/powerpc/sysdev/xive/spapr.c
index 5aedbe3e8e6a..dca293f07303 100644
--- a/arch/powerpc/sysdev/xive/spapr.c
+++ b/arch/powerpc/sysdev/xive/spapr.c
@@ -52,7 +52,7 @@ static int __init xive_irq_bitmap_add(int base, int count)
{
struct xive_irq_bitmap *xibm;
- xibm = kzalloc(sizeof(*xibm), GFP_KERNEL);
+ xibm = kzalloc_obj(*xibm, GFP_KERNEL);
if (!xibm)
return -ENOMEM;