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 /arch/sparc | |
| parent | d39a1d7486d98668dd34aaa6732aad7977c45f5a (diff) | |
| download | lwn-69050f8d6d075dc01af7a5f2f550a8067510366f.tar.gz lwn-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 'arch/sparc')
31 files changed, 47 insertions, 48 deletions
diff --git a/arch/sparc/kernel/central.c b/arch/sparc/kernel/central.c index a1a6485c9183..904c4223230f 100644 --- a/arch/sparc/kernel/central.c +++ b/arch/sparc/kernel/central.c @@ -63,7 +63,7 @@ static int clock_board_calc_nslots(struct clock_board *p) static int clock_board_probe(struct platform_device *op) { - struct clock_board *p = kzalloc(sizeof(*p), GFP_KERNEL); + struct clock_board *p = kzalloc_obj(*p, GFP_KERNEL); int err = -ENOMEM; if (!p) { @@ -159,7 +159,7 @@ static struct platform_driver clock_board_driver = { static int fhc_probe(struct platform_device *op) { - struct fhc *p = kzalloc(sizeof(*p), GFP_KERNEL); + struct fhc *p = kzalloc_obj(*p, GFP_KERNEL); int err = -ENOMEM; u32 reg; diff --git a/arch/sparc/kernel/chmc.c b/arch/sparc/kernel/chmc.c index d4c74d6b2e1b..663b2d7ff7bc 100644 --- a/arch/sparc/kernel/chmc.c +++ b/arch/sparc/kernel/chmc.c @@ -417,7 +417,7 @@ static int jbusmc_probe(struct platform_device *op) num_mem_regs = len / sizeof(*mem_regs); err = -ENOMEM; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = kzalloc_obj(*p, GFP_KERNEL); if (!p) { printk(KERN_ERR PFX "Cannot allocate struct jbusmc.\n"); goto out; @@ -718,7 +718,7 @@ static int chmc_probe(struct platform_device *op) } err = -ENOMEM; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = kzalloc_obj(*p, GFP_KERNEL); if (!p) { printk(KERN_ERR PFX "Could not allocate struct chmc.\n"); goto out; diff --git a/arch/sparc/kernel/cpumap.c b/arch/sparc/kernel/cpumap.c index 8fcf2d8c6bd2..d51ff010176c 100644 --- a/arch/sparc/kernel/cpumap.c +++ b/arch/sparc/kernel/cpumap.c @@ -194,7 +194,7 @@ static struct cpuinfo_tree *build_cpuinfo_tree(void) n = enumerate_cpuinfo_nodes(tmp_level); - new_tree = kzalloc(struct_size(new_tree, nodes, n), GFP_ATOMIC); + new_tree = kzalloc_flex(*new_tree, nodes, n, GFP_ATOMIC); if (!new_tree) return NULL; diff --git a/arch/sparc/kernel/ds.c b/arch/sparc/kernel/ds.c index f7fc6f2af2f2..df3fa6d96074 100644 --- a/arch/sparc/kernel/ds.c +++ b/arch/sparc/kernel/ds.c @@ -1175,7 +1175,7 @@ static int ds_probe(struct vio_dev *vdev, const struct vio_device_id *id) if (ds_version_printed++ == 0) printk(KERN_INFO "%s", version); - dp = kzalloc(sizeof(*dp), GFP_KERNEL); + dp = kzalloc_obj(*dp, GFP_KERNEL); err = -ENOMEM; if (!dp) goto out_err; diff --git a/arch/sparc/kernel/ioport.c b/arch/sparc/kernel/ioport.c index 5ebca5c7af1e..82d248e6b822 100644 --- a/arch/sparc/kernel/ioport.c +++ b/arch/sparc/kernel/ioport.c @@ -238,7 +238,7 @@ unsigned long sparc_dma_alloc_resource(struct device *dev, size_t len) { struct resource *res; - res = kzalloc(sizeof(*res), GFP_KERNEL); + res = kzalloc_obj(*res, GFP_KERNEL); if (!res) return 0; res->name = dev->of_node->full_name; diff --git a/arch/sparc/kernel/irq_64.c b/arch/sparc/kernel/irq_64.c index ded463c82abd..c5466a9fd560 100644 --- a/arch/sparc/kernel/irq_64.c +++ b/arch/sparc/kernel/irq_64.c @@ -628,7 +628,7 @@ unsigned int build_irq(int inofixup, unsigned long iclr, unsigned long imap) if (unlikely(handler_data)) goto out; - handler_data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC); + handler_data = kzalloc_obj(struct irq_handler_data, GFP_ATOMIC); if (unlikely(!handler_data)) { prom_printf("IRQ: kzalloc(irq_handler_data) failed.\n"); prom_halt(); @@ -654,7 +654,7 @@ static unsigned int sun4v_build_common(u32 devhandle, unsigned int devino, if (!irq) goto out; - data = kzalloc(sizeof(struct irq_handler_data), GFP_ATOMIC); + data = kzalloc_obj(struct irq_handler_data, GFP_ATOMIC); if (unlikely(!data)) { pr_err("IRQ handler data allocation failed.\n"); irq_free(irq); diff --git a/arch/sparc/kernel/ldc.c b/arch/sparc/kernel/ldc.c index 7f3cdb6f644d..4fd357d5fc29 100644 --- a/arch/sparc/kernel/ldc.c +++ b/arch/sparc/kernel/ldc.c @@ -1171,7 +1171,7 @@ struct ldc_channel *ldc_alloc(unsigned long id, mssbuf = NULL; - lp = kzalloc(sizeof(*lp), GFP_KERNEL); + lp = kzalloc_obj(*lp, GFP_KERNEL); err = -ENOMEM; if (!lp) goto out_err; diff --git a/arch/sparc/kernel/leon_pci_grpci2.c b/arch/sparc/kernel/leon_pci_grpci2.c index 9f662340b5b2..c6d5cec12b67 100644 --- a/arch/sparc/kernel/leon_pci_grpci2.c +++ b/arch/sparc/kernel/leon_pci_grpci2.c @@ -721,7 +721,7 @@ static int grpci2_of_probe(struct platform_device *ofdev) goto err1; } - priv = grpci2priv = kzalloc(sizeof(struct grpci2_priv), GFP_KERNEL); + priv = grpci2priv = kzalloc_obj(struct grpci2_priv, GFP_KERNEL); if (grpci2priv == NULL) { err = -ENOMEM; goto err1; diff --git a/arch/sparc/kernel/of_device_32.c b/arch/sparc/kernel/of_device_32.c index 284a4cafa432..51e90a093ee0 100644 --- a/arch/sparc/kernel/of_device_32.c +++ b/arch/sparc/kernel/of_device_32.c @@ -340,7 +340,7 @@ static void __init build_device_resources(struct platform_device *op, static struct platform_device * __init scan_one_device(struct device_node *dp, struct device *parent) { - struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL); + struct platform_device *op = kzalloc_obj(*op, GFP_KERNEL); const struct linux_prom_irqs *intr; struct dev_archdata *sd; int len, i; diff --git a/arch/sparc/kernel/of_device_64.c b/arch/sparc/kernel/of_device_64.c index f53092b07b9e..c30ad34525bd 100644 --- a/arch/sparc/kernel/of_device_64.c +++ b/arch/sparc/kernel/of_device_64.c @@ -633,7 +633,7 @@ out: static struct platform_device * __init scan_one_device(struct device_node *dp, struct device *parent) { - struct platform_device *op = kzalloc(sizeof(*op), GFP_KERNEL); + struct platform_device *op = kzalloc_obj(*op, GFP_KERNEL); const unsigned int *irq; struct dev_archdata *sd; int len, i; diff --git a/arch/sparc/kernel/pci.c b/arch/sparc/kernel/pci.c index b290107170e9..432f83cf61aa 100644 --- a/arch/sparc/kernel/pci.c +++ b/arch/sparc/kernel/pci.c @@ -650,7 +650,7 @@ static void pci_claim_legacy_resources(struct pci_dev *dev) if ((dev->class >> 8) != PCI_CLASS_DISPLAY_VGA) return; - p = kzalloc(sizeof(*p), GFP_KERNEL); + p = kzalloc_obj(*p, GFP_KERNEL); if (!p) return; diff --git a/arch/sparc/kernel/pci_common.c b/arch/sparc/kernel/pci_common.c index 2576f4f31309..588cfc595b84 100644 --- a/arch/sparc/kernel/pci_common.c +++ b/arch/sparc/kernel/pci_common.c @@ -336,7 +336,7 @@ static void pci_register_iommu_region(struct pci_pbm_info *pbm) NULL); if (vdma) { - struct resource *rp = kzalloc(sizeof(*rp), GFP_KERNEL); + struct resource *rp = kzalloc_obj(*rp, GFP_KERNEL); if (!rp) { pr_info("%s: Cannot allocate IOMMU resource.\n", diff --git a/arch/sparc/kernel/pci_fire.c b/arch/sparc/kernel/pci_fire.c index 0b91bde80fdc..b72cf5acbdba 100644 --- a/arch/sparc/kernel/pci_fire.c +++ b/arch/sparc/kernel/pci_fire.c @@ -468,13 +468,13 @@ static int fire_probe(struct platform_device *op) portid = of_getintprop_default(dp, "portid", 0xff); err = -ENOMEM; - pbm = kzalloc(sizeof(*pbm), GFP_KERNEL); + pbm = kzalloc_obj(*pbm, GFP_KERNEL); if (!pbm) { printk(KERN_ERR PFX "Cannot allocate pci_pbminfo.\n"); goto out_err; } - iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL); + iommu = kzalloc_obj(struct iommu, GFP_KERNEL); if (!iommu) { printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n"); goto out_free_controller; diff --git a/arch/sparc/kernel/pci_psycho.c b/arch/sparc/kernel/pci_psycho.c index 1efc98305ec7..9880b341a631 100644 --- a/arch/sparc/kernel/pci_psycho.c +++ b/arch/sparc/kernel/pci_psycho.c @@ -519,7 +519,7 @@ static int psycho_probe(struct platform_device *op) upa_portid = of_getintprop_default(dp, "upa-portid", 0xff); err = -ENOMEM; - pbm = kzalloc(sizeof(*pbm), GFP_KERNEL); + pbm = kzalloc_obj(*pbm, GFP_KERNEL); if (!pbm) { printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n"); goto out_err; @@ -529,7 +529,7 @@ static int psycho_probe(struct platform_device *op) if (pbm->sibling) { iommu = pbm->sibling->iommu; } else { - iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL); + iommu = kzalloc_obj(struct iommu, GFP_KERNEL); if (!iommu) { printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n"); goto out_free_controller; diff --git a/arch/sparc/kernel/pci_sabre.c b/arch/sparc/kernel/pci_sabre.c index a84598568300..3b4116f23862 100644 --- a/arch/sparc/kernel/pci_sabre.c +++ b/arch/sparc/kernel/pci_sabre.c @@ -482,13 +482,13 @@ static int sabre_probe(struct platform_device *op) } err = -ENOMEM; - pbm = kzalloc(sizeof(*pbm), GFP_KERNEL); + pbm = kzalloc_obj(*pbm, GFP_KERNEL); if (!pbm) { printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n"); goto out_err; } - iommu = kzalloc(sizeof(*iommu), GFP_KERNEL); + iommu = kzalloc_obj(*iommu, GFP_KERNEL); if (!iommu) { printk(KERN_ERR PFX "Cannot allocate PBM iommu.\n"); goto out_free_controller; diff --git a/arch/sparc/kernel/pci_schizo.c b/arch/sparc/kernel/pci_schizo.c index 93cd9e5a8099..519a80a639d6 100644 --- a/arch/sparc/kernel/pci_schizo.c +++ b/arch/sparc/kernel/pci_schizo.c @@ -1426,7 +1426,7 @@ static int __schizo_init(struct platform_device *op, unsigned long chip_type) portid = of_getintprop_default(dp, "portid", 0xff); err = -ENOMEM; - pbm = kzalloc(sizeof(*pbm), GFP_KERNEL); + pbm = kzalloc_obj(*pbm, GFP_KERNEL); if (!pbm) { printk(KERN_ERR PFX "Cannot allocate pci_pbm_info.\n"); goto out_err; @@ -1434,7 +1434,7 @@ static int __schizo_init(struct platform_device *op, unsigned long chip_type) pbm->sibling = schizo_find_sibling(portid, chip_type); - iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL); + iommu = kzalloc_obj(struct iommu, GFP_KERNEL); if (!iommu) { printk(KERN_ERR PFX "Cannot allocate PBM A iommu.\n"); goto out_free_pbm; diff --git a/arch/sparc/kernel/pci_sun4v.c b/arch/sparc/kernel/pci_sun4v.c index 791f0a76665f..4e842fb48602 100644 --- a/arch/sparc/kernel/pci_sun4v.c +++ b/arch/sparc/kernel/pci_sun4v.c @@ -754,7 +754,7 @@ static int pci_sun4v_atu_alloc_iotsb(struct pci_pbm_info *pbm) unsigned long order; unsigned long err; - iotsb = kzalloc(sizeof(*iotsb), GFP_KERNEL); + iotsb = kzalloc_obj(*iotsb, GFP_KERNEL); if (!iotsb) { err = -ENOMEM; goto out_err; @@ -1292,13 +1292,13 @@ static int pci_sun4v_probe(struct platform_device *op) iommu_batch_initialized = 1; } - pbm = kzalloc(sizeof(*pbm), GFP_KERNEL); + pbm = kzalloc_obj(*pbm, GFP_KERNEL); if (!pbm) { printk(KERN_ERR PFX "Could not allocate pci_pbm_info\n"); goto out_err; } - iommu = kzalloc(sizeof(struct iommu), GFP_KERNEL); + iommu = kzalloc_obj(struct iommu, GFP_KERNEL); if (!iommu) { printk(KERN_ERR PFX "Could not allocate pbm iommu\n"); goto out_free_controller; @@ -1307,7 +1307,7 @@ static int pci_sun4v_probe(struct platform_device *op) pbm->iommu = iommu; iommu->atu = NULL; if (hv_atu) { - atu = kzalloc(sizeof(*atu), GFP_KERNEL); + atu = kzalloc_obj(*atu, GFP_KERNEL); if (!atu) pr_err(PFX "Could not allocate atu\n"); else diff --git a/arch/sparc/kernel/pcic.c b/arch/sparc/kernel/pcic.c index d7c911724435..4cd32ccc5191 100644 --- a/arch/sparc/kernel/pcic.c +++ b/arch/sparc/kernel/pcic.c @@ -466,7 +466,7 @@ static int pdev_to_pnode(struct linux_pbm_info *pbm, struct pci_dev *pdev) static inline struct pcidev_cookie *pci_devcookie_alloc(void) { - return kmalloc(sizeof(struct pcidev_cookie), GFP_ATOMIC); + return kmalloc_obj(struct pcidev_cookie, GFP_ATOMIC); } static void pcic_map_pci_device(struct linux_pcic *pcic, diff --git a/arch/sparc/kernel/sbus.c b/arch/sparc/kernel/sbus.c index 0bababf6f2bc..bb2794ce7aad 100644 --- a/arch/sparc/kernel/sbus.c +++ b/arch/sparc/kernel/sbus.c @@ -556,8 +556,8 @@ static void __init sbus_iommu_init(struct platform_device *op) } regs = pr->phys_addr; - iommu = kzalloc(sizeof(*iommu), GFP_ATOMIC); - strbuf = kzalloc(sizeof(*strbuf), GFP_ATOMIC); + iommu = kzalloc_obj(*iommu, GFP_ATOMIC); + strbuf = kzalloc_obj(*strbuf, GFP_ATOMIC); if (!iommu || !strbuf) goto fatal_memory_error; diff --git a/arch/sparc/kernel/setup_32.c b/arch/sparc/kernel/setup_32.c index 704375c061e7..46a7b53737d4 100644 --- a/arch/sparc/kernel/setup_32.c +++ b/arch/sparc/kernel/setup_32.c @@ -388,7 +388,7 @@ static int __init topology_init(void) err = 0; for_each_online_cpu(i) { - struct cpu *p = kzalloc(sizeof(*p), GFP_KERNEL); + struct cpu *p = kzalloc_obj(*p, GFP_KERNEL); if (!p) err = -ENOMEM; else diff --git a/arch/sparc/kernel/smp_64.c b/arch/sparc/kernel/smp_64.c index 5cbd6ed5ef6f..81f0be76f48a 100644 --- a/arch/sparc/kernel/smp_64.c +++ b/arch/sparc/kernel/smp_64.c @@ -297,8 +297,8 @@ static void ldom_startcpu_cpuid(unsigned int cpu, unsigned long thread_reg, unsigned long hv_err; int i; - hdesc = kzalloc(struct_size(hdesc, maps, num_kernel_image_mappings), - GFP_KERNEL); + hdesc = kzalloc_flex(*hdesc, maps, num_kernel_image_mappings, + GFP_KERNEL); if (!hdesc) { printk(KERN_ERR "ldom_startcpu_cpuid: Cannot allocate " "hvtramp_descr.\n"); diff --git a/arch/sparc/kernel/starfire.c b/arch/sparc/kernel/starfire.c index b8cd57d9182b..7736dc34f6ad 100644 --- a/arch/sparc/kernel/starfire.c +++ b/arch/sparc/kernel/starfire.c @@ -50,7 +50,7 @@ void starfire_hookup(int upaid) struct starfire_irqinfo *p; unsigned long treg_base, hwmid, i; - p = kmalloc(sizeof(*p), GFP_KERNEL); + p = kmalloc_obj(*p, GFP_KERNEL); if (!p) { prom_printf("starfire_hookup: No memory, this is insane.\n"); prom_halt(); diff --git a/arch/sparc/kernel/sun4d_irq.c b/arch/sparc/kernel/sun4d_irq.c index 9a137c70e8d1..95683ecdc590 100644 --- a/arch/sparc/kernel/sun4d_irq.c +++ b/arch/sparc/kernel/sun4d_irq.c @@ -304,7 +304,7 @@ static unsigned int _sun4d_build_device_irq(unsigned int real_irq, if (unlikely(handler_data)) goto err_out; - handler_data = kzalloc(sizeof(struct sun4d_handler_data), GFP_ATOMIC); + handler_data = kzalloc_obj(struct sun4d_handler_data, GFP_ATOMIC); if (unlikely(!handler_data)) { prom_printf("IRQ: kzalloc(sun4d_handler_data) failed.\n"); prom_halt(); diff --git a/arch/sparc/kernel/sun4m_irq.c b/arch/sparc/kernel/sun4m_irq.c index 1079638986b5..fe8cfb1cdd3a 100644 --- a/arch/sparc/kernel/sun4m_irq.c +++ b/arch/sparc/kernel/sun4m_irq.c @@ -268,7 +268,7 @@ static unsigned int sun4m_build_device_irq(struct platform_device *op, if (unlikely(handler_data)) goto out; - handler_data = kzalloc(sizeof(struct sun4m_handler_data), GFP_ATOMIC); + handler_data = kzalloc_obj(struct sun4m_handler_data, GFP_ATOMIC); if (unlikely(!handler_data)) { prom_printf("IRQ: kzalloc(sun4m_handler_data) failed.\n"); prom_halt(); diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index dbf118b40601..8d5e2d5c0bc5 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c @@ -647,8 +647,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, } if (!current_thread_info()->utraps) { current_thread_info()->utraps = - kcalloc(UT_TRAP_INSTRUCTION_31 + 1, sizeof(long), - GFP_KERNEL); + kzalloc_objs(long, UT_TRAP_INSTRUCTION_31 + 1, + GFP_KERNEL); if (!current_thread_info()->utraps) return -ENOMEM; current_thread_info()->utraps[0] = 1; @@ -658,9 +658,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, unsigned long *p = current_thread_info()->utraps; current_thread_info()->utraps = - kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1, - sizeof(long), - GFP_KERNEL); + kmalloc_objs(long, UT_TRAP_INSTRUCTION_31 + 1, + GFP_KERNEL); if (!current_thread_info()->utraps) { current_thread_info()->utraps = p; return -ENOMEM; diff --git a/arch/sparc/kernel/vio.c b/arch/sparc/kernel/vio.c index 8c7dd72ef334..0d21a8e567da 100644 --- a/arch/sparc/kernel/vio.c +++ b/arch/sparc/kernel/vio.c @@ -325,7 +325,7 @@ static struct vio_dev *vio_create_one(struct mdesc_handle *hp, u64 mp, return NULL; } - vdev = kzalloc(sizeof(*vdev), GFP_KERNEL); + vdev = kzalloc_obj(*vdev, GFP_KERNEL); if (!vdev) { printk(KERN_ERR "VIO: Could not allocate vio_dev\n"); return NULL; diff --git a/arch/sparc/mm/init_64.c b/arch/sparc/mm/init_64.c index 3c3a6607fa51..2c4986e95713 100644 --- a/arch/sparc/mm/init_64.c +++ b/arch/sparc/mm/init_64.c @@ -3070,7 +3070,7 @@ static int __init report_memory(void) kernel_lds_init(); for (i = 0; i < pavail_ents; i++) { - res = kzalloc(sizeof(struct resource), GFP_KERNEL); + res = kzalloc_obj(struct resource, GFP_KERNEL); if (!res) { pr_warn("Failed to allocate source.\n"); diff --git a/arch/sparc/mm/io-unit.c b/arch/sparc/mm/io-unit.c index d409cb450de4..2b5e40cc9d58 100644 --- a/arch/sparc/mm/io-unit.c +++ b/arch/sparc/mm/io-unit.c @@ -44,7 +44,7 @@ static void __init iounit_iommu_init(struct platform_device *op) iopte_t __iomem *xpt; iopte_t __iomem *xptend; - iounit = kzalloc(sizeof(struct iounit_struct), GFP_ATOMIC); + iounit = kzalloc_obj(struct iounit_struct, GFP_ATOMIC); if (!iounit) { prom_printf("SUN4D: Cannot alloc iounit, halting.\n"); prom_halt(); diff --git a/arch/sparc/mm/iommu.c b/arch/sparc/mm/iommu.c index f48adf62724a..3ca7cc2b9bfb 100644 --- a/arch/sparc/mm/iommu.c +++ b/arch/sparc/mm/iommu.c @@ -64,7 +64,7 @@ static void __init sbus_iommu_init(struct platform_device *op) unsigned long base; unsigned long tmp; - iommu = kmalloc(sizeof(struct iommu_struct), GFP_KERNEL); + iommu = kmalloc_obj(struct iommu_struct, GFP_KERNEL); if (!iommu) { prom_printf("Unable to allocate iommu structure\n"); prom_halt(); diff --git a/arch/sparc/net/bpf_jit_comp_64.c b/arch/sparc/net/bpf_jit_comp_64.c index 73bf0aea8baf..884b201259d6 100644 --- a/arch/sparc/net/bpf_jit_comp_64.c +++ b/arch/sparc/net/bpf_jit_comp_64.c @@ -1505,7 +1505,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; diff --git a/arch/sparc/vdso/vma.c b/arch/sparc/vdso/vma.c index bab7a59575e8..bba84959c69d 100644 --- a/arch/sparc/vdso/vma.c +++ b/arch/sparc/vdso/vma.c @@ -266,7 +266,7 @@ static int __init init_vdso_image(const struct vdso_image *image, if (WARN_ON(image->size % PAGE_SIZE != 0)) goto oom; - cpp = kcalloc(cnpages, sizeof(struct page *), GFP_KERNEL); + cpp = kzalloc_objs(struct page *, cnpages, GFP_KERNEL); vdso_mapping->pages = cpp; if (!cpp) @@ -288,7 +288,7 @@ static int __init init_vdso_image(const struct vdso_image *image, dnpages = (sizeof(struct vvar_data) / PAGE_SIZE) + 1; if (WARN_ON(dnpages != 1)) goto oom; - dpp = kcalloc(dnpages, sizeof(struct page *), GFP_KERNEL); + dpp = kzalloc_objs(struct page *, dnpages, GFP_KERNEL); vvar_mapping.pages = dpp; if (!dpp) |
