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>
This commit is contained in:
Kees Cook
2026-02-20 23:49:23 -08:00
parent d39a1d7486
commit 69050f8d6d
8016 changed files with 20055 additions and 20913 deletions

View File

@@ -861,7 +861,7 @@ marvel_agp_setup(alpha_agp_info *agp)
if (!alpha_agpgart_size)
return -ENOMEM;
aper = kmalloc(sizeof(*aper), GFP_KERNEL);
aper = kmalloc_obj(*aper, GFP_KERNEL);
if (aper == NULL) return -ENOMEM;
aper->arena = agp->hose->sg_pci;
@@ -1059,7 +1059,7 @@ marvel_agp_info(void)
/*
* Allocate the info structure.
*/
agp = kmalloc(sizeof(*agp), GFP_KERNEL);
agp = kmalloc_obj(*agp, GFP_KERNEL);
if (!agp)
return NULL;

View File

@@ -594,7 +594,7 @@ titan_agp_setup(alpha_agp_info *agp)
if (!alpha_agpgart_size)
return -ENOMEM;
aper = kmalloc(sizeof(struct titan_agp_aperture), GFP_KERNEL);
aper = kmalloc_obj(struct titan_agp_aperture, GFP_KERNEL);
if (aper == NULL)
return -ENOMEM;
@@ -760,7 +760,7 @@ titan_agp_info(void)
/*
* Allocate the info structure.
*/
agp = kmalloc(sizeof(*agp), GFP_KERNEL);
agp = kmalloc_obj(*agp, GFP_KERNEL);
if (!agp)
return NULL;

View File

@@ -46,7 +46,7 @@ process_reloc_for_got(Elf64_Rela *rela,
goto found_entry;
}
g = kmalloc (sizeof (*g), GFP_KERNEL);
g = kmalloc_obj(*g, GFP_KERNEL);
g->next = chains[r_sym].next;
g->r_addend = r_addend;
g->got_offset = *poffset;
@@ -93,7 +93,7 @@ module_frob_arch_sections(Elf64_Ehdr *hdr, Elf64_Shdr *sechdrs,
}
nsyms = symtab->sh_size / sizeof(Elf64_Sym);
chains = kcalloc(nsyms, sizeof(struct got_entry), GFP_KERNEL);
chains = kzalloc_objs(struct got_entry, nsyms, GFP_KERNEL);
if (!chains) {
printk(KERN_ERR
"module %s: no memory for symbol chain buffer\n",

View File

@@ -220,7 +220,7 @@ static void pdev_save_srm_config(struct pci_dev *dev)
printed = 1;
}
tmp = kmalloc(sizeof(*tmp), GFP_KERNEL);
tmp = kmalloc_obj(*tmp, GFP_KERNEL);
if (!tmp) {
printk(KERN_ERR "%s: kmalloc() failed!\n", __func__);
return;

View File

@@ -392,7 +392,7 @@ register_cpus(void)
int i;
for_each_possible_cpu(i) {
struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL);
struct cpu *p = kzalloc_obj(*p, GFP_KERNEL);
if (!p)
return -ENOMEM;
register_cpu(p, i);

View File

@@ -366,7 +366,7 @@ void *unwind_add_table(struct module *module, const void *table_start,
if (table_size <= 0)
return NULL;
table = kmalloc(sizeof(*table), GFP_KERNEL);
table = kmalloc_obj(*table, GFP_KERNEL);
if (!table)
return NULL;

View File

@@ -1140,7 +1140,7 @@ static int jit_prepare_final_mem_alloc(struct jit_context *ctx)
}
if (ctx->need_extra_pass) {
ctx->jit_data = kzalloc(sizeof(*ctx->jit_data), GFP_KERNEL);
ctx->jit_data = kzalloc_obj(*ctx->jit_data, GFP_KERNEL);
if (!ctx->jit_data)
return -ENOMEM;
}

View File

@@ -222,7 +222,7 @@ locomo_init_one_child(struct locomo *lchip, struct locomo_dev_info *info)
struct locomo_dev *dev;
int ret;
dev = kzalloc(sizeof(struct locomo_dev), GFP_KERNEL);
dev = kzalloc_obj(struct locomo_dev, GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto out;
@@ -277,7 +277,7 @@ static int locomo_suspend(struct platform_device *dev, pm_message_t state)
struct locomo_save_data *save;
unsigned long flags;
save = kmalloc(sizeof(struct locomo_save_data), GFP_KERNEL);
save = kmalloc_obj(struct locomo_save_data, GFP_KERNEL);
if (!save)
return -ENOMEM;
@@ -360,7 +360,7 @@ __locomo_probe(struct device *me, struct resource *mem, int irq)
unsigned long r;
int i, ret = -ENODEV;
lchip = kzalloc(sizeof(struct locomo), GFP_KERNEL);
lchip = kzalloc_obj(struct locomo, GFP_KERNEL);
if (!lchip)
return -ENOMEM;

View File

@@ -737,7 +737,7 @@ sa1111_init_one_child(struct sa1111 *sachip, struct resource *parent,
unsigned i;
int ret;
dev = kzalloc(sizeof(struct sa1111_dev), GFP_KERNEL);
dev = kzalloc_obj(struct sa1111_dev, GFP_KERNEL);
if (!dev) {
ret = -ENOMEM;
goto err_alloc;
@@ -969,7 +969,7 @@ static int sa1111_suspend_noirq(struct device *dev)
unsigned int val;
void __iomem *base;
save = kmalloc(sizeof(struct sa1111_save_data), GFP_KERNEL);
save = kmalloc_obj(struct sa1111_save_data, GFP_KERNEL);
if (!save)
return -ENOMEM;
sachip->saved_state = save;

View File

@@ -185,7 +185,7 @@ static int scoop_probe(struct platform_device *pdev)
if (!mem)
return -EINVAL;
devptr = kzalloc(sizeof(struct scoop_dev), GFP_KERNEL);
devptr = kzalloc_obj(struct scoop_dev, GFP_KERNEL);
if (!devptr)
return -ENOMEM;

View File

@@ -54,7 +54,7 @@ static int __init init_atags_procfs(void)
WARN_ON(tag->hdr.tag != ATAG_NONE);
b = kmalloc(struct_size(b, data, size), GFP_KERNEL);
b = kmalloc_flex(*b, data, size, GFP_KERNEL);
if (!b)
goto nomem;

View File

@@ -108,7 +108,7 @@ static unsigned long get_arch_pgd(pgd_t *pgd)
static int secondary_biglittle_prepare(unsigned int cpu)
{
if (!cpu_vtable[cpu])
cpu_vtable[cpu] = kzalloc(sizeof(*cpu_vtable[cpu]), GFP_KERNEL);
cpu_vtable[cpu] = kzalloc_obj(*cpu_vtable[cpu], GFP_KERNEL);
return cpu_vtable[cpu] ? 0 : -ENOMEM;
}

View File

@@ -349,7 +349,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
return -E2BIG;
if (nsops < 1 || nsops > SEMOPM)
return -EINVAL;
sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
sops = kvmalloc_objs(*sops, nsops, GFP_KERNEL);
if (!sops)
return -ENOMEM;
err = 0;

View File

@@ -574,7 +574,7 @@ struct unwind_table *unwind_table_add(unsigned long start, unsigned long size,
unsigned long text_size)
{
unsigned long flags;
struct unwind_table *tab = kmalloc(sizeof(*tab), GFP_KERNEL);
struct unwind_table *tab = kmalloc_obj(*tab, GFP_KERNEL);
pr_debug("%s(%08lx, %08lx, %08lx, %08lx)\n", __func__, start, size,
text_addr, text_size);

View File

@@ -179,8 +179,7 @@ static int __init vdso_init(void)
text_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
/* Allocate the VDSO text pagelist */
vdso_text_pagelist = kcalloc(text_pages, sizeof(struct page *),
GFP_KERNEL);
vdso_text_pagelist = kzalloc_objs(struct page *, text_pages, GFP_KERNEL);
if (vdso_text_pagelist == NULL)
return -ENOMEM;

View File

@@ -262,7 +262,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
{
struct resource *res;
res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
res = kzalloc_objs(struct resource, 2, GFP_KERNEL);
if (!res) {
printk("out of memory for root bus resources");
return 0;

View File

@@ -84,7 +84,7 @@ static int __init ebsa285_leds_init(void)
for (i = 0; i < ARRAY_SIZE(ebsa285_leds); i++) {
struct ebsa285_led *led;
led = kzalloc(sizeof(*led), GFP_KERNEL);
led = kzalloc_obj(*led, GFP_KERNEL);
if (!led)
break;

View File

@@ -727,7 +727,7 @@ static int __init netwinder_leds_init(void)
for (i = 0; i < ARRAY_SIZE(netwinder_leds); i++) {
struct netwinder_led *led;
led = kzalloc(sizeof(*led), GFP_KERNEL);
led = kzalloc_obj(*led, GFP_KERNEL);
if (!led)
break;

View File

@@ -477,7 +477,7 @@ static int imx_mmdc_perf_init(struct platform_device *pdev, void __iomem *mmdc_b
char *name;
int ret;
pmu_mmdc = kzalloc(sizeof(*pmu_mmdc), GFP_KERNEL);
pmu_mmdc = kzalloc_obj(*pmu_mmdc, GFP_KERNEL);
if (!pmu_mmdc) {
pr_err("failed to allocate PMU device!\n");
return -ENOMEM;

View File

@@ -127,7 +127,7 @@ static void __init i2c_quirk(void)
for_each_compatible_node(np, NULL, "marvell,mv78230-i2c") {
struct property *new_compat;
new_compat = kzalloc(sizeof(*new_compat), GFP_KERNEL);
new_compat = kzalloc_obj(*new_compat, GFP_KERNEL);
new_compat->name = kstrdup("compatible", GFP_KERNEL);
new_compat->length = sizeof("marvell,mv78230-a0-i2c");

View File

@@ -190,7 +190,7 @@ static void __init armada_375_380_coherency_init(struct device_node *np)
for_each_compatible_node(cache_dn, NULL, "arm,pl310-cache") {
struct property *p;
p = kzalloc(sizeof(*p), GFP_KERNEL);
p = kzalloc_obj(*p, GFP_KERNEL);
p->name = kstrdup("arm,io-coherent", GFP_KERNEL);
of_add_property(cache_dn, p);
}

View File

@@ -154,7 +154,7 @@ static int __init mvebu_soc_device(void)
if (!is_id_valid)
return 0;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;

View File

@@ -387,7 +387,7 @@ static void __init mxs_machine_init(void)
const u32 *ocotp = mxs_get_ocotp();
int ret;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return;

View File

@@ -319,7 +319,7 @@ static int __init omap1_system_dma_init(void)
goto exit_iounmap;
}
d = kzalloc(sizeof(*d), GFP_KERNEL);
d = kzalloc_obj(*d, GFP_KERNEL);
if (!d) {
ret = -ENOMEM;
goto exit_iounmap;

View File

@@ -294,8 +294,8 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
{
int i;
omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *),
GFP_KERNEL);
omap_mcbsp_devices = kzalloc_objs(struct platform_device *, size,
GFP_KERNEL);
if (!omap_mcbsp_devices) {
printk(KERN_ERR "Could not register McBSP devices\n");
return;

View File

@@ -125,7 +125,7 @@ static int __init omap1_dm_timer_init(void)
goto err_free_pdev;
}
pdata = kzalloc(sizeof(*pdata), GFP_KERNEL);
pdata = kzalloc_obj(*pdata, GFP_KERNEL);
if (!pdata) {
ret = -ENOMEM;
goto err_free_pdata;

View File

@@ -237,7 +237,7 @@ void omap2xxx_clkt_vps_init(void)
omap2xxx_clkt_vps_late_init();
omap2xxx_clkt_vps_check_bootloader_rates();
hw = kzalloc(sizeof(*hw), GFP_KERNEL);
hw = kzalloc_obj(*hw, GFP_KERNEL);
if (!hw)
return;
init.name = "virt_prcm_set";

View File

@@ -787,7 +787,7 @@ void __init omap_soc_device_init(void)
struct soc_device *soc_dev;
struct soc_device_attribute *soc_dev_attr;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return;

View File

@@ -99,7 +99,7 @@ static struct powerdomain *_get_pwrdm(struct device *dev)
return NULL;
}
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
entry = kmalloc_obj(*entry, GFP_KERNEL);
if (entry) {
entry->dev = dev;
entry->pwrdm = pwrdm;

View File

@@ -156,7 +156,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
!omap_hwmod_parse_module_range(NULL, node, &res))
return -ENODEV;
hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL);
hwmods = kzalloc_objs(struct omap_hwmod *, oh_cnt, GFP_KERNEL);
if (!hwmods) {
ret = -ENOMEM;
goto odbfd_exit;
@@ -309,7 +309,7 @@ static struct omap_device *omap_device_alloc(struct platform_device *pdev,
int i;
struct omap_hwmod **hwmods;
od = kzalloc(sizeof(struct omap_device), GFP_KERNEL);
od = kzalloc_obj(struct omap_device, GFP_KERNEL);
if (!od)
goto oda_exit1;

View File

@@ -3392,7 +3392,7 @@ static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
void __iomem *regs = NULL;
unsigned long flags;
sysc = kzalloc(sizeof(*sysc), GFP_KERNEL);
sysc = kzalloc_obj(*sysc, GFP_KERNEL);
if (!sysc)
return -ENOMEM;
@@ -3422,7 +3422,7 @@ static int omap_hwmod_allocate_module(struct device *dev, struct omap_hwmod *oh,
}
if (list_empty(&oh->slave_ports)) {
oi = kzalloc(sizeof(*oi), GFP_KERNEL);
oi = kzalloc_obj(*oi, GFP_KERNEL);
if (!oi)
goto out_free_class;
@@ -3525,7 +3525,7 @@ int omap_hwmod_init_module(struct device *dev,
oh = _lookup(data->name);
if (!oh) {
oh = kzalloc(sizeof(*oh), GFP_KERNEL);
oh = kzalloc_obj(*oh, GFP_KERNEL);
if (!oh)
return -ENOMEM;
@@ -3536,7 +3536,7 @@ int omap_hwmod_init_module(struct device *dev,
/* Unused, can be handled by PRM driver handling resets */
oh->prcm.omap4.flags = HWMOD_OMAP4_NO_CONTEXT_LOSS_BIT;
oh->class = kzalloc(sizeof(*oh->class), GFP_KERNEL);
oh->class = kzalloc_obj(*oh->class, GFP_KERNEL);
if (!oh->class) {
kfree(oh);
return -ENOMEM;

View File

@@ -410,7 +410,7 @@ static int __init amx3_idle_init(struct device_node *cpu_node, int cpu)
state_count++;
}
idle_states = kcalloc(state_count, sizeof(*idle_states), GFP_KERNEL);
idle_states = kzalloc_objs(*idle_states, state_count, GFP_KERNEL);
if (!idle_states)
return -ENOMEM;

View File

@@ -410,7 +410,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
if (!pwrdm->pwrsts)
return 0;
pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
pwrst = kmalloc_obj(struct power_state, GFP_ATOMIC);
if (!pwrst)
return -ENOMEM;
pwrst->pwrdm = pwrdm;

View File

@@ -132,7 +132,7 @@ static int __init pwrdms_setup(struct powerdomain *pwrdm, void *unused)
!strncmp(pwrdm->name, "l4per", 5))
pwrdm_set_logic_retst(pwrdm, PWRDM_POWER_OFF);
pwrst = kmalloc(sizeof(struct power_state), GFP_ATOMIC);
pwrst = kmalloc_obj(struct power_state, GFP_ATOMIC);
if (!pwrst)
return -ENOMEM;

View File

@@ -39,7 +39,7 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
while (volt_data[count].volt_nominal)
count++;
nvalue_table = kcalloc(count, sizeof(*nvalue_table), GFP_KERNEL);
nvalue_table = kzalloc_objs(*nvalue_table, count, GFP_KERNEL);
if (!nvalue_table)
return;

View File

@@ -169,7 +169,7 @@ static int __init pcie_setup(struct pci_sys_data *sys)
/*
* Request resources.
*/
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc_obj(struct resource, GFP_KERNEL);
if (!res)
panic("pcie_setup unable to alloc resources");
@@ -490,7 +490,7 @@ static int __init pci_setup(struct pci_sys_data *sys)
/*
* Request resources
*/
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc_obj(struct resource, GFP_KERNEL);
if (!res)
panic("pci_setup unable to alloc resources");

View File

@@ -692,7 +692,7 @@ static struct expansion_card *__init ecard_alloc_card(int type, int slot)
unsigned long base;
int i;
ec = kzalloc(sizeof(ecard_t), GFP_KERNEL);
ec = kzalloc_obj(ecard_t, GFP_KERNEL);
if (!ec) {
ec = ERR_PTR(-ENOMEM);
goto nomem;

View File

@@ -107,7 +107,7 @@ int __init sa11xx_clk_init(void)
clk_hw_register_clkdev(hw, "OSTIMER0", NULL);
hw = kzalloc(sizeof(*hw), GFP_KERNEL);
hw = kzalloc_obj(*hw, GFP_KERNEL);
if (!hw)
return -ENOMEM;
hw->init = &clk_mpll_init_data;
@@ -129,7 +129,7 @@ int __init sa11xx_clk_init(void)
FAlnMsk(TUCR_TSEL), 0, &tucr_lock);
clk_set_rate(hw->clk, 3686400);
hw = kzalloc(sizeof(*hw), GFP_KERNEL);
hw = kzalloc_obj(*hw, GFP_KERNEL);
if (!hw)
return -ENOMEM;
hw->init = &clk_gpio27_init_data;

View File

@@ -321,7 +321,7 @@ int __init sa11x0_register_fixed_regulator(int n,
{
struct regulator_init_data *id;
cfg->init_data = id = kzalloc(sizeof(*cfg->init_data), GFP_KERNEL);
cfg->init_data = id = kzalloc_obj(*cfg->init_data, GFP_KERNEL);
if (!cfg->init_data)
return -ENOMEM;

View File

@@ -276,7 +276,7 @@ static int neponset_probe(struct platform_device *dev)
goto err_alloc;
}
d = kzalloc(sizeof(*d), GFP_KERNEL);
d = kzalloc_obj(*d, GFP_KERNEL);
if (!d) {
ret = -ENOMEM;
goto err_alloc;

View File

@@ -164,7 +164,7 @@ static int __init rcar_gen2_regulator_quirk(void)
if (ret) /* Skip invalid entry and continue */
continue;
quirk = kzalloc(sizeof(*quirk), GFP_KERNEL);
quirk = kzalloc_obj(*quirk, GFP_KERNEL);
if (!quirk) {
ret = -ENOMEM;
of_node_put(np);

View File

@@ -395,7 +395,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
uint32_t data = 0, off, ret, idx;
struct ve_spc_opp *opps;
opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL);
opps = kzalloc_objs(*opps, MAX_OPPS, GFP_KERNEL);
if (!opps)
return -ENOMEM;
@@ -442,7 +442,7 @@ static int ve_init_opp_table(struct device *cpu_dev)
int __init ve_spc_init(void __iomem *baseaddr, u32 a15_clusid, int irq)
{
int ret;
info = kzalloc(sizeof(*info), GFP_KERNEL);
info = kzalloc_obj(*info, GFP_KERNEL);
if (!info)
return -ENOMEM;
@@ -525,7 +525,7 @@ static struct clk *ve_spc_clk_register(struct device *cpu_dev)
struct clk_init_data init;
struct clk_spc *spc;
spc = kzalloc(sizeof(*spc), GFP_KERNEL);
spc = kzalloc_obj(*spc, GFP_KERNEL);
if (!spc)
return ERR_PTR(-ENOMEM);

View File

@@ -142,7 +142,7 @@ static void __init versatile_dt_pci_init(void)
goto out_put_node;
}
newprop = kzalloc(sizeof(*newprop), GFP_KERNEL);
newprop = kzalloc_obj(*newprop, GFP_KERNEL);
if (!newprop)
goto out_put_node;

View File

@@ -108,7 +108,7 @@ static void __init zynq_init_machine(void)
struct soc_device *soc_dev;
struct device *parent = NULL;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
goto out;

View File

@@ -507,7 +507,7 @@ static __init int l2x0_pmu_init(void)
if (!l2x0_base)
return 0;
l2x0_pmu = kzalloc(sizeof(*l2x0_pmu), GFP_KERNEL);
l2x0_pmu = kzalloc_obj(*l2x0_pmu, GFP_KERNEL);
if (!l2x0_pmu) {
pr_warn("Unable to allocate L2x0 PMU\n");
return -ENOMEM;

View File

@@ -342,7 +342,7 @@ static int __init __uniphier_cache_init(struct device_node *np,
return -EINVAL;
}
data = kzalloc(sizeof(*data), GFP_KERNEL);
data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;

View File

@@ -558,8 +558,8 @@ static void *__dma_alloc(struct device *dev, size_t size, dma_addr_t *handle,
}
#endif
buf = kzalloc(sizeof(*buf),
gfp & ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM));
buf = kzalloc_obj(*buf,
gfp & ~(__GFP_DMA | __GFP_DMA32 | __GFP_HIGHMEM));
if (!buf)
return NULL;
@@ -1504,7 +1504,7 @@ arm_iommu_create_mapping(struct device *dev, dma_addr_t base, u64 size)
bitmap_size = PAGE_SIZE;
}
mapping = kzalloc(sizeof(struct dma_iommu_mapping), GFP_KERNEL);
mapping = kzalloc_obj(struct dma_iommu_mapping, GFP_KERNEL);
if (!mapping)
goto err;

View File

@@ -17,7 +17,7 @@
#include "mm.h"
#ifdef CONFIG_ARM_LPAE
#define _pgd_alloc(mm) kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL | __GFP_ZERO)
#define _pgd_alloc(mm) kmalloc_objs(pgd_t, PTRS_PER_PGD, GFP_KERNEL | __GFP_ZERO)
#define _pgd_free(mm, pgd) kfree(pgd)
#else
#define _pgd_alloc(mm) __pgd_alloc(mm, 2)

View File

@@ -763,9 +763,8 @@ static int coverage_start_fn(const struct decode_header *h, void *args)
static int coverage_start(const union decode_item *table)
{
coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
sizeof(struct coverage_entry),
GFP_KERNEL);
coverage.base = kmalloc_objs(struct coverage_entry,
MAX_COVERAGE_ENTRIES, GFP_KERNEL);
coverage.num_entries = 0;
coverage.nesting = 0;
return table_iter(table, coverage_start_fn, &coverage);

View File

@@ -339,7 +339,7 @@ int __init arch_xen_unpopulated_init(struct resource **res)
return -EINVAL;
}
regs = kcalloc(nr_reg, sizeof(*regs), GFP_KERNEL);
regs = kzalloc_objs(*regs, nr_reg, GFP_KERNEL);
if (!regs) {
of_node_put(np);
return -ENOMEM;
@@ -383,7 +383,7 @@ int __init arch_xen_unpopulated_init(struct resource **res)
start = regs[i - 1].end + 1;
end = regs[i].start - 1;
tmp_res = kzalloc(sizeof(*tmp_res), GFP_KERNEL);
tmp_res = kzalloc_obj(*tmp_res, GFP_KERNEL);
if (!tmp_res) {
rc = -ENOMEM;
goto err;

View File

@@ -176,7 +176,7 @@ bool __set_phys_to_machine_multi(unsigned long pfn,
return true;
}
p2m_entry = kzalloc(sizeof(*p2m_entry), GFP_NOWAIT);
p2m_entry = kzalloc_obj(*p2m_entry, GFP_NOWAIT);
if (!p2m_entry)
return false;

View File

@@ -52,7 +52,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
for_each_mem_range(i, &start, &end)
nr_ranges++;
cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL);
cmem = kmalloc_flex(*cmem, ranges, nr_ranges, GFP_KERNEL);
if (!cmem)
return -ENOMEM;

View File

@@ -81,9 +81,8 @@ static int __init __vdso_init(enum vdso_abi abi)
vdso_info[abi].vdso_code_start) >>
PAGE_SHIFT;
vdso_pagelist = kcalloc(vdso_info[abi].vdso_pages,
sizeof(struct page *),
GFP_KERNEL);
vdso_pagelist = kzalloc_objs(struct page *, vdso_info[abi].vdso_pages,
GFP_KERNEL);
if (vdso_pagelist == NULL)
return -ENOMEM;

View File

@@ -854,8 +854,8 @@ static void kvm_init_mpidr_data(struct kvm *kvm)
* iterative method. Single vcpu VMs do not need this either.
*/
if (struct_size(data, cmpidr_to_idx, nr_entries) <= PAGE_SIZE)
data = kzalloc(struct_size(data, cmpidr_to_idx, nr_entries),
GFP_KERNEL_ACCOUNT);
data = kzalloc_flex(*data, cmpidr_to_idx, nr_entries,
GFP_KERNEL_ACCOUNT);
if (!data)
goto out;

View File

@@ -487,7 +487,7 @@ static int share_pfn_hyp(u64 pfn)
goto unlock;
}
this = kzalloc(sizeof(*this), GFP_KERNEL);
this = kzalloc_obj(*this, GFP_KERNEL);
if (!this) {
ret = -ENOMEM;
goto unlock;
@@ -978,7 +978,7 @@ int kvm_init_stage2_mmu(struct kvm *kvm, struct kvm_s2_mmu *mmu, unsigned long t
if (err)
return err;
pgt = kzalloc(sizeof(*pgt), GFP_KERNEL_ACCOUNT);
pgt = kzalloc_obj(*pgt, GFP_KERNEL_ACCOUNT);
if (!pgt)
return -ENOMEM;
@@ -1155,7 +1155,8 @@ int topup_hyp_memcache(struct kvm_hyp_memcache *mc, unsigned long min_pages)
return 0;
if (!mc->mapping) {
mc->mapping = kzalloc(sizeof(struct pkvm_mapping), GFP_KERNEL_ACCOUNT);
mc->mapping = kzalloc_obj(struct pkvm_mapping,
GFP_KERNEL_ACCOUNT);
if (!mc->mapping)
return -ENOMEM;
}
@@ -2328,7 +2329,7 @@ int __init kvm_mmu_init(u32 hyp_va_bits)
goto out;
}
hyp_pgtable = kzalloc(sizeof(*hyp_pgtable), GFP_KERNEL);
hyp_pgtable = kzalloc_obj(*hyp_pgtable, GFP_KERNEL);
if (!hyp_pgtable) {
kvm_err("Hyp mode page-table not allocated\n");
err = -ENOMEM;

View File

@@ -1215,8 +1215,8 @@ int kvm_vcpu_allocate_vncr_tlb(struct kvm_vcpu *vcpu)
if (!kvm_has_feat(vcpu->kvm, ID_AA64MMFR4_EL1, NV_frac, NV2_ONLY))
return 0;
vcpu->arch.vncr_tlb = kzalloc(sizeof(*vcpu->arch.vncr_tlb),
GFP_KERNEL_ACCOUNT);
vcpu->arch.vncr_tlb = kzalloc_obj(*vcpu->arch.vncr_tlb,
GFP_KERNEL_ACCOUNT);
if (!vcpu->arch.vncr_tlb)
return -ENOMEM;
@@ -1704,8 +1704,8 @@ int kvm_init_nv_sysregs(struct kvm_vcpu *vcpu)
if (kvm->arch.sysreg_masks)
goto out;
kvm->arch.sysreg_masks = kzalloc(sizeof(*(kvm->arch.sysreg_masks)),
GFP_KERNEL_ACCOUNT);
kvm->arch.sysreg_masks = kzalloc_obj(*(kvm->arch.sysreg_masks),
GFP_KERNEL_ACCOUNT);
if (!kvm->arch.sysreg_masks)
return -ENOMEM;

View File

@@ -797,7 +797,7 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
guard(mutex)(&arm_pmus_lock);
entry = kmalloc(sizeof(*entry), GFP_KERNEL);
entry = kmalloc_obj(*entry, GFP_KERNEL);
if (!entry)
return;

View File

@@ -119,7 +119,7 @@ static struct kvm_ptdump_guest_state *kvm_ptdump_parser_create(struct kvm *kvm)
struct kvm_pgtable *pgtable = mmu->pgt;
int ret;
st = kzalloc(sizeof(struct kvm_ptdump_guest_state), GFP_KERNEL_ACCOUNT);
st = kzalloc_obj(struct kvm_ptdump_guest_state, GFP_KERNEL_ACCOUNT);
if (!st)
return ERR_PTR(-ENOMEM);

View File

@@ -104,7 +104,7 @@ static void *vgic_debug_start(struct seq_file *s, loff_t *pos)
struct kvm *kvm = s->private;
struct vgic_state_iter *iter;
iter = kmalloc(sizeof(*iter), GFP_KERNEL);
iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return ERR_PTR(-ENOMEM);
@@ -375,7 +375,7 @@ static void *vgic_its_debug_start(struct seq_file *s, loff_t *pos)
if (!dev)
return NULL;
iter = kmalloc(sizeof(*iter), GFP_KERNEL);
iter = kmalloc_obj(*iter, GFP_KERNEL);
if (!iter)
return ERR_PTR(-ENOMEM);

View File

@@ -199,7 +199,7 @@ static int kvm_vgic_dist_init(struct kvm *kvm, unsigned int nr_spis)
int i;
dist->active_spis = (atomic_t)ATOMIC_INIT(0);
dist->spis = kcalloc(nr_spis, sizeof(struct vgic_irq), GFP_KERNEL_ACCOUNT);
dist->spis = kzalloc_objs(struct vgic_irq, nr_spis, GFP_KERNEL_ACCOUNT);
if (!dist->spis)
return -ENOMEM;
@@ -269,9 +269,9 @@ static int vgic_allocate_private_irqs_locked(struct kvm_vcpu *vcpu, u32 type)
if (vgic_cpu->private_irqs)
return 0;
vgic_cpu->private_irqs = kcalloc(VGIC_NR_PRIVATE_IRQS,
sizeof(struct vgic_irq),
GFP_KERNEL_ACCOUNT);
vgic_cpu->private_irqs = kzalloc_objs(struct vgic_irq,
VGIC_NR_PRIVATE_IRQS,
GFP_KERNEL_ACCOUNT);
if (!vgic_cpu->private_irqs)
return -ENOMEM;
@@ -654,7 +654,7 @@ static struct gic_kvm_info *gic_kvm_info;
void __init vgic_set_kvm_info(const struct gic_kvm_info *info)
{
BUG_ON(gic_kvm_info != NULL);
gic_kvm_info = kmalloc(sizeof(*gic_kvm_info), GFP_KERNEL);
gic_kvm_info = kmalloc_obj(*gic_kvm_info, GFP_KERNEL);
if (gic_kvm_info)
*gic_kvm_info = *info;
}

View File

@@ -140,7 +140,7 @@ int kvm_vgic_setup_default_irq_routing(struct kvm *kvm)
u32 nr = dist->nr_spis;
int i, ret;
entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL_ACCOUNT);
entries = kzalloc_objs(*entries, nr, GFP_KERNEL_ACCOUNT);
if (!entries)
return -ENOMEM;

View File

@@ -85,7 +85,7 @@ static struct vgic_irq *vgic_add_lpi(struct kvm *kvm, u32 intid,
if (irq)
return irq;
irq = kzalloc(sizeof(struct vgic_irq), GFP_KERNEL_ACCOUNT);
irq = kzalloc_obj(struct vgic_irq, GFP_KERNEL_ACCOUNT);
if (!irq)
return ERR_PTR(-ENOMEM);
@@ -960,7 +960,7 @@ static int vgic_its_alloc_collection(struct vgic_its *its,
{
struct its_collection *collection;
collection = kzalloc(sizeof(*collection), GFP_KERNEL_ACCOUNT);
collection = kzalloc_obj(*collection, GFP_KERNEL_ACCOUNT);
if (!collection)
return -ENOMEM;
@@ -1004,7 +1004,7 @@ static struct its_ite *vgic_its_alloc_ite(struct its_device *device,
{
struct its_ite *ite;
ite = kzalloc(sizeof(*ite), GFP_KERNEL_ACCOUNT);
ite = kzalloc_obj(*ite, GFP_KERNEL_ACCOUNT);
if (!ite)
return ERR_PTR(-ENOMEM);
@@ -1131,7 +1131,7 @@ static struct its_device *vgic_its_alloc_device(struct vgic_its *its,
{
struct its_device *device;
device = kzalloc(sizeof(*device), GFP_KERNEL_ACCOUNT);
device = kzalloc_obj(*device, GFP_KERNEL_ACCOUNT);
if (!device)
return ERR_PTR(-ENOMEM);
@@ -1846,7 +1846,7 @@ static int vgic_its_create(struct kvm_device *dev, u32 type)
if (type != KVM_DEV_TYPE_ARM_VGIC_ITS)
return -ENODEV;
its = kzalloc(sizeof(struct vgic_its), GFP_KERNEL_ACCOUNT);
its = kzalloc_obj(struct vgic_its, GFP_KERNEL_ACCOUNT);
if (!its)
return -ENOMEM;

View File

@@ -929,7 +929,7 @@ static int vgic_v3_alloc_redist_region(struct kvm *kvm, uint32_t index,
if (vgic_v3_rdist_overlap(kvm, base, size))
return -EINVAL;
rdreg = kzalloc(sizeof(*rdreg), GFP_KERNEL_ACCOUNT);
rdreg = kzalloc_obj(*rdreg, GFP_KERNEL_ACCOUNT);
if (!rdreg)
return -ENOMEM;

View File

@@ -256,8 +256,8 @@ int vgic_v4_init(struct kvm *kvm)
nr_vcpus = atomic_read(&kvm->online_vcpus);
dist->its_vm.vpes = kcalloc(nr_vcpus, sizeof(*dist->its_vm.vpes),
GFP_KERNEL_ACCOUNT);
dist->its_vm.vpes = kzalloc_objs(*dist->its_vm.vpes, nr_vcpus,
GFP_KERNEL_ACCOUNT);
if (!dist->its_vm.vpes)
return -ENOMEM;

View File

@@ -2040,7 +2040,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
jit_data = prog->aux->jit_data;
if (!jit_data) {
jit_data = kzalloc(sizeof(*jit_data), GFP_KERNEL);
jit_data = kzalloc_obj(*jit_data, GFP_KERNEL);
if (!jit_data) {
prog = orig_prog;
goto out;
@@ -2078,7 +2078,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
memset(&ctx, 0, sizeof(ctx));
ctx.prog = prog;
ctx.offset = kvcalloc(prog->len + 1, sizeof(int), GFP_KERNEL);
ctx.offset = kvzalloc_objs(int, prog->len + 1, GFP_KERNEL);
if (ctx.offset == NULL) {
prog = orig_prog;
goto out_off;

View File

@@ -20,7 +20,7 @@ static int __init vdso_init(void)
vdso_pages = (vdso_end - vdso_start) >> PAGE_SHIFT;
vdso_pagelist =
kcalloc(vdso_pages, sizeof(struct page *), GFP_KERNEL);
kzalloc_objs(struct page *, vdso_pages, GFP_KERNEL);
if (unlikely(vdso_pagelist == NULL)) {
pr_err("vdso: pagelist allocation failed\n");
return -ENOMEM;

View File

@@ -68,7 +68,7 @@ static int prepare_elf_headers(void **addr, unsigned long *sz)
for_each_mem_range(i, &start, &end)
nr_ranges++;
cmem = kmalloc(struct_size(cmem, ranges, nr_ranges), GFP_KERNEL);
cmem = kmalloc_flex(*cmem, ranges, nr_ranges, GFP_KERNEL);
if (!cmem)
return -ENOMEM;

View File

@@ -470,7 +470,7 @@ static int __init add_legacy_isa_io(struct fwnode_handle *fwnode,
unsigned long vaddr;
struct logic_pio_hwaddr *range;
range = kzalloc(sizeof(*range), GFP_ATOMIC);
range = kzalloc_obj(*range, GFP_ATOMIC);
if (!range)
return -ENOMEM;

View File

@@ -52,7 +52,8 @@ static int __init init_vdso(void)
vdso_info.size = PAGE_ALIGN(vdso_end - vdso_start);
vdso_info.code_mapping.pages =
kcalloc(vdso_info.size / PAGE_SIZE, sizeof(struct page *), GFP_KERNEL);
kzalloc_objs(struct page *, vdso_info.size / PAGE_SIZE,
GFP_KERNEL);
if (!vdso_info.code_mapping.pages)
return -ENOMEM;

View File

@@ -622,7 +622,7 @@ static int kvm_eiointc_create(struct kvm_device *dev, u32 type)
if (kvm->arch.eiointc)
return -EINVAL;
s = kzalloc(sizeof(struct loongarch_eiointc), GFP_KERNEL);
s = kzalloc_obj(struct loongarch_eiointc, GFP_KERNEL);
if (!s)
return -ENOMEM;

View File

@@ -409,7 +409,7 @@ static int kvm_ipi_create(struct kvm_device *dev, u32 type)
return -EINVAL;
}
s = kzalloc(sizeof(struct loongarch_ipi), GFP_KERNEL);
s = kzalloc_obj(struct loongarch_ipi, GFP_KERNEL);
if (!s)
return -ENOMEM;

View File

@@ -402,7 +402,7 @@ static int kvm_setup_default_irq_routing(struct kvm *kvm)
u32 nr = KVM_IRQCHIP_NUM_PINS;
struct kvm_irq_routing_entry *entries;
entries = kcalloc(nr, sizeof(*entries), GFP_KERNEL);
entries = kzalloc_objs(*entries, nr, GFP_KERNEL);
if (!entries)
return -ENOMEM;
@@ -432,7 +432,7 @@ static int kvm_pch_pic_create(struct kvm_device *dev, u32 type)
if (ret)
return -ENOMEM;
s = kzalloc(sizeof(struct loongarch_pch_pic), GFP_KERNEL);
s = kzalloc_obj(struct loongarch_pch_pic, GFP_KERNEL);
if (!s)
return -ENOMEM;

View File

@@ -358,7 +358,7 @@ static int kvm_loongarch_env_init(void)
return -ENOMEM;
}
kvm_loongarch_ops = kzalloc(sizeof(*kvm_loongarch_ops), GFP_KERNEL);
kvm_loongarch_ops = kzalloc_obj(*kvm_loongarch_ops, GFP_KERNEL);
if (!kvm_loongarch_ops) {
free_percpu(vmcs);
vmcs = NULL;

View File

@@ -1547,7 +1547,7 @@ int kvm_arch_vcpu_create(struct kvm_vcpu *vcpu)
vcpu->arch.handle_exit = kvm_handle_exit;
vcpu->arch.guest_eentry = (unsigned long)kvm_loongarch_ops->exc_entry;
vcpu->arch.csr = kzalloc(sizeof(struct loongarch_csrs), GFP_KERNEL);
vcpu->arch.csr = kzalloc_obj(struct loongarch_csrs, GFP_KERNEL);
if (!vcpu->arch.csr)
return -ENOMEM;

View File

@@ -68,7 +68,8 @@ int kvm_arch_init_vm(struct kvm *kvm, unsigned long type)
if (!kvm->arch.pgd)
return -ENOMEM;
kvm->arch.phyid_map = kvzalloc(sizeof(struct kvm_phyid_map), GFP_KERNEL_ACCOUNT);
kvm->arch.phyid_map = kvzalloc_obj(struct kvm_phyid_map,
GFP_KERNEL_ACCOUNT);
if (!kvm->arch.phyid_map) {
free_page((unsigned long)kvm->arch.pgd);
kvm->arch.pgd = NULL;

View File

@@ -1943,7 +1943,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
jit_data = prog->aux->jit_data;
if (!jit_data) {
jit_data = kzalloc(sizeof(*jit_data), GFP_KERNEL);
jit_data = kzalloc_obj(*jit_data, GFP_KERNEL);
if (!jit_data) {
prog = orig_prog;
goto out;

View File

@@ -101,7 +101,7 @@ static struct pci_config_window *arch_pci_ecam_create(struct device *dev,
if (busr->start > busr->end)
return ERR_PTR(-EINVAL);
cfg = kzalloc(sizeof(*cfg), GFP_KERNEL);
cfg = kzalloc_obj(*cfg, GFP_KERNEL);
if (!cfg)
return ERR_PTR(-ENOMEM);
@@ -199,13 +199,13 @@ struct pci_bus *pci_acpi_scan_root(struct acpi_pci_root *root)
int domain = root->segment;
int busnum = root->secondary.start;
info = kzalloc(sizeof(*info), GFP_KERNEL);
info = kzalloc_obj(*info, GFP_KERNEL);
if (!info) {
pr_warn("pci_bus %04x:%02x: ignored (out of memory)\n", domain, busnum);
return NULL;
}
root_ops = kzalloc(sizeof(*root_ops), GFP_KERNEL);
root_ops = kzalloc_obj(*root_ops, GFP_KERNEL);
if (!root_ops) {
kfree(info);
return NULL;

View File

@@ -47,7 +47,7 @@ void *amiga_chip_alloc(unsigned long size, const char *name)
struct resource *res;
void *p;
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc_obj(struct resource, GFP_KERNEL);
if (!res)
return NULL;

View File

@@ -161,7 +161,7 @@ void *atari_stram_alloc(unsigned long size, const char *owner)
/* round up */
size = PAGE_ALIGN(size);
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc_obj(struct resource, GFP_KERNEL);
if (!res)
return NULL;

View File

@@ -112,7 +112,7 @@ static int __init nfhd_init_one(int id, u32 blocks, u32 bsize)
return -EINVAL;
}
dev = kmalloc(sizeof(struct nfhd_device), GFP_KERNEL);
dev = kmalloc_obj(struct nfhd_device, GFP_KERNEL);
if (!dev)
goto out;

View File

@@ -110,7 +110,7 @@ static struct vm_struct *get_io_area(unsigned long size)
unsigned long addr;
struct vm_struct **p, *tmp, *area;
area = kmalloc(sizeof(*area), GFP_KERNEL);
area = kmalloc_obj(*area, GFP_KERNEL);
if (!area)
return NULL;
addr = KMAP_START;

View File

@@ -154,7 +154,7 @@ static struct clk __init *alchemy_clk_setup_cpu(const char *parent_name,
struct clk_hw *h;
struct clk *clk;
h = kzalloc(sizeof(*h), GFP_KERNEL);
h = kzalloc_obj(*h, GFP_KERNEL);
if (!h)
return ERR_PTR(-ENOMEM);
@@ -249,7 +249,7 @@ static struct clk __init *alchemy_clk_setup_aux(const char *parent_name,
struct clk *c;
struct alchemy_auxpll_clk *a;
a = kzalloc(sizeof(*a), GFP_KERNEL);
a = kzalloc_obj(*a, GFP_KERNEL);
if (!a)
return ERR_PTR(-ENOMEM);
@@ -775,7 +775,7 @@ static int __init alchemy_clk_init_fgens(int ctype)
}
id.flags = CLK_SET_RATE_PARENT | CLK_GET_RATE_NOCACHE;
a = kcalloc(6, sizeof(*a), GFP_KERNEL);
a = kzalloc_objs(*a, 6, GFP_KERNEL);
if (!a)
return -ENOMEM;
@@ -996,7 +996,7 @@ static int __init alchemy_clk_setup_imux(int ctype)
return -ENODEV;
}
a = kcalloc(6, sizeof(*a), GFP_KERNEL);
a = kzalloc_objs(*a, 6, GFP_KERNEL);
if (!a)
return -ENOMEM;

View File

@@ -310,7 +310,7 @@ u32 au1xxx_dbdma_chan_alloc(u32 srcid, u32 destid,
* If kmalloc fails, it is caught below same
* as a channel not available.
*/
ctp = kmalloc(sizeof(chan_tab_t), GFP_ATOMIC);
ctp = kmalloc_obj(chan_tab_t, GFP_ATOMIC);
chan_tab_ptr[i] = ctp;
break;
}
@@ -412,8 +412,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
* and if we try that first we are likely to not waste larger
* slabs of memory.
*/
desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t),
GFP_KERNEL|GFP_DMA);
desc_base = (u32) kmalloc_objs(au1x_ddma_desc_t, entries,
GFP_KERNEL | GFP_DMA);
if (desc_base == 0)
return 0;
@@ -1057,7 +1057,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable)
{
int ret;
dbdev_tab = kcalloc(DBDEV_TAB_SIZE, sizeof(dbdev_tab_t), GFP_KERNEL);
dbdev_tab = kzalloc_objs(dbdev_tab_t, DBDEV_TAB_SIZE, GFP_KERNEL);
if (!dbdev_tab)
return -ENOMEM;

View File

@@ -202,10 +202,10 @@ static unsigned long alchemy_ehci_data[][2] __initdata = {
static int __init _new_usbres(struct resource **r, struct platform_device **d)
{
*r = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
*r = kzalloc_objs(struct resource, 2, GFP_KERNEL);
if (!*r)
return -ENOMEM;
*d = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
*d = kzalloc_obj(struct platform_device, GFP_KERNEL);
if (!*d) {
kfree(*r);
return -ENOMEM;

View File

@@ -87,7 +87,7 @@ int __init db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start,
if (stschg_irq)
cnt++;
sr = kcalloc(cnt, sizeof(struct resource), GFP_KERNEL);
sr = kzalloc_objs(struct resource, cnt, GFP_KERNEL);
if (!sr)
return -ENOMEM;
@@ -162,15 +162,15 @@ int __init db1x_register_norflash(unsigned long size, int width,
return -EINVAL;
ret = -ENOMEM;
parts = kcalloc(5, sizeof(struct mtd_partition), GFP_KERNEL);
parts = kzalloc_objs(struct mtd_partition, 5, GFP_KERNEL);
if (!parts)
goto out;
res = kzalloc(sizeof(struct resource), GFP_KERNEL);
res = kzalloc_obj(struct resource, GFP_KERNEL);
if (!res)
goto out1;
pfd = kzalloc(sizeof(struct physmap_flash_data), GFP_KERNEL);
pfd = kzalloc_obj(struct physmap_flash_data, GFP_KERNEL);
if (!pfd)
goto out2;

View File

@@ -187,7 +187,7 @@ static struct device * __init bcm47xx_setup_device(void)
struct device *dev;
int err;
dev = kzalloc(sizeof(*dev), GFP_KERNEL);
dev = kzalloc_obj(*dev, GFP_KERNEL);
if (!dev)
return NULL;

View File

@@ -100,7 +100,7 @@ static int octeon_irq_set_ciu_mapping(int irq, int line, int bit, int gpio_line,
{
struct octeon_ciu_chip_data *cd;
cd = kzalloc(sizeof(*cd), GFP_KERNEL);
cd = kzalloc_obj(*cd, GFP_KERNEL);
if (!cd)
return -ENOMEM;
@@ -1462,7 +1462,7 @@ static int __init octeon_irq_init_ciu(
struct irq_domain *ciu_domain = NULL;
struct octeon_irq_ciu_domain_data *dd;
dd = kzalloc(sizeof(*dd), GFP_KERNEL);
dd = kzalloc_obj(*dd, GFP_KERNEL);
if (!dd)
return -ENOMEM;
@@ -1633,7 +1633,7 @@ static int __init octeon_irq_init_gpio(
return -EINVAL;
}
gpiod = kzalloc(sizeof(*gpiod), GFP_KERNEL);
gpiod = kzalloc_obj(*gpiod, GFP_KERNEL);
if (gpiod) {
/* gpio domain host_data is the base hwirq number. */
gpiod->base_hwirq = base_hwirq;
@@ -2223,7 +2223,7 @@ static int octeon_irq_cib_map(struct irq_domain *d,
return -EINVAL;
}
cd = kzalloc(sizeof(*cd), GFP_KERNEL);
cd = kzalloc_obj(*cd, GFP_KERNEL);
if (!cd)
return -ENOMEM;
@@ -2304,7 +2304,7 @@ static int __init octeon_irq_init_cib(struct device_node *ciu_node,
return -EINVAL;
}
host_data = kzalloc(sizeof(*host_data), GFP_KERNEL);
host_data = kzalloc_obj(*host_data, GFP_KERNEL);
if (!host_data)
return -ENOMEM;
raw_spin_lock_init(&host_data->lock);

View File

@@ -72,7 +72,7 @@ static int apply_r_mips_hi16(struct module *me, u32 *location, Elf_Addr v,
* the carry we need to add. Save the information, and let LO16 do the
* actual relocation.
*/
n = kmalloc(sizeof *n, GFP_KERNEL);
n = kmalloc_obj(*n, GFP_KERNEL);
if (!n)
return -ENOMEM;

View File

@@ -341,9 +341,8 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
/* Allocate cluster boot configuration structs */
nclusters = mips_cps_numclusters();
mips_cps_cluster_bootcfg = kcalloc(nclusters,
sizeof(*mips_cps_cluster_bootcfg),
GFP_KERNEL);
mips_cps_cluster_bootcfg = kzalloc_objs(*mips_cps_cluster_bootcfg,
nclusters, GFP_KERNEL);
if (!mips_cps_cluster_bootcfg)
goto err_out;
@@ -353,8 +352,7 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
for (cl = 0; cl < nclusters; cl++) {
/* Allocate core boot configuration structs */
ncores = mips_cps_numcores(cl);
core_bootcfg = kcalloc(ncores, sizeof(*core_bootcfg),
GFP_KERNEL);
core_bootcfg = kzalloc_objs(*core_bootcfg, ncores, GFP_KERNEL);
if (!core_bootcfg)
goto err_out;
mips_cps_cluster_bootcfg[cl].core_config = core_bootcfg;
@@ -369,9 +367,9 @@ static void __init cps_prepare_cpus(unsigned int max_cpus)
for (c = 0; c < ncores; c++) {
int v;
core_vpes = core_vpe_count(cl, c);
core_bootcfg[c].vpe_config = kcalloc(core_vpes,
sizeof(*core_bootcfg[c].vpe_config),
GFP_KERNEL);
core_bootcfg[c].vpe_config = kzalloc_objs(*core_bootcfg[c].vpe_config,
core_vpes,
GFP_KERNEL);
for (v = 0; v < core_vpes; v++)
cpumask_set_cpu(nvpe++, &mips_cps_cluster_bootcfg[cl].cpumask);
if (!core_bootcfg[c].vpe_config)

View File

@@ -94,7 +94,7 @@ struct vpe *alloc_vpe(int minor)
{
struct vpe *v;
v = kzalloc(sizeof(struct vpe), GFP_KERNEL);
v = kzalloc_obj(struct vpe, GFP_KERNEL);
if (v == NULL)
goto out;
@@ -115,7 +115,7 @@ struct tc *alloc_tc(int index)
{
struct tc *tc;
tc = kzalloc(sizeof(struct tc), GFP_KERNEL);
tc = kzalloc_obj(struct tc, GFP_KERNEL);
if (tc == NULL)
goto out;
@@ -318,7 +318,7 @@ static int apply_r_mips_hi16(struct module *me, uint32_t *location,
* the carry we need to add. Save the information, and let LO16 do the
* actual relocation.
*/
n = kmalloc(sizeof(*n), GFP_KERNEL);
n = kmalloc_obj(*n, GFP_KERNEL);
if (!n)
return -ENOMEM;

View File

@@ -161,7 +161,7 @@ static void falcon_gpe_enable(void)
static inline void clkdev_add_sys(const char *dev, unsigned int module,
unsigned int bits)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk = kzalloc_obj(struct clk, GFP_KERNEL);
if (!clk)
return;

View File

@@ -121,7 +121,7 @@ static void gptu_disable(struct clk *clk)
static inline void clkdev_add_gptu(struct device *dev, const char *con,
unsigned int timer)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk = kzalloc_obj(struct clk, GFP_KERNEL);
if (!clk)
return;

View File

@@ -331,7 +331,7 @@ static int clkout_enable(struct clk *clk)
static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate,
unsigned int module, unsigned int bits)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk = kzalloc_obj(struct clk, GFP_KERNEL);
if (!clk)
return;
@@ -356,7 +356,7 @@ static void clkdev_add_pmu(const char *dev, const char *con, bool deactivate,
static void clkdev_add_cgu(const char *dev, const char *con,
unsigned int bits)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk = kzalloc_obj(struct clk, GFP_KERNEL);
if (!clk)
return;
@@ -374,8 +374,8 @@ static unsigned long valid_pci_rates[] = {CLOCK_33M, CLOCK_62_5M, 0};
static void clkdev_add_pci(void)
{
struct clk *clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk_ext = kzalloc(sizeof(struct clk), GFP_KERNEL);
struct clk *clk = kzalloc_obj(struct clk, GFP_KERNEL);
struct clk *clk_ext = kzalloc_obj(struct clk, GFP_KERNEL);
/* main pci clock */
if (clk) {
@@ -423,7 +423,7 @@ static void clkdev_add_clkout(void)
continue;
sprintf(name, "clkout%d", i);
clk = kzalloc(sizeof(struct clk), GFP_KERNEL);
clk = kzalloc_obj(struct clk, GFP_KERNEL);
if (!clk) {
kfree(name);
continue;

View File

@@ -156,7 +156,7 @@ static int __init add_legacy_isa_io(struct fwnode_handle *fwnode, resource_size_
struct logic_pio_hwaddr *range;
unsigned long vaddr;
range = kzalloc(sizeof(*range), GFP_ATOMIC);
range = kzalloc_obj(*range, GFP_ATOMIC);
if (!range)
return -ENOMEM;

View File

@@ -380,7 +380,7 @@ static int alchemy_pci_probe(struct platform_device *pdev)
goto out;
}
ctx = kzalloc(sizeof(*ctx), GFP_KERNEL);
ctx = kzalloc_obj(*ctx, GFP_KERNEL);
if (!ctx) {
dev_err(&pdev->dev, "no memory for pcictl context\n");
ret = -ENOMEM;

View File

@@ -341,7 +341,7 @@ static int bridge_domain_alloc(struct irq_domain *domain, unsigned int virq,
if (nr_irqs > 1 || !info)
return -EINVAL;
data = kzalloc(sizeof(*data), GFP_KERNEL);
data = kzalloc_obj(*data, GFP_KERNEL);
if (!data)
return -ENOMEM;

View File

@@ -198,7 +198,7 @@ static int __init mt7620_soc_dev_init(void)
struct soc_device *soc_dev;
struct soc_device_attribute *soc_dev_attr;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;

View File

@@ -144,7 +144,7 @@ static int __init mt7621_soc_dev_init(void)
struct soc_device *soc_dev;
struct soc_device_attribute *soc_dev_attr;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;

View File

@@ -68,7 +68,7 @@ static int __init rt2880_soc_dev_init(void)
struct soc_device *soc_dev;
struct soc_device_attribute *soc_dev_attr;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;

View File

@@ -171,7 +171,7 @@ static int __init rt305x_soc_dev_init(void)
struct soc_device *soc_dev;
struct soc_device_attribute *soc_dev_attr;
soc_dev_attr = kzalloc(sizeof(*soc_dev_attr), GFP_KERNEL);
soc_dev_attr = kzalloc_obj(*soc_dev_attr, GFP_KERNEL);
if (!soc_dev_attr)
return -ENOMEM;

Some files were not shown because too many files have changed in this diff Show More