Skip to content
This repository has been archived by the owner on Jul 3, 2019. It is now read-only.

Commit

Permalink
Merge branch 'overflow' into 8.1.0-unified
Browse files Browse the repository at this point in the history
* overflow:
  BACKPORT: treewide: Use array_size() in vzalloc_node()
  BACKPORT: treewide: Use array_size() in vzalloc()
  BACKPORT: treewide: Use array_size() in vmalloc()
  BACKPORT: treewide: devm_kzalloc() -> devm_kcalloc()
  BACKPORT: treewide: devm_kmalloc() -> devm_kmalloc_array()
  BACKPORT: treewide: kzalloc_node() -> kcalloc_node()
  BACKPORT: treewide: kzalloc() -> kcalloc()
  BACKPORT: treewide: kmalloc() -> kmalloc_array()
  BACKPORT: treewide: Use struct_size() for devm_kmalloc() and friends
  BACKPORT: treewide: Use struct_size() for vmalloc()-family
  BACKPORT: treewide: Use struct_size() for kmalloc()-family
  UPSTREAM: mm: Introduce kvcalloc()
  UPSTREAM: Convert v4l2 event to struct_size
  UPSTREAM: Convert virtio_console to struct_size
  UPSTREAM: device: Use overflow helpers for devm_kmalloc()
  BACKPORT: mm: Use overflow helpers in kvmalloc()
  UPSTREAM: mm: Use overflow helpers in kmalloc_array*()
  UPSTREAM: mm: faster kmalloc_array(), kcalloc()
  UPSTREAM: include/linux/slab.h: add kmalloc_array_node() and kcalloc_node()
  UPSTREAM: overflow.h: Add allocation size calculation helpers
  UPSTREAM: compiler.h: enable builtin overflow checkers and add fallback code

Signed-off-by: Nathan Chancellor <[email protected]>
  • Loading branch information
nathanchance committed Jul 3, 2018
2 parents 11240a6 + c78c03d commit 176b157
Show file tree
Hide file tree
Showing 1,495 changed files with 5,210 additions and 4,110 deletions.
4 changes: 2 additions & 2 deletions arch/arm/kernel/sys_oabi-compat.c
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,
return -EINVAL;
if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
return -EFAULT;
kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
if (!kbuf)
return -ENOMEM;
fs = get_fs();
Expand Down Expand Up @@ -323,7 +323,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
return -EINVAL;
if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
return -EFAULT;
sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL);
sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
if (!sops)
return -ENOMEM;
err = 0;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/kvm/mmu.c
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,8 @@ int kvm_alloc_stage2_pgd(struct kvm *kvm)
* work. This is not used by the hardware and we have no
* alignment requirement for this allocation.
*/
pgd = kmalloc(PTRS_PER_S2_PGD * sizeof(pgd_t),
GFP_KERNEL | __GFP_ZERO);
pgd = kmalloc_array(PTRS_PER_S2_PGD, sizeof(pgd_t),
GFP_KERNEL | __GFP_ZERO);

if (!pgd) {
kvm_free_hwpgd(hwpgd);
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-footbridge/dc21285.c
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
if (nr || !footbridge_cfn_mode())
return 0;

res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
if (!res) {
printk("out of memory for root bus resources");
return 0;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-ixp4xx/common-pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
if (nr >= 1)
return 0;

res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
res = kcalloc(2, sizeof(*res), GFP_KERNEL);
if (res == NULL) {
/*
* If we're out of memory this early, something is wrong,
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap1/mcbsp.c
Original file line number Diff line number Diff line change
Expand Up @@ -389,7 +389,7 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
{
int i;

omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *),
GFP_KERNEL);
if (!omap_mcbsp_devices) {
printk(KERN_ERR "Could not register McBSP devices\n");
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-omap2/hsmmc.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,7 +237,7 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
{
char *hc_name;

hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL);
if (!hc_name) {
pr_err("Cannot allocate memory for controller slot name\n");
kfree(hc_name);
Expand Down
9 changes: 5 additions & 4 deletions arch/arm/mach-omap2/mux.c
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)

hmux->nr_pads = nr_pads;

hmux->pads = kzalloc(sizeof(struct omap_device_pad) *
nr_pads, GFP_KERNEL);
hmux->pads = kcalloc(nr_pads, sizeof(struct omap_device_pad),
GFP_KERNEL);
if (!hmux->pads)
goto err2;

Expand Down Expand Up @@ -323,8 +323,9 @@ omap_hwmod_mux_init(struct omap_device_pad *bpads, int nr_pads)
*/

hmux->nr_pads_dynamic = nr_pads_dynamic;
hmux->pads_dynamic = kzalloc(sizeof(struct omap_device_pad *) *
nr_pads_dynamic, GFP_KERNEL);
hmux->pads_dynamic = kcalloc(nr_pads_dynamic,
sizeof(struct omap_device_pad *),
GFP_KERNEL);
if (!hmux->pads_dynamic) {
pr_err("%s: Could not allocate dynamic pads\n", __func__);
return hmux;
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/omap_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
return -ENODEV;
}

hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL);
if (!hwmods) {
ret = -ENOMEM;
goto odbfd_exit;
Expand Down Expand Up @@ -434,7 +434,7 @@ struct omap_device *omap_device_alloc(struct platform_device *pdev,
}

/* Allocate resources memory to account for new resources */
res = kzalloc(sizeof(struct resource) * res_count, GFP_KERNEL);
res = kcalloc(res_count, sizeof(struct resource), GFP_KERNEL);
if (!res)
goto oda_exit3;

Expand Down
9 changes: 5 additions & 4 deletions arch/arm/mach-omap2/prm_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -289,10 +289,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)

prcm_irq_setup = irq_setup;

prcm_irq_chips = kzalloc(sizeof(void *) * nr_regs, GFP_KERNEL);
prcm_irq_setup->saved_mask = kzalloc(sizeof(u32) * nr_regs, GFP_KERNEL);
prcm_irq_setup->priority_mask = kzalloc(sizeof(u32) * nr_regs,
GFP_KERNEL);
prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL);
prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32),
GFP_KERNEL);
prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32),
GFP_KERNEL);

if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
!prcm_irq_setup->priority_mask) {
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mach-omap2/sr_device.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ static void __init sr_set_nvalues(struct omap_volt_data *volt_data,
while (volt_data[count].volt_nominal)
count++;

nvalue_table = kzalloc(sizeof(struct omap_sr_nvalue_table)*count,
GFP_KERNEL);
nvalue_table = kcalloc(count, sizeof(struct omap_sr_nvalue_table),
GFP_KERNEL);

if (!nvalue_table) {
pr_err("OMAP: SmartReflex: cannot allocate memory for n-value table\n");
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/mach-pxa/pm.c
Original file line number Diff line number Diff line change
Expand Up @@ -104,8 +104,9 @@ static int __init pxa_pm_init(void)
return -EINVAL;
}

sleep_save = kmalloc(pxa_cpu_pm_fns->save_count * sizeof(unsigned long),
GFP_KERNEL);
sleep_save = kmalloc_array(pxa_cpu_pm_fns->save_count,
sizeof(unsigned long),
GFP_KERNEL);
if (!sleep_save) {
printk(KERN_ERR "failed to alloc memory for pm save\n");
return -ENOMEM;
Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mach-vexpress/spc.c
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
uint32_t data = 0, off, ret, idx;
struct ve_spc_opp *opps;

opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL);
if (!opps)
return -ENOMEM;

Expand Down
4 changes: 2 additions & 2 deletions arch/arm/mm/dma-mapping.c
Original file line number Diff line number Diff line change
Expand Up @@ -2200,8 +2200,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)
goto err;

mapping->bitmap_size = bitmap_size;
mapping->bitmaps = kzalloc(extensions * sizeof(unsigned long *),
GFP_KERNEL);
mapping->bitmaps = kcalloc(extensions, sizeof(unsigned long *),
GFP_KERNEL);
if (!mapping->bitmaps)
goto err2;

Expand Down
2 changes: 1 addition & 1 deletion arch/arm/mm/pgd.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#include "mm.h"

#ifdef CONFIG_ARM_LPAE
#define __pgd_alloc() kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL)
#define __pgd_alloc() kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL)
#define __pgd_free(pgd) kfree(pgd)
#else
#define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL | __GFP_REPEAT, 2)
Expand Down
4 changes: 2 additions & 2 deletions arch/arm/net/bpf_jit_32.c
Original file line number Diff line number Diff line change
Expand Up @@ -1001,7 +1001,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
ctx.skf = fp;
ctx.ret0_fp_idx = -1;

ctx.offsets = kzalloc(4 * (ctx.skf->len + 1), GFP_KERNEL);
ctx.offsets = kcalloc(4, (ctx.skf->len + 1), GFP_KERNEL);
if (ctx.offsets == NULL)
return;

Expand All @@ -1020,7 +1020,7 @@ void bpf_jit_compile(struct bpf_prog *fp)

ctx.idx += ctx.imm_count;
if (ctx.imm_count) {
ctx.imms = kzalloc(4 * ctx.imm_count, GFP_KERNEL);
ctx.imms = kcalloc(4, ctx.imm_count, GFP_KERNEL);
if (ctx.imms == NULL)
goto out;
}
Expand Down
5 changes: 3 additions & 2 deletions arch/arm/plat-omap/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -1324,8 +1324,9 @@ static int omap_system_dma_probe(struct platform_device *pdev)


if (dma_omap2plus()) {
dma_linked_lch = kzalloc(sizeof(struct dma_link_info) *
dma_lch_count, GFP_KERNEL);
dma_linked_lch = kcalloc(dma_lch_count,
sizeof(struct dma_link_info),
GFP_KERNEL);
if (!dma_linked_lch) {
ret = -ENOMEM;
goto exit_dma_lch_fail;
Expand Down
7 changes: 4 additions & 3 deletions arch/arm/plat-pxa/dma.c
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,8 @@ static void pxa_dma_init_debugfs(void)
if (!dbgfs_state)
goto err_state;

dbgfs_chan = kmalloc(sizeof(*dbgfs_state) * num_dma_channels,
GFP_KERNEL);
dbgfs_chan = kmalloc_array(num_dma_channels, sizeof(*dbgfs_state),
GFP_KERNEL);
if (!dbgfs_chan)
goto err_alloc;

Expand Down Expand Up @@ -356,7 +356,8 @@ int __init pxa_init_dma(int irq, int num_ch)
{
int i, ret;

dma_channels = kzalloc(sizeof(struct dma_channel) * num_ch, GFP_KERNEL);
dma_channels = kcalloc(num_ch, sizeof(struct dma_channel),
GFP_KERNEL);
if (dma_channels == NULL)
return -ENOMEM;

Expand Down
5 changes: 3 additions & 2 deletions arch/arm/probes/kprobes/test-core.c
Original file line number Diff line number Diff line change
Expand Up @@ -822,8 +822,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args)

static int coverage_start(const union decode_item *table)
{
coverage.base = kmalloc(MAX_COVERAGE_ENTRIES *
sizeof(struct coverage_entry), GFP_KERNEL);
coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
sizeof(struct coverage_entry),
GFP_KERNEL);
coverage.num_entries = 0;
coverage.nesting = 0;
return table_iter(table, coverage_start_fn, &coverage);
Expand Down
4 changes: 2 additions & 2 deletions arch/arm64/kernel/armv8_deprecated.c
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,8 @@ static void __init register_insn_emulation_sysctl(struct ctl_table *table)
struct insn_emulation *insn;
struct ctl_table *insns_sysctl, *sysctl;

insns_sysctl = kzalloc(sizeof(*sysctl) * (nr_insn_emulated + 1),
GFP_KERNEL);
insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
GFP_KERNEL);

raw_spin_lock_irqsave(&insn_emulation_lock, flags);
list_for_each_entry(insn, &insn_emulation, node) {
Expand Down
2 changes: 1 addition & 1 deletion arch/arm64/mm/context.c
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,7 @@ static int asids_init(void)
/* If we end up with more CPUs than ASIDs, expect things to crash */
WARN_ON(NUM_USER_ASIDS < num_possible_cpus());
atomic64_set(&asid_generation, ASID_FIRST_VERSION);
asid_map = kzalloc(BITS_TO_LONGS(NUM_USER_ASIDS) * sizeof(*asid_map),
asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map),
GFP_KERNEL);
if (!asid_map)
panic("Failed to allocate bitmap for %lu ASIDs\n",
Expand Down
3 changes: 1 addition & 2 deletions arch/avr32/kernel/module.c
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,7 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,

/* Allocate room for one syminfo structure per symbol. */
module->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym);
module->arch.syminfo = vmalloc(module->arch.nsyms
* sizeof(struct mod_arch_syminfo));
module->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo), module->arch.nsyms));
if (!module->arch.syminfo)
return -ENOMEM;

Expand Down
2 changes: 1 addition & 1 deletion arch/blackfin/mm/isram-driver.c
Original file line number Diff line number Diff line change
Expand Up @@ -369,7 +369,7 @@ static __init int isram_test_init(void)
pr_info("INFO: testing %#x bytes (%p - %p)\n",
test_len, l1inst, l1inst + test_len);

sdram = kmalloc(test_len * 2, GFP_KERNEL);
sdram = kmalloc_array(test_len, 2, GFP_KERNEL);
if (!sdram) {
sram_free(l1inst);
pr_warning("SKIP: could not allocate sdram\n");
Expand Down
16 changes: 11 additions & 5 deletions arch/cris/arch-v32/drivers/cryptocop.c
Original file line number Diff line number Diff line change
Expand Up @@ -1532,7 +1532,9 @@ int cryptocop_new_session(cryptocop_session_id *sid, struct cryptocop_transform_
return -ENOMEM;
}

sess->tfrm_ctx = kmalloc(no_tfrms * sizeof(struct cryptocop_transform_ctx), alloc_flag);
sess->tfrm_ctx = kmalloc_array(no_tfrms,
sizeof(struct cryptocop_transform_ctx),
alloc_flag);
if (!sess->tfrm_ctx) {
DEBUG_API(printk("cryptocop_new_session, kmalloc cryptocop_transform_ctx\n"));
kfree(sess);
Expand Down Expand Up @@ -2697,7 +2699,7 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
/* Map user pages for in and out data of the operation. */
noinpages = (((unsigned long int)(oper.indata + prev_ix) & ~PAGE_MASK) + oper.inlen - 1 - prev_ix + ~PAGE_MASK) >> PAGE_SHIFT;
DEBUG(printk("cryptocop_ioctl_process: noinpages=%d\n", noinpages));
inpages = kmalloc(noinpages * sizeof(struct page*), GFP_KERNEL);
inpages = kmalloc_array(noinpages, sizeof(struct page *), GFP_KERNEL);
if (!inpages){
DEBUG_API(printk("cryptocop_ioctl_process: kmalloc inpages\n"));
nooutpages = noinpages = 0;
Expand All @@ -2707,7 +2709,8 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig
if (oper.do_cipher){
nooutpages = (((unsigned long int)oper.cipher_outdata & ~PAGE_MASK) + oper.cipher_outlen - 1 + ~PAGE_MASK) >> PAGE_SHIFT;
DEBUG(printk("cryptocop_ioctl_process: nooutpages=%d\n", nooutpages));
outpages = kmalloc(nooutpages * sizeof(struct page*), GFP_KERNEL);
outpages = kmalloc_array(nooutpages, sizeof(struct page *),
GFP_KERNEL);
if (!outpages){
DEBUG_API(printk("cryptocop_ioctl_process: kmalloc outpages\n"));
nooutpages = noinpages = 0;
Expand Down Expand Up @@ -2757,8 +2760,11 @@ static int cryptocop_ioctl_process(struct inode *inode, struct file *filp, unsig

/* Add 6 to nooutpages to make room for possibly inserted buffers for storing digest and
* csum output and splits when units are (dis-)connected. */
cop->tfrm_op.indata = kmalloc((noinpages) * sizeof(struct iovec), GFP_KERNEL);
cop->tfrm_op.outdata = kmalloc((6 + nooutpages) * sizeof(struct iovec), GFP_KERNEL);
cop->tfrm_op.indata = kmalloc_array(noinpages, sizeof(struct iovec),
GFP_KERNEL);
cop->tfrm_op.outdata = kmalloc_array(6 + nooutpages,
sizeof(struct iovec),
GFP_KERNEL);
if (!cop->tfrm_op.indata || !cop->tfrm_op.outdata) {
DEBUG_API(printk("cryptocop_ioctl_process: kmalloc iovecs\n"));
err = -ENOMEM;
Expand Down
3 changes: 2 additions & 1 deletion arch/ia64/kernel/mca_drv.c
Original file line number Diff line number Diff line change
Expand Up @@ -350,7 +350,8 @@ init_record_index_pools(void)
/* - 3 - */
slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
slidx_pool.buffer =
kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
kmalloc_array(slidx_pool.max_idx, sizeof(slidx_list_t),
GFP_KERNEL);

return slidx_pool.buffer ? 0 : -ENOMEM;
}
Expand Down
6 changes: 3 additions & 3 deletions arch/ia64/kernel/topology.c
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ static int __init topology_init(void)
}
#endif

sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
sysfs_cpus = kcalloc(NR_CPUS, sizeof(struct ia64_cpu), GFP_KERNEL);
if (!sysfs_cpus)
panic("kzalloc in topology_init failed - NR_CPUS too big?");

Expand Down Expand Up @@ -319,8 +319,8 @@ static int cpu_cache_sysfs_init(unsigned int cpu)
return -1;
}

this_cache=kzalloc(sizeof(struct cache_info)*unique_caches,
GFP_KERNEL);
this_cache=kcalloc(unique_caches, sizeof(struct cache_info),
GFP_KERNEL);
if (this_cache == NULL)
return -ENOMEM;

Expand Down
5 changes: 3 additions & 2 deletions arch/ia64/mm/tlb.c
Original file line number Diff line number Diff line change
Expand Up @@ -430,8 +430,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size)
int cpu = smp_processor_id();

if (!ia64_idtrs[cpu]) {
ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
sizeof (struct ia64_tr_entry), GFP_KERNEL);
ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
sizeof(struct ia64_tr_entry),
GFP_KERNEL);
if (!ia64_idtrs[cpu])
return -ENOMEM;
}
Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/kernel/io_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
printk_once(KERN_WARNING
"PROM version < 4.50 -- implementing old PROM flush WAR\n");

war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
war_list = kcalloc(DEV_PER_WIDGET, sizeof(*war_list), GFP_KERNEL);
BUG_ON(!war_list);

SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
Expand Down
3 changes: 2 additions & 1 deletion arch/ia64/sn/kernel/irq.c
Original file line number Diff line number Diff line change
Expand Up @@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void)
{
int i;

sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL);
sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(struct list_head *),
GFP_KERNEL);
if (!sn_irq_lh)
panic("SN PCI INIT: Failed to allocate memory for PCI init\n");

Expand Down
2 changes: 1 addition & 1 deletion arch/ia64/sn/pci/pcibr/pcibr_provider.c
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
/* Setup the PMU ATE map */
soft->pbi_int_ate_resource.lowest_free_index = 0;
soft->pbi_int_ate_resource.ate =
kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL);
kcalloc(soft->pbi_int_ate_size, sizeof(u64), GFP_KERNEL);

if (!soft->pbi_int_ate_resource.ate) {
kfree(soft);
Expand Down
2 changes: 1 addition & 1 deletion arch/mips/alchemy/common/clock.c
Original file line number Diff line number Diff line change
Expand Up @@ -984,7 +984,7 @@ static int __init alchemy_clk_setup_imux(int ctype)
return -ENODEV;
}

a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL);
a = kcalloc(6, sizeof(*a), GFP_KERNEL);
if (!a)
return -ENOMEM;

Expand Down
Loading

0 comments on commit 176b157

Please sign in to comment.