diff options
1201 files changed, 3586 insertions, 2796 deletions
diff --git a/arch/arm/kernel/sys_oabi-compat.c b/arch/arm/kernel/sys_oabi-compat.c index b9786f491873..1df21a61e379 100644 --- a/arch/arm/kernel/sys_oabi-compat.c +++ b/arch/arm/kernel/sys_oabi-compat.c | |||
| @@ -286,7 +286,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd, | |||
| 286 | return -EINVAL; | 286 | return -EINVAL; |
| 287 | if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents)) | 287 | if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents)) |
| 288 | return -EFAULT; | 288 | return -EFAULT; |
| 289 | kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL); | 289 | kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL); |
| 290 | if (!kbuf) | 290 | if (!kbuf) |
| 291 | return -ENOMEM; | 291 | return -ENOMEM; |
| 292 | fs = get_fs(); | 292 | fs = get_fs(); |
| @@ -324,7 +324,7 @@ asmlinkage long sys_oabi_semtimedop(int semid, | |||
| 324 | return -EINVAL; | 324 | return -EINVAL; |
| 325 | if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops)) | 325 | if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops)) |
| 326 | return -EFAULT; | 326 | return -EFAULT; |
| 327 | sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL); | 327 | sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL); |
| 328 | if (!sops) | 328 | if (!sops) |
| 329 | return -ENOMEM; | 329 | return -ENOMEM; |
| 330 | err = 0; | 330 | err = 0; |
diff --git a/arch/arm/mach-footbridge/dc21285.c b/arch/arm/mach-footbridge/dc21285.c index e7b350f18f5f..16d71bac0061 100644 --- a/arch/arm/mach-footbridge/dc21285.c +++ b/arch/arm/mach-footbridge/dc21285.c | |||
| @@ -252,7 +252,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys) | |||
| 252 | if (nr || !footbridge_cfn_mode()) | 252 | if (nr || !footbridge_cfn_mode()) |
| 253 | return 0; | 253 | return 0; |
| 254 | 254 | ||
| 255 | res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); | 255 | res = kcalloc(2, sizeof(struct resource), GFP_KERNEL); |
| 256 | if (!res) { | 256 | if (!res) { |
| 257 | printk("out of memory for root bus resources"); | 257 | printk("out of memory for root bus resources"); |
| 258 | return 0; | 258 | return 0; |
diff --git a/arch/arm/mach-ixp4xx/common-pci.c b/arch/arm/mach-ixp4xx/common-pci.c index bcf3df59f71b..6835b17113e5 100644 --- a/arch/arm/mach-ixp4xx/common-pci.c +++ b/arch/arm/mach-ixp4xx/common-pci.c | |||
| @@ -421,7 +421,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys) | |||
| 421 | if (nr >= 1) | 421 | if (nr >= 1) |
| 422 | return 0; | 422 | return 0; |
| 423 | 423 | ||
| 424 | res = kzalloc(sizeof(*res) * 2, GFP_KERNEL); | 424 | res = kcalloc(2, sizeof(*res), GFP_KERNEL); |
| 425 | if (res == NULL) { | 425 | if (res == NULL) { |
| 426 | /* | 426 | /* |
| 427 | * If we're out of memory this early, something is wrong, | 427 | * If we're out of memory this early, something is wrong, |
diff --git a/arch/arm/mach-omap1/mcbsp.c b/arch/arm/mach-omap1/mcbsp.c index 8ed67f8d1762..27e22e702f96 100644 --- a/arch/arm/mach-omap1/mcbsp.c +++ b/arch/arm/mach-omap1/mcbsp.c | |||
| @@ -389,7 +389,7 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count, | |||
| 389 | { | 389 | { |
| 390 | int i; | 390 | int i; |
| 391 | 391 | ||
| 392 | omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *), | 392 | omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *), |
| 393 | GFP_KERNEL); | 393 | GFP_KERNEL); |
| 394 | if (!omap_mcbsp_devices) { | 394 | if (!omap_mcbsp_devices) { |
| 395 | printk(KERN_ERR "Could not register McBSP devices\n"); | 395 | printk(KERN_ERR "Could not register McBSP devices\n"); |
diff --git a/arch/arm/mach-omap2/hsmmc.c b/arch/arm/mach-omap2/hsmmc.c index 0103548b0b15..af545193f673 100644 --- a/arch/arm/mach-omap2/hsmmc.c +++ b/arch/arm/mach-omap2/hsmmc.c | |||
| @@ -34,7 +34,7 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c, | |||
| 34 | { | 34 | { |
| 35 | char *hc_name; | 35 | char *hc_name; |
| 36 | 36 | ||
| 37 | hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL); | 37 | hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL); |
| 38 | if (!hc_name) { | 38 | if (!hc_name) { |
| 39 | kfree(hc_name); | 39 | kfree(hc_name); |
| 40 | return -ENOMEM; | 40 | return -ENOMEM; |
diff --git a/arch/arm/mach-omap2/omap_device.c b/arch/arm/mach-omap2/omap_device.c index ac219b9e6a4c..41c7b905980a 100644 --- a/arch/arm/mach-omap2/omap_device.c +++ b/arch/arm/mach-omap2/omap_device.c | |||
| @@ -162,7 +162,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev) | |||
| 162 | !omap_hwmod_parse_module_range(NULL, node, &res)) | 162 | !omap_hwmod_parse_module_range(NULL, node, &res)) |
| 163 | return -ENODEV; | 163 | return -ENODEV; |
| 164 | 164 | ||
| 165 | hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL); | 165 | hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL); |
| 166 | if (!hwmods) { | 166 | if (!hwmods) { |
| 167 | ret = -ENOMEM; | 167 | ret = -ENOMEM; |
| 168 | goto odbfd_exit; | 168 | goto odbfd_exit; |
| @@ -413,7 +413,7 @@ omap_device_copy_resources(struct omap_hwmod *oh, | |||
| 413 | goto error; | 413 | goto error; |
| 414 | } | 414 | } |
| 415 | 415 | ||
| 416 | res = kzalloc(sizeof(*res) * 2, GFP_KERNEL); | 416 | res = kcalloc(2, sizeof(*res), GFP_KERNEL); |
| 417 | if (!res) | 417 | if (!res) |
| 418 | return -ENOMEM; | 418 | return -ENOMEM; |
| 419 | 419 | ||
diff --git a/arch/arm/mach-omap2/prm_common.c b/arch/arm/mach-omap2/prm_common.c index 021b5a8b9c0a..058a37e6d11c 100644 --- a/arch/arm/mach-omap2/prm_common.c +++ b/arch/arm/mach-omap2/prm_common.c | |||
| @@ -285,10 +285,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup) | |||
| 285 | 285 | ||
| 286 | prcm_irq_setup = irq_setup; | 286 | prcm_irq_setup = irq_setup; |
| 287 | 287 | ||
| 288 | prcm_irq_chips = kzalloc(sizeof(void *) * nr_regs, GFP_KERNEL); | 288 | prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL); |
| 289 | prcm_irq_setup->saved_mask = kzalloc(sizeof(u32) * nr_regs, GFP_KERNEL); | 289 | prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32), |
| 290 | prcm_irq_setup->priority_mask = kzalloc(sizeof(u32) * nr_regs, | 290 | GFP_KERNEL); |
| 291 | GFP_KERNEL); | 291 | prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32), |
| 292 | GFP_KERNEL); | ||
| 292 | 293 | ||
| 293 | if (!prcm_irq_chips || !prcm_irq_setup->saved_mask || | 294 | if (!prcm_irq_chips || !prcm_irq_setup->saved_mask || |
| 294 | !prcm_irq_setup->priority_mask) | 295 | !prcm_irq_setup->priority_mask) |
diff --git a/arch/arm/mach-vexpress/spc.c b/arch/arm/mach-vexpress/spc.c index 21c064267af5..0f5381d13494 100644 --- a/arch/arm/mach-vexpress/spc.c +++ b/arch/arm/mach-vexpress/spc.c | |||
| @@ -403,7 +403,7 @@ static int ve_spc_populate_opps(uint32_t cluster) | |||
| 403 | uint32_t data = 0, off, ret, idx; | 403 | uint32_t data = 0, off, ret, idx; |
| 404 | struct ve_spc_opp *opps; | 404 | struct ve_spc_opp *opps; |
| 405 | 405 | ||
| 406 | opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL); | 406 | opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL); |
| 407 | if (!opps) | 407 | if (!opps) |
| 408 | return -ENOMEM; | 408 | return -ENOMEM; |
| 409 | 409 | ||
diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index af27f1c22d93..be0fa7e39c26 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c | |||
| @@ -2162,8 +2162,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size) | |||
| 2162 | goto err; | 2162 | goto err; |
| 2163 | 2163 | ||
| 2164 | mapping->bitmap_size = bitmap_size; | 2164 | mapping->bitmap_size = bitmap_size; |
| 2165 | mapping->bitmaps = kzalloc(extensions * sizeof(unsigned long *), | 2165 | mapping->bitmaps = kcalloc(extensions, sizeof(unsigned long *), |
| 2166 | GFP_KERNEL); | 2166 | GFP_KERNEL); |
| 2167 | if (!mapping->bitmaps) | 2167 | if (!mapping->bitmaps) |
| 2168 | goto err2; | 2168 | goto err2; |
| 2169 | 2169 | ||
diff --git a/arch/arm/mm/pgd.c b/arch/arm/mm/pgd.c index 61e281cb29fb..a1606d950251 100644 --- a/arch/arm/mm/pgd.c +++ b/arch/arm/mm/pgd.c | |||
| @@ -20,7 +20,7 @@ | |||
| 20 | #include "mm.h" | 20 | #include "mm.h" |
| 21 | 21 | ||
| 22 | #ifdef CONFIG_ARM_LPAE | 22 | #ifdef CONFIG_ARM_LPAE |
| 23 | #define __pgd_alloc() kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL) | 23 | #define __pgd_alloc() kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL) |
| 24 | #define __pgd_free(pgd) kfree(pgd) | 24 | #define __pgd_free(pgd) kfree(pgd) |
| 25 | #else | 25 | #else |
| 26 | #define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL, 2) | 26 | #define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL, 2) |
diff --git a/arch/arm/probes/kprobes/test-core.c b/arch/arm/probes/kprobes/test-core.c index 9ed0129bed3c..14db14152909 100644 --- a/arch/arm/probes/kprobes/test-core.c +++ b/arch/arm/probes/kprobes/test-core.c | |||
| @@ -766,8 +766,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args) | |||
| 766 | 766 | ||
| 767 | static int coverage_start(const union decode_item *table) | 767 | static int coverage_start(const union decode_item *table) |
| 768 | { | 768 | { |
| 769 | coverage.base = kmalloc(MAX_COVERAGE_ENTRIES * | 769 | coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES, |
| 770 | sizeof(struct coverage_entry), GFP_KERNEL); | 770 | sizeof(struct coverage_entry), |
| 771 | GFP_KERNEL); | ||
| 771 | coverage.num_entries = 0; | 772 | coverage.num_entries = 0; |
| 772 | coverage.nesting = 0; | 773 | coverage.nesting = 0; |
| 773 | return table_iter(table, coverage_start_fn, &coverage); | 774 | return table_iter(table, coverage_start_fn, &coverage); |
diff --git a/arch/arm64/kernel/armv8_deprecated.c b/arch/arm64/kernel/armv8_deprecated.c index 97d45d5151d4..d4707abb2f16 100644 --- a/arch/arm64/kernel/armv8_deprecated.c +++ b/arch/arm64/kernel/armv8_deprecated.c | |||
| @@ -234,8 +234,8 @@ static void __init register_insn_emulation_sysctl(void) | |||
| 234 | struct insn_emulation *insn; | 234 | struct insn_emulation *insn; |
| 235 | struct ctl_table *insns_sysctl, *sysctl; | 235 | struct ctl_table *insns_sysctl, *sysctl; |
| 236 | 236 | ||
| 237 | insns_sysctl = kzalloc(sizeof(*sysctl) * (nr_insn_emulated + 1), | 237 | insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl), |
| 238 | GFP_KERNEL); | 238 | GFP_KERNEL); |
| 239 | 239 | ||
| 240 | raw_spin_lock_irqsave(&insn_emulation_lock, flags); | 240 | raw_spin_lock_irqsave(&insn_emulation_lock, flags); |
| 241 | list_for_each_entry(insn, &insn_emulation, node) { | 241 | list_for_each_entry(insn, &insn_emulation, node) { |
diff --git a/arch/arm64/mm/context.c b/arch/arm64/mm/context.c index 301417ae2ba8..c127f94da8e2 100644 --- a/arch/arm64/mm/context.c +++ b/arch/arm64/mm/context.c | |||
| @@ -263,7 +263,7 @@ static int asids_init(void) | |||
| 263 | */ | 263 | */ |
| 264 | WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus()); | 264 | WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus()); |
| 265 | atomic64_set(&asid_generation, ASID_FIRST_VERSION); | 265 | atomic64_set(&asid_generation, ASID_FIRST_VERSION); |
| 266 | asid_map = kzalloc(BITS_TO_LONGS(NUM_USER_ASIDS) * sizeof(*asid_map), | 266 | asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map), |
| 267 | GFP_KERNEL); | 267 | GFP_KERNEL); |
| 268 | if (!asid_map) | 268 | if (!asid_map) |
| 269 | panic("Failed to allocate bitmap for %lu ASIDs\n", | 269 | panic("Failed to allocate bitmap for %lu ASIDs\n", |
diff --git a/arch/ia64/kernel/mca_drv.c b/arch/ia64/kernel/mca_drv.c index 94f8bf777afa..dfe40cbdf3b3 100644 --- a/arch/ia64/kernel/mca_drv.c +++ b/arch/ia64/kernel/mca_drv.c | |||
| @@ -350,7 +350,8 @@ init_record_index_pools(void) | |||
| 350 | /* - 3 - */ | 350 | /* - 3 - */ |
| 351 | slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1; | 351 | slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1; |
| 352 | slidx_pool.buffer = | 352 | slidx_pool.buffer = |
| 353 | kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL); | 353 | kmalloc_array(slidx_pool.max_idx, sizeof(slidx_list_t), |
| 354 | GFP_KERNEL); | ||
| 354 | 355 | ||
| 355 | return slidx_pool.buffer ? 0 : -ENOMEM; | 356 | return slidx_pool.buffer ? 0 : -ENOMEM; |
| 356 | } | 357 | } |
diff --git a/arch/ia64/kernel/topology.c b/arch/ia64/kernel/topology.c index d76529cbff20..9b820f7a6a98 100644 --- a/arch/ia64/kernel/topology.c +++ b/arch/ia64/kernel/topology.c | |||
| @@ -85,7 +85,7 @@ static int __init topology_init(void) | |||
| 85 | } | 85 | } |
| 86 | #endif | 86 | #endif |
| 87 | 87 | ||
| 88 | sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL); | 88 | sysfs_cpus = kcalloc(NR_CPUS, sizeof(struct ia64_cpu), GFP_KERNEL); |
| 89 | if (!sysfs_cpus) | 89 | if (!sysfs_cpus) |
| 90 | panic("kzalloc in topology_init failed - NR_CPUS too big?"); | 90 | panic("kzalloc in topology_init failed - NR_CPUS too big?"); |
| 91 | 91 | ||
| @@ -319,8 +319,8 @@ static int cpu_cache_sysfs_init(unsigned int cpu) | |||
| 319 | return -1; | 319 | return -1; |
| 320 | } | 320 | } |
| 321 | 321 | ||
| 322 | this_cache=kzalloc(sizeof(struct cache_info)*unique_caches, | 322 | this_cache=kcalloc(unique_caches, sizeof(struct cache_info), |
| 323 | GFP_KERNEL); | 323 | GFP_KERNEL); |
| 324 | if (this_cache == NULL) | 324 | if (this_cache == NULL) |
| 325 | return -ENOMEM; | 325 | return -ENOMEM; |
| 326 | 326 | ||
diff --git a/arch/ia64/mm/tlb.c b/arch/ia64/mm/tlb.c index 46ecc5d948aa..acf10eb9da15 100644 --- a/arch/ia64/mm/tlb.c +++ b/arch/ia64/mm/tlb.c | |||
| @@ -430,8 +430,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size) | |||
| 430 | int cpu = smp_processor_id(); | 430 | int cpu = smp_processor_id(); |
| 431 | 431 | ||
| 432 | if (!ia64_idtrs[cpu]) { | 432 | if (!ia64_idtrs[cpu]) { |
| 433 | ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX * | 433 | ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX, |
| 434 | sizeof (struct ia64_tr_entry), GFP_KERNEL); | 434 | sizeof(struct ia64_tr_entry), |
| 435 | GFP_KERNEL); | ||
| 435 | if (!ia64_idtrs[cpu]) | 436 | if (!ia64_idtrs[cpu]) |
| 436 | return -ENOMEM; | 437 | return -ENOMEM; |
| 437 | } | 438 | } |
diff --git a/arch/ia64/sn/kernel/io_common.c b/arch/ia64/sn/kernel/io_common.c index 8479e9a7ce16..102aabad6d20 100644 --- a/arch/ia64/sn/kernel/io_common.c +++ b/arch/ia64/sn/kernel/io_common.c | |||
| @@ -132,7 +132,7 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, | |||
| 132 | printk_once(KERN_WARNING | 132 | printk_once(KERN_WARNING |
| 133 | "PROM version < 4.50 -- implementing old PROM flush WAR\n"); | 133 | "PROM version < 4.50 -- implementing old PROM flush WAR\n"); |
| 134 | 134 | ||
| 135 | war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL); | 135 | war_list = kcalloc(DEV_PER_WIDGET, sizeof(*war_list), GFP_KERNEL); |
| 136 | BUG_ON(!war_list); | 136 | BUG_ON(!war_list); |
| 137 | 137 | ||
| 138 | SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST, | 138 | SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST, |
diff --git a/arch/ia64/sn/kernel/irq.c b/arch/ia64/sn/kernel/irq.c index 85d095154902..d9b576df4f82 100644 --- a/arch/ia64/sn/kernel/irq.c +++ b/arch/ia64/sn/kernel/irq.c | |||
| @@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void) | |||
| 474 | { | 474 | { |
| 475 | int i; | 475 | int i; |
| 476 | 476 | ||
| 477 | sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL); | 477 | sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(struct list_head *), |
| 478 | GFP_KERNEL); | ||
| 478 | if (!sn_irq_lh) | 479 | if (!sn_irq_lh) |
| 479 | panic("SN PCI INIT: Failed to allocate memory for PCI init\n"); | 480 | panic("SN PCI INIT: Failed to allocate memory for PCI init\n"); |
| 480 | 481 | ||
diff --git a/arch/ia64/sn/pci/pcibr/pcibr_provider.c b/arch/ia64/sn/pci/pcibr/pcibr_provider.c index 8dbbef4a4f47..7195df1da121 100644 --- a/arch/ia64/sn/pci/pcibr/pcibr_provider.c +++ b/arch/ia64/sn/pci/pcibr/pcibr_provider.c | |||
| @@ -184,7 +184,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont | |||
| 184 | /* Setup the PMU ATE map */ | 184 | /* Setup the PMU ATE map */ |
| 185 | soft->pbi_int_ate_resource.lowest_free_index = 0; | 185 | soft->pbi_int_ate_resource.lowest_free_index = 0; |
| 186 | soft->pbi_int_ate_resource.ate = | 186 | soft->pbi_int_ate_resource.ate = |
| 187 | kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL); | 187 | kcalloc(soft->pbi_int_ate_size, sizeof(u64), GFP_KERNEL); |
| 188 | 188 | ||
| 189 | if (!soft->pbi_int_ate_resource.ate) { | 189 | if (!soft->pbi_int_ate_resource.ate) { |
| 190 | kfree(soft); | 190 | kfree(soft); |
diff --git a/arch/mips/alchemy/common/clock.c b/arch/mips/alchemy/common/clock.c index 6b6f6851df92..d129475fd40d 100644 --- a/arch/mips/alchemy/common/clock.c +++ b/arch/mips/alchemy/common/clock.c | |||
| @@ -985,7 +985,7 @@ static int __init alchemy_clk_setup_imux(int ctype) | |||
| 985 | return -ENODEV; | 985 | return -ENODEV; |
| 986 | } | 986 | } |
| 987 | 987 | ||
| 988 | a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL); | 988 | a = kcalloc(6, sizeof(*a), GFP_KERNEL); |
| 989 | if (!a) | 989 | if (!a) |
| 990 | return -ENOMEM; | 990 | return -ENOMEM; |
| 991 | 991 | ||
diff --git a/arch/mips/alchemy/common/dbdma.c b/arch/mips/alchemy/common/dbdma.c index fc482d900ddd..4ca2c28878e0 100644 --- a/arch/mips/alchemy/common/dbdma.c +++ b/arch/mips/alchemy/common/dbdma.c | |||
| @@ -411,8 +411,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries) | |||
| 411 | * and if we try that first we are likely to not waste larger | 411 | * and if we try that first we are likely to not waste larger |
| 412 | * slabs of memory. | 412 | * slabs of memory. |
| 413 | */ | 413 | */ |
| 414 | desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t), | 414 | desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t), |
| 415 | GFP_KERNEL|GFP_DMA); | 415 | GFP_KERNEL|GFP_DMA); |
| 416 | if (desc_base == 0) | 416 | if (desc_base == 0) |
| 417 | return 0; | 417 | return 0; |
| 418 | 418 | ||
| @@ -1050,7 +1050,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable) | |||
| 1050 | { | 1050 | { |
| 1051 | int ret; | 1051 | int ret; |
| 1052 | 1052 | ||
| 1053 | dbdev_tab = kzalloc(sizeof(dbdev_tab_t) * DBDEV_TAB_SIZE, GFP_KERNEL); | 1053 | dbdev_tab = kcalloc(DBDEV_TAB_SIZE, sizeof(dbdev_tab_t), GFP_KERNEL); |
| 1054 | if (!dbdev_tab) | 1054 | if (!dbdev_tab) |
| 1055 | return -ENOMEM; | 1055 | return -ENOMEM; |
| 1056 | 1056 | ||
diff --git a/arch/mips/alchemy/common/platform.c b/arch/mips/alchemy/common/platform.c index d77a64f4c78b..1454d9f6ab2d 100644 --- a/arch/mips/alchemy/common/platform.c +++ b/arch/mips/alchemy/common/platform.c | |||
| @@ -115,7 +115,7 @@ static void __init alchemy_setup_uarts(int ctype) | |||
| 115 | uartclk = clk_get_rate(clk); | 115 | uartclk = clk_get_rate(clk); |
| 116 | clk_put(clk); | 116 | clk_put(clk); |
| 117 | 117 | ||
| 118 | ports = kzalloc(s * (c + 1), GFP_KERNEL); | 118 | ports = kcalloc(s, (c + 1), GFP_KERNEL); |
| 119 | if (!ports) { | 119 | if (!ports) { |
| 120 | printk(KERN_INFO "Alchemy: no memory for UART data\n"); | 120 | printk(KERN_INFO "Alchemy: no memory for UART data\n"); |
| 121 | return; | 121 | return; |
| @@ -198,7 +198,7 @@ static unsigned long alchemy_ehci_data[][2] __initdata = { | |||
| 198 | 198 | ||
| 199 | static int __init _new_usbres(struct resource **r, struct platform_device **d) | 199 | static int __init _new_usbres(struct resource **r, struct platform_device **d) |
| 200 | { | 200 | { |
| 201 | *r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL); | 201 | *r = kcalloc(2, sizeof(struct resource), GFP_KERNEL); |
| 202 | if (!*r) | 202 | if (!*r) |
| 203 | return -ENOMEM; | 203 | return -ENOMEM; |
| 204 | *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL); | 204 | *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL); |
diff --git a/arch/mips/alchemy/devboards/platform.c b/arch/mips/alchemy/devboards/platform.c index 4640edab207c..203854ddd1bb 100644 --- a/arch/mips/alchemy/devboards/platform.c +++ b/arch/mips/alchemy/devboards/platform.c | |||
| @@ -103,7 +103,7 @@ int __init db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start, | |||
| 103 | if (stschg_irq) | 103 | if (stschg_irq) |
| 104 | cnt++; | 104 | cnt++; |
| 105 | 105 | ||
| 106 | sr = kzalloc(sizeof(struct resource) * cnt, GFP_KERNEL); | 106 | sr = kcalloc(cnt, sizeof(struct resource), GFP_KERNEL); |
| 107 | if (!sr) | 107 | if (!sr) |
| 108 | return -ENOMEM; | 108 | return -ENOMEM; |
| 109 | 109 | ||
| @@ -178,7 +178,7 @@ int __init db1x_register_norflash(unsigned long size, int width, | |||
| 178 | return -EINVAL; | 178 | return -EINVAL; |
| 179 | 179 | ||
| 180 | ret = -ENOMEM; | 180 | ret = -ENOMEM; |
| 181 | parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL); | 181 | parts = kcalloc(5, sizeof(struct mtd_partition), GFP_KERNEL); |
| 182 | if (!parts) | 182 | if (!parts) |
| 183 | goto out; | 183 | goto out; |
| 184 | 184 | ||
diff --git a/arch/mips/bmips/dma.c b/arch/mips/bmips/dma.c index 04790f4e1805..6dec30842b2f 100644 --- a/arch/mips/bmips/dma.c +++ b/arch/mips/bmips/dma.c | |||
| @@ -94,7 +94,7 @@ static int __init bmips_init_dma_ranges(void) | |||
| 94 | goto out_bad; | 94 | goto out_bad; |
| 95 | 95 | ||
| 96 | /* add a dummy (zero) entry at the end as a sentinel */ | 96 | /* add a dummy (zero) entry at the end as a sentinel */ |
| 97 | bmips_dma_ranges = kzalloc(sizeof(struct bmips_dma_range) * (len + 1), | 97 | bmips_dma_ranges = kcalloc(len + 1, sizeof(struct bmips_dma_range), |
| 98 | GFP_KERNEL); | 98 | GFP_KERNEL); |
| 99 | if (!bmips_dma_ranges) | 99 | if (!bmips_dma_ranges) |
| 100 | goto out_bad; | 100 | goto out_bad; |
diff --git a/arch/mips/txx9/rbtx4939/setup.c b/arch/mips/txx9/rbtx4939/setup.c index fd26fadc8617..ef29a9c2ffd6 100644 --- a/arch/mips/txx9/rbtx4939/setup.c +++ b/arch/mips/txx9/rbtx4939/setup.c | |||
| @@ -219,7 +219,7 @@ static int __init rbtx4939_led_probe(struct platform_device *pdev) | |||
| 219 | "nand-disk", | 219 | "nand-disk", |
| 220 | }; | 220 | }; |
| 221 | 221 | ||
| 222 | leds_data = kzalloc(sizeof(*leds_data) * RBTX4939_MAX_7SEGLEDS, | 222 | leds_data = kcalloc(RBTX4939_MAX_7SEGLEDS, sizeof(*leds_data), |
| 223 | GFP_KERNEL); | 223 | GFP_KERNEL); |
| 224 | if (!leds_data) | 224 | if (!leds_data) |
| 225 | return -ENOMEM; | 225 | return -ENOMEM; |
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c index f915db93cd42..44d66c33d59d 100644 --- a/arch/powerpc/kernel/rtasd.c +++ b/arch/powerpc/kernel/rtasd.c | |||
| @@ -559,7 +559,8 @@ static int __init rtas_event_scan_init(void) | |||
| 559 | rtas_error_log_max = rtas_get_error_log_max(); | 559 | rtas_error_log_max = rtas_get_error_log_max(); |
| 560 | rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int); | 560 | rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int); |
| 561 | 561 | ||
| 562 | rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER); | 562 | rtas_log_buf = vmalloc(array_size(LOG_NUMBER, |
| 563 | rtas_error_log_buffer_max)); | ||
| 563 | if (!rtas_log_buf) { | 564 | if (!rtas_log_buf) { |
| 564 | printk(KERN_ERR "rtasd: no memory\n"); | 565 | printk(KERN_ERR "rtasd: no memory\n"); |
| 565 | return -ENOMEM; | 566 | return -ENOMEM; |
diff --git a/arch/powerpc/kernel/vdso.c b/arch/powerpc/kernel/vdso.c index b44ec104a5a1..d2205b97628c 100644 --- a/arch/powerpc/kernel/vdso.c +++ b/arch/powerpc/kernel/vdso.c | |||
| @@ -791,7 +791,7 @@ static int __init vdso_init(void) | |||
| 791 | 791 | ||
| 792 | #ifdef CONFIG_VDSO32 | 792 | #ifdef CONFIG_VDSO32 |
| 793 | /* Make sure pages are in the correct state */ | 793 | /* Make sure pages are in the correct state */ |
| 794 | vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2), | 794 | vdso32_pagelist = kcalloc(vdso32_pages + 2, sizeof(struct page *), |
| 795 | GFP_KERNEL); | 795 | GFP_KERNEL); |
| 796 | BUG_ON(vdso32_pagelist == NULL); | 796 | BUG_ON(vdso32_pagelist == NULL); |
| 797 | for (i = 0; i < vdso32_pages; i++) { | 797 | for (i = 0; i < vdso32_pages; i++) { |
| @@ -805,7 +805,7 @@ static int __init vdso_init(void) | |||
| 805 | #endif | 805 | #endif |
| 806 | 806 | ||
| 807 | #ifdef CONFIG_PPC64 | 807 | #ifdef CONFIG_PPC64 |
| 808 | vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2), | 808 | vdso64_pagelist = kcalloc(vdso64_pages + 2, sizeof(struct page *), |
| 809 | GFP_KERNEL); | 809 | GFP_KERNEL); |
| 810 | BUG_ON(vdso64_pagelist == NULL); | 810 | BUG_ON(vdso64_pagelist == NULL); |
| 811 | for (i = 0; i < vdso64_pages; i++) { | 811 | for (i = 0; i < vdso64_pages; i++) { |
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c index a670fa5fbe50..1b3fcafc685e 100644 --- a/arch/powerpc/kvm/book3s_64_mmu_hv.c +++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c | |||
| @@ -108,7 +108,7 @@ int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order) | |||
| 108 | npte = 1ul << (order - 4); | 108 | npte = 1ul << (order - 4); |
| 109 | 109 | ||
| 110 | /* Allocate reverse map array */ | 110 | /* Allocate reverse map array */ |
| 111 | rev = vmalloc(sizeof(struct revmap_entry) * npte); | 111 | rev = vmalloc(array_size(npte, sizeof(struct revmap_entry))); |
| 112 | if (!rev) { | 112 | if (!rev) { |
| 113 | if (cma) | 113 | if (cma) |
| 114 | kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT)); | 114 | kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT)); |
diff --git a/arch/powerpc/kvm/book3s_hv.c b/arch/powerpc/kvm/book3s_hv.c index 69895597736a..8858ab8b6ca4 100644 --- a/arch/powerpc/kvm/book3s_hv.c +++ b/arch/powerpc/kvm/book3s_hv.c | |||
| @@ -3548,7 +3548,7 @@ static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free, | |||
| 3548 | static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot, | 3548 | static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot, |
| 3549 | unsigned long npages) | 3549 | unsigned long npages) |
| 3550 | { | 3550 | { |
| 3551 | slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap)); | 3551 | slot->arch.rmap = vzalloc(array_size(npages, sizeof(*slot->arch.rmap))); |
| 3552 | if (!slot->arch.rmap) | 3552 | if (!slot->arch.rmap) |
| 3553 | return -ENOMEM; | 3553 | return -ENOMEM; |
| 3554 | 3554 | ||
diff --git a/arch/powerpc/lib/rheap.c b/arch/powerpc/lib/rheap.c index 94058c21a482..6aa774aa5b16 100644 --- a/arch/powerpc/lib/rheap.c +++ b/arch/powerpc/lib/rheap.c | |||
| @@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks) | |||
| 54 | 54 | ||
| 55 | new_blocks = max_blocks - info->max_blocks; | 55 | new_blocks = max_blocks - info->max_blocks; |
| 56 | 56 | ||
| 57 | block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC); | 57 | block = kmalloc_array(max_blocks, sizeof(rh_block_t), GFP_ATOMIC); |
| 58 | if (block == NULL) | 58 | if (block == NULL) |
| 59 | return -ENOMEM; | 59 | return -ENOMEM; |
| 60 | 60 | ||
diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c index 4c615fcb0cf0..abb43646927a 100644 --- a/arch/powerpc/mm/mmu_context_iommu.c +++ b/arch/powerpc/mm/mmu_context_iommu.c | |||
| @@ -159,7 +159,7 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries, | |||
| 159 | goto unlock_exit; | 159 | goto unlock_exit; |
| 160 | } | 160 | } |
| 161 | 161 | ||
| 162 | mem->hpas = vzalloc(entries * sizeof(mem->hpas[0])); | 162 | mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0]))); |
| 163 | if (!mem->hpas) { | 163 | if (!mem->hpas) { |
| 164 | kfree(mem); | 164 | kfree(mem); |
| 165 | ret = -ENOMEM; | 165 | ret = -ENOMEM; |
diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 57a5029b4521..0c7e05d89244 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c | |||
| @@ -1316,7 +1316,7 @@ int numa_update_cpu_topology(bool cpus_locked) | |||
| 1316 | if (!weight) | 1316 | if (!weight) |
| 1317 | return 0; | 1317 | return 0; |
| 1318 | 1318 | ||
| 1319 | updates = kzalloc(weight * (sizeof(*updates)), GFP_KERNEL); | 1319 | updates = kcalloc(weight, sizeof(*updates), GFP_KERNEL); |
| 1320 | if (!updates) | 1320 | if (!updates) |
| 1321 | return 0; | 1321 | return 0; |
| 1322 | 1322 | ||
diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c index a9636d8cba15..5b061fc81df3 100644 --- a/arch/powerpc/net/bpf_jit_comp.c +++ b/arch/powerpc/net/bpf_jit_comp.c | |||
| @@ -566,7 +566,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
| 566 | if (!bpf_jit_enable) | 566 | if (!bpf_jit_enable) |
| 567 | return; | 567 | return; |
| 568 | 568 | ||
| 569 | addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL); | 569 | addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL); |
| 570 | if (addrs == NULL) | 570 | if (addrs == NULL) |
| 571 | return; | 571 | return; |
| 572 | 572 | ||
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c index f1c95779843b..380cbf9a40d9 100644 --- a/arch/powerpc/net/bpf_jit_comp64.c +++ b/arch/powerpc/net/bpf_jit_comp64.c | |||
| @@ -949,7 +949,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) | |||
| 949 | goto skip_init_ctx; | 949 | goto skip_init_ctx; |
| 950 | } | 950 | } |
| 951 | 951 | ||
| 952 | addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL); | 952 | addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL); |
| 953 | if (addrs == NULL) { | 953 | if (addrs == NULL) { |
| 954 | fp = org_fp; | 954 | fp = org_fp; |
| 955 | goto out_addrs; | 955 | goto out_addrs; |
diff --git a/arch/powerpc/oprofile/cell/spu_profiler.c b/arch/powerpc/oprofile/cell/spu_profiler.c index 5182f2936af2..4e099e556645 100644 --- a/arch/powerpc/oprofile/cell/spu_profiler.c +++ b/arch/powerpc/oprofile/cell/spu_profiler.c | |||
| @@ -210,8 +210,8 @@ int start_spu_profiling_cycles(unsigned int cycles_reset) | |||
| 210 | timer.function = profile_spus; | 210 | timer.function = profile_spus; |
| 211 | 211 | ||
| 212 | /* Allocate arrays for collecting SPU PC samples */ | 212 | /* Allocate arrays for collecting SPU PC samples */ |
| 213 | samples = kzalloc(SPUS_PER_NODE * | 213 | samples = kcalloc(SPUS_PER_NODE * TRACE_ARRAY_SIZE, sizeof(u32), |
| 214 | TRACE_ARRAY_SIZE * sizeof(u32), GFP_KERNEL); | 214 | GFP_KERNEL); |
| 215 | 215 | ||
| 216 | if (!samples) | 216 | if (!samples) |
| 217 | return -ENOMEM; | 217 | return -ENOMEM; |
diff --git a/arch/powerpc/platforms/4xx/hsta_msi.c b/arch/powerpc/platforms/4xx/hsta_msi.c index 9926ad67af76..1c18f2955f7d 100644 --- a/arch/powerpc/platforms/4xx/hsta_msi.c +++ b/arch/powerpc/platforms/4xx/hsta_msi.c | |||
| @@ -156,7 +156,8 @@ static int hsta_msi_probe(struct platform_device *pdev) | |||
| 156 | if (ret) | 156 | if (ret) |
| 157 | goto out; | 157 | goto out; |
| 158 | 158 | ||
| 159 | ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL); | 159 | ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count, sizeof(int), |
| 160 | GFP_KERNEL); | ||
| 160 | if (!ppc4xx_hsta_msi.irq_map) { | 161 | if (!ppc4xx_hsta_msi.irq_map) { |
| 161 | ret = -ENOMEM; | 162 | ret = -ENOMEM; |
| 162 | goto out1; | 163 | goto out1; |
diff --git a/arch/powerpc/platforms/4xx/msi.c b/arch/powerpc/platforms/4xx/msi.c index 96aaae678928..81b2cbce7df8 100644 --- a/arch/powerpc/platforms/4xx/msi.c +++ b/arch/powerpc/platforms/4xx/msi.c | |||
| @@ -89,7 +89,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
| 89 | if (type == PCI_CAP_ID_MSIX) | 89 | if (type == PCI_CAP_ID_MSIX) |
| 90 | pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n"); | 90 | pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n"); |
| 91 | 91 | ||
| 92 | msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int), GFP_KERNEL); | 92 | msi_data->msi_virqs = kmalloc_array(msi_irqs, sizeof(int), GFP_KERNEL); |
| 93 | if (!msi_data->msi_virqs) | 93 | if (!msi_data->msi_virqs) |
| 94 | return -ENOMEM; | 94 | return -ENOMEM; |
| 95 | 95 | ||
diff --git a/arch/powerpc/platforms/4xx/pci.c b/arch/powerpc/platforms/4xx/pci.c index 73e6b36bcd51..5aca523551ae 100644 --- a/arch/powerpc/platforms/4xx/pci.c +++ b/arch/powerpc/platforms/4xx/pci.c | |||
| @@ -1449,7 +1449,7 @@ static int __init ppc4xx_pciex_check_core_init(struct device_node *np) | |||
| 1449 | count = ppc4xx_pciex_hwops->core_init(np); | 1449 | count = ppc4xx_pciex_hwops->core_init(np); |
| 1450 | if (count > 0) { | 1450 | if (count > 0) { |
| 1451 | ppc4xx_pciex_ports = | 1451 | ppc4xx_pciex_ports = |
| 1452 | kzalloc(count * sizeof(struct ppc4xx_pciex_port), | 1452 | kcalloc(count, sizeof(struct ppc4xx_pciex_port), |
| 1453 | GFP_KERNEL); | 1453 | GFP_KERNEL); |
| 1454 | if (ppc4xx_pciex_ports) { | 1454 | if (ppc4xx_pciex_ports) { |
| 1455 | ppc4xx_pciex_port_count = count; | 1455 | ppc4xx_pciex_port_count = count; |
diff --git a/arch/powerpc/platforms/powernv/opal-sysparam.c b/arch/powerpc/platforms/powernv/opal-sysparam.c index 6fd4092798d5..9aa87df114fd 100644 --- a/arch/powerpc/platforms/powernv/opal-sysparam.c +++ b/arch/powerpc/platforms/powernv/opal-sysparam.c | |||
| @@ -198,21 +198,21 @@ void __init opal_sys_param_init(void) | |||
| 198 | goto out_param_buf; | 198 | goto out_param_buf; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | id = kzalloc(sizeof(*id) * count, GFP_KERNEL); | 201 | id = kcalloc(count, sizeof(*id), GFP_KERNEL); |
| 202 | if (!id) { | 202 | if (!id) { |
| 203 | pr_err("SYSPARAM: Failed to allocate memory to read parameter " | 203 | pr_err("SYSPARAM: Failed to allocate memory to read parameter " |
| 204 | "id\n"); | 204 | "id\n"); |
| 205 | goto out_param_buf; | 205 | goto out_param_buf; |
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | size = kzalloc(sizeof(*size) * count, GFP_KERNEL); | 208 | size = kcalloc(count, sizeof(*size), GFP_KERNEL); |
| 209 | if (!size) { | 209 | if (!size) { |
| 210 | pr_err("SYSPARAM: Failed to allocate memory to read parameter " | 210 | pr_err("SYSPARAM: Failed to allocate memory to read parameter " |
| 211 | "size\n"); | 211 | "size\n"); |
| 212 | goto out_free_id; | 212 | goto out_free_id; |
| 213 | } | 213 | } |
| 214 | 214 | ||
| 215 | perm = kzalloc(sizeof(*perm) * count, GFP_KERNEL); | 215 | perm = kcalloc(count, sizeof(*perm), GFP_KERNEL); |
| 216 | if (!perm) { | 216 | if (!perm) { |
| 217 | pr_err("SYSPARAM: Failed to allocate memory to read supported " | 217 | pr_err("SYSPARAM: Failed to allocate memory to read supported " |
| 218 | "action on the parameter"); | 218 | "action on the parameter"); |
| @@ -235,7 +235,7 @@ void __init opal_sys_param_init(void) | |||
| 235 | goto out_free_perm; | 235 | goto out_free_perm; |
| 236 | } | 236 | } |
| 237 | 237 | ||
| 238 | attr = kzalloc(sizeof(*attr) * count, GFP_KERNEL); | 238 | attr = kcalloc(count, sizeof(*attr), GFP_KERNEL); |
| 239 | if (!attr) { | 239 | if (!attr) { |
| 240 | pr_err("SYSPARAM: Failed to allocate memory for parameter " | 240 | pr_err("SYSPARAM: Failed to allocate memory for parameter " |
| 241 | "attributes\n"); | 241 | "attributes\n"); |
diff --git a/arch/powerpc/sysdev/mpic.c b/arch/powerpc/sysdev/mpic.c index 1d4e0ef658d3..353b43972bbf 100644 --- a/arch/powerpc/sysdev/mpic.c +++ b/arch/powerpc/sysdev/mpic.c | |||
| @@ -544,7 +544,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic) | |||
| 544 | printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n"); | 544 | printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n"); |
| 545 | 545 | ||
| 546 | /* Allocate fixups array */ | 546 | /* Allocate fixups array */ |
| 547 | mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL); | 547 | mpic->fixups = kcalloc(128, sizeof(*mpic->fixups), GFP_KERNEL); |
| 548 | BUG_ON(mpic->fixups == NULL); | 548 | BUG_ON(mpic->fixups == NULL); |
| 549 | 549 | ||
| 550 | /* Init spinlock */ | 550 | /* Init spinlock */ |
| @@ -1324,7 +1324,7 @@ struct mpic * __init mpic_alloc(struct device_node *node, | |||
| 1324 | if (psrc) { | 1324 | if (psrc) { |
| 1325 | /* Allocate a bitmap with one bit per interrupt */ | 1325 | /* Allocate a bitmap with one bit per interrupt */ |
| 1326 | unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1); | 1326 | unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1); |
| 1327 | mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL); | 1327 | mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL); |
| 1328 | BUG_ON(mpic->protected == NULL); | 1328 | BUG_ON(mpic->protected == NULL); |
| 1329 | for (i = 0; i < psize/sizeof(u32); i++) { | 1329 | for (i = 0; i < psize/sizeof(u32); i++) { |
| 1330 | if (psrc[i] > intvec_top) | 1330 | if (psrc[i] > intvec_top) |
| @@ -1639,8 +1639,9 @@ void __init mpic_init(struct mpic *mpic) | |||
| 1639 | 1639 | ||
| 1640 | #ifdef CONFIG_PM | 1640 | #ifdef CONFIG_PM |
| 1641 | /* allocate memory to save mpic state */ | 1641 | /* allocate memory to save mpic state */ |
| 1642 | mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data), | 1642 | mpic->save_data = kmalloc_array(mpic->num_sources, |
| 1643 | GFP_KERNEL); | 1643 | sizeof(*mpic->save_data), |
| 1644 | GFP_KERNEL); | ||
| 1644 | BUG_ON(mpic->save_data == NULL); | 1645 | BUG_ON(mpic->save_data == NULL); |
| 1645 | #endif | 1646 | #endif |
| 1646 | 1647 | ||
diff --git a/arch/powerpc/sysdev/xive/native.c b/arch/powerpc/sysdev/xive/native.c index 83bcd72b21cf..311185b9960a 100644 --- a/arch/powerpc/sysdev/xive/native.c +++ b/arch/powerpc/sysdev/xive/native.c | |||
| @@ -489,7 +489,7 @@ static bool xive_parse_provisioning(struct device_node *np) | |||
| 489 | if (rc == 0) | 489 | if (rc == 0) |
| 490 | return true; | 490 | return true; |
| 491 | 491 | ||
| 492 | xive_provision_chips = kzalloc(4 * xive_provision_chip_count, | 492 | xive_provision_chips = kcalloc(4, xive_provision_chip_count, |
| 493 | GFP_KERNEL); | 493 | GFP_KERNEL); |
| 494 | if (WARN_ON(!xive_provision_chips)) | 494 | if (WARN_ON(!xive_provision_chips)) |
| 495 | return false; | 495 | return false; |
diff --git a/arch/s390/appldata/appldata_base.c b/arch/s390/appldata/appldata_base.c index cb6e8066b1ad..ee6a9c387c87 100644 --- a/arch/s390/appldata/appldata_base.c +++ b/arch/s390/appldata/appldata_base.c | |||
| @@ -391,7 +391,7 @@ int appldata_register_ops(struct appldata_ops *ops) | |||
| 391 | if (ops->size > APPLDATA_MAX_REC_SIZE) | 391 | if (ops->size > APPLDATA_MAX_REC_SIZE) |
| 392 | return -EINVAL; | 392 | return -EINVAL; |
| 393 | 393 | ||
| 394 | ops->ctl_table = kzalloc(4 * sizeof(struct ctl_table), GFP_KERNEL); | 394 | ops->ctl_table = kcalloc(4, sizeof(struct ctl_table), GFP_KERNEL); |
| 395 | if (!ops->ctl_table) | 395 | if (!ops->ctl_table) |
| 396 | return -ENOMEM; | 396 | return -ENOMEM; |
| 397 | 397 | ||
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c index be8cc53204b5..a2945b289a29 100644 --- a/arch/s390/hypfs/hypfs_diag.c +++ b/arch/s390/hypfs/hypfs_diag.c | |||
| @@ -239,7 +239,7 @@ static void *page_align_ptr(void *ptr) | |||
| 239 | static void *diag204_alloc_vbuf(int pages) | 239 | static void *diag204_alloc_vbuf(int pages) |
| 240 | { | 240 | { |
| 241 | /* The buffer has to be page aligned! */ | 241 | /* The buffer has to be page aligned! */ |
| 242 | diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1)); | 242 | diag204_buf_vmalloc = vmalloc(array_size(PAGE_SIZE, (pages + 1))); |
| 243 | if (!diag204_buf_vmalloc) | 243 | if (!diag204_buf_vmalloc) |
| 244 | return ERR_PTR(-ENOMEM); | 244 | return ERR_PTR(-ENOMEM); |
| 245 | diag204_buf = page_align_ptr(diag204_buf_vmalloc); | 245 | diag204_buf = page_align_ptr(diag204_buf_vmalloc); |
diff --git a/arch/s390/hypfs/hypfs_diag0c.c b/arch/s390/hypfs/hypfs_diag0c.c index dce87f1bec94..cebf05150cc1 100644 --- a/arch/s390/hypfs/hypfs_diag0c.c +++ b/arch/s390/hypfs/hypfs_diag0c.c | |||
| @@ -49,7 +49,8 @@ static void *diag0c_store(unsigned int *count) | |||
| 49 | 49 | ||
| 50 | get_online_cpus(); | 50 | get_online_cpus(); |
| 51 | cpu_count = num_online_cpus(); | 51 | cpu_count = num_online_cpus(); |
| 52 | cpu_vec = kmalloc(sizeof(*cpu_vec) * num_possible_cpus(), GFP_KERNEL); | 52 | cpu_vec = kmalloc_array(num_possible_cpus(), sizeof(*cpu_vec), |
| 53 | GFP_KERNEL); | ||
| 53 | if (!cpu_vec) | 54 | if (!cpu_vec) |
| 54 | goto fail_put_online_cpus; | 55 | goto fail_put_online_cpus; |
| 55 | /* Note: Diag 0c needs 8 byte alignment and real storage */ | 56 | /* Note: Diag 0c needs 8 byte alignment and real storage */ |
diff --git a/arch/s390/kernel/debug.c b/arch/s390/kernel/debug.c index 80e974adb9e8..d374f9b218b4 100644 --- a/arch/s390/kernel/debug.c +++ b/arch/s390/kernel/debug.c | |||
| @@ -194,11 +194,13 @@ static debug_entry_t ***debug_areas_alloc(int pages_per_area, int nr_areas) | |||
| 194 | debug_entry_t ***areas; | 194 | debug_entry_t ***areas; |
| 195 | int i, j; | 195 | int i, j; |
| 196 | 196 | ||
| 197 | areas = kmalloc(nr_areas * sizeof(debug_entry_t **), GFP_KERNEL); | 197 | areas = kmalloc_array(nr_areas, sizeof(debug_entry_t **), GFP_KERNEL); |
| 198 | if (!areas) | 198 | if (!areas) |
| 199 | goto fail_malloc_areas; | 199 | goto fail_malloc_areas; |
| 200 | for (i = 0; i < nr_areas; i++) { | 200 | for (i = 0; i < nr_areas; i++) { |
| 201 | areas[i] = kmalloc(pages_per_area * sizeof(debug_entry_t *), GFP_KERNEL); | 201 | areas[i] = kmalloc_array(pages_per_area, |
| 202 | sizeof(debug_entry_t *), | ||
| 203 | GFP_KERNEL); | ||
| 202 | if (!areas[i]) | 204 | if (!areas[i]) |
| 203 | goto fail_malloc_areas2; | 205 | goto fail_malloc_areas2; |
| 204 | for (j = 0; j < pages_per_area; j++) { | 206 | for (j = 0; j < pages_per_area; j++) { |
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c index 0dc8ac8548ee..d298d3cb46d0 100644 --- a/arch/s390/kernel/module.c +++ b/arch/s390/kernel/module.c | |||
| @@ -123,8 +123,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, | |||
| 123 | 123 | ||
| 124 | /* Allocate one syminfo structure per symbol. */ | 124 | /* Allocate one syminfo structure per symbol. */ |
| 125 | me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym); | 125 | me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym); |
| 126 | me->arch.syminfo = vmalloc(me->arch.nsyms * | 126 | me->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo), |
| 127 | sizeof(struct mod_arch_syminfo)); | 127 | me->arch.nsyms)); |
| 128 | if (!me->arch.syminfo) | 128 | if (!me->arch.syminfo) |
| 129 | return -ENOMEM; | 129 | return -ENOMEM; |
| 130 | symbols = (void *) hdr + symtab->sh_offset; | 130 | symbols = (void *) hdr + symtab->sh_offset; |
diff --git a/arch/s390/kernel/perf_cpum_cf_events.c b/arch/s390/kernel/perf_cpum_cf_events.c index feebb2944882..d63fb3c56b8a 100644 --- a/arch/s390/kernel/perf_cpum_cf_events.c +++ b/arch/s390/kernel/perf_cpum_cf_events.c | |||
| @@ -527,7 +527,7 @@ static __init struct attribute **merge_attr(struct attribute **a, | |||
| 527 | j++; | 527 | j++; |
| 528 | j++; | 528 | j++; |
| 529 | 529 | ||
| 530 | new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL); | 530 | new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL); |
| 531 | if (!new) | 531 | if (!new) |
| 532 | return NULL; | 532 | return NULL; |
| 533 | j = 0; | 533 | j = 0; |
diff --git a/arch/s390/kernel/sthyi.c b/arch/s390/kernel/sthyi.c index 80b862e9c53c..0859cde36f75 100644 --- a/arch/s390/kernel/sthyi.c +++ b/arch/s390/kernel/sthyi.c | |||
| @@ -315,7 +315,7 @@ static void fill_diag(struct sthyi_sctns *sctns) | |||
| 315 | if (pages <= 0) | 315 | if (pages <= 0) |
| 316 | return; | 316 | return; |
| 317 | 317 | ||
| 318 | diag204_buf = vmalloc(PAGE_SIZE * pages); | 318 | diag204_buf = vmalloc(array_size(pages, PAGE_SIZE)); |
| 319 | if (!diag204_buf) | 319 | if (!diag204_buf) |
| 320 | return; | 320 | return; |
| 321 | 321 | ||
diff --git a/arch/s390/kernel/vdso.c b/arch/s390/kernel/vdso.c index f3a1c7c6824e..09abae40f917 100644 --- a/arch/s390/kernel/vdso.c +++ b/arch/s390/kernel/vdso.c | |||
| @@ -285,7 +285,7 @@ static int __init vdso_init(void) | |||
| 285 | + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1; | 285 | + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1; |
| 286 | 286 | ||
| 287 | /* Make sure pages are in the correct state */ | 287 | /* Make sure pages are in the correct state */ |
| 288 | vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 1), | 288 | vdso32_pagelist = kcalloc(vdso32_pages + 1, sizeof(struct page *), |
| 289 | GFP_KERNEL); | 289 | GFP_KERNEL); |
| 290 | BUG_ON(vdso32_pagelist == NULL); | 290 | BUG_ON(vdso32_pagelist == NULL); |
| 291 | for (i = 0; i < vdso32_pages - 1; i++) { | 291 | for (i = 0; i < vdso32_pages - 1; i++) { |
| @@ -303,7 +303,7 @@ static int __init vdso_init(void) | |||
| 303 | + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1; | 303 | + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1; |
| 304 | 304 | ||
| 305 | /* Make sure pages are in the correct state */ | 305 | /* Make sure pages are in the correct state */ |
| 306 | vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 1), | 306 | vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *), |
| 307 | GFP_KERNEL); | 307 | GFP_KERNEL); |
| 308 | BUG_ON(vdso64_pagelist == NULL); | 308 | BUG_ON(vdso64_pagelist == NULL); |
| 309 | for (i = 0; i < vdso64_pages - 1; i++) { | 309 | for (i = 0; i < vdso64_pages - 1; i++) { |
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c index 8e2b8647ee12..07d30ffcfa41 100644 --- a/arch/s390/kvm/gaccess.c +++ b/arch/s390/kvm/gaccess.c | |||
| @@ -847,7 +847,7 @@ int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data, | |||
| 847 | nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1; | 847 | nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1; |
| 848 | pages = pages_array; | 848 | pages = pages_array; |
| 849 | if (nr_pages > ARRAY_SIZE(pages_array)) | 849 | if (nr_pages > ARRAY_SIZE(pages_array)) |
| 850 | pages = vmalloc(nr_pages * sizeof(unsigned long)); | 850 | pages = vmalloc(array_size(nr_pages, sizeof(unsigned long))); |
| 851 | if (!pages) | 851 | if (!pages) |
| 852 | return -ENOMEM; | 852 | return -ENOMEM; |
| 853 | need_ipte_lock = psw_bits(*psw).dat && !asce.r; | 853 | need_ipte_lock = psw_bits(*psw).dat && !asce.r; |
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c index 7142508ca6e1..3b7a5151b6a5 100644 --- a/arch/s390/kvm/kvm-s390.c +++ b/arch/s390/kvm/kvm-s390.c | |||
| @@ -1729,7 +1729,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm, | |||
| 1729 | if (args->count == 0) | 1729 | if (args->count == 0) |
| 1730 | return 0; | 1730 | return 0; |
| 1731 | 1731 | ||
| 1732 | bits = vmalloc(sizeof(*bits) * args->count); | 1732 | bits = vmalloc(array_size(sizeof(*bits), args->count)); |
| 1733 | if (!bits) | 1733 | if (!bits) |
| 1734 | return -ENOMEM; | 1734 | return -ENOMEM; |
| 1735 | 1735 | ||
diff --git a/arch/s390/mm/extmem.c b/arch/s390/mm/extmem.c index 920d40894535..6ad15d3fab81 100644 --- a/arch/s390/mm/extmem.c +++ b/arch/s390/mm/extmem.c | |||
| @@ -103,7 +103,7 @@ static int scode_set; | |||
| 103 | static int | 103 | static int |
| 104 | dcss_set_subcodes(void) | 104 | dcss_set_subcodes(void) |
| 105 | { | 105 | { |
| 106 | char *name = kmalloc(8 * sizeof(char), GFP_KERNEL | GFP_DMA); | 106 | char *name = kmalloc(8, GFP_KERNEL | GFP_DMA); |
| 107 | unsigned long rx, ry; | 107 | unsigned long rx, ry; |
| 108 | int rc; | 108 | int rc; |
| 109 | 109 | ||
diff --git a/arch/sh/drivers/dma/dmabrg.c b/arch/sh/drivers/dma/dmabrg.c index c0dd904483c7..e5a57a109d6c 100644 --- a/arch/sh/drivers/dma/dmabrg.c +++ b/arch/sh/drivers/dma/dmabrg.c | |||
| @@ -154,7 +154,7 @@ static int __init dmabrg_init(void) | |||
| 154 | unsigned long or; | 154 | unsigned long or; |
| 155 | int ret; | 155 | int ret; |
| 156 | 156 | ||
| 157 | dmabrg_handlers = kzalloc(10 * sizeof(struct dmabrg_handler), | 157 | dmabrg_handlers = kcalloc(10, sizeof(struct dmabrg_handler), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!dmabrg_handlers) | 159 | if (!dmabrg_handlers) |
| 160 | return -ENOMEM; | 160 | return -ENOMEM; |
diff --git a/arch/sh/drivers/pci/pcie-sh7786.c b/arch/sh/drivers/pci/pcie-sh7786.c index 382e7ecf4c82..3d81a8b80942 100644 --- a/arch/sh/drivers/pci/pcie-sh7786.c +++ b/arch/sh/drivers/pci/pcie-sh7786.c | |||
| @@ -561,7 +561,7 @@ static int __init sh7786_pcie_init(void) | |||
| 561 | if (unlikely(nr_ports == 0)) | 561 | if (unlikely(nr_ports == 0)) |
| 562 | return -ENODEV; | 562 | return -ENODEV; |
| 563 | 563 | ||
| 564 | sh7786_pcie_ports = kzalloc(nr_ports * sizeof(struct sh7786_pcie_port), | 564 | sh7786_pcie_ports = kcalloc(nr_ports, sizeof(struct sh7786_pcie_port), |
| 565 | GFP_KERNEL); | 565 | GFP_KERNEL); |
| 566 | if (unlikely(!sh7786_pcie_ports)) | 566 | if (unlikely(!sh7786_pcie_ports)) |
| 567 | return -ENOMEM; | 567 | return -ENOMEM; |
diff --git a/arch/sparc/kernel/nmi.c b/arch/sparc/kernel/nmi.c index 048ad783ea3f..8babbeb30adf 100644 --- a/arch/sparc/kernel/nmi.c +++ b/arch/sparc/kernel/nmi.c | |||
| @@ -166,7 +166,8 @@ static int __init check_nmi_watchdog(void) | |||
| 166 | if (!atomic_read(&nmi_active)) | 166 | if (!atomic_read(&nmi_active)) |
| 167 | return 0; | 167 | return 0; |
| 168 | 168 | ||
| 169 | prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(unsigned int), GFP_KERNEL); | 169 | prev_nmi_count = kmalloc_array(nr_cpu_ids, sizeof(unsigned int), |
| 170 | GFP_KERNEL); | ||
| 170 | if (!prev_nmi_count) { | 171 | if (!prev_nmi_count) { |
| 171 | err = -ENOMEM; | 172 | err = -ENOMEM; |
| 172 | goto error; | 173 | goto error; |
diff --git a/arch/sparc/kernel/sys_sparc_64.c b/arch/sparc/kernel/sys_sparc_64.c index 7e49bbc925a5..63baa8aa9414 100644 --- a/arch/sparc/kernel/sys_sparc_64.c +++ b/arch/sparc/kernel/sys_sparc_64.c | |||
| @@ -565,7 +565,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, | |||
| 565 | } | 565 | } |
| 566 | if (!current_thread_info()->utraps) { | 566 | if (!current_thread_info()->utraps) { |
| 567 | current_thread_info()->utraps = | 567 | current_thread_info()->utraps = |
| 568 | kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL); | 568 | kcalloc(UT_TRAP_INSTRUCTION_31 + 1, sizeof(long), |
| 569 | GFP_KERNEL); | ||
| 569 | if (!current_thread_info()->utraps) | 570 | if (!current_thread_info()->utraps) |
| 570 | return -ENOMEM; | 571 | return -ENOMEM; |
| 571 | current_thread_info()->utraps[0] = 1; | 572 | current_thread_info()->utraps[0] = 1; |
| @@ -575,8 +576,9 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, | |||
| 575 | unsigned long *p = current_thread_info()->utraps; | 576 | unsigned long *p = current_thread_info()->utraps; |
| 576 | 577 | ||
| 577 | current_thread_info()->utraps = | 578 | current_thread_info()->utraps = |
| 578 | kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), | 579 | kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1, |
| 579 | GFP_KERNEL); | 580 | sizeof(long), |
| 581 | GFP_KERNEL); | ||
| 580 | if (!current_thread_info()->utraps) { | 582 | if (!current_thread_info()->utraps) { |
| 581 | current_thread_info()->utraps = p; | 583 | current_thread_info()->utraps = p; |
| 582 | return -ENOMEM; | 584 | return -ENOMEM; |
diff --git a/arch/sparc/net/bpf_jit_comp_32.c b/arch/sparc/net/bpf_jit_comp_32.c index 3bd8ca95e521..a5ff88643d5c 100644 --- a/arch/sparc/net/bpf_jit_comp_32.c +++ b/arch/sparc/net/bpf_jit_comp_32.c | |||
| @@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp) | |||
| 335 | if (!bpf_jit_enable) | 335 | if (!bpf_jit_enable) |
| 336 | return; | 336 | return; |
| 337 | 337 | ||
| 338 | addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL); | 338 | addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL); |
| 339 | if (addrs == NULL) | 339 | if (addrs == NULL) |
| 340 | return; | 340 | return; |
| 341 | 341 | ||
diff --git a/arch/um/drivers/ubd_kern.c b/arch/um/drivers/ubd_kern.c index dcf5ea28a281..83c470364dfb 100644 --- a/arch/um/drivers/ubd_kern.c +++ b/arch/um/drivers/ubd_kern.c | |||
| @@ -1127,9 +1127,9 @@ static int __init ubd_init(void) | |||
| 1127 | return -1; | 1127 | return -1; |
| 1128 | } | 1128 | } |
| 1129 | 1129 | ||
| 1130 | irq_req_buffer = kmalloc( | 1130 | irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, |
| 1131 | sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE, | 1131 | sizeof(struct io_thread_req *), |
| 1132 | GFP_KERNEL | 1132 | GFP_KERNEL |
| 1133 | ); | 1133 | ); |
| 1134 | irq_remainder = 0; | 1134 | irq_remainder = 0; |
| 1135 | 1135 | ||
| @@ -1137,9 +1137,9 @@ static int __init ubd_init(void) | |||
| 1137 | printk(KERN_ERR "Failed to initialize ubd buffering\n"); | 1137 | printk(KERN_ERR "Failed to initialize ubd buffering\n"); |
| 1138 | return -1; | 1138 | return -1; |
| 1139 | } | 1139 | } |
| 1140 | io_req_buffer = kmalloc( | 1140 | io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE, |
| 1141 | sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE, | 1141 | sizeof(struct io_thread_req *), |
| 1142 | GFP_KERNEL | 1142 | GFP_KERNEL |
| 1143 | ); | 1143 | ); |
| 1144 | 1144 | ||
| 1145 | io_remainder = 0; | 1145 | io_remainder = 0; |
diff --git a/arch/um/drivers/vector_kern.c b/arch/um/drivers/vector_kern.c index 02168fe25105..627075e6d875 100644 --- a/arch/um/drivers/vector_kern.c +++ b/arch/um/drivers/vector_kern.c | |||
| @@ -527,14 +527,14 @@ static struct vector_queue *create_queue( | |||
| 527 | result->max_iov_frags = num_extra_frags; | 527 | result->max_iov_frags = num_extra_frags; |
| 528 | for (i = 0; i < max_size; i++) { | 528 | for (i = 0; i < max_size; i++) { |
| 529 | if (vp->header_size > 0) | 529 | if (vp->header_size > 0) |
| 530 | iov = kmalloc( | 530 | iov = kmalloc_array(3 + num_extra_frags, |
| 531 | sizeof(struct iovec) * (3 + num_extra_frags), | 531 | sizeof(struct iovec), |
| 532 | GFP_KERNEL | 532 | GFP_KERNEL |
| 533 | ); | 533 | ); |
| 534 | else | 534 | else |
| 535 | iov = kmalloc( | 535 | iov = kmalloc_array(2 + num_extra_frags, |
| 536 | sizeof(struct iovec) * (2 + num_extra_frags), | 536 | sizeof(struct iovec), |
| 537 | GFP_KERNEL | 537 | GFP_KERNEL |
| 538 | ); | 538 | ); |
| 539 | if (iov == NULL) | 539 | if (iov == NULL) |
| 540 | goto out_fail; | 540 | goto out_fail; |
diff --git a/arch/unicore32/kernel/pm.c b/arch/unicore32/kernel/pm.c index 784bc2db3b28..6f8164d91dc2 100644 --- a/arch/unicore32/kernel/pm.c +++ b/arch/unicore32/kernel/pm.c | |||
| @@ -109,8 +109,9 @@ static int __init puv3_pm_init(void) | |||
| 109 | return -EINVAL; | 109 | return -EINVAL; |
| 110 | } | 110 | } |
| 111 | 111 | ||
| 112 | sleep_save = kmalloc(puv3_cpu_pm_fns->save_count | 112 | sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count, |
| 113 | * sizeof(unsigned long), GFP_KERNEL); | 113 | sizeof(unsigned long), |
| 114 | GFP_KERNEL); | ||
| 114 | if (!sleep_save) { | 115 | if (!sleep_save) { |
| 115 | printk(KERN_ERR "failed to alloc memory for pm save\n"); | 116 | printk(KERN_ERR "failed to alloc memory for pm save\n"); |
| 116 | return -ENOMEM; | 117 | return -ENOMEM; |
diff --git a/arch/x86/events/amd/iommu.c b/arch/x86/events/amd/iommu.c index 38b5d41b0c37..3210fee27e7f 100644 --- a/arch/x86/events/amd/iommu.c +++ b/arch/x86/events/amd/iommu.c | |||
| @@ -387,7 +387,7 @@ static __init int _init_events_attrs(void) | |||
| 387 | while (amd_iommu_v2_event_descs[i].attr.attr.name) | 387 | while (amd_iommu_v2_event_descs[i].attr.attr.name) |
| 388 | i++; | 388 | i++; |
| 389 | 389 | ||
| 390 | attrs = kzalloc(sizeof(struct attribute **) * (i + 1), GFP_KERNEL); | 390 | attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL); |
| 391 | if (!attrs) | 391 | if (!attrs) |
| 392 | return -ENOMEM; | 392 | return -ENOMEM; |
| 393 | 393 | ||
diff --git a/arch/x86/events/core.c b/arch/x86/events/core.c index 6e461fb1e0d4..5f4829f10129 100644 --- a/arch/x86/events/core.c +++ b/arch/x86/events/core.c | |||
| @@ -1637,7 +1637,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b) | |||
| 1637 | j++; | 1637 | j++; |
| 1638 | j++; | 1638 | j++; |
| 1639 | 1639 | ||
| 1640 | new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL); | 1640 | new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL); |
| 1641 | if (!new) | 1641 | if (!new) |
| 1642 | return NULL; | 1642 | return NULL; |
| 1643 | 1643 | ||
diff --git a/arch/x86/events/intel/uncore.c b/arch/x86/events/intel/uncore.c index 15b07379e72d..27a461414b30 100644 --- a/arch/x86/events/intel/uncore.c +++ b/arch/x86/events/intel/uncore.c | |||
| @@ -865,12 +865,10 @@ static void uncore_types_exit(struct intel_uncore_type **types) | |||
| 865 | static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) | 865 | static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) |
| 866 | { | 866 | { |
| 867 | struct intel_uncore_pmu *pmus; | 867 | struct intel_uncore_pmu *pmus; |
| 868 | struct attribute_group *attr_group; | ||
| 869 | struct attribute **attrs; | ||
| 870 | size_t size; | 868 | size_t size; |
| 871 | int i, j; | 869 | int i, j; |
| 872 | 870 | ||
| 873 | pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL); | 871 | pmus = kcalloc(type->num_boxes, sizeof(*pmus), GFP_KERNEL); |
| 874 | if (!pmus) | 872 | if (!pmus) |
| 875 | return -ENOMEM; | 873 | return -ENOMEM; |
| 876 | 874 | ||
| @@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) | |||
| 891 | 0, type->num_counters, 0, 0); | 889 | 0, type->num_counters, 0, 0); |
| 892 | 890 | ||
| 893 | if (type->event_descs) { | 891 | if (type->event_descs) { |
| 892 | struct { | ||
| 893 | struct attribute_group group; | ||
| 894 | struct attribute *attrs[]; | ||
| 895 | } *attr_group; | ||
| 894 | for (i = 0; type->event_descs[i].attr.attr.name; i++); | 896 | for (i = 0; type->event_descs[i].attr.attr.name; i++); |
| 895 | 897 | ||
| 896 | attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) + | 898 | attr_group = kzalloc(struct_size(attr_group, attrs, i + 1), |
| 897 | sizeof(*attr_group), GFP_KERNEL); | 899 | GFP_KERNEL); |
| 898 | if (!attr_group) | 900 | if (!attr_group) |
| 899 | goto err; | 901 | goto err; |
| 900 | 902 | ||
| 901 | attrs = (struct attribute **)(attr_group + 1); | 903 | attr_group->group.name = "events"; |
| 902 | attr_group->name = "events"; | 904 | attr_group->group.attrs = attr_group->attrs; |
| 903 | attr_group->attrs = attrs; | ||
| 904 | 905 | ||
| 905 | for (j = 0; j < i; j++) | 906 | for (j = 0; j < i; j++) |
| 906 | attrs[j] = &type->event_descs[j].attr.attr; | 907 | attr_group->attrs[j] = &type->event_descs[j].attr.attr; |
| 907 | 908 | ||
| 908 | type->events_group = attr_group; | 909 | type->events_group = &attr_group->group; |
| 909 | } | 910 | } |
| 910 | 911 | ||
| 911 | type->pmu_group = &uncore_pmu_attr_group; | 912 | type->pmu_group = &uncore_pmu_attr_group; |
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c index cd76380af79f..e4cf6ff1c2e1 100644 --- a/arch/x86/kernel/cpu/mcheck/mce.c +++ b/arch/x86/kernel/cpu/mcheck/mce.c | |||
| @@ -1457,7 +1457,7 @@ static int __mcheck_cpu_mce_banks_init(void) | |||
| 1457 | int i; | 1457 | int i; |
| 1458 | u8 num_banks = mca_cfg.banks; | 1458 | u8 num_banks = mca_cfg.banks; |
| 1459 | 1459 | ||
| 1460 | mce_banks = kzalloc(num_banks * sizeof(struct mce_bank), GFP_KERNEL); | 1460 | mce_banks = kcalloc(num_banks, sizeof(struct mce_bank), GFP_KERNEL); |
| 1461 | if (!mce_banks) | 1461 | if (!mce_banks) |
| 1462 | return -ENOMEM; | 1462 | return -ENOMEM; |
| 1463 | 1463 | ||
diff --git a/arch/x86/kernel/cpu/mcheck/mce_amd.c b/arch/x86/kernel/cpu/mcheck/mce_amd.c index f591b01930db..dd33c357548f 100644 --- a/arch/x86/kernel/cpu/mcheck/mce_amd.c +++ b/arch/x86/kernel/cpu/mcheck/mce_amd.c | |||
| @@ -1384,7 +1384,7 @@ int mce_threshold_create_device(unsigned int cpu) | |||
| 1384 | if (bp) | 1384 | if (bp) |
| 1385 | return 0; | 1385 | return 0; |
| 1386 | 1386 | ||
| 1387 | bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks, | 1387 | bp = kcalloc(mca_cfg.banks, sizeof(struct threshold_bank *), |
| 1388 | GFP_KERNEL); | 1388 | GFP_KERNEL); |
| 1389 | if (!bp) | 1389 | if (!bp) |
| 1390 | return -ENOMEM; | 1390 | return -ENOMEM; |
diff --git a/arch/x86/kernel/cpu/mtrr/if.c b/arch/x86/kernel/cpu/mtrr/if.c index c610f47373e4..4021d3859499 100644 --- a/arch/x86/kernel/cpu/mtrr/if.c +++ b/arch/x86/kernel/cpu/mtrr/if.c | |||
| @@ -43,7 +43,7 @@ mtrr_file_add(unsigned long base, unsigned long size, | |||
| 43 | 43 | ||
| 44 | max = num_var_ranges; | 44 | max = num_var_ranges; |
| 45 | if (fcount == NULL) { | 45 | if (fcount == NULL) { |
| 46 | fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL); | 46 | fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL); |
| 47 | if (!fcount) | 47 | if (!fcount) |
| 48 | return -ENOMEM; | 48 | return -ENOMEM; |
| 49 | FILE_FCOUNT(file) = fcount; | 49 | FILE_FCOUNT(file) = fcount; |
diff --git a/arch/x86/kernel/hpet.c b/arch/x86/kernel/hpet.c index b6be34ee88e9..346b24883911 100644 --- a/arch/x86/kernel/hpet.c +++ b/arch/x86/kernel/hpet.c | |||
| @@ -610,7 +610,7 @@ static void hpet_msi_capability_lookup(unsigned int start_timer) | |||
| 610 | if (!hpet_domain) | 610 | if (!hpet_domain) |
| 611 | return; | 611 | return; |
| 612 | 612 | ||
| 613 | hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL); | 613 | hpet_devs = kcalloc(num_timers, sizeof(struct hpet_dev), GFP_KERNEL); |
| 614 | if (!hpet_devs) | 614 | if (!hpet_devs) |
| 615 | return; | 615 | return; |
| 616 | 616 | ||
| @@ -966,8 +966,8 @@ int __init hpet_enable(void) | |||
| 966 | #endif | 966 | #endif |
| 967 | 967 | ||
| 968 | cfg = hpet_readl(HPET_CFG); | 968 | cfg = hpet_readl(HPET_CFG); |
| 969 | hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg), | 969 | hpet_boot_cfg = kmalloc_array(last + 2, sizeof(*hpet_boot_cfg), |
| 970 | GFP_KERNEL); | 970 | GFP_KERNEL); |
| 971 | if (hpet_boot_cfg) | 971 | if (hpet_boot_cfg) |
| 972 | *hpet_boot_cfg = cfg; | 972 | *hpet_boot_cfg = cfg; |
| 973 | else | 973 | else |
diff --git a/arch/x86/kernel/ksysfs.c b/arch/x86/kernel/ksysfs.c index 8c1cc08f514f..163ae706a0d4 100644 --- a/arch/x86/kernel/ksysfs.c +++ b/arch/x86/kernel/ksysfs.c | |||
| @@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent) | |||
| 283 | if (ret) | 283 | if (ret) |
| 284 | goto out_setup_data_kobj; | 284 | goto out_setup_data_kobj; |
| 285 | 285 | ||
| 286 | kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL); | 286 | kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL); |
| 287 | if (!kobjp) { | 287 | if (!kobjp) { |
| 288 | ret = -ENOMEM; | 288 | ret = -ENOMEM; |
| 289 | goto out_setup_data_kobj; | 289 | goto out_setup_data_kobj; |
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c index 5720e78b2f7b..7e042e3d47fd 100644 --- a/arch/x86/kvm/cpuid.c +++ b/arch/x86/kvm/cpuid.c | |||
| @@ -203,8 +203,9 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, | |||
| 203 | goto out; | 203 | goto out; |
| 204 | r = -ENOMEM; | 204 | r = -ENOMEM; |
| 205 | if (cpuid->nent) { | 205 | if (cpuid->nent) { |
| 206 | cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry) * | 206 | cpuid_entries = |
| 207 | cpuid->nent); | 207 | vmalloc(array_size(sizeof(struct kvm_cpuid_entry), |
| 208 | cpuid->nent)); | ||
| 208 | if (!cpuid_entries) | 209 | if (!cpuid_entries) |
| 209 | goto out; | 210 | goto out; |
| 210 | r = -EFAULT; | 211 | r = -EFAULT; |
| @@ -785,7 +786,8 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid, | |||
| 785 | return -EINVAL; | 786 | return -EINVAL; |
| 786 | 787 | ||
| 787 | r = -ENOMEM; | 788 | r = -ENOMEM; |
| 788 | cpuid_entries = vzalloc(sizeof(struct kvm_cpuid_entry2) * cpuid->nent); | 789 | cpuid_entries = vzalloc(array_size(sizeof(struct kvm_cpuid_entry2), |
| 790 | cpuid->nent)); | ||
| 789 | if (!cpuid_entries) | 791 | if (!cpuid_entries) |
| 790 | goto out; | 792 | goto out; |
| 791 | 793 | ||
diff --git a/arch/x86/kvm/page_track.c b/arch/x86/kvm/page_track.c index 01c1371f39f8..3052a59a3065 100644 --- a/arch/x86/kvm/page_track.c +++ b/arch/x86/kvm/page_track.c | |||
| @@ -40,8 +40,9 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot, | |||
| 40 | int i; | 40 | int i; |
| 41 | 41 | ||
| 42 | for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) { | 42 | for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) { |
| 43 | slot->arch.gfn_track[i] = kvzalloc(npages * | 43 | slot->arch.gfn_track[i] = |
| 44 | sizeof(*slot->arch.gfn_track[i]), GFP_KERNEL); | 44 | kvcalloc(npages, sizeof(*slot->arch.gfn_track[i]), |
| 45 | GFP_KERNEL); | ||
| 45 | if (!slot->arch.gfn_track[i]) | 46 | if (!slot->arch.gfn_track[i]) |
| 46 | goto track_free; | 47 | goto track_free; |
| 47 | } | 48 | } |
diff --git a/arch/x86/kvm/svm.c b/arch/x86/kvm/svm.c index 695b0bd02220..f059a73f0fd0 100644 --- a/arch/x86/kvm/svm.c +++ b/arch/x86/kvm/svm.c | |||
| @@ -1001,7 +1001,9 @@ static int svm_cpu_init(int cpu) | |||
| 1001 | 1001 | ||
| 1002 | if (svm_sev_enabled()) { | 1002 | if (svm_sev_enabled()) { |
| 1003 | r = -ENOMEM; | 1003 | r = -ENOMEM; |
| 1004 | sd->sev_vmcbs = kmalloc((max_sev_asid + 1) * sizeof(void *), GFP_KERNEL); | 1004 | sd->sev_vmcbs = kmalloc_array(max_sev_asid + 1, |
| 1005 | sizeof(void *), | ||
| 1006 | GFP_KERNEL); | ||
| 1005 | if (!sd->sev_vmcbs) | 1007 | if (!sd->sev_vmcbs) |
| 1006 | goto err_1; | 1008 | goto err_1; |
| 1007 | } | 1009 | } |
diff --git a/arch/x86/kvm/x86.c b/arch/x86/kvm/x86.c index cc8c8be1e92d..6bcecc325e7e 100644 --- a/arch/x86/kvm/x86.c +++ b/arch/x86/kvm/x86.c | |||
| @@ -8900,13 +8900,14 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, | |||
| 8900 | slot->base_gfn, level) + 1; | 8900 | slot->base_gfn, level) + 1; |
| 8901 | 8901 | ||
| 8902 | slot->arch.rmap[i] = | 8902 | slot->arch.rmap[i] = |
| 8903 | kvzalloc(lpages * sizeof(*slot->arch.rmap[i]), GFP_KERNEL); | 8903 | kvcalloc(lpages, sizeof(*slot->arch.rmap[i]), |
| 8904 | GFP_KERNEL); | ||
| 8904 | if (!slot->arch.rmap[i]) | 8905 | if (!slot->arch.rmap[i]) |
| 8905 | goto out_free; | 8906 | goto out_free; |
| 8906 | if (i == 0) | 8907 | if (i == 0) |
| 8907 | continue; | 8908 | continue; |
| 8908 | 8909 | ||
| 8909 | linfo = kvzalloc(lpages * sizeof(*linfo), GFP_KERNEL); | 8910 | linfo = kvcalloc(lpages, sizeof(*linfo), GFP_KERNEL); |
| 8910 | if (!linfo) | 8911 | if (!linfo) |
| 8911 | goto out_free; | 8912 | goto out_free; |
| 8912 | 8913 | ||
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c index 8fca446aaef6..2580cd2e98b1 100644 --- a/arch/x86/net/bpf_jit_comp.c +++ b/arch/x86/net/bpf_jit_comp.c | |||
| @@ -1107,7 +1107,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) | |||
| 1107 | extra_pass = true; | 1107 | extra_pass = true; |
| 1108 | goto skip_init_addrs; | 1108 | goto skip_init_addrs; |
| 1109 | } | 1109 | } |
| 1110 | addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL); | 1110 | addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL); |
| 1111 | if (!addrs) { | 1111 | if (!addrs) { |
| 1112 | prog = orig_prog; | 1112 | prog = orig_prog; |
| 1113 | goto out_addrs; | 1113 | goto out_addrs; |
diff --git a/arch/x86/net/bpf_jit_comp32.c b/arch/x86/net/bpf_jit_comp32.c index 0cc04e30adc1..55799873ebe5 100644 --- a/arch/x86/net/bpf_jit_comp32.c +++ b/arch/x86/net/bpf_jit_comp32.c | |||
| @@ -2345,7 +2345,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) | |||
| 2345 | prog = tmp; | 2345 | prog = tmp; |
| 2346 | } | 2346 | } |
| 2347 | 2347 | ||
| 2348 | addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL); | 2348 | addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL); |
| 2349 | if (!addrs) { | 2349 | if (!addrs) { |
| 2350 | prog = orig_prog; | 2350 | prog = orig_prog; |
| 2351 | goto out; | 2351 | goto out; |
diff --git a/arch/x86/pci/xen.c b/arch/x86/pci/xen.c index 9542a746dc50..9112d1cb397b 100644 --- a/arch/x86/pci/xen.c +++ b/arch/x86/pci/xen.c | |||
| @@ -168,7 +168,7 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) | |||
| 168 | if (type == PCI_CAP_ID_MSI && nvec > 1) | 168 | if (type == PCI_CAP_ID_MSI && nvec > 1) |
| 169 | return 1; | 169 | return 1; |
| 170 | 170 | ||
| 171 | v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL); | 171 | v = kcalloc(max(1, nvec), sizeof(int), GFP_KERNEL); |
| 172 | if (!v) | 172 | if (!v) |
| 173 | return -ENOMEM; | 173 | return -ENOMEM; |
| 174 | 174 | ||
diff --git a/arch/x86/platform/uv/tlb_uv.c b/arch/x86/platform/uv/tlb_uv.c index b96d38288c60..ca446da48fd2 100644 --- a/arch/x86/platform/uv/tlb_uv.c +++ b/arch/x86/platform/uv/tlb_uv.c | |||
| @@ -2142,7 +2142,7 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode) | |||
| 2142 | if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub()) | 2142 | if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub()) |
| 2143 | timeout_us = calculate_destination_timeout(); | 2143 | timeout_us = calculate_destination_timeout(); |
| 2144 | 2144 | ||
| 2145 | vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL); | 2145 | vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL); |
| 2146 | uvhub_descs = (struct uvhub_desc *)vp; | 2146 | uvhub_descs = (struct uvhub_desc *)vp; |
| 2147 | memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); | 2147 | memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc)); |
| 2148 | uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); | 2148 | uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL); |
diff --git a/arch/x86/platform/uv/uv_time.c b/arch/x86/platform/uv/uv_time.c index b082d71b08ee..a36b368eea08 100644 --- a/arch/x86/platform/uv/uv_time.c +++ b/arch/x86/platform/uv/uv_time.c | |||
| @@ -158,7 +158,7 @@ static __init int uv_rtc_allocate_timers(void) | |||
| 158 | { | 158 | { |
| 159 | int cpu; | 159 | int cpu; |
| 160 | 160 | ||
| 161 | blade_info = kzalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL); | 161 | blade_info = kcalloc(uv_possible_blades, sizeof(void *), GFP_KERNEL); |
| 162 | if (!blade_info) | 162 | if (!blade_info) |
| 163 | return -ENOMEM; | 163 | return -ENOMEM; |
| 164 | 164 | ||
diff --git a/block/bio.c b/block/bio.c index db9a40e9a136..9710e275f230 100644 --- a/block/bio.c +++ b/block/bio.c | |||
| @@ -2091,7 +2091,8 @@ static int __init init_bio(void) | |||
| 2091 | { | 2091 | { |
| 2092 | bio_slab_max = 2; | 2092 | bio_slab_max = 2; |
| 2093 | bio_slab_nr = 0; | 2093 | bio_slab_nr = 0; |
| 2094 | bio_slabs = kzalloc(bio_slab_max * sizeof(struct bio_slab), GFP_KERNEL); | 2094 | bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab), |
| 2095 | GFP_KERNEL); | ||
| 2095 | if (!bio_slabs) | 2096 | if (!bio_slabs) |
| 2096 | panic("bio: can't allocate bios\n"); | 2097 | panic("bio: can't allocate bios\n"); |
| 2097 | 2098 | ||
diff --git a/block/blk-mq.c b/block/blk-mq.c index d2de0a719ab8..e9da5e6a8526 100644 --- a/block/blk-mq.c +++ b/block/blk-mq.c | |||
| @@ -1903,7 +1903,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, | |||
| 1903 | if (!tags) | 1903 | if (!tags) |
| 1904 | return NULL; | 1904 | return NULL; |
| 1905 | 1905 | ||
| 1906 | tags->rqs = kzalloc_node(nr_tags * sizeof(struct request *), | 1906 | tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *), |
| 1907 | GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, | 1907 | GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, |
| 1908 | node); | 1908 | node); |
| 1909 | if (!tags->rqs) { | 1909 | if (!tags->rqs) { |
| @@ -1911,9 +1911,9 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, | |||
| 1911 | return NULL; | 1911 | return NULL; |
| 1912 | } | 1912 | } |
| 1913 | 1913 | ||
| 1914 | tags->static_rqs = kzalloc_node(nr_tags * sizeof(struct request *), | 1914 | tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *), |
| 1915 | GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, | 1915 | GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY, |
| 1916 | node); | 1916 | node); |
| 1917 | if (!tags->static_rqs) { | 1917 | if (!tags->static_rqs) { |
| 1918 | kfree(tags->rqs); | 1918 | kfree(tags->rqs); |
| 1919 | blk_mq_free_tags(tags); | 1919 | blk_mq_free_tags(tags); |
| @@ -2522,7 +2522,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, | |||
| 2522 | /* init q->mq_kobj and sw queues' kobjects */ | 2522 | /* init q->mq_kobj and sw queues' kobjects */ |
| 2523 | blk_mq_sysfs_init(q); | 2523 | blk_mq_sysfs_init(q); |
| 2524 | 2524 | ||
| 2525 | q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)), | 2525 | q->queue_hw_ctx = kcalloc_node(nr_cpu_ids, sizeof(*(q->queue_hw_ctx)), |
| 2526 | GFP_KERNEL, set->numa_node); | 2526 | GFP_KERNEL, set->numa_node); |
| 2527 | if (!q->queue_hw_ctx) | 2527 | if (!q->queue_hw_ctx) |
| 2528 | goto err_percpu; | 2528 | goto err_percpu; |
| @@ -2741,14 +2741,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) | |||
| 2741 | if (set->nr_hw_queues > nr_cpu_ids) | 2741 | if (set->nr_hw_queues > nr_cpu_ids) |
| 2742 | set->nr_hw_queues = nr_cpu_ids; | 2742 | set->nr_hw_queues = nr_cpu_ids; |
| 2743 | 2743 | ||
| 2744 | set->tags = kzalloc_node(nr_cpu_ids * sizeof(struct blk_mq_tags *), | 2744 | set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *), |
| 2745 | GFP_KERNEL, set->numa_node); | 2745 | GFP_KERNEL, set->numa_node); |
| 2746 | if (!set->tags) | 2746 | if (!set->tags) |
| 2747 | return -ENOMEM; | 2747 | return -ENOMEM; |
| 2748 | 2748 | ||
| 2749 | ret = -ENOMEM; | 2749 | ret = -ENOMEM; |
| 2750 | set->mq_map = kzalloc_node(sizeof(*set->mq_map) * nr_cpu_ids, | 2750 | set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map), |
| 2751 | GFP_KERNEL, set->numa_node); | 2751 | GFP_KERNEL, set->numa_node); |
| 2752 | if (!set->mq_map) | 2752 | if (!set->mq_map) |
| 2753 | goto out_free_tags; | 2753 | goto out_free_tags; |
| 2754 | 2754 | ||
diff --git a/block/blk-tag.c b/block/blk-tag.c index 09f19c6c52ce..24b20d86bcbc 100644 --- a/block/blk-tag.c +++ b/block/blk-tag.c | |||
| @@ -99,12 +99,12 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth) | |||
| 99 | __func__, depth); | 99 | __func__, depth); |
| 100 | } | 100 | } |
| 101 | 101 | ||
| 102 | tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC); | 102 | tag_index = kcalloc(depth, sizeof(struct request *), GFP_ATOMIC); |
| 103 | if (!tag_index) | 103 | if (!tag_index) |
| 104 | goto fail; | 104 | goto fail; |
| 105 | 105 | ||
| 106 | nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG; | 106 | nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG; |
| 107 | tag_map = kzalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC); | 107 | tag_map = kcalloc(nr_ulongs, sizeof(unsigned long), GFP_ATOMIC); |
| 108 | if (!tag_map) | 108 | if (!tag_map) |
| 109 | goto fail; | 109 | goto fail; |
| 110 | 110 | ||
diff --git a/block/blk-zoned.c b/block/blk-zoned.c index 3d08dc84db16..51000914e23f 100644 --- a/block/blk-zoned.c +++ b/block/blk-zoned.c | |||
| @@ -331,8 +331,8 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, | |||
| 331 | if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) | 331 | if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone)) |
| 332 | return -ERANGE; | 332 | return -ERANGE; |
| 333 | 333 | ||
| 334 | zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone), | 334 | zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone), |
| 335 | GFP_KERNEL | __GFP_ZERO); | 335 | GFP_KERNEL | __GFP_ZERO); |
| 336 | if (!zones) | 336 | if (!zones) |
| 337 | return -ENOMEM; | 337 | return -ENOMEM; |
| 338 | 338 | ||
diff --git a/block/partitions/check.c b/block/partitions/check.c index 720145c49066..ffe408fead0c 100644 --- a/block/partitions/check.c +++ b/block/partitions/check.c | |||
| @@ -122,7 +122,7 @@ static struct parsed_partitions *allocate_partitions(struct gendisk *hd) | |||
| 122 | return NULL; | 122 | return NULL; |
| 123 | 123 | ||
| 124 | nr = disk_max_parts(hd); | 124 | nr = disk_max_parts(hd); |
| 125 | state->parts = vzalloc(nr * sizeof(state->parts[0])); | 125 | state->parts = vzalloc(array_size(nr, sizeof(state->parts[0]))); |
| 126 | if (!state->parts) { | 126 | if (!state->parts) { |
| 127 | kfree(state); | 127 | kfree(state); |
| 128 | return NULL; | 128 | return NULL; |
diff --git a/block/partitions/ldm.c b/block/partitions/ldm.c index 2a365c756648..0417937dfe99 100644 --- a/block/partitions/ldm.c +++ b/block/partitions/ldm.c | |||
| @@ -378,7 +378,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state, | |||
| 378 | BUG_ON(!state || !ldb); | 378 | BUG_ON(!state || !ldb); |
| 379 | ph = &ldb->ph; | 379 | ph = &ldb->ph; |
| 380 | tb[0] = &ldb->toc; | 380 | tb[0] = &ldb->toc; |
| 381 | tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL); | 381 | tb[1] = kmalloc_array(3, sizeof(*tb[1]), GFP_KERNEL); |
| 382 | if (!tb[1]) { | 382 | if (!tb[1]) { |
| 383 | ldm_crit("Out of memory."); | 383 | ldm_crit("Out of memory."); |
| 384 | goto err; | 384 | goto err; |
diff --git a/crypto/algif_aead.c b/crypto/algif_aead.c index 330cf9f2b767..825524f27438 100644 --- a/crypto/algif_aead.c +++ b/crypto/algif_aead.c | |||
| @@ -255,8 +255,8 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 255 | processed - as); | 255 | processed - as); |
| 256 | if (!areq->tsgl_entries) | 256 | if (!areq->tsgl_entries) |
| 257 | areq->tsgl_entries = 1; | 257 | areq->tsgl_entries = 1; |
| 258 | areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * | 258 | areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl), |
| 259 | areq->tsgl_entries, | 259 | areq->tsgl_entries), |
| 260 | GFP_KERNEL); | 260 | GFP_KERNEL); |
| 261 | if (!areq->tsgl) { | 261 | if (!areq->tsgl) { |
| 262 | err = -ENOMEM; | 262 | err = -ENOMEM; |
diff --git a/crypto/algif_skcipher.c b/crypto/algif_skcipher.c index 15cf3c5222e0..4c04eb9888ad 100644 --- a/crypto/algif_skcipher.c +++ b/crypto/algif_skcipher.c | |||
| @@ -100,7 +100,8 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, | |||
| 100 | areq->tsgl_entries = af_alg_count_tsgl(sk, len, 0); | 100 | areq->tsgl_entries = af_alg_count_tsgl(sk, len, 0); |
| 101 | if (!areq->tsgl_entries) | 101 | if (!areq->tsgl_entries) |
| 102 | areq->tsgl_entries = 1; | 102 | areq->tsgl_entries = 1; |
| 103 | areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * areq->tsgl_entries, | 103 | areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl), |
| 104 | areq->tsgl_entries), | ||
| 104 | GFP_KERNEL); | 105 | GFP_KERNEL); |
| 105 | if (!areq->tsgl) { | 106 | if (!areq->tsgl) { |
| 106 | err = -ENOMEM; | 107 | err = -ENOMEM; |
diff --git a/crypto/testmgr.c b/crypto/testmgr.c index d1d99843cce4..11e45352fd0b 100644 --- a/crypto/testmgr.c +++ b/crypto/testmgr.c | |||
| @@ -603,7 +603,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, | |||
| 603 | goto out_nooutbuf; | 603 | goto out_nooutbuf; |
| 604 | 604 | ||
| 605 | /* avoid "the frame size is larger than 1024 bytes" compiler warning */ | 605 | /* avoid "the frame size is larger than 1024 bytes" compiler warning */ |
| 606 | sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 4 : 2), GFP_KERNEL); | 606 | sg = kmalloc(array3_size(sizeof(*sg), 8, (diff_dst ? 4 : 2)), |
| 607 | GFP_KERNEL); | ||
| 607 | if (!sg) | 608 | if (!sg) |
| 608 | goto out_nosg; | 609 | goto out_nosg; |
| 609 | sgout = &sg[16]; | 610 | sgout = &sg[16]; |
diff --git a/drivers/acpi/acpi_platform.c b/drivers/acpi/acpi_platform.c index 88cd949003f3..eaa60c94205a 100644 --- a/drivers/acpi/acpi_platform.c +++ b/drivers/acpi/acpi_platform.c | |||
| @@ -82,7 +82,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, | |||
| 82 | if (count < 0) { | 82 | if (count < 0) { |
| 83 | return NULL; | 83 | return NULL; |
| 84 | } else if (count > 0) { | 84 | } else if (count > 0) { |
| 85 | resources = kzalloc(count * sizeof(struct resource), | 85 | resources = kcalloc(count, sizeof(struct resource), |
| 86 | GFP_KERNEL); | 86 | GFP_KERNEL); |
| 87 | if (!resources) { | 87 | if (!resources) { |
| 88 | dev_err(&adev->dev, "No memory for resources\n"); | 88 | dev_err(&adev->dev, "No memory for resources\n"); |
diff --git a/drivers/acpi/acpi_video.c b/drivers/acpi/acpi_video.c index 2f2e737be0f8..f0b52266b3ac 100644 --- a/drivers/acpi/acpi_video.c +++ b/drivers/acpi/acpi_video.c | |||
| @@ -832,8 +832,9 @@ int acpi_video_get_levels(struct acpi_device *device, | |||
| 832 | * in order to account for buggy BIOS which don't export the first two | 832 | * in order to account for buggy BIOS which don't export the first two |
| 833 | * special levels (see below) | 833 | * special levels (see below) |
| 834 | */ | 834 | */ |
| 835 | br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) * | 835 | br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL, |
| 836 | sizeof(*br->levels), GFP_KERNEL); | 836 | sizeof(*br->levels), |
| 837 | GFP_KERNEL); | ||
| 837 | if (!br->levels) { | 838 | if (!br->levels) { |
| 838 | result = -ENOMEM; | 839 | result = -ENOMEM; |
| 839 | goto out_free; | 840 | goto out_free; |
diff --git a/drivers/acpi/apei/erst.c b/drivers/acpi/apei/erst.c index 9bff853e85f3..3c5ea7cb693e 100644 --- a/drivers/acpi/apei/erst.c +++ b/drivers/acpi/apei/erst.c | |||
| @@ -524,7 +524,8 @@ retry: | |||
| 524 | pr_warn(FW_WARN "too many record IDs!\n"); | 524 | pr_warn(FW_WARN "too many record IDs!\n"); |
| 525 | return 0; | 525 | return 0; |
| 526 | } | 526 | } |
| 527 | new_entries = kvmalloc(new_size * sizeof(entries[0]), GFP_KERNEL); | 527 | new_entries = kvmalloc_array(new_size, sizeof(entries[0]), |
| 528 | GFP_KERNEL); | ||
| 528 | if (!new_entries) | 529 | if (!new_entries) |
| 529 | return -ENOMEM; | 530 | return -ENOMEM; |
| 530 | memcpy(new_entries, entries, | 531 | memcpy(new_entries, entries, |
diff --git a/drivers/acpi/apei/hest.c b/drivers/acpi/apei/hest.c index 9cb74115a43d..b1e9f81ebeea 100644 --- a/drivers/acpi/apei/hest.c +++ b/drivers/acpi/apei/hest.c | |||
| @@ -195,7 +195,8 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count) | |||
| 195 | struct ghes_arr ghes_arr; | 195 | struct ghes_arr ghes_arr; |
| 196 | 196 | ||
| 197 | ghes_arr.count = 0; | 197 | ghes_arr.count = 0; |
| 198 | ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL); | 198 | ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *), |
| 199 | GFP_KERNEL); | ||
| 199 | if (!ghes_arr.ghes_devs) | 200 | if (!ghes_arr.ghes_devs) |
| 200 | return -ENOMEM; | 201 | return -ENOMEM; |
| 201 | 202 | ||
diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 3563103590c6..fe0183d48dcd 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c | |||
| @@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device) | |||
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | fan->fps_count = obj->package.count - 1; /* minus revision field */ | 300 | fan->fps_count = obj->package.count - 1; /* minus revision field */ |
| 301 | fan->fps = devm_kzalloc(&device->dev, | 301 | fan->fps = devm_kcalloc(&device->dev, |
| 302 | fan->fps_count * sizeof(struct acpi_fan_fps), | 302 | fan->fps_count, sizeof(struct acpi_fan_fps), |
| 303 | GFP_KERNEL); | 303 | GFP_KERNEL); |
| 304 | if (!fan->fps) { | 304 | if (!fan->fps) { |
| 305 | dev_err(&device->dev, "Not enough memory\n"); | 305 | dev_err(&device->dev, "Not enough memory\n"); |
diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index b87252bf4571..d15814e1727f 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c | |||
| @@ -1082,9 +1082,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc, | |||
| 1082 | continue; | 1082 | continue; |
| 1083 | nfit_mem->nfit_flush = nfit_flush; | 1083 | nfit_mem->nfit_flush = nfit_flush; |
| 1084 | flush = nfit_flush->flush; | 1084 | flush = nfit_flush->flush; |
| 1085 | nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev, | 1085 | nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev, |
| 1086 | flush->hint_count | 1086 | flush->hint_count, |
| 1087 | * sizeof(struct resource), GFP_KERNEL); | 1087 | sizeof(struct resource), |
| 1088 | GFP_KERNEL); | ||
| 1088 | if (!nfit_mem->flush_wpq) | 1089 | if (!nfit_mem->flush_wpq) |
| 1089 | return -ENOMEM; | 1090 | return -ENOMEM; |
| 1090 | for (i = 0; i < flush->hint_count; i++) { | 1091 | for (i = 0; i < flush->hint_count; i++) { |
diff --git a/drivers/acpi/processor_perflib.c b/drivers/acpi/processor_perflib.c index a651ab3490d8..a303fd0e108c 100644 --- a/drivers/acpi/processor_perflib.c +++ b/drivers/acpi/processor_perflib.c | |||
| @@ -343,8 +343,9 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) | |||
| 343 | 343 | ||
| 344 | pr->performance->state_count = pss->package.count; | 344 | pr->performance->state_count = pss->package.count; |
| 345 | pr->performance->states = | 345 | pr->performance->states = |
| 346 | kmalloc(sizeof(struct acpi_processor_px) * pss->package.count, | 346 | kmalloc_array(pss->package.count, |
| 347 | GFP_KERNEL); | 347 | sizeof(struct acpi_processor_px), |
| 348 | GFP_KERNEL); | ||
| 348 | if (!pr->performance->states) { | 349 | if (!pr->performance->states) { |
| 349 | result = -ENOMEM; | 350 | result = -ENOMEM; |
| 350 | goto end; | 351 | goto end; |
diff --git a/drivers/acpi/processor_throttling.c b/drivers/acpi/processor_throttling.c index 7f9aff4b8d62..fbc936cf2025 100644 --- a/drivers/acpi/processor_throttling.c +++ b/drivers/acpi/processor_throttling.c | |||
| @@ -534,8 +534,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr) | |||
| 534 | 534 | ||
| 535 | pr->throttling.state_count = tss->package.count; | 535 | pr->throttling.state_count = tss->package.count; |
| 536 | pr->throttling.states_tss = | 536 | pr->throttling.states_tss = |
| 537 | kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count, | 537 | kmalloc_array(tss->package.count, |
| 538 | GFP_KERNEL); | 538 | sizeof(struct acpi_processor_tx_tss), |
| 539 | GFP_KERNEL); | ||
| 539 | if (!pr->throttling.states_tss) { | 540 | if (!pr->throttling.states_tss) { |
| 540 | result = -ENOMEM; | 541 | result = -ENOMEM; |
| 541 | goto end; | 542 | goto end; |
diff --git a/drivers/acpi/sysfs.c b/drivers/acpi/sysfs.c index 4fc59c3bc673..41324f0b1bee 100644 --- a/drivers/acpi/sysfs.c +++ b/drivers/acpi/sysfs.c | |||
| @@ -857,12 +857,12 @@ void acpi_irq_stats_init(void) | |||
| 857 | num_gpes = acpi_current_gpe_count; | 857 | num_gpes = acpi_current_gpe_count; |
| 858 | num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; | 858 | num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA; |
| 859 | 859 | ||
| 860 | all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1), | 860 | all_attrs = kcalloc(num_counters + 1, sizeof(struct attribute *), |
| 861 | GFP_KERNEL); | 861 | GFP_KERNEL); |
| 862 | if (all_attrs == NULL) | 862 | if (all_attrs == NULL) |
| 863 | return; | 863 | return; |
| 864 | 864 | ||
| 865 | all_counters = kzalloc(sizeof(struct event_counter) * (num_counters), | 865 | all_counters = kcalloc(num_counters, sizeof(struct event_counter), |
| 866 | GFP_KERNEL); | 866 | GFP_KERNEL); |
| 867 | if (all_counters == NULL) | 867 | if (all_counters == NULL) |
| 868 | goto fail; | 868 | goto fail; |
| @@ -871,7 +871,7 @@ void acpi_irq_stats_init(void) | |||
| 871 | if (ACPI_FAILURE(status)) | 871 | if (ACPI_FAILURE(status)) |
| 872 | goto fail; | 872 | goto fail; |
| 873 | 873 | ||
| 874 | counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters), | 874 | counter_attrs = kcalloc(num_counters, sizeof(struct kobj_attribute), |
| 875 | GFP_KERNEL); | 875 | GFP_KERNEL); |
| 876 | if (counter_attrs == NULL) | 876 | if (counter_attrs == NULL) |
| 877 | goto fail; | 877 | goto fail; |
diff --git a/drivers/android/binder_alloc.c b/drivers/android/binder_alloc.c index 4f382d51def1..2628806c64a2 100644 --- a/drivers/android/binder_alloc.c +++ b/drivers/android/binder_alloc.c | |||
| @@ -692,8 +692,8 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc, | |||
| 692 | } | 692 | } |
| 693 | } | 693 | } |
| 694 | #endif | 694 | #endif |
| 695 | alloc->pages = kzalloc(sizeof(alloc->pages[0]) * | 695 | alloc->pages = kcalloc((vma->vm_end - vma->vm_start) / PAGE_SIZE, |
| 696 | ((vma->vm_end - vma->vm_start) / PAGE_SIZE), | 696 | sizeof(alloc->pages[0]), |
| 697 | GFP_KERNEL); | 697 | GFP_KERNEL); |
| 698 | if (alloc->pages == NULL) { | 698 | if (alloc->pages == NULL) { |
| 699 | ret = -ENOMEM; | 699 | ret = -ENOMEM; |
diff --git a/drivers/ata/libata-core.c b/drivers/ata/libata-core.c index c41b9eeabe7c..27d15ed7fa3d 100644 --- a/drivers/ata/libata-core.c +++ b/drivers/ata/libata-core.c | |||
| @@ -6987,7 +6987,7 @@ static void __init ata_parse_force_param(void) | |||
| 6987 | if (*p == ',') | 6987 | if (*p == ',') |
| 6988 | size++; | 6988 | size++; |
| 6989 | 6989 | ||
| 6990 | ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL); | 6990 | ata_force_tbl = kcalloc(size, sizeof(ata_force_tbl[0]), GFP_KERNEL); |
| 6991 | if (!ata_force_tbl) { | 6991 | if (!ata_force_tbl) { |
| 6992 | printk(KERN_WARNING "ata: failed to extend force table, " | 6992 | printk(KERN_WARNING "ata: failed to extend force table, " |
| 6993 | "libata.force ignored\n"); | 6993 | "libata.force ignored\n"); |
diff --git a/drivers/ata/libata-pmp.c b/drivers/ata/libata-pmp.c index 85aa76116a30..2ae1799f4992 100644 --- a/drivers/ata/libata-pmp.c +++ b/drivers/ata/libata-pmp.c | |||
| @@ -340,7 +340,7 @@ static int sata_pmp_init_links (struct ata_port *ap, int nr_ports) | |||
| 340 | int i, err; | 340 | int i, err; |
| 341 | 341 | ||
| 342 | if (!pmp_link) { | 342 | if (!pmp_link) { |
| 343 | pmp_link = kzalloc(sizeof(pmp_link[0]) * SATA_PMP_MAX_PORTS, | 343 | pmp_link = kcalloc(SATA_PMP_MAX_PORTS, sizeof(pmp_link[0]), |
| 344 | GFP_NOIO); | 344 | GFP_NOIO); |
| 345 | if (!pmp_link) | 345 | if (!pmp_link) |
| 346 | return -ENOMEM; | 346 | return -ENOMEM; |
diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index cddf96f6e431..73ba8e134ca9 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c | |||
| @@ -4114,13 +4114,13 @@ static int mv_platform_probe(struct platform_device *pdev) | |||
| 4114 | 4114 | ||
| 4115 | if (!host || !hpriv) | 4115 | if (!host || !hpriv) |
| 4116 | return -ENOMEM; | 4116 | return -ENOMEM; |
| 4117 | hpriv->port_clks = devm_kzalloc(&pdev->dev, | 4117 | hpriv->port_clks = devm_kcalloc(&pdev->dev, |
| 4118 | sizeof(struct clk *) * n_ports, | 4118 | n_ports, sizeof(struct clk *), |
| 4119 | GFP_KERNEL); | 4119 | GFP_KERNEL); |
| 4120 | if (!hpriv->port_clks) | 4120 | if (!hpriv->port_clks) |
| 4121 | return -ENOMEM; | 4121 | return -ENOMEM; |
| 4122 | hpriv->port_phys = devm_kzalloc(&pdev->dev, | 4122 | hpriv->port_phys = devm_kcalloc(&pdev->dev, |
| 4123 | sizeof(struct phy *) * n_ports, | 4123 | n_ports, sizeof(struct phy *), |
| 4124 | GFP_KERNEL); | 4124 | GFP_KERNEL); |
| 4125 | if (!hpriv->port_phys) | 4125 | if (!hpriv->port_phys) |
| 4126 | return -ENOMEM; | 4126 | return -ENOMEM; |
diff --git a/drivers/atm/fore200e.c b/drivers/atm/fore200e.c index 6ebc4e4820fc..99a38115b0a8 100644 --- a/drivers/atm/fore200e.c +++ b/drivers/atm/fore200e.c | |||
| @@ -2094,7 +2094,8 @@ static int fore200e_alloc_rx_buf(struct fore200e *fore200e) | |||
| 2094 | DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn); | 2094 | DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn); |
| 2095 | 2095 | ||
| 2096 | /* allocate the array of receive buffers */ | 2096 | /* allocate the array of receive buffers */ |
| 2097 | buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL); | 2097 | buffer = bsq->buffer = kcalloc(nbr, sizeof(struct buffer), |
| 2098 | GFP_KERNEL); | ||
| 2098 | 2099 | ||
| 2099 | if (buffer == NULL) | 2100 | if (buffer == NULL) |
| 2100 | return -ENOMEM; | 2101 | return -ENOMEM; |
diff --git a/drivers/atm/iphase.c b/drivers/atm/iphase.c index be076606d30e..ff81a576347e 100644 --- a/drivers/atm/iphase.c +++ b/drivers/atm/iphase.c | |||
| @@ -1618,7 +1618,7 @@ static int rx_init(struct atm_dev *dev) | |||
| 1618 | skb_queue_head_init(&iadev->rx_dma_q); | 1618 | skb_queue_head_init(&iadev->rx_dma_q); |
| 1619 | iadev->rx_free_desc_qhead = NULL; | 1619 | iadev->rx_free_desc_qhead = NULL; |
| 1620 | 1620 | ||
| 1621 | iadev->rx_open = kzalloc(4 * iadev->num_vc, GFP_KERNEL); | 1621 | iadev->rx_open = kcalloc(4, iadev->num_vc, GFP_KERNEL); |
| 1622 | if (!iadev->rx_open) { | 1622 | if (!iadev->rx_open) { |
| 1623 | printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n", | 1623 | printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n", |
| 1624 | dev->number); | 1624 | dev->number); |
diff --git a/drivers/atm/solos-pci.c b/drivers/atm/solos-pci.c index 0df1a1c80b00..17283018269f 100644 --- a/drivers/atm/solos-pci.c +++ b/drivers/atm/solos-pci.c | |||
| @@ -1291,7 +1291,8 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 1291 | card->using_dma = 1; | 1291 | card->using_dma = 1; |
| 1292 | if (1) { /* All known FPGA versions so far */ | 1292 | if (1) { /* All known FPGA versions so far */ |
| 1293 | card->dma_alignment = 3; | 1293 | card->dma_alignment = 3; |
| 1294 | card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL); | 1294 | card->dma_bounce = kmalloc_array(card->nr_ports, |
| 1295 | BUF_SIZE, GFP_KERNEL); | ||
| 1295 | if (!card->dma_bounce) { | 1296 | if (!card->dma_bounce) { |
| 1296 | dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n"); | 1297 | dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n"); |
| 1297 | err = -ENOMEM; | 1298 | err = -ENOMEM; |
diff --git a/drivers/auxdisplay/cfag12864b.c b/drivers/auxdisplay/cfag12864b.c index 6bd2f65e116a..7eebae7e322c 100644 --- a/drivers/auxdisplay/cfag12864b.c +++ b/drivers/auxdisplay/cfag12864b.c | |||
| @@ -333,8 +333,8 @@ static int __init cfag12864b_init(void) | |||
| 333 | goto none; | 333 | goto none; |
| 334 | } | 334 | } |
| 335 | 335 | ||
| 336 | cfag12864b_cache = kmalloc(sizeof(unsigned char) * | 336 | cfag12864b_cache = kmalloc(CFAG12864B_SIZE, |
| 337 | CFAG12864B_SIZE, GFP_KERNEL); | 337 | GFP_KERNEL); |
| 338 | if (cfag12864b_cache == NULL) { | 338 | if (cfag12864b_cache == NULL) { |
| 339 | printk(KERN_ERR CFAG12864B_NAME ": ERROR: " | 339 | printk(KERN_ERR CFAG12864B_NAME ": ERROR: " |
| 340 | "can't alloc cache buffer (%i bytes)\n", | 340 | "can't alloc cache buffer (%i bytes)\n", |
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c index b676a99c469c..7f732744f0d3 100644 --- a/drivers/base/firmware_loader/fallback.c +++ b/drivers/base/firmware_loader/fallback.c | |||
| @@ -403,7 +403,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size) | |||
| 403 | fw_priv->page_array_size * 2); | 403 | fw_priv->page_array_size * 2); |
| 404 | struct page **new_pages; | 404 | struct page **new_pages; |
| 405 | 405 | ||
| 406 | new_pages = vmalloc(new_array_size * sizeof(void *)); | 406 | new_pages = vmalloc(array_size(new_array_size, sizeof(void *))); |
| 407 | if (!new_pages) { | 407 | if (!new_pages) { |
| 408 | fw_load_abort(fw_sysfs); | 408 | fw_load_abort(fw_sysfs); |
| 409 | return -ENOMEM; | 409 | return -ENOMEM; |
diff --git a/drivers/block/DAC960.c b/drivers/block/DAC960.c index 6ca77d6047d6..f6518067aa7d 100644 --- a/drivers/block/DAC960.c +++ b/drivers/block/DAC960.c | |||
| @@ -5719,8 +5719,8 @@ static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller, | |||
| 5719 | Controller->CombinedStatusBufferLength = NewStatusBufferLength; | 5719 | Controller->CombinedStatusBufferLength = NewStatusBufferLength; |
| 5720 | return true; | 5720 | return true; |
| 5721 | } | 5721 | } |
| 5722 | NewStatusBuffer = kmalloc(2 * Controller->CombinedStatusBufferLength, | 5722 | NewStatusBuffer = kmalloc_array(2, Controller->CombinedStatusBufferLength, |
| 5723 | GFP_ATOMIC); | 5723 | GFP_ATOMIC); |
| 5724 | if (NewStatusBuffer == NULL) | 5724 | if (NewStatusBuffer == NULL) |
| 5725 | { | 5725 | { |
| 5726 | DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n", | 5726 | DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n", |
diff --git a/drivers/block/drbd/drbd_main.c b/drivers/block/drbd/drbd_main.c index 7655d6133139..a80809bd3057 100644 --- a/drivers/block/drbd/drbd_main.c +++ b/drivers/block/drbd/drbd_main.c | |||
| @@ -511,7 +511,8 @@ static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask) | |||
| 511 | { | 511 | { |
| 512 | unsigned int *resources_per_cpu, min_index = ~0; | 512 | unsigned int *resources_per_cpu, min_index = ~0; |
| 513 | 513 | ||
| 514 | resources_per_cpu = kzalloc(nr_cpu_ids * sizeof(*resources_per_cpu), GFP_KERNEL); | 514 | resources_per_cpu = kcalloc(nr_cpu_ids, sizeof(*resources_per_cpu), |
| 515 | GFP_KERNEL); | ||
| 515 | if (resources_per_cpu) { | 516 | if (resources_per_cpu) { |
| 516 | struct drbd_resource *resource; | 517 | struct drbd_resource *resource; |
| 517 | unsigned int cpu, min = ~0; | 518 | unsigned int cpu, min = ~0; |
diff --git a/drivers/block/loop.c b/drivers/block/loop.c index 21e6d1b3b393..d6b6f434fd4b 100644 --- a/drivers/block/loop.c +++ b/drivers/block/loop.c | |||
| @@ -524,7 +524,8 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, | |||
| 524 | 524 | ||
| 525 | __rq_for_each_bio(bio, rq) | 525 | __rq_for_each_bio(bio, rq) |
| 526 | segments += bio_segments(bio); | 526 | segments += bio_segments(bio); |
| 527 | bvec = kmalloc(sizeof(struct bio_vec) * segments, GFP_NOIO); | 527 | bvec = kmalloc_array(segments, sizeof(struct bio_vec), |
| 528 | GFP_NOIO); | ||
| 528 | if (!bvec) | 529 | if (!bvec) |
| 529 | return -EIO; | 530 | return -EIO; |
| 530 | cmd->bvec = bvec; | 531 | cmd->bvec = bvec; |
diff --git a/drivers/block/null_blk.c b/drivers/block/null_blk.c index 2bdadd7f1454..7948049f6c43 100644 --- a/drivers/block/null_blk.c +++ b/drivers/block/null_blk.c | |||
| @@ -1575,12 +1575,12 @@ static int setup_commands(struct nullb_queue *nq) | |||
| 1575 | struct nullb_cmd *cmd; | 1575 | struct nullb_cmd *cmd; |
| 1576 | int i, tag_size; | 1576 | int i, tag_size; |
| 1577 | 1577 | ||
| 1578 | nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL); | 1578 | nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL); |
| 1579 | if (!nq->cmds) | 1579 | if (!nq->cmds) |
| 1580 | return -ENOMEM; | 1580 | return -ENOMEM; |
| 1581 | 1581 | ||
| 1582 | tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; | 1582 | tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG; |
| 1583 | nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL); | 1583 | nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL); |
| 1584 | if (!nq->tag_map) { | 1584 | if (!nq->tag_map) { |
| 1585 | kfree(nq->cmds); | 1585 | kfree(nq->cmds); |
| 1586 | return -ENOMEM; | 1586 | return -ENOMEM; |
| @@ -1598,8 +1598,9 @@ static int setup_commands(struct nullb_queue *nq) | |||
| 1598 | 1598 | ||
| 1599 | static int setup_queues(struct nullb *nullb) | 1599 | static int setup_queues(struct nullb *nullb) |
| 1600 | { | 1600 | { |
| 1601 | nullb->queues = kzalloc(nullb->dev->submit_queues * | 1601 | nullb->queues = kcalloc(nullb->dev->submit_queues, |
| 1602 | sizeof(struct nullb_queue), GFP_KERNEL); | 1602 | sizeof(struct nullb_queue), |
| 1603 | GFP_KERNEL); | ||
| 1603 | if (!nullb->queues) | 1604 | if (!nullb->queues) |
| 1604 | return -ENOMEM; | 1605 | return -ENOMEM; |
| 1605 | 1606 | ||
diff --git a/drivers/block/ps3vram.c b/drivers/block/ps3vram.c index 8fa4533a1249..1e3d5de9d838 100644 --- a/drivers/block/ps3vram.c +++ b/drivers/block/ps3vram.c | |||
| @@ -407,8 +407,9 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev) | |||
| 407 | 407 | ||
| 408 | priv->cache.page_count = CACHE_PAGE_COUNT; | 408 | priv->cache.page_count = CACHE_PAGE_COUNT; |
| 409 | priv->cache.page_size = CACHE_PAGE_SIZE; | 409 | priv->cache.page_size = CACHE_PAGE_SIZE; |
| 410 | priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) * | 410 | priv->cache.tags = kcalloc(CACHE_PAGE_COUNT, |
| 411 | CACHE_PAGE_COUNT, GFP_KERNEL); | 411 | sizeof(struct ps3vram_tag), |
| 412 | GFP_KERNEL); | ||
| 412 | if (!priv->cache.tags) | 413 | if (!priv->cache.tags) |
| 413 | return -ENOMEM; | 414 | return -ENOMEM; |
| 414 | 415 | ||
diff --git a/drivers/block/rsxx/core.c b/drivers/block/rsxx/core.c index 09537bee387f..b7d71914a32a 100644 --- a/drivers/block/rsxx/core.c +++ b/drivers/block/rsxx/core.c | |||
| @@ -873,7 +873,8 @@ static int rsxx_pci_probe(struct pci_dev *dev, | |||
| 873 | dev_info(CARD_TO_DEV(card), | 873 | dev_info(CARD_TO_DEV(card), |
| 874 | "Failed reading the number of DMA targets\n"); | 874 | "Failed reading the number of DMA targets\n"); |
| 875 | 875 | ||
| 876 | card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL); | 876 | card->ctrl = kcalloc(card->n_targets, sizeof(*card->ctrl), |
| 877 | GFP_KERNEL); | ||
| 877 | if (!card->ctrl) { | 878 | if (!card->ctrl) { |
| 878 | st = -ENOMEM; | 879 | st = -ENOMEM; |
| 879 | goto failed_dma_setup; | 880 | goto failed_dma_setup; |
diff --git a/drivers/block/rsxx/dma.c b/drivers/block/rsxx/dma.c index beaccf197a5a..8fbc1bf6db3d 100644 --- a/drivers/block/rsxx/dma.c +++ b/drivers/block/rsxx/dma.c | |||
| @@ -1038,7 +1038,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card) | |||
| 1038 | struct rsxx_dma *dma; | 1038 | struct rsxx_dma *dma; |
| 1039 | struct list_head *issued_dmas; | 1039 | struct list_head *issued_dmas; |
| 1040 | 1040 | ||
| 1041 | issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets, | 1041 | issued_dmas = kcalloc(card->n_targets, sizeof(*issued_dmas), |
| 1042 | GFP_KERNEL); | 1042 | GFP_KERNEL); |
| 1043 | if (!issued_dmas) | 1043 | if (!issued_dmas) |
| 1044 | return -ENOMEM; | 1044 | return -ENOMEM; |
diff --git a/drivers/block/xen-blkback/xenbus.c b/drivers/block/xen-blkback/xenbus.c index 66412eededda..a4bc74e72c39 100644 --- a/drivers/block/xen-blkback/xenbus.c +++ b/drivers/block/xen-blkback/xenbus.c | |||
| @@ -139,7 +139,8 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif) | |||
| 139 | { | 139 | { |
| 140 | unsigned int r; | 140 | unsigned int r; |
| 141 | 141 | ||
| 142 | blkif->rings = kzalloc(blkif->nr_rings * sizeof(struct xen_blkif_ring), GFP_KERNEL); | 142 | blkif->rings = kcalloc(blkif->nr_rings, sizeof(struct xen_blkif_ring), |
| 143 | GFP_KERNEL); | ||
| 143 | if (!blkif->rings) | 144 | if (!blkif->rings) |
| 144 | return -ENOMEM; | 145 | return -ENOMEM; |
| 145 | 146 | ||
diff --git a/drivers/block/xen-blkfront.c b/drivers/block/xen-blkfront.c index ae00a82f350b..b5cedccb5d7d 100644 --- a/drivers/block/xen-blkfront.c +++ b/drivers/block/xen-blkfront.c | |||
| @@ -1906,7 +1906,9 @@ static int negotiate_mq(struct blkfront_info *info) | |||
| 1906 | if (!info->nr_rings) | 1906 | if (!info->nr_rings) |
| 1907 | info->nr_rings = 1; | 1907 | info->nr_rings = 1; |
| 1908 | 1908 | ||
| 1909 | info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL); | 1909 | info->rinfo = kcalloc(info->nr_rings, |
| 1910 | sizeof(struct blkfront_ring_info), | ||
| 1911 | GFP_KERNEL); | ||
| 1910 | if (!info->rinfo) { | 1912 | if (!info->rinfo) { |
| 1911 | xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure"); | 1913 | xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure"); |
| 1912 | return -ENOMEM; | 1914 | return -ENOMEM; |
| @@ -2216,15 +2218,18 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) | |||
| 2216 | } | 2218 | } |
| 2217 | 2219 | ||
| 2218 | for (i = 0; i < BLK_RING_SIZE(info); i++) { | 2220 | for (i = 0; i < BLK_RING_SIZE(info); i++) { |
| 2219 | rinfo->shadow[i].grants_used = kzalloc( | 2221 | rinfo->shadow[i].grants_used = |
| 2220 | sizeof(rinfo->shadow[i].grants_used[0]) * grants, | 2222 | kcalloc(grants, |
| 2221 | GFP_NOIO); | 2223 | sizeof(rinfo->shadow[i].grants_used[0]), |
| 2222 | rinfo->shadow[i].sg = kzalloc(sizeof(rinfo->shadow[i].sg[0]) * psegs, GFP_NOIO); | ||
| 2223 | if (info->max_indirect_segments) | ||
| 2224 | rinfo->shadow[i].indirect_grants = kzalloc( | ||
| 2225 | sizeof(rinfo->shadow[i].indirect_grants[0]) * | ||
| 2226 | INDIRECT_GREFS(grants), | ||
| 2227 | GFP_NOIO); | 2224 | GFP_NOIO); |
| 2225 | rinfo->shadow[i].sg = kcalloc(psegs, | ||
| 2226 | sizeof(rinfo->shadow[i].sg[0]), | ||
| 2227 | GFP_NOIO); | ||
| 2228 | if (info->max_indirect_segments) | ||
| 2229 | rinfo->shadow[i].indirect_grants = | ||
| 2230 | kcalloc(INDIRECT_GREFS(grants), | ||
| 2231 | sizeof(rinfo->shadow[i].indirect_grants[0]), | ||
| 2232 | GFP_NOIO); | ||
| 2228 | if ((rinfo->shadow[i].grants_used == NULL) || | 2233 | if ((rinfo->shadow[i].grants_used == NULL) || |
| 2229 | (rinfo->shadow[i].sg == NULL) || | 2234 | (rinfo->shadow[i].sg == NULL) || |
| 2230 | (info->max_indirect_segments && | 2235 | (info->max_indirect_segments && |
diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c index 8f9130ab5887..d0c5bc4e0703 100644 --- a/drivers/block/z2ram.c +++ b/drivers/block/z2ram.c | |||
| @@ -197,8 +197,9 @@ static int z2_open(struct block_device *bdev, fmode_t mode) | |||
| 197 | vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); | 197 | vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size); |
| 198 | #endif | 198 | #endif |
| 199 | z2ram_map = | 199 | z2ram_map = |
| 200 | kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]), | 200 | kmalloc_array(size / Z2RAM_CHUNKSIZE, |
| 201 | GFP_KERNEL); | 201 | sizeof(z2ram_map[0]), |
| 202 | GFP_KERNEL); | ||
| 202 | if ( z2ram_map == NULL ) | 203 | if ( z2ram_map == NULL ) |
| 203 | { | 204 | { |
| 204 | printk( KERN_ERR DEVICE_NAME | 205 | printk( KERN_ERR DEVICE_NAME |
diff --git a/drivers/block/zram/zram_drv.c b/drivers/block/zram/zram_drv.c index da51293e7c03..7436b2d27fa3 100644 --- a/drivers/block/zram/zram_drv.c +++ b/drivers/block/zram/zram_drv.c | |||
| @@ -898,7 +898,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize) | |||
| 898 | size_t num_pages; | 898 | size_t num_pages; |
| 899 | 899 | ||
| 900 | num_pages = disksize >> PAGE_SHIFT; | 900 | num_pages = disksize >> PAGE_SHIFT; |
| 901 | zram->table = vzalloc(num_pages * sizeof(*zram->table)); | 901 | zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table))); |
| 902 | if (!zram->table) | 902 | if (!zram->table) |
| 903 | return false; | 903 | return false; |
| 904 | 904 | ||
diff --git a/drivers/bus/fsl-mc/fsl-mc-allocator.c b/drivers/bus/fsl-mc/fsl-mc-allocator.c index fb1442b08962..e906ecfe23dd 100644 --- a/drivers/bus/fsl-mc/fsl-mc-allocator.c +++ b/drivers/bus/fsl-mc/fsl-mc-allocator.c | |||
| @@ -354,8 +354,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, | |||
| 354 | if (error < 0) | 354 | if (error < 0) |
| 355 | return error; | 355 | return error; |
| 356 | 356 | ||
| 357 | irq_resources = devm_kzalloc(&mc_bus_dev->dev, | 357 | irq_resources = devm_kcalloc(&mc_bus_dev->dev, |
| 358 | sizeof(*irq_resources) * irq_count, | 358 | irq_count, sizeof(*irq_resources), |
| 359 | GFP_KERNEL); | 359 | GFP_KERNEL); |
| 360 | if (!irq_resources) { | 360 | if (!irq_resources) { |
| 361 | error = -ENOMEM; | 361 | error = -ENOMEM; |
| @@ -455,7 +455,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev) | |||
| 455 | return -ENOSPC; | 455 | return -ENOSPC; |
| 456 | } | 456 | } |
| 457 | 457 | ||
| 458 | irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]), | 458 | irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]), |
| 459 | GFP_KERNEL); | 459 | GFP_KERNEL); |
| 460 | if (!irqs) | 460 | if (!irqs) |
| 461 | return -ENOMEM; | 461 | return -ENOMEM; |
diff --git a/drivers/cdrom/cdrom.c b/drivers/cdrom/cdrom.c index 9adc8c3eb0fa..a78b8e7085e9 100644 --- a/drivers/cdrom/cdrom.c +++ b/drivers/cdrom/cdrom.c | |||
| @@ -2132,7 +2132,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, | |||
| 2132 | */ | 2132 | */ |
| 2133 | nr = nframes; | 2133 | nr = nframes; |
| 2134 | do { | 2134 | do { |
| 2135 | cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL); | 2135 | cgc.buffer = kmalloc_array(nr, CD_FRAMESIZE_RAW, GFP_KERNEL); |
| 2136 | if (cgc.buffer) | 2136 | if (cgc.buffer) |
| 2137 | break; | 2137 | break; |
| 2138 | 2138 | ||
diff --git a/drivers/char/agp/amd-k7-agp.c b/drivers/char/agp/amd-k7-agp.c index b450544dcaf0..6914e4f0ce98 100644 --- a/drivers/char/agp/amd-k7-agp.c +++ b/drivers/char/agp/amd-k7-agp.c | |||
| @@ -85,7 +85,8 @@ static int amd_create_gatt_pages(int nr_tables) | |||
| 85 | int retval = 0; | 85 | int retval = 0; |
| 86 | int i; | 86 | int i; |
| 87 | 87 | ||
| 88 | tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL); | 88 | tables = kcalloc(nr_tables + 1, sizeof(struct amd_page_map *), |
| 89 | GFP_KERNEL); | ||
| 89 | if (tables == NULL) | 90 | if (tables == NULL) |
| 90 | return -ENOMEM; | 91 | return -ENOMEM; |
| 91 | 92 | ||
diff --git a/drivers/char/agp/ati-agp.c b/drivers/char/agp/ati-agp.c index 88b4cbee4dac..20bf5f78a362 100644 --- a/drivers/char/agp/ati-agp.c +++ b/drivers/char/agp/ati-agp.c | |||
| @@ -108,7 +108,8 @@ static int ati_create_gatt_pages(int nr_tables) | |||
| 108 | int retval = 0; | 108 | int retval = 0; |
| 109 | int i; | 109 | int i; |
| 110 | 110 | ||
| 111 | tables = kzalloc((nr_tables + 1) * sizeof(struct ati_page_map *),GFP_KERNEL); | 111 | tables = kcalloc(nr_tables + 1, sizeof(struct ati_page_map *), |
| 112 | GFP_KERNEL); | ||
| 112 | if (tables == NULL) | 113 | if (tables == NULL) |
| 113 | return -ENOMEM; | 114 | return -ENOMEM; |
| 114 | 115 | ||
diff --git a/drivers/char/agp/compat_ioctl.c b/drivers/char/agp/compat_ioctl.c index 2053f70ef66b..52ffe1706ce0 100644 --- a/drivers/char/agp/compat_ioctl.c +++ b/drivers/char/agp/compat_ioctl.c | |||
| @@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user | |||
| 98 | if (ureserve.seg_count >= 16384) | 98 | if (ureserve.seg_count >= 16384) |
| 99 | return -EINVAL; | 99 | return -EINVAL; |
| 100 | 100 | ||
| 101 | usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL); | 101 | usegment = kmalloc_array(ureserve.seg_count, |
| 102 | sizeof(*usegment), | ||
| 103 | GFP_KERNEL); | ||
| 102 | if (!usegment) | 104 | if (!usegment) |
| 103 | return -ENOMEM; | 105 | return -ENOMEM; |
| 104 | 106 | ||
| 105 | ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL); | 107 | ksegment = kmalloc_array(kreserve.seg_count, |
| 108 | sizeof(*ksegment), | ||
| 109 | GFP_KERNEL); | ||
| 106 | if (!ksegment) { | 110 | if (!ksegment) { |
| 107 | kfree(usegment); | 111 | kfree(usegment); |
| 108 | return -ENOMEM; | 112 | return -ENOMEM; |
diff --git a/drivers/char/agp/isoch.c b/drivers/char/agp/isoch.c index fc8e1bc3347d..31c374b1b91b 100644 --- a/drivers/char/agp/isoch.c +++ b/drivers/char/agp/isoch.c | |||
| @@ -93,7 +93,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge, | |||
| 93 | * We'll work with an array of isoch_data's (one for each | 93 | * We'll work with an array of isoch_data's (one for each |
| 94 | * device in dev_list) throughout this function. | 94 | * device in dev_list) throughout this function. |
| 95 | */ | 95 | */ |
| 96 | if ((master = kmalloc(ndevs * sizeof(*master), GFP_KERNEL)) == NULL) { | 96 | master = kmalloc_array(ndevs, sizeof(*master), GFP_KERNEL); |
| 97 | if (master == NULL) { | ||
| 97 | ret = -ENOMEM; | 98 | ret = -ENOMEM; |
| 98 | goto get_out; | 99 | goto get_out; |
| 99 | } | 100 | } |
diff --git a/drivers/char/agp/sgi-agp.c b/drivers/char/agp/sgi-agp.c index 3051c73bc383..e7d5bdc02d93 100644 --- a/drivers/char/agp/sgi-agp.c +++ b/drivers/char/agp/sgi-agp.c | |||
| @@ -280,9 +280,9 @@ static int agp_sgi_init(void) | |||
| 280 | else | 280 | else |
| 281 | return 0; | 281 | return 0; |
| 282 | 282 | ||
| 283 | sgi_tioca_agp_bridges = kmalloc(tioca_gart_found * | 283 | sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found, |
| 284 | sizeof(struct agp_bridge_data *), | 284 | sizeof(struct agp_bridge_data *), |
| 285 | GFP_KERNEL); | 285 | GFP_KERNEL); |
| 286 | if (!sgi_tioca_agp_bridges) | 286 | if (!sgi_tioca_agp_bridges) |
| 287 | return -ENOMEM; | 287 | return -ENOMEM; |
| 288 | 288 | ||
diff --git a/drivers/char/agp/sworks-agp.c b/drivers/char/agp/sworks-agp.c index 4dbdd3bc9bb8..7729414100ff 100644 --- a/drivers/char/agp/sworks-agp.c +++ b/drivers/char/agp/sworks-agp.c | |||
| @@ -96,7 +96,7 @@ static int serverworks_create_gatt_pages(int nr_tables) | |||
| 96 | int retval = 0; | 96 | int retval = 0; |
| 97 | int i; | 97 | int i; |
| 98 | 98 | ||
| 99 | tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *), | 99 | tables = kcalloc(nr_tables + 1, sizeof(struct serverworks_page_map *), |
| 100 | GFP_KERNEL); | 100 | GFP_KERNEL); |
| 101 | if (tables == NULL) | 101 | if (tables == NULL) |
| 102 | return -ENOMEM; | 102 | return -ENOMEM; |
diff --git a/drivers/char/agp/uninorth-agp.c b/drivers/char/agp/uninorth-agp.c index 79d8c84693a1..31fcd0430426 100644 --- a/drivers/char/agp/uninorth-agp.c +++ b/drivers/char/agp/uninorth-agp.c | |||
| @@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge) | |||
| 402 | if (table == NULL) | 402 | if (table == NULL) |
| 403 | return -ENOMEM; | 403 | return -ENOMEM; |
| 404 | 404 | ||
| 405 | uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL); | 405 | uninorth_priv.pages_arr = kmalloc_array(1 << page_order, |
| 406 | sizeof(struct page *), | ||
| 407 | GFP_KERNEL); | ||
| 406 | if (uninorth_priv.pages_arr == NULL) | 408 | if (uninorth_priv.pages_arr == NULL) |
| 407 | goto enomem; | 409 | goto enomem; |
| 408 | 410 | ||
diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 22f634eb09fd..18e4650c233b 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c | |||
| @@ -1757,7 +1757,8 @@ static unsigned short *ssif_address_list(void) | |||
| 1757 | list_for_each_entry(info, &ssif_infos, link) | 1757 | list_for_each_entry(info, &ssif_infos, link) |
| 1758 | count++; | 1758 | count++; |
| 1759 | 1759 | ||
| 1760 | address_list = kzalloc(sizeof(*address_list) * (count + 1), GFP_KERNEL); | 1760 | address_list = kcalloc(count + 1, sizeof(*address_list), |
| 1761 | GFP_KERNEL); | ||
| 1761 | if (!address_list) | 1762 | if (!address_list) |
| 1762 | return NULL; | 1763 | return NULL; |
| 1763 | 1764 | ||
diff --git a/drivers/char/raw.c b/drivers/char/raw.c index 293167c6e254..fd6eec8085b4 100644 --- a/drivers/char/raw.c +++ b/drivers/char/raw.c | |||
| @@ -321,7 +321,8 @@ static int __init raw_init(void) | |||
| 321 | max_raw_minors = MAX_RAW_MINORS; | 321 | max_raw_minors = MAX_RAW_MINORS; |
| 322 | } | 322 | } |
| 323 | 323 | ||
| 324 | raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors); | 324 | raw_devices = vzalloc(array_size(max_raw_minors, |
| 325 | sizeof(struct raw_device_data))); | ||
| 325 | if (!raw_devices) { | 326 | if (!raw_devices) { |
| 326 | printk(KERN_ERR "Not enough memory for raw device structures\n"); | 327 | printk(KERN_ERR "Not enough memory for raw device structures\n"); |
| 327 | ret = -ENOMEM; | 328 | ret = -ENOMEM; |
diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index 96c77c8e7f40..d31b09099216 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c | |||
| @@ -980,7 +980,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip) | |||
| 980 | goto out; | 980 | goto out; |
| 981 | } | 981 | } |
| 982 | 982 | ||
| 983 | chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands, | 983 | chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands, |
| 984 | GFP_KERNEL); | 984 | GFP_KERNEL); |
| 985 | 985 | ||
| 986 | rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); | 986 | rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY); |
diff --git a/drivers/char/virtio_console.c b/drivers/char/virtio_console.c index 21085515814f..17084cfcf53e 100644 --- a/drivers/char/virtio_console.c +++ b/drivers/char/virtio_console.c | |||
| @@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size | |||
| 433 | * Allocate buffer and the sg list. The sg list array is allocated | 433 | * Allocate buffer and the sg list. The sg list array is allocated |
| 434 | * directly after the port_buffer struct. | 434 | * directly after the port_buffer struct. |
| 435 | */ | 435 | */ |
| 436 | buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages, | 436 | buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL); |
| 437 | GFP_KERNEL); | ||
| 438 | if (!buf) | 437 | if (!buf) |
| 439 | goto fail; | 438 | goto fail; |
| 440 | 439 | ||
| @@ -1892,13 +1891,14 @@ static int init_vqs(struct ports_device *portdev) | |||
| 1892 | nr_ports = portdev->max_nr_ports; | 1891 | nr_ports = portdev->max_nr_ports; |
| 1893 | nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; | 1892 | nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2; |
| 1894 | 1893 | ||
| 1895 | vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL); | 1894 | vqs = kmalloc_array(nr_queues, sizeof(struct virtqueue *), GFP_KERNEL); |
| 1896 | io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL); | 1895 | io_callbacks = kmalloc_array(nr_queues, sizeof(vq_callback_t *), |
| 1897 | io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL); | 1896 | GFP_KERNEL); |
| 1898 | portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), | 1897 | io_names = kmalloc_array(nr_queues, sizeof(char *), GFP_KERNEL); |
| 1899 | GFP_KERNEL); | 1898 | portdev->in_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *), |
| 1900 | portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *), | 1899 | GFP_KERNEL); |
| 1901 | GFP_KERNEL); | 1900 | portdev->out_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *), |
| 1901 | GFP_KERNEL); | ||
| 1902 | if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs || | 1902 | if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs || |
| 1903 | !portdev->out_vqs) { | 1903 | !portdev->out_vqs) { |
| 1904 | err = -ENOMEM; | 1904 | err = -ENOMEM; |
diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 9e0b2f2b48e7..7bef0666ae7e 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c | |||
| @@ -734,7 +734,7 @@ static void bcm2835_pll_debug_init(struct clk_hw *hw, | |||
| 734 | const struct bcm2835_pll_data *data = pll->data; | 734 | const struct bcm2835_pll_data *data = pll->data; |
| 735 | struct debugfs_reg32 *regs; | 735 | struct debugfs_reg32 *regs; |
| 736 | 736 | ||
| 737 | regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL); | 737 | regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); |
| 738 | if (!regs) | 738 | if (!regs) |
| 739 | return; | 739 | return; |
| 740 | 740 | ||
| @@ -865,7 +865,7 @@ static void bcm2835_pll_divider_debug_init(struct clk_hw *hw, | |||
| 865 | const struct bcm2835_pll_divider_data *data = divider->data; | 865 | const struct bcm2835_pll_divider_data *data = divider->data; |
| 866 | struct debugfs_reg32 *regs; | 866 | struct debugfs_reg32 *regs; |
| 867 | 867 | ||
| 868 | regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL); | 868 | regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); |
| 869 | if (!regs) | 869 | if (!regs) |
| 870 | return; | 870 | return; |
| 871 | 871 | ||
diff --git a/drivers/clk/renesas/clk-r8a7740.c b/drivers/clk/renesas/clk-r8a7740.c index d074f8e982d0..a7a30d2eca41 100644 --- a/drivers/clk/renesas/clk-r8a7740.c +++ b/drivers/clk/renesas/clk-r8a7740.c | |||
| @@ -161,7 +161,7 @@ static void __init r8a7740_cpg_clocks_init(struct device_node *np) | |||
| 161 | } | 161 | } |
| 162 | 162 | ||
| 163 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); | 163 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); |
| 164 | clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL); | 164 | clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL); |
| 165 | if (cpg == NULL || clks == NULL) { | 165 | if (cpg == NULL || clks == NULL) { |
| 166 | /* We're leaking memory on purpose, there's no point in cleaning | 166 | /* We're leaking memory on purpose, there's no point in cleaning |
| 167 | * up as the system won't boot anyway. | 167 | * up as the system won't boot anyway. |
diff --git a/drivers/clk/renesas/clk-r8a7779.c b/drivers/clk/renesas/clk-r8a7779.c index 27fbfafaf2cd..5adcca4656c3 100644 --- a/drivers/clk/renesas/clk-r8a7779.c +++ b/drivers/clk/renesas/clk-r8a7779.c | |||
| @@ -138,7 +138,7 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np) | |||
| 138 | } | 138 | } |
| 139 | 139 | ||
| 140 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); | 140 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); |
| 141 | clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL); | 141 | clks = kcalloc(CPG_NUM_CLOCKS, sizeof(*clks), GFP_KERNEL); |
| 142 | if (cpg == NULL || clks == NULL) { | 142 | if (cpg == NULL || clks == NULL) { |
| 143 | /* We're leaking memory on purpose, there's no point in cleaning | 143 | /* We're leaking memory on purpose, there's no point in cleaning |
| 144 | * up as the system won't boot anyway. | 144 | * up as the system won't boot anyway. |
diff --git a/drivers/clk/renesas/clk-rcar-gen2.c b/drivers/clk/renesas/clk-rcar-gen2.c index ee32a022e6da..bccd62f2cb09 100644 --- a/drivers/clk/renesas/clk-rcar-gen2.c +++ b/drivers/clk/renesas/clk-rcar-gen2.c | |||
| @@ -417,7 +417,7 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np) | |||
| 417 | } | 417 | } |
| 418 | 418 | ||
| 419 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); | 419 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); |
| 420 | clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL); | 420 | clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL); |
| 421 | if (cpg == NULL || clks == NULL) { | 421 | if (cpg == NULL || clks == NULL) { |
| 422 | /* We're leaking memory on purpose, there's no point in cleaning | 422 | /* We're leaking memory on purpose, there's no point in cleaning |
| 423 | * up as the system won't boot anyway. | 423 | * up as the system won't boot anyway. |
diff --git a/drivers/clk/renesas/clk-rz.c b/drivers/clk/renesas/clk-rz.c index 67dd712aa723..ac2f86d626b6 100644 --- a/drivers/clk/renesas/clk-rz.c +++ b/drivers/clk/renesas/clk-rz.c | |||
| @@ -97,7 +97,7 @@ static void __init rz_cpg_clocks_init(struct device_node *np) | |||
| 97 | return; | 97 | return; |
| 98 | 98 | ||
| 99 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); | 99 | cpg = kzalloc(sizeof(*cpg), GFP_KERNEL); |
| 100 | clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL); | 100 | clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL); |
| 101 | BUG_ON(!cpg || !clks); | 101 | BUG_ON(!cpg || !clks); |
| 102 | 102 | ||
| 103 | cpg->data.clks = clks; | 103 | cpg->data.clks = clks; |
diff --git a/drivers/clk/st/clkgen-fsyn.c b/drivers/clk/st/clkgen-fsyn.c index 14819d919df1..a79d81985c4e 100644 --- a/drivers/clk/st/clkgen-fsyn.c +++ b/drivers/clk/st/clkgen-fsyn.c | |||
| @@ -874,7 +874,7 @@ static void __init st_of_create_quadfs_fsynths( | |||
| 874 | return; | 874 | return; |
| 875 | 875 | ||
| 876 | clk_data->clk_num = QUADFS_MAX_CHAN; | 876 | clk_data->clk_num = QUADFS_MAX_CHAN; |
| 877 | clk_data->clks = kzalloc(QUADFS_MAX_CHAN * sizeof(struct clk *), | 877 | clk_data->clks = kcalloc(QUADFS_MAX_CHAN, sizeof(struct clk *), |
| 878 | GFP_KERNEL); | 878 | GFP_KERNEL); |
| 879 | 879 | ||
| 880 | if (!clk_data->clks) { | 880 | if (!clk_data->clks) { |
diff --git a/drivers/clk/st/clkgen-pll.c b/drivers/clk/st/clkgen-pll.c index 25bda48a5d35..7a7106dc80bf 100644 --- a/drivers/clk/st/clkgen-pll.c +++ b/drivers/clk/st/clkgen-pll.c | |||
| @@ -738,7 +738,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, | |||
| 738 | return; | 738 | return; |
| 739 | 739 | ||
| 740 | clk_data->clk_num = num_odfs; | 740 | clk_data->clk_num = num_odfs; |
| 741 | clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *), | 741 | clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *), |
| 742 | GFP_KERNEL); | 742 | GFP_KERNEL); |
| 743 | 743 | ||
| 744 | if (!clk_data->clks) | 744 | if (!clk_data->clks) |
diff --git a/drivers/clk/sunxi/clk-usb.c b/drivers/clk/sunxi/clk-usb.c index fe0c3d169377..917fc27a33dd 100644 --- a/drivers/clk/sunxi/clk-usb.c +++ b/drivers/clk/sunxi/clk-usb.c | |||
| @@ -122,7 +122,7 @@ static void __init sunxi_usb_clk_setup(struct device_node *node, | |||
| 122 | if (!clk_data) | 122 | if (!clk_data) |
| 123 | return; | 123 | return; |
| 124 | 124 | ||
| 125 | clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL); | 125 | clk_data->clks = kcalloc(qty + 1, sizeof(struct clk *), GFP_KERNEL); |
| 126 | if (!clk_data->clks) { | 126 | if (!clk_data->clks) { |
| 127 | kfree(clk_data); | 127 | kfree(clk_data); |
| 128 | return; | 128 | return; |
diff --git a/drivers/clk/tegra/clk.c b/drivers/clk/tegra/clk.c index 593d76a114f9..ffaf17f71860 100644 --- a/drivers/clk/tegra/clk.c +++ b/drivers/clk/tegra/clk.c | |||
| @@ -216,14 +216,15 @@ struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks) | |||
| 216 | if (WARN_ON(banks > ARRAY_SIZE(periph_regs))) | 216 | if (WARN_ON(banks > ARRAY_SIZE(periph_regs))) |
| 217 | return NULL; | 217 | return NULL; |
| 218 | 218 | ||
| 219 | periph_clk_enb_refcnt = kzalloc(32 * banks * | 219 | periph_clk_enb_refcnt = kcalloc(32 * banks, |
| 220 | sizeof(*periph_clk_enb_refcnt), GFP_KERNEL); | 220 | sizeof(*periph_clk_enb_refcnt), |
| 221 | GFP_KERNEL); | ||
| 221 | if (!periph_clk_enb_refcnt) | 222 | if (!periph_clk_enb_refcnt) |
| 222 | return NULL; | 223 | return NULL; |
| 223 | 224 | ||
| 224 | periph_banks = banks; | 225 | periph_banks = banks; |
| 225 | 226 | ||
| 226 | clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL); | 227 | clks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL); |
| 227 | if (!clks) | 228 | if (!clks) |
| 228 | kfree(periph_clk_enb_refcnt); | 229 | kfree(periph_clk_enb_refcnt); |
| 229 | 230 | ||
diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c index d6036c788fab..688e403333b9 100644 --- a/drivers/clk/ti/adpll.c +++ b/drivers/clk/ti/adpll.c | |||
| @@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d) | |||
| 501 | const char *postfix; | 501 | const char *postfix; |
| 502 | int width, err; | 502 | int width, err; |
| 503 | 503 | ||
| 504 | d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) * | 504 | d->outputs.clks = devm_kcalloc(d->dev, |
| 505 | MAX_ADPLL_OUTPUTS, | 505 | MAX_ADPLL_OUTPUTS, |
| 506 | sizeof(struct clk *), | ||
| 506 | GFP_KERNEL); | 507 | GFP_KERNEL); |
| 507 | if (!d->outputs.clks) | 508 | if (!d->outputs.clks) |
| 508 | return -ENOMEM; | 509 | return -ENOMEM; |
| @@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev) | |||
| 915 | if (err) | 916 | if (err) |
| 916 | return err; | 917 | return err; |
| 917 | 918 | ||
| 918 | d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) * | 919 | d->clocks = devm_kcalloc(d->dev, |
| 919 | TI_ADPLL_NR_CLOCKS, | 920 | TI_ADPLL_NR_CLOCKS, |
| 921 | sizeof(struct ti_adpll_clock), | ||
| 920 | GFP_KERNEL); | 922 | GFP_KERNEL); |
| 921 | if (!d->clocks) | 923 | if (!d->clocks) |
| 922 | return -ENOMEM; | 924 | return -ENOMEM; |
diff --git a/drivers/clk/ti/apll.c b/drivers/clk/ti/apll.c index 9498e9363b57..61c126a5d26a 100644 --- a/drivers/clk/ti/apll.c +++ b/drivers/clk/ti/apll.c | |||
| @@ -206,7 +206,7 @@ static void __init of_dra7_apll_setup(struct device_node *node) | |||
| 206 | goto cleanup; | 206 | goto cleanup; |
| 207 | } | 207 | } |
| 208 | 208 | ||
| 209 | parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL); | 209 | parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL); |
| 210 | if (!parent_names) | 210 | if (!parent_names) |
| 211 | goto cleanup; | 211 | goto cleanup; |
| 212 | 212 | ||
diff --git a/drivers/clk/ti/divider.c b/drivers/clk/ti/divider.c index aaa277dd6d99..ccfb4d9a152a 100644 --- a/drivers/clk/ti/divider.c +++ b/drivers/clk/ti/divider.c | |||
| @@ -366,7 +366,7 @@ int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div, | |||
| 366 | 366 | ||
| 367 | num_dividers = i; | 367 | num_dividers = i; |
| 368 | 368 | ||
| 369 | tmp = kzalloc(sizeof(*tmp) * (valid_div + 1), GFP_KERNEL); | 369 | tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL); |
| 370 | if (!tmp) | 370 | if (!tmp) |
| 371 | return -ENOMEM; | 371 | return -ENOMEM; |
| 372 | 372 | ||
| @@ -496,7 +496,7 @@ __init ti_clk_get_div_table(struct device_node *node) | |||
| 496 | return ERR_PTR(-EINVAL); | 496 | return ERR_PTR(-EINVAL); |
| 497 | } | 497 | } |
| 498 | 498 | ||
| 499 | table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL); | 499 | table = kcalloc(valid_div + 1, sizeof(*table), GFP_KERNEL); |
| 500 | 500 | ||
| 501 | if (!table) | 501 | if (!table) |
| 502 | return ERR_PTR(-ENOMEM); | 502 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/clk/ti/dpll.c b/drivers/clk/ti/dpll.c index 7d33ca9042cb..dc86d07d0921 100644 --- a/drivers/clk/ti/dpll.c +++ b/drivers/clk/ti/dpll.c | |||
| @@ -309,7 +309,7 @@ static void __init of_ti_dpll_setup(struct device_node *node, | |||
| 309 | goto cleanup; | 309 | goto cleanup; |
| 310 | } | 310 | } |
| 311 | 311 | ||
| 312 | parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL); | 312 | parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL); |
| 313 | if (!parent_names) | 313 | if (!parent_names) |
| 314 | goto cleanup; | 314 | goto cleanup; |
| 315 | 315 | ||
diff --git a/drivers/clocksource/sh_cmt.c b/drivers/clocksource/sh_cmt.c index 70b3cf8e23d0..bbbf37c471a3 100644 --- a/drivers/clocksource/sh_cmt.c +++ b/drivers/clocksource/sh_cmt.c | |||
| @@ -1000,7 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) | |||
| 1000 | 1000 | ||
| 1001 | /* Allocate and setup the channels. */ | 1001 | /* Allocate and setup the channels. */ |
| 1002 | cmt->num_channels = hweight8(cmt->hw_channels); | 1002 | cmt->num_channels = hweight8(cmt->hw_channels); |
| 1003 | cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels), | 1003 | cmt->channels = kcalloc(cmt->num_channels, sizeof(*cmt->channels), |
| 1004 | GFP_KERNEL); | 1004 | GFP_KERNEL); |
| 1005 | if (cmt->channels == NULL) { | 1005 | if (cmt->channels == NULL) { |
| 1006 | ret = -ENOMEM; | 1006 | ret = -ENOMEM; |
diff --git a/drivers/clocksource/sh_mtu2.c b/drivers/clocksource/sh_mtu2.c index 53aa7e92a7d7..6812e099b6a3 100644 --- a/drivers/clocksource/sh_mtu2.c +++ b/drivers/clocksource/sh_mtu2.c | |||
| @@ -418,7 +418,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, | |||
| 418 | /* Allocate and setup the channels. */ | 418 | /* Allocate and setup the channels. */ |
| 419 | mtu->num_channels = 3; | 419 | mtu->num_channels = 3; |
| 420 | 420 | ||
| 421 | mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels, | 421 | mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels), |
| 422 | GFP_KERNEL); | 422 | GFP_KERNEL); |
| 423 | if (mtu->channels == NULL) { | 423 | if (mtu->channels == NULL) { |
| 424 | ret = -ENOMEM; | 424 | ret = -ENOMEM; |
diff --git a/drivers/clocksource/sh_tmu.c b/drivers/clocksource/sh_tmu.c index 31d881621e41..c74a6c543ca2 100644 --- a/drivers/clocksource/sh_tmu.c +++ b/drivers/clocksource/sh_tmu.c | |||
| @@ -569,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) | |||
| 569 | } | 569 | } |
| 570 | 570 | ||
| 571 | /* Allocate and setup the channels. */ | 571 | /* Allocate and setup the channels. */ |
| 572 | tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels, | 572 | tmu->channels = kcalloc(tmu->num_channels, sizeof(*tmu->channels), |
| 573 | GFP_KERNEL); | 573 | GFP_KERNEL); |
| 574 | if (tmu->channels == NULL) { | 574 | if (tmu->channels == NULL) { |
| 575 | ret = -ENOMEM; | 575 | ret = -ENOMEM; |
diff --git a/drivers/cpufreq/acpi-cpufreq.c b/drivers/cpufreq/acpi-cpufreq.c index 9449657d72f0..8ff1c9123834 100644 --- a/drivers/cpufreq/acpi-cpufreq.c +++ b/drivers/cpufreq/acpi-cpufreq.c | |||
| @@ -759,8 +759,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) | |||
| 759 | goto err_unreg; | 759 | goto err_unreg; |
| 760 | } | 760 | } |
| 761 | 761 | ||
| 762 | freq_table = kzalloc(sizeof(*freq_table) * | 762 | freq_table = kcalloc(perf->state_count + 1, sizeof(*freq_table), |
| 763 | (perf->state_count+1), GFP_KERNEL); | 763 | GFP_KERNEL); |
| 764 | if (!freq_table) { | 764 | if (!freq_table) { |
| 765 | result = -ENOMEM; | 765 | result = -ENOMEM; |
| 766 | goto err_unreg; | 766 | goto err_unreg; |
diff --git a/drivers/cpufreq/arm_big_little.c b/drivers/cpufreq/arm_big_little.c index 1d7ef5fc1977..cf62a1f64dd7 100644 --- a/drivers/cpufreq/arm_big_little.c +++ b/drivers/cpufreq/arm_big_little.c | |||
| @@ -280,7 +280,7 @@ static int merge_cluster_tables(void) | |||
| 280 | for (i = 0; i < MAX_CLUSTERS; i++) | 280 | for (i = 0; i < MAX_CLUSTERS; i++) |
| 281 | count += get_table_count(freq_table[i]); | 281 | count += get_table_count(freq_table[i]); |
| 282 | 282 | ||
| 283 | table = kzalloc(sizeof(*table) * count, GFP_KERNEL); | 283 | table = kcalloc(count, sizeof(*table), GFP_KERNEL); |
| 284 | if (!table) | 284 | if (!table) |
| 285 | return -ENOMEM; | 285 | return -ENOMEM; |
| 286 | 286 | ||
diff --git a/drivers/cpufreq/bmips-cpufreq.c b/drivers/cpufreq/bmips-cpufreq.c index 1653151b77df..56a4ebbf00e0 100644 --- a/drivers/cpufreq/bmips-cpufreq.c +++ b/drivers/cpufreq/bmips-cpufreq.c | |||
| @@ -71,7 +71,7 @@ bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy) | |||
| 71 | 71 | ||
| 72 | cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult); | 72 | cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult); |
| 73 | 73 | ||
| 74 | table = kmalloc((priv->max_freqs + 1) * sizeof(*table), GFP_KERNEL); | 74 | table = kmalloc_array(priv->max_freqs + 1, sizeof(*table), GFP_KERNEL); |
| 75 | if (!table) | 75 | if (!table) |
| 76 | return ERR_PTR(-ENOMEM); | 76 | return ERR_PTR(-ENOMEM); |
| 77 | 77 | ||
diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index b07559b9ed99..e6f9cbe5835f 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c | |||
| @@ -410,7 +410,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv) | |||
| 410 | if (ret) | 410 | if (ret) |
| 411 | return ERR_PTR(ret); | 411 | return ERR_PTR(ret); |
| 412 | 412 | ||
| 413 | table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table), | 413 | table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table), |
| 414 | GFP_KERNEL); | 414 | GFP_KERNEL); |
| 415 | if (!table) | 415 | if (!table) |
| 416 | return ERR_PTR(-ENOMEM); | 416 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/cpufreq/cppc_cpufreq.c b/drivers/cpufreq/cppc_cpufreq.c index 3464580ac3ca..a9d3eec32795 100644 --- a/drivers/cpufreq/cppc_cpufreq.c +++ b/drivers/cpufreq/cppc_cpufreq.c | |||
| @@ -313,7 +313,8 @@ static int __init cppc_cpufreq_init(void) | |||
| 313 | if (acpi_disabled) | 313 | if (acpi_disabled) |
| 314 | return -ENODEV; | 314 | return -ENODEV; |
| 315 | 315 | ||
| 316 | all_cpu_data = kzalloc(sizeof(void *) * num_possible_cpus(), GFP_KERNEL); | 316 | all_cpu_data = kcalloc(num_possible_cpus(), sizeof(void *), |
| 317 | GFP_KERNEL); | ||
| 317 | if (!all_cpu_data) | 318 | if (!all_cpu_data) |
| 318 | return -ENOMEM; | 319 | return -ENOMEM; |
| 319 | 320 | ||
diff --git a/drivers/cpufreq/ia64-acpi-cpufreq.c b/drivers/cpufreq/ia64-acpi-cpufreq.c index 7974a2fdb760..dd5440d3372d 100644 --- a/drivers/cpufreq/ia64-acpi-cpufreq.c +++ b/drivers/cpufreq/ia64-acpi-cpufreq.c | |||
| @@ -241,8 +241,8 @@ acpi_cpufreq_cpu_init ( | |||
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | /* alloc freq_table */ | 243 | /* alloc freq_table */ |
| 244 | freq_table = kzalloc(sizeof(*freq_table) * | 244 | freq_table = kcalloc(data->acpi_data.state_count + 1, |
| 245 | (data->acpi_data.state_count + 1), | 245 | sizeof(*freq_table), |
| 246 | GFP_KERNEL); | 246 | GFP_KERNEL); |
| 247 | if (!freq_table) { | 247 | if (!freq_table) { |
| 248 | result = -ENOMEM; | 248 | result = -ENOMEM; |
diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 83cf631fc9bc..70912104a199 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c | |||
| @@ -377,7 +377,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) | |||
| 377 | } | 377 | } |
| 378 | 378 | ||
| 379 | /* Make imx6_soc_volt array's size same as arm opp number */ | 379 | /* Make imx6_soc_volt array's size same as arm opp number */ |
| 380 | imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL); | 380 | imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt), |
| 381 | GFP_KERNEL); | ||
| 381 | if (imx6_soc_volt == NULL) { | 382 | if (imx6_soc_volt == NULL) { |
| 382 | ret = -ENOMEM; | 383 | ret = -ENOMEM; |
| 383 | goto free_freq_table; | 384 | goto free_freq_table; |
diff --git a/drivers/cpufreq/intel_pstate.c b/drivers/cpufreq/intel_pstate.c index 08960a55eb27..b6575408f279 100644 --- a/drivers/cpufreq/intel_pstate.c +++ b/drivers/cpufreq/intel_pstate.c | |||
| @@ -2339,7 +2339,7 @@ hwp_cpu_matched: | |||
| 2339 | 2339 | ||
| 2340 | pr_info("Intel P-state driver initializing\n"); | 2340 | pr_info("Intel P-state driver initializing\n"); |
| 2341 | 2341 | ||
| 2342 | all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus()); | 2342 | all_cpu_data = vzalloc(array_size(sizeof(void *), num_possible_cpus())); |
| 2343 | if (!all_cpu_data) | 2343 | if (!all_cpu_data) |
| 2344 | return -ENOMEM; | 2344 | return -ENOMEM; |
| 2345 | 2345 | ||
diff --git a/drivers/cpufreq/longhaul.c b/drivers/cpufreq/longhaul.c index 61a4c5b08219..279bd9e9fa95 100644 --- a/drivers/cpufreq/longhaul.c +++ b/drivers/cpufreq/longhaul.c | |||
| @@ -474,8 +474,8 @@ static int longhaul_get_ranges(void) | |||
| 474 | return -EINVAL; | 474 | return -EINVAL; |
| 475 | } | 475 | } |
| 476 | 476 | ||
| 477 | longhaul_table = kzalloc((numscales + 1) * sizeof(*longhaul_table), | 477 | longhaul_table = kcalloc(numscales + 1, sizeof(*longhaul_table), |
| 478 | GFP_KERNEL); | 478 | GFP_KERNEL); |
| 479 | if (!longhaul_table) | 479 | if (!longhaul_table) |
| 480 | return -ENOMEM; | 480 | return -ENOMEM; |
| 481 | 481 | ||
diff --git a/drivers/cpufreq/pxa3xx-cpufreq.c b/drivers/cpufreq/pxa3xx-cpufreq.c index 7acc7fa4536d..9daa2cc318bb 100644 --- a/drivers/cpufreq/pxa3xx-cpufreq.c +++ b/drivers/cpufreq/pxa3xx-cpufreq.c | |||
| @@ -93,7 +93,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy, | |||
| 93 | struct cpufreq_frequency_table *table; | 93 | struct cpufreq_frequency_table *table; |
| 94 | int i; | 94 | int i; |
| 95 | 95 | ||
| 96 | table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL); | 96 | table = kcalloc(num + 1, sizeof(*table), GFP_KERNEL); |
| 97 | if (table == NULL) | 97 | if (table == NULL) |
| 98 | return -ENOMEM; | 98 | return -ENOMEM; |
| 99 | 99 | ||
diff --git a/drivers/cpufreq/s3c24xx-cpufreq.c b/drivers/cpufreq/s3c24xx-cpufreq.c index 909bd6e27639..3b291a2b0cb3 100644 --- a/drivers/cpufreq/s3c24xx-cpufreq.c +++ b/drivers/cpufreq/s3c24xx-cpufreq.c | |||
| @@ -562,7 +562,7 @@ static int s3c_cpufreq_build_freq(void) | |||
| 562 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); | 562 | size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0); |
| 563 | size++; | 563 | size++; |
| 564 | 564 | ||
| 565 | ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL); | 565 | ftab = kcalloc(size, sizeof(*ftab), GFP_KERNEL); |
| 566 | if (!ftab) | 566 | if (!ftab) |
| 567 | return -ENOMEM; | 567 | return -ENOMEM; |
| 568 | 568 | ||
diff --git a/drivers/cpufreq/sfi-cpufreq.c b/drivers/cpufreq/sfi-cpufreq.c index 9767afe05da2..978770432b13 100644 --- a/drivers/cpufreq/sfi-cpufreq.c +++ b/drivers/cpufreq/sfi-cpufreq.c | |||
| @@ -95,8 +95,8 @@ static int __init sfi_cpufreq_init(void) | |||
| 95 | if (ret) | 95 | if (ret) |
| 96 | return ret; | 96 | return ret; |
| 97 | 97 | ||
| 98 | freq_table = kzalloc(sizeof(*freq_table) * | 98 | freq_table = kcalloc(num_freq_table_entries + 1, sizeof(*freq_table), |
| 99 | (num_freq_table_entries + 1), GFP_KERNEL); | 99 | GFP_KERNEL); |
| 100 | if (!freq_table) { | 100 | if (!freq_table) { |
| 101 | ret = -ENOMEM; | 101 | ret = -ENOMEM; |
| 102 | goto err_free_array; | 102 | goto err_free_array; |
diff --git a/drivers/cpufreq/spear-cpufreq.c b/drivers/cpufreq/spear-cpufreq.c index 195f27f9c1cb..4074e2615522 100644 --- a/drivers/cpufreq/spear-cpufreq.c +++ b/drivers/cpufreq/spear-cpufreq.c | |||
| @@ -195,7 +195,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev) | |||
| 195 | cnt = prop->length / sizeof(u32); | 195 | cnt = prop->length / sizeof(u32); |
| 196 | val = prop->value; | 196 | val = prop->value; |
| 197 | 197 | ||
| 198 | freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL); | 198 | freq_tbl = kcalloc(cnt + 1, sizeof(*freq_tbl), GFP_KERNEL); |
| 199 | if (!freq_tbl) { | 199 | if (!freq_tbl) { |
| 200 | ret = -ENOMEM; | 200 | ret = -ENOMEM; |
| 201 | goto out_put_node; | 201 | goto out_put_node; |
diff --git a/drivers/crypto/amcc/crypto4xx_core.c b/drivers/crypto/amcc/crypto4xx_core.c index 9cb234c72549..05981ccd9901 100644 --- a/drivers/crypto/amcc/crypto4xx_core.c +++ b/drivers/crypto/amcc/crypto4xx_core.c | |||
| @@ -141,11 +141,11 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev) | |||
| 141 | 141 | ||
| 142 | int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size) | 142 | int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size) |
| 143 | { | 143 | { |
| 144 | ctx->sa_in = kzalloc(size * 4, GFP_ATOMIC); | 144 | ctx->sa_in = kcalloc(size, 4, GFP_ATOMIC); |
| 145 | if (ctx->sa_in == NULL) | 145 | if (ctx->sa_in == NULL) |
| 146 | return -ENOMEM; | 146 | return -ENOMEM; |
| 147 | 147 | ||
| 148 | ctx->sa_out = kzalloc(size * 4, GFP_ATOMIC); | 148 | ctx->sa_out = kcalloc(size, 4, GFP_ATOMIC); |
| 149 | if (ctx->sa_out == NULL) { | 149 | if (ctx->sa_out == NULL) { |
| 150 | kfree(ctx->sa_in); | 150 | kfree(ctx->sa_in); |
| 151 | ctx->sa_in = NULL; | 151 | ctx->sa_in = NULL; |
| @@ -180,8 +180,8 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev) | |||
| 180 | if (!dev->pdr) | 180 | if (!dev->pdr) |
| 181 | return -ENOMEM; | 181 | return -ENOMEM; |
| 182 | 182 | ||
| 183 | dev->pdr_uinfo = kzalloc(sizeof(struct pd_uinfo) * PPC4XX_NUM_PD, | 183 | dev->pdr_uinfo = kcalloc(PPC4XX_NUM_PD, sizeof(struct pd_uinfo), |
| 184 | GFP_KERNEL); | 184 | GFP_KERNEL); |
| 185 | if (!dev->pdr_uinfo) { | 185 | if (!dev->pdr_uinfo) { |
| 186 | dma_free_coherent(dev->core_dev->device, | 186 | dma_free_coherent(dev->core_dev->device, |
| 187 | sizeof(struct ce_pd) * PPC4XX_NUM_PD, | 187 | sizeof(struct ce_pd) * PPC4XX_NUM_PD, |
diff --git a/drivers/crypto/cavium/nitrox/nitrox_isr.c b/drivers/crypto/cavium/nitrox/nitrox_isr.c index dbead5f45df3..ee0d70ba25d5 100644 --- a/drivers/crypto/cavium/nitrox/nitrox_isr.c +++ b/drivers/crypto/cavium/nitrox/nitrox_isr.c | |||
| @@ -254,7 +254,7 @@ static int nitrox_enable_msix(struct nitrox_device *ndev) | |||
| 254 | * Entry 192: NPS_CORE_INT_ACTIVE | 254 | * Entry 192: NPS_CORE_INT_ACTIVE |
| 255 | */ | 255 | */ |
| 256 | nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1; | 256 | nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1; |
| 257 | entries = kzalloc_node(nr_entries * sizeof(struct msix_entry), | 257 | entries = kcalloc_node(nr_entries, sizeof(struct msix_entry), |
| 258 | GFP_KERNEL, ndev->node); | 258 | GFP_KERNEL, ndev->node); |
| 259 | if (!entries) | 259 | if (!entries) |
| 260 | return -ENOMEM; | 260 | return -ENOMEM; |
diff --git a/drivers/crypto/chelsio/chtls/chtls_io.c b/drivers/crypto/chelsio/chtls/chtls_io.c index 51fc6821cbbf..00c7aab8e7d0 100644 --- a/drivers/crypto/chelsio/chtls/chtls_io.c +++ b/drivers/crypto/chelsio/chtls/chtls_io.c | |||
| @@ -240,7 +240,7 @@ static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb) | |||
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | /* generate the IVs */ | 242 | /* generate the IVs */ |
| 243 | ivs = kmalloc(number_of_ivs * CIPHER_BLOCK_SIZE, GFP_ATOMIC); | 243 | ivs = kmalloc_array(CIPHER_BLOCK_SIZE, number_of_ivs, GFP_ATOMIC); |
| 244 | if (!ivs) | 244 | if (!ivs) |
| 245 | return -ENOMEM; | 245 | return -ENOMEM; |
| 246 | get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE); | 246 | get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE); |
diff --git a/drivers/crypto/inside-secure/safexcel_hash.c b/drivers/crypto/inside-secure/safexcel_hash.c index d138d6b8fec5..c77b0e1655a8 100644 --- a/drivers/crypto/inside-secure/safexcel_hash.c +++ b/drivers/crypto/inside-secure/safexcel_hash.c | |||
| @@ -922,7 +922,7 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen, | |||
| 922 | crypto_ahash_clear_flags(tfm, ~0); | 922 | crypto_ahash_clear_flags(tfm, ~0); |
| 923 | blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); | 923 | blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); |
| 924 | 924 | ||
| 925 | ipad = kzalloc(2 * blocksize, GFP_KERNEL); | 925 | ipad = kcalloc(2, blocksize, GFP_KERNEL); |
| 926 | if (!ipad) { | 926 | if (!ipad) { |
| 927 | ret = -ENOMEM; | 927 | ret = -ENOMEM; |
| 928 | goto free_request; | 928 | goto free_request; |
diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c index f81fa4a3e66b..a4aa6813de4b 100644 --- a/drivers/crypto/marvell/cesa.c +++ b/drivers/crypto/marvell/cesa.c | |||
| @@ -471,7 +471,7 @@ static int mv_cesa_probe(struct platform_device *pdev) | |||
| 471 | sram_size = CESA_SA_MIN_SRAM_SIZE; | 471 | sram_size = CESA_SA_MIN_SRAM_SIZE; |
| 472 | 472 | ||
| 473 | cesa->sram_size = sram_size; | 473 | cesa->sram_size = sram_size; |
| 474 | cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines), | 474 | cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines), |
| 475 | GFP_KERNEL); | 475 | GFP_KERNEL); |
| 476 | if (!cesa->engines) | 476 | if (!cesa->engines) |
| 477 | return -ENOMEM; | 477 | return -ENOMEM; |
diff --git a/drivers/crypto/marvell/hash.c b/drivers/crypto/marvell/hash.c index e61b08566093..e34d80b6b7e5 100644 --- a/drivers/crypto/marvell/hash.c +++ b/drivers/crypto/marvell/hash.c | |||
| @@ -1198,7 +1198,7 @@ static int mv_cesa_ahmac_setkey(const char *hash_alg_name, | |||
| 1198 | 1198 | ||
| 1199 | blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); | 1199 | blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm)); |
| 1200 | 1200 | ||
| 1201 | ipad = kzalloc(2 * blocksize, GFP_KERNEL); | 1201 | ipad = kcalloc(2, blocksize, GFP_KERNEL); |
| 1202 | if (!ipad) { | 1202 | if (!ipad) { |
| 1203 | ret = -ENOMEM; | 1203 | ret = -ENOMEM; |
| 1204 | goto free_req; | 1204 | goto free_req; |
diff --git a/drivers/crypto/n2_core.c b/drivers/crypto/n2_core.c index 80e9c842aad4..ab6235b7ff22 100644 --- a/drivers/crypto/n2_core.c +++ b/drivers/crypto/n2_core.c | |||
| @@ -1919,12 +1919,12 @@ static int grab_global_resources(void) | |||
| 1919 | goto out_hvapi_release; | 1919 | goto out_hvapi_release; |
| 1920 | 1920 | ||
| 1921 | err = -ENOMEM; | 1921 | err = -ENOMEM; |
| 1922 | cpu_to_cwq = kzalloc(sizeof(struct spu_queue *) * NR_CPUS, | 1922 | cpu_to_cwq = kcalloc(NR_CPUS, sizeof(struct spu_queue *), |
| 1923 | GFP_KERNEL); | 1923 | GFP_KERNEL); |
| 1924 | if (!cpu_to_cwq) | 1924 | if (!cpu_to_cwq) |
| 1925 | goto out_queue_cache_destroy; | 1925 | goto out_queue_cache_destroy; |
| 1926 | 1926 | ||
| 1927 | cpu_to_mau = kzalloc(sizeof(struct spu_queue *) * NR_CPUS, | 1927 | cpu_to_mau = kcalloc(NR_CPUS, sizeof(struct spu_queue *), |
| 1928 | GFP_KERNEL); | 1928 | GFP_KERNEL); |
| 1929 | if (!cpu_to_mau) | 1929 | if (!cpu_to_mau) |
| 1930 | goto out_free_cwq_table; | 1930 | goto out_free_cwq_table; |
diff --git a/drivers/crypto/qat/qat_common/adf_isr.c b/drivers/crypto/qat/qat_common/adf_isr.c index 06d49017a52b..cd1cdf5305bc 100644 --- a/drivers/crypto/qat/qat_common/adf_isr.c +++ b/drivers/crypto/qat/qat_common/adf_isr.c | |||
| @@ -238,7 +238,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev) | |||
| 238 | if (!accel_dev->pf.vf_info) | 238 | if (!accel_dev->pf.vf_info) |
| 239 | msix_num_entries += hw_data->num_banks; | 239 | msix_num_entries += hw_data->num_banks; |
| 240 | 240 | ||
| 241 | entries = kzalloc_node(msix_num_entries * sizeof(*entries), | 241 | entries = kcalloc_node(msix_num_entries, sizeof(*entries), |
| 242 | GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev))); | 242 | GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev))); |
| 243 | if (!entries) | 243 | if (!entries) |
| 244 | return -ENOMEM; | 244 | return -ENOMEM; |
diff --git a/drivers/crypto/qat/qat_common/qat_uclo.c b/drivers/crypto/qat/qat_common/qat_uclo.c index 98d22c2096e3..6bd8f6a2a24f 100644 --- a/drivers/crypto/qat/qat_common/qat_uclo.c +++ b/drivers/crypto/qat/qat_common/qat_uclo.c | |||
| @@ -1162,8 +1162,9 @@ static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle, | |||
| 1162 | suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1; | 1162 | suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1; |
| 1163 | 1163 | ||
| 1164 | if (suof_handle->img_table.num_simgs != 0) { | 1164 | if (suof_handle->img_table.num_simgs != 0) { |
| 1165 | suof_img_hdr = kzalloc(suof_handle->img_table.num_simgs * | 1165 | suof_img_hdr = kcalloc(suof_handle->img_table.num_simgs, |
| 1166 | sizeof(img_header), GFP_KERNEL); | 1166 | sizeof(img_header), |
| 1167 | GFP_KERNEL); | ||
| 1167 | if (!suof_img_hdr) | 1168 | if (!suof_img_hdr) |
| 1168 | return -ENOMEM; | 1169 | return -ENOMEM; |
| 1169 | suof_handle->img_table.simg_hdr = suof_img_hdr; | 1170 | suof_handle->img_table.simg_hdr = suof_img_hdr; |
diff --git a/drivers/crypto/stm32/stm32-hash.c b/drivers/crypto/stm32/stm32-hash.c index 981e45692695..cdc96f1bb917 100644 --- a/drivers/crypto/stm32/stm32-hash.c +++ b/drivers/crypto/stm32/stm32-hash.c | |||
| @@ -970,8 +970,9 @@ static int stm32_hash_export(struct ahash_request *req, void *out) | |||
| 970 | while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY)) | 970 | while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY)) |
| 971 | cpu_relax(); | 971 | cpu_relax(); |
| 972 | 972 | ||
| 973 | rctx->hw_context = kmalloc(sizeof(u32) * (3 + HASH_CSR_REGISTER_NUMBER), | 973 | rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER, |
| 974 | GFP_KERNEL); | 974 | sizeof(u32), |
| 975 | GFP_KERNEL); | ||
| 975 | 976 | ||
| 976 | preg = rctx->hw_context; | 977 | preg = rctx->hw_context; |
| 977 | 978 | ||
diff --git a/drivers/crypto/talitos.c b/drivers/crypto/talitos.c index 7cebf0a6ffbc..cf14f099ce4a 100644 --- a/drivers/crypto/talitos.c +++ b/drivers/crypto/talitos.c | |||
| @@ -3393,8 +3393,10 @@ static int talitos_probe(struct platform_device *ofdev) | |||
| 3393 | } | 3393 | } |
| 3394 | } | 3394 | } |
| 3395 | 3395 | ||
| 3396 | priv->chan = devm_kzalloc(dev, sizeof(struct talitos_channel) * | 3396 | priv->chan = devm_kcalloc(dev, |
| 3397 | priv->num_channels, GFP_KERNEL); | 3397 | priv->num_channels, |
| 3398 | sizeof(struct talitos_channel), | ||
| 3399 | GFP_KERNEL); | ||
| 3398 | if (!priv->chan) { | 3400 | if (!priv->chan) { |
| 3399 | dev_err(dev, "failed to allocate channel management space\n"); | 3401 | dev_err(dev, "failed to allocate channel management space\n"); |
| 3400 | err = -ENOMEM; | 3402 | err = -ENOMEM; |
| @@ -3411,9 +3413,10 @@ static int talitos_probe(struct platform_device *ofdev) | |||
| 3411 | spin_lock_init(&priv->chan[i].head_lock); | 3413 | spin_lock_init(&priv->chan[i].head_lock); |
| 3412 | spin_lock_init(&priv->chan[i].tail_lock); | 3414 | spin_lock_init(&priv->chan[i].tail_lock); |
| 3413 | 3415 | ||
| 3414 | priv->chan[i].fifo = devm_kzalloc(dev, | 3416 | priv->chan[i].fifo = devm_kcalloc(dev, |
| 3415 | sizeof(struct talitos_request) * | 3417 | priv->fifo_len, |
| 3416 | priv->fifo_len, GFP_KERNEL); | 3418 | sizeof(struct talitos_request), |
| 3419 | GFP_KERNEL); | ||
| 3417 | if (!priv->chan[i].fifo) { | 3420 | if (!priv->chan[i].fifo) { |
| 3418 | dev_err(dev, "failed to allocate request fifo %d\n", i); | 3421 | dev_err(dev, "failed to allocate request fifo %d\n", i); |
| 3419 | err = -ENOMEM; | 3422 | err = -ENOMEM; |
diff --git a/drivers/crypto/virtio/virtio_crypto_algs.c b/drivers/crypto/virtio/virtio_crypto_algs.c index ba190cfa7aa1..af6a908dfa7a 100644 --- a/drivers/crypto/virtio/virtio_crypto_algs.c +++ b/drivers/crypto/virtio/virtio_crypto_algs.c | |||
| @@ -371,7 +371,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, | |||
| 371 | 371 | ||
| 372 | /* Why 3? outhdr + iv + inhdr */ | 372 | /* Why 3? outhdr + iv + inhdr */ |
| 373 | sg_total = src_nents + dst_nents + 3; | 373 | sg_total = src_nents + dst_nents + 3; |
| 374 | sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC, | 374 | sgs = kcalloc_node(sg_total, sizeof(*sgs), GFP_ATOMIC, |
| 375 | dev_to_node(&vcrypto->vdev->dev)); | 375 | dev_to_node(&vcrypto->vdev->dev)); |
| 376 | if (!sgs) | 376 | if (!sgs) |
| 377 | return -ENOMEM; | 377 | return -ENOMEM; |
diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index fe2af6aa88fc..0b5b3abe054e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c | |||
| @@ -628,14 +628,15 @@ struct devfreq *devfreq_add_device(struct device *dev, | |||
| 628 | goto err_dev; | 628 | goto err_dev; |
| 629 | } | 629 | } |
| 630 | 630 | ||
| 631 | devfreq->trans_table = devm_kzalloc(&devfreq->dev, | 631 | devfreq->trans_table = |
| 632 | sizeof(unsigned int) * | 632 | devm_kzalloc(&devfreq->dev, |
| 633 | devfreq->profile->max_state * | 633 | array3_size(sizeof(unsigned int), |
| 634 | devfreq->profile->max_state, | 634 | devfreq->profile->max_state, |
| 635 | GFP_KERNEL); | 635 | devfreq->profile->max_state), |
| 636 | devfreq->time_in_state = devm_kzalloc(&devfreq->dev, | 636 | GFP_KERNEL); |
| 637 | sizeof(unsigned long) * | 637 | devfreq->time_in_state = devm_kcalloc(&devfreq->dev, |
| 638 | devfreq->profile->max_state, | 638 | devfreq->profile->max_state, |
| 639 | sizeof(unsigned long), | ||
| 639 | GFP_KERNEL); | 640 | GFP_KERNEL); |
| 640 | devfreq->last_stat_updated = jiffies; | 641 | devfreq->last_stat_updated = jiffies; |
| 641 | 642 | ||
diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c index d96e3dc71cf8..3cd6a184fe7c 100644 --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c | |||
| @@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np, | |||
| 518 | event_ops = exynos_bus_get_ops(np); | 518 | event_ops = exynos_bus_get_ops(np); |
| 519 | 519 | ||
| 520 | count = of_get_child_count(events_np); | 520 | count = of_get_child_count(events_np); |
| 521 | desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL); | 521 | desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL); |
| 522 | if (!desc) | 522 | if (!desc) |
| 523 | return -ENOMEM; | 523 | return -ENOMEM; |
| 524 | info->num_events = count; | 524 | info->num_events = count; |
diff --git a/drivers/dma/bestcomm/bestcomm.c b/drivers/dma/bestcomm/bestcomm.c index 7a67b8345092..d91cbbe7a48f 100644 --- a/drivers/dma/bestcomm/bestcomm.c +++ b/drivers/dma/bestcomm/bestcomm.c | |||
| @@ -87,7 +87,8 @@ bcom_task_alloc(int bd_count, int bd_size, int priv_size) | |||
| 87 | 87 | ||
| 88 | /* Init the BDs, if needed */ | 88 | /* Init the BDs, if needed */ |
| 89 | if (bd_count) { | 89 | if (bd_count) { |
| 90 | tsk->cookie = kmalloc(sizeof(void*) * bd_count, GFP_KERNEL); | 90 | tsk->cookie = kmalloc_array(bd_count, sizeof(void *), |
| 91 | GFP_KERNEL); | ||
| 91 | if (!tsk->cookie) | 92 | if (!tsk->cookie) |
| 92 | goto error; | 93 | goto error; |
| 93 | 94 | ||
diff --git a/drivers/dma/ioat/init.c b/drivers/dma/ioat/init.c index 7792a9186f9c..4fa4c06c9edb 100644 --- a/drivers/dma/ioat/init.c +++ b/drivers/dma/ioat/init.c | |||
| @@ -322,10 +322,10 @@ static int ioat_dma_self_test(struct ioatdma_device *ioat_dma) | |||
| 322 | unsigned long tmo; | 322 | unsigned long tmo; |
| 323 | unsigned long flags; | 323 | unsigned long flags; |
| 324 | 324 | ||
| 325 | src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); | 325 | src = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL); |
| 326 | if (!src) | 326 | if (!src) |
| 327 | return -ENOMEM; | 327 | return -ENOMEM; |
| 328 | dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL); | 328 | dest = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL); |
| 329 | if (!dest) { | 329 | if (!dest) { |
| 330 | kfree(src); | 330 | kfree(src); |
| 331 | return -ENOMEM; | 331 | return -ENOMEM; |
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c index ed76044ce4b9..bbff52be4f0f 100644 --- a/drivers/dma/ipu/ipu_idmac.c +++ b/drivers/dma/ipu/ipu_idmac.c | |||
| @@ -910,7 +910,8 @@ out: | |||
| 910 | /* Called with ichan->chan_mutex held */ | 910 | /* Called with ichan->chan_mutex held */ |
| 911 | static int idmac_desc_alloc(struct idmac_channel *ichan, int n) | 911 | static int idmac_desc_alloc(struct idmac_channel *ichan, int n) |
| 912 | { | 912 | { |
| 913 | struct idmac_tx_desc *desc = vmalloc(n * sizeof(struct idmac_tx_desc)); | 913 | struct idmac_tx_desc *desc = |
| 914 | vmalloc(array_size(n, sizeof(struct idmac_tx_desc))); | ||
| 914 | struct idmac *idmac = to_idmac(ichan->dma_chan.device); | 915 | struct idmac *idmac = to_idmac(ichan->dma_chan.device); |
| 915 | 916 | ||
| 916 | if (!desc) | 917 | if (!desc) |
diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index 26b67455208f..fa31cccbe04f 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c | |||
| @@ -848,8 +848,8 @@ static int k3_dma_probe(struct platform_device *op) | |||
| 848 | return -ENOMEM; | 848 | return -ENOMEM; |
| 849 | 849 | ||
| 850 | /* init phy channel */ | 850 | /* init phy channel */ |
| 851 | d->phy = devm_kzalloc(&op->dev, | 851 | d->phy = devm_kcalloc(&op->dev, |
| 852 | d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL); | 852 | d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL); |
| 853 | if (d->phy == NULL) | 853 | if (d->phy == NULL) |
| 854 | return -ENOMEM; | 854 | return -ENOMEM; |
| 855 | 855 | ||
| @@ -879,8 +879,8 @@ static int k3_dma_probe(struct platform_device *op) | |||
| 879 | d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES; | 879 | d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES; |
| 880 | 880 | ||
| 881 | /* init virtual channel */ | 881 | /* init virtual channel */ |
| 882 | d->chans = devm_kzalloc(&op->dev, | 882 | d->chans = devm_kcalloc(&op->dev, |
| 883 | d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL); | 883 | d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL); |
| 884 | if (d->chans == NULL) | 884 | if (d->chans == NULL) |
| 885 | return -ENOMEM; | 885 | return -ENOMEM; |
| 886 | 886 | ||
diff --git a/drivers/dma/mic_x100_dma.c b/drivers/dma/mic_x100_dma.c index 94d7bd7d2880..68dd79783b54 100644 --- a/drivers/dma/mic_x100_dma.c +++ b/drivers/dma/mic_x100_dma.c | |||
| @@ -385,7 +385,8 @@ static int mic_dma_alloc_desc_ring(struct mic_dma_chan *ch) | |||
| 385 | if (dma_mapping_error(dev, ch->desc_ring_micpa)) | 385 | if (dma_mapping_error(dev, ch->desc_ring_micpa)) |
| 386 | goto map_error; | 386 | goto map_error; |
| 387 | 387 | ||
| 388 | ch->tx_array = vzalloc(MIC_DMA_DESC_RX_SIZE * sizeof(*ch->tx_array)); | 388 | ch->tx_array = vzalloc(array_size(MIC_DMA_DESC_RX_SIZE, |
| 389 | sizeof(*ch->tx_array))); | ||
| 389 | if (!ch->tx_array) | 390 | if (!ch->tx_array) |
| 390 | goto tx_error; | 391 | goto tx_error; |
| 391 | return 0; | 392 | return 0; |
diff --git a/drivers/dma/mv_xor.c b/drivers/dma/mv_xor.c index 1993889003fd..969534c1a6c6 100644 --- a/drivers/dma/mv_xor.c +++ b/drivers/dma/mv_xor.c | |||
| @@ -777,11 +777,11 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan) | |||
| 777 | struct dmaengine_unmap_data *unmap; | 777 | struct dmaengine_unmap_data *unmap; |
| 778 | int err = 0; | 778 | int err = 0; |
| 779 | 779 | ||
| 780 | src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); | 780 | src = kmalloc(PAGE_SIZE, GFP_KERNEL); |
| 781 | if (!src) | 781 | if (!src) |
| 782 | return -ENOMEM; | 782 | return -ENOMEM; |
| 783 | 783 | ||
| 784 | dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL); | 784 | dest = kzalloc(PAGE_SIZE, GFP_KERNEL); |
| 785 | if (!dest) { | 785 | if (!dest) { |
| 786 | kfree(src); | 786 | kfree(src); |
| 787 | return -ENOMEM; | 787 | return -ENOMEM; |
diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index 3548caa9e933..c6589ccf1b9a 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c | |||
| @@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev) | |||
| 809 | } | 809 | } |
| 810 | 810 | ||
| 811 | /* alloc memory for the SW descriptors */ | 811 | /* alloc memory for the SW descriptors */ |
| 812 | xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) * | 812 | xor_dev->sw_desq = devm_kcalloc(&pdev->dev, |
| 813 | MV_XOR_V2_DESC_NUM, GFP_KERNEL); | 813 | MV_XOR_V2_DESC_NUM, sizeof(*sw_desc), |
| 814 | GFP_KERNEL); | ||
| 814 | if (!xor_dev->sw_desq) { | 815 | if (!xor_dev->sw_desq) { |
| 815 | ret = -ENOMEM; | 816 | ret = -ENOMEM; |
| 816 | goto free_hw_desq; | 817 | goto free_hw_desq; |
diff --git a/drivers/dma/pl330.c b/drivers/dma/pl330.c index 6237069001c4..defcdde4d358 100644 --- a/drivers/dma/pl330.c +++ b/drivers/dma/pl330.c | |||
| @@ -1866,7 +1866,7 @@ static int dmac_alloc_threads(struct pl330_dmac *pl330) | |||
| 1866 | int i; | 1866 | int i; |
| 1867 | 1867 | ||
| 1868 | /* Allocate 1 Manager and 'chans' Channel threads */ | 1868 | /* Allocate 1 Manager and 'chans' Channel threads */ |
| 1869 | pl330->channels = kzalloc((1 + chans) * sizeof(*thrd), | 1869 | pl330->channels = kcalloc(1 + chans, sizeof(*thrd), |
| 1870 | GFP_KERNEL); | 1870 | GFP_KERNEL); |
| 1871 | if (!pl330->channels) | 1871 | if (!pl330->channels) |
| 1872 | return -ENOMEM; | 1872 | return -ENOMEM; |
| @@ -2990,7 +2990,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 2990 | 2990 | ||
| 2991 | pl330->num_peripherals = num_chan; | 2991 | pl330->num_peripherals = num_chan; |
| 2992 | 2992 | ||
| 2993 | pl330->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL); | 2993 | pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL); |
| 2994 | if (!pl330->peripherals) { | 2994 | if (!pl330->peripherals) { |
| 2995 | ret = -ENOMEM; | 2995 | ret = -ENOMEM; |
| 2996 | goto probe_err2; | 2996 | goto probe_err2; |
diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c index cd92d696bcf9..7056fe7513b4 100644 --- a/drivers/dma/s3c24xx-dma.c +++ b/drivers/dma/s3c24xx-dma.c | |||
| @@ -1223,9 +1223,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev) | |||
| 1223 | if (IS_ERR(s3cdma->base)) | 1223 | if (IS_ERR(s3cdma->base)) |
| 1224 | return PTR_ERR(s3cdma->base); | 1224 | return PTR_ERR(s3cdma->base); |
| 1225 | 1225 | ||
| 1226 | s3cdma->phy_chans = devm_kzalloc(&pdev->dev, | 1226 | s3cdma->phy_chans = devm_kcalloc(&pdev->dev, |
| 1227 | sizeof(struct s3c24xx_dma_phy) * | 1227 | pdata->num_phy_channels, |
| 1228 | pdata->num_phy_channels, | 1228 | sizeof(struct s3c24xx_dma_phy), |
| 1229 | GFP_KERNEL); | 1229 | GFP_KERNEL); |
| 1230 | if (!s3cdma->phy_chans) | 1230 | if (!s3cdma->phy_chans) |
| 1231 | return -ENOMEM; | 1231 | return -ENOMEM; |
diff --git a/drivers/dma/sh/shdma-base.c b/drivers/dma/sh/shdma-base.c index 12fa48e380cf..6b5626e299b2 100644 --- a/drivers/dma/sh/shdma-base.c +++ b/drivers/dma/sh/shdma-base.c | |||
| @@ -1045,8 +1045,9 @@ EXPORT_SYMBOL(shdma_cleanup); | |||
| 1045 | 1045 | ||
| 1046 | static int __init shdma_enter(void) | 1046 | static int __init shdma_enter(void) |
| 1047 | { | 1047 | { |
| 1048 | shdma_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) * | 1048 | shdma_slave_used = kcalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG), |
| 1049 | sizeof(long), GFP_KERNEL); | 1049 | sizeof(long), |
| 1050 | GFP_KERNEL); | ||
| 1050 | if (!shdma_slave_used) | 1051 | if (!shdma_slave_used) |
| 1051 | return -ENOMEM; | 1052 | return -ENOMEM; |
| 1052 | return 0; | 1053 | return 0; |
diff --git a/drivers/dma/xilinx/zynqmp_dma.c b/drivers/dma/xilinx/zynqmp_dma.c index f14645817ed8..c74a88b65039 100644 --- a/drivers/dma/xilinx/zynqmp_dma.c +++ b/drivers/dma/xilinx/zynqmp_dma.c | |||
| @@ -471,7 +471,7 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan) | |||
| 471 | if (ret < 0) | 471 | if (ret < 0) |
| 472 | return ret; | 472 | return ret; |
| 473 | 473 | ||
| 474 | chan->sw_desc_pool = kzalloc(sizeof(*desc) * ZYNQMP_DMA_NUM_DESCS, | 474 | chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc), |
| 475 | GFP_KERNEL); | 475 | GFP_KERNEL); |
| 476 | if (!chan->sw_desc_pool) | 476 | if (!chan->sw_desc_pool) |
| 477 | return -ENOMEM; | 477 | return -ENOMEM; |
diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c index 2bb695315300..2571bc7693df 100644 --- a/drivers/dma/zx_dma.c +++ b/drivers/dma/zx_dma.c | |||
| @@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op) | |||
| 798 | return -ENOMEM; | 798 | return -ENOMEM; |
| 799 | 799 | ||
| 800 | /* init phy channel */ | 800 | /* init phy channel */ |
| 801 | d->phy = devm_kzalloc(&op->dev, | 801 | d->phy = devm_kcalloc(&op->dev, |
| 802 | d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL); | 802 | d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL); |
| 803 | if (!d->phy) | 803 | if (!d->phy) |
| 804 | return -ENOMEM; | 804 | return -ENOMEM; |
| 805 | 805 | ||
| @@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op) | |||
| 834 | d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; | 834 | d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; |
| 835 | 835 | ||
| 836 | /* init virtual channel */ | 836 | /* init virtual channel */ |
| 837 | d->chans = devm_kzalloc(&op->dev, | 837 | d->chans = devm_kcalloc(&op->dev, |
| 838 | d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL); | 838 | d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL); |
| 839 | if (!d->chans) | 839 | if (!d->chans) |
| 840 | return -ENOMEM; | 840 | return -ENOMEM; |
| 841 | 841 | ||
diff --git a/drivers/edac/amd64_edac.c b/drivers/edac/amd64_edac.c index 329cb96f886f..18aeabb1d5ee 100644 --- a/drivers/edac/amd64_edac.c +++ b/drivers/edac/amd64_edac.c | |||
| @@ -3451,7 +3451,7 @@ static int __init amd64_edac_init(void) | |||
| 3451 | opstate_init(); | 3451 | opstate_init(); |
| 3452 | 3452 | ||
| 3453 | err = -ENOMEM; | 3453 | err = -ENOMEM; |
| 3454 | ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL); | 3454 | ecc_stngs = kcalloc(amd_nb_num(), sizeof(ecc_stngs[0]), GFP_KERNEL); |
| 3455 | if (!ecc_stngs) | 3455 | if (!ecc_stngs) |
| 3456 | goto err_free; | 3456 | goto err_free; |
| 3457 | 3457 | ||
diff --git a/drivers/edac/i7core_edac.c b/drivers/edac/i7core_edac.c index 4d0ea3563d47..8ed4dd9c571b 100644 --- a/drivers/edac/i7core_edac.c +++ b/drivers/edac/i7core_edac.c | |||
| @@ -461,7 +461,7 @@ static struct i7core_dev *alloc_i7core_dev(u8 socket, | |||
| 461 | if (!i7core_dev) | 461 | if (!i7core_dev) |
| 462 | return NULL; | 462 | return NULL; |
| 463 | 463 | ||
| 464 | i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs, | 464 | i7core_dev->pdev = kcalloc(table->n_devs, sizeof(*i7core_dev->pdev), |
| 465 | GFP_KERNEL); | 465 | GFP_KERNEL); |
| 466 | if (!i7core_dev->pdev) { | 466 | if (!i7core_dev->pdev) { |
| 467 | kfree(i7core_dev); | 467 | kfree(i7core_dev); |
diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 8bff5fd18185..af83ad58819c 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c | |||
| @@ -1126,8 +1126,9 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
| 1126 | char *str; | 1126 | char *str; |
| 1127 | struct extcon_cable *cable; | 1127 | struct extcon_cable *cable; |
| 1128 | 1128 | ||
| 1129 | edev->cables = kzalloc(sizeof(struct extcon_cable) * | 1129 | edev->cables = kcalloc(edev->max_supported, |
| 1130 | edev->max_supported, GFP_KERNEL); | 1130 | sizeof(struct extcon_cable), |
| 1131 | GFP_KERNEL); | ||
| 1131 | if (!edev->cables) { | 1132 | if (!edev->cables) { |
| 1132 | ret = -ENOMEM; | 1133 | ret = -ENOMEM; |
| 1133 | goto err_sysfs_alloc; | 1134 | goto err_sysfs_alloc; |
| @@ -1136,7 +1137,7 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
| 1136 | cable = &edev->cables[index]; | 1137 | cable = &edev->cables[index]; |
| 1137 | 1138 | ||
| 1138 | snprintf(buf, 10, "cable.%d", index); | 1139 | snprintf(buf, 10, "cable.%d", index); |
| 1139 | str = kzalloc(sizeof(char) * (strlen(buf) + 1), | 1140 | str = kzalloc(strlen(buf) + 1, |
| 1140 | GFP_KERNEL); | 1141 | GFP_KERNEL); |
| 1141 | if (!str) { | 1142 | if (!str) { |
| 1142 | for (index--; index >= 0; index--) { | 1143 | for (index--; index >= 0; index--) { |
| @@ -1177,15 +1178,17 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
| 1177 | for (index = 0; edev->mutually_exclusive[index]; index++) | 1178 | for (index = 0; edev->mutually_exclusive[index]; index++) |
| 1178 | ; | 1179 | ; |
| 1179 | 1180 | ||
| 1180 | edev->attrs_muex = kzalloc(sizeof(struct attribute *) * | 1181 | edev->attrs_muex = kcalloc(index + 1, |
| 1181 | (index + 1), GFP_KERNEL); | 1182 | sizeof(struct attribute *), |
| 1183 | GFP_KERNEL); | ||
| 1182 | if (!edev->attrs_muex) { | 1184 | if (!edev->attrs_muex) { |
| 1183 | ret = -ENOMEM; | 1185 | ret = -ENOMEM; |
| 1184 | goto err_muex; | 1186 | goto err_muex; |
| 1185 | } | 1187 | } |
| 1186 | 1188 | ||
| 1187 | edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) * | 1189 | edev->d_attrs_muex = kcalloc(index, |
| 1188 | index, GFP_KERNEL); | 1190 | sizeof(struct device_attribute), |
| 1191 | GFP_KERNEL); | ||
| 1189 | if (!edev->d_attrs_muex) { | 1192 | if (!edev->d_attrs_muex) { |
| 1190 | ret = -ENOMEM; | 1193 | ret = -ENOMEM; |
| 1191 | kfree(edev->attrs_muex); | 1194 | kfree(edev->attrs_muex); |
| @@ -1194,7 +1197,7 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
| 1194 | 1197 | ||
| 1195 | for (index = 0; edev->mutually_exclusive[index]; index++) { | 1198 | for (index = 0; edev->mutually_exclusive[index]; index++) { |
| 1196 | sprintf(buf, "0x%x", edev->mutually_exclusive[index]); | 1199 | sprintf(buf, "0x%x", edev->mutually_exclusive[index]); |
| 1197 | name = kzalloc(sizeof(char) * (strlen(buf) + 1), | 1200 | name = kzalloc(strlen(buf) + 1, |
| 1198 | GFP_KERNEL); | 1201 | GFP_KERNEL); |
| 1199 | if (!name) { | 1202 | if (!name) { |
| 1200 | for (index--; index >= 0; index--) { | 1203 | for (index--; index >= 0; index--) { |
| @@ -1220,8 +1223,9 @@ int extcon_dev_register(struct extcon_dev *edev) | |||
| 1220 | 1223 | ||
| 1221 | if (edev->max_supported) { | 1224 | if (edev->max_supported) { |
| 1222 | edev->extcon_dev_type.groups = | 1225 | edev->extcon_dev_type.groups = |
| 1223 | kzalloc(sizeof(struct attribute_group *) * | 1226 | kcalloc(edev->max_supported + 2, |
| 1224 | (edev->max_supported + 2), GFP_KERNEL); | 1227 | sizeof(struct attribute_group *), |
| 1228 | GFP_KERNEL); | ||
| 1225 | if (!edev->extcon_dev_type.groups) { | 1229 | if (!edev->extcon_dev_type.groups) { |
| 1226 | ret = -ENOMEM; | 1230 | ret = -ENOMEM; |
| 1227 | goto err_alloc_groups; | 1231 | goto err_alloc_groups; |
diff --git a/drivers/firewire/core-iso.c b/drivers/firewire/core-iso.c index 38c0aa60b2cb..051327a951b1 100644 --- a/drivers/firewire/core-iso.c +++ b/drivers/firewire/core-iso.c | |||
| @@ -45,8 +45,8 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count) | |||
| 45 | 45 | ||
| 46 | buffer->page_count = 0; | 46 | buffer->page_count = 0; |
| 47 | buffer->page_count_mapped = 0; | 47 | buffer->page_count_mapped = 0; |
| 48 | buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]), | 48 | buffer->pages = kmalloc_array(page_count, sizeof(buffer->pages[0]), |
| 49 | GFP_KERNEL); | 49 | GFP_KERNEL); |
| 50 | if (buffer->pages == NULL) | 50 | if (buffer->pages == NULL) |
| 51 | return -ENOMEM; | 51 | return -ENOMEM; |
| 52 | 52 | ||
diff --git a/drivers/firewire/net.c b/drivers/firewire/net.c index 60e75e6d9104..82ba110d9d1a 100644 --- a/drivers/firewire/net.c +++ b/drivers/firewire/net.c | |||
| @@ -1121,7 +1121,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev) | |||
| 1121 | max_receive = 1U << (dev->card->max_receive + 1); | 1121 | max_receive = 1U << (dev->card->max_receive + 1); |
| 1122 | num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; | 1122 | num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive; |
| 1123 | 1123 | ||
| 1124 | ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL); | 1124 | ptrptr = kmalloc_array(num_packets, sizeof(void *), GFP_KERNEL); |
| 1125 | if (!ptrptr) { | 1125 | if (!ptrptr) { |
| 1126 | retval = -ENOMEM; | 1126 | retval = -ENOMEM; |
| 1127 | goto failed; | 1127 | goto failed; |
diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 6d7a6c0a5e07..c7d06a36b23a 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c | |||
| @@ -890,7 +890,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch) | |||
| 890 | int i; | 890 | int i; |
| 891 | struct scpi_xfer *xfers; | 891 | struct scpi_xfer *xfers; |
| 892 | 892 | ||
| 893 | xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL); | 893 | xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL); |
| 894 | if (!xfers) | 894 | if (!xfers) |
| 895 | return -ENOMEM; | 895 | return -ENOMEM; |
| 896 | 896 | ||
diff --git a/drivers/firmware/dell_rbu.c b/drivers/firmware/dell_rbu.c index 2f452f1f7c8a..fb8af5cb7c9b 100644 --- a/drivers/firmware/dell_rbu.c +++ b/drivers/firmware/dell_rbu.c | |||
| @@ -146,7 +146,7 @@ static int create_packet(void *data, size_t length) | |||
| 146 | packet_array_size = max( | 146 | packet_array_size = max( |
| 147 | (unsigned int)(allocation_floor / rbu_data.packetsize), | 147 | (unsigned int)(allocation_floor / rbu_data.packetsize), |
| 148 | (unsigned int)1); | 148 | (unsigned int)1); |
| 149 | invalid_addr_packet_array = kzalloc(packet_array_size * sizeof(void*), | 149 | invalid_addr_packet_array = kcalloc(packet_array_size, sizeof(void *), |
| 150 | GFP_KERNEL); | 150 | GFP_KERNEL); |
| 151 | 151 | ||
| 152 | if (!invalid_addr_packet_array) { | 152 | if (!invalid_addr_packet_array) { |
diff --git a/drivers/firmware/efi/capsule.c b/drivers/firmware/efi/capsule.c index 901b9306bf94..4938c29b7c5d 100644 --- a/drivers/firmware/efi/capsule.c +++ b/drivers/firmware/efi/capsule.c | |||
| @@ -231,7 +231,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages) | |||
| 231 | count = DIV_ROUND_UP(imagesize, PAGE_SIZE); | 231 | count = DIV_ROUND_UP(imagesize, PAGE_SIZE); |
| 232 | sg_count = sg_pages_num(count); | 232 | sg_count = sg_pages_num(count); |
| 233 | 233 | ||
| 234 | sg_pages = kzalloc(sg_count * sizeof(*sg_pages), GFP_KERNEL); | 234 | sg_pages = kcalloc(sg_count, sizeof(*sg_pages), GFP_KERNEL); |
| 235 | if (!sg_pages) | 235 | if (!sg_pages) |
| 236 | return -ENOMEM; | 236 | return -ENOMEM; |
| 237 | 237 | ||
diff --git a/drivers/firmware/efi/runtime-map.c b/drivers/firmware/efi/runtime-map.c index f377609ff141..84a11d0a8023 100644 --- a/drivers/firmware/efi/runtime-map.c +++ b/drivers/firmware/efi/runtime-map.c | |||
| @@ -166,7 +166,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj) | |||
| 166 | if (!efi_enabled(EFI_MEMMAP)) | 166 | if (!efi_enabled(EFI_MEMMAP)) |
| 167 | return 0; | 167 | return 0; |
| 168 | 168 | ||
| 169 | map_entries = kzalloc(efi.memmap.nr_map * sizeof(entry), GFP_KERNEL); | 169 | map_entries = kcalloc(efi.memmap.nr_map, sizeof(entry), GFP_KERNEL); |
| 170 | if (!map_entries) { | 170 | if (!map_entries) { |
| 171 | ret = -ENOMEM; | 171 | ret = -ENOMEM; |
| 172 | goto out; | 172 | goto out; |
diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index b74a533ef35b..7fa744793bc5 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c | |||
| @@ -1854,9 +1854,9 @@ static int ti_sci_probe(struct platform_device *pdev) | |||
| 1854 | if (!minfo->xfer_block) | 1854 | if (!minfo->xfer_block) |
| 1855 | return -ENOMEM; | 1855 | return -ENOMEM; |
| 1856 | 1856 | ||
| 1857 | minfo->xfer_alloc_table = devm_kzalloc(dev, | 1857 | minfo->xfer_alloc_table = devm_kcalloc(dev, |
| 1858 | BITS_TO_LONGS(desc->max_msgs) | 1858 | BITS_TO_LONGS(desc->max_msgs), |
| 1859 | * sizeof(unsigned long), | 1859 | sizeof(unsigned long), |
| 1860 | GFP_KERNEL); | 1860 | GFP_KERNEL); |
| 1861 | if (!minfo->xfer_alloc_table) | 1861 | if (!minfo->xfer_alloc_table) |
| 1862 | return -ENOMEM; | 1862 | return -ENOMEM; |
diff --git a/drivers/fmc/fmc-sdb.c b/drivers/fmc/fmc-sdb.c index ffdc1762b580..d0e65b86dc22 100644 --- a/drivers/fmc/fmc-sdb.c +++ b/drivers/fmc/fmc-sdb.c | |||
| @@ -48,8 +48,8 @@ static struct sdb_array *__fmc_scan_sdb_tree(struct fmc_device *fmc, | |||
| 48 | arr = kzalloc(sizeof(*arr), GFP_KERNEL); | 48 | arr = kzalloc(sizeof(*arr), GFP_KERNEL); |
| 49 | if (!arr) | 49 | if (!arr) |
| 50 | return ERR_PTR(-ENOMEM); | 50 | return ERR_PTR(-ENOMEM); |
| 51 | arr->record = kzalloc(sizeof(arr->record[0]) * n, GFP_KERNEL); | 51 | arr->record = kcalloc(n, sizeof(arr->record[0]), GFP_KERNEL); |
| 52 | arr->subtree = kzalloc(sizeof(arr->subtree[0]) * n, GFP_KERNEL); | 52 | arr->subtree = kcalloc(n, sizeof(arr->subtree[0]), GFP_KERNEL); |
| 53 | if (!arr->record || !arr->subtree) { | 53 | if (!arr->record || !arr->subtree) { |
| 54 | kfree(arr->record); | 54 | kfree(arr->record); |
| 55 | kfree(arr->subtree); | 55 | kfree(arr->subtree); |
diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index 44c09904daa6..91b90c0cea73 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c | |||
| @@ -427,7 +427,7 @@ static int adnp_irq_setup(struct adnp *adnp) | |||
| 427 | * is chosen to match the register layout of the hardware in that | 427 | * is chosen to match the register layout of the hardware in that |
| 428 | * each segment contains the corresponding bits for all interrupts. | 428 | * each segment contains the corresponding bits for all interrupts. |
| 429 | */ | 429 | */ |
| 430 | adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6, | 430 | adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6, |
| 431 | GFP_KERNEL); | 431 | GFP_KERNEL); |
| 432 | if (!adnp->irq_enable) | 432 | if (!adnp->irq_enable) |
| 433 | return -ENOMEM; | 433 | return -ENOMEM; |
diff --git a/drivers/gpio/gpio-aspeed.c b/drivers/gpio/gpio-aspeed.c index 5e89f1c74a33..b31ae16170e7 100644 --- a/drivers/gpio/gpio-aspeed.c +++ b/drivers/gpio/gpio-aspeed.c | |||
| @@ -897,8 +897,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) | |||
| 897 | 897 | ||
| 898 | /* Allocate a cache of the output registers */ | 898 | /* Allocate a cache of the output registers */ |
| 899 | banks = gpio->config->nr_gpios >> 5; | 899 | banks = gpio->config->nr_gpios >> 5; |
| 900 | gpio->dcache = devm_kzalloc(&pdev->dev, | 900 | gpio->dcache = devm_kcalloc(&pdev->dev, |
| 901 | sizeof(u32) * banks, GFP_KERNEL); | 901 | banks, sizeof(u32), GFP_KERNEL); |
| 902 | if (!gpio->dcache) | 902 | if (!gpio->dcache) |
| 903 | return -ENOMEM; | 903 | return -ENOMEM; |
| 904 | 904 | ||
diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index eb8369b21e90..00272fa7cc4f 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c | |||
| @@ -601,9 +601,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) | |||
| 601 | GPIO_MAX_BANK_NUM); | 601 | GPIO_MAX_BANK_NUM); |
| 602 | return -ENXIO; | 602 | return -ENXIO; |
| 603 | } | 603 | } |
| 604 | kona_gpio->banks = devm_kzalloc(dev, | 604 | kona_gpio->banks = devm_kcalloc(dev, |
| 605 | kona_gpio->num_bank * | 605 | kona_gpio->num_bank, |
| 606 | sizeof(*kona_gpio->banks), GFP_KERNEL); | 606 | sizeof(*kona_gpio->banks), |
| 607 | GFP_KERNEL); | ||
| 607 | if (!kona_gpio->banks) | 608 | if (!kona_gpio->banks) |
| 608 | return -ENOMEM; | 609 | return -ENOMEM; |
| 609 | 610 | ||
diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index b574ecff7761..035a454eca43 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c | |||
| @@ -198,8 +198,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) | |||
| 198 | ngpio = ARCH_NR_GPIOS; | 198 | ngpio = ARCH_NR_GPIOS; |
| 199 | 199 | ||
| 200 | nbank = DIV_ROUND_UP(ngpio, 32); | 200 | nbank = DIV_ROUND_UP(ngpio, 32); |
| 201 | chips = devm_kzalloc(dev, | 201 | chips = devm_kcalloc(dev, |
| 202 | nbank * sizeof(struct davinci_gpio_controller), | 202 | nbank, sizeof(struct davinci_gpio_controller), |
| 203 | GFP_KERNEL); | 203 | GFP_KERNEL); |
| 204 | if (!chips) | 204 | if (!chips) |
| 205 | return -ENOMEM; | 205 | return -ENOMEM; |
diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c index 516383934945..ad6e5b518669 100644 --- a/drivers/gpio/gpio-htc-egpio.c +++ b/drivers/gpio/gpio-htc-egpio.c | |||
| @@ -321,8 +321,8 @@ static int __init egpio_probe(struct platform_device *pdev) | |||
| 321 | platform_set_drvdata(pdev, ei); | 321 | platform_set_drvdata(pdev, ei); |
| 322 | 322 | ||
| 323 | ei->nchips = pdata->num_chips; | 323 | ei->nchips = pdata->num_chips; |
| 324 | ei->chip = devm_kzalloc(&pdev->dev, | 324 | ei->chip = devm_kcalloc(&pdev->dev, |
| 325 | sizeof(struct egpio_chip) * ei->nchips, | 325 | ei->nchips, sizeof(struct egpio_chip), |
| 326 | GFP_KERNEL); | 326 | GFP_KERNEL); |
| 327 | if (!ei->chip) { | 327 | if (!ei->chip) { |
| 328 | ret = -ENOMEM; | 328 | ret = -ENOMEM; |
diff --git a/drivers/gpio/gpio-ml-ioh.c b/drivers/gpio/gpio-ml-ioh.c index e2bee27eb526..b23d9a36be1f 100644 --- a/drivers/gpio/gpio-ml-ioh.c +++ b/drivers/gpio/gpio-ml-ioh.c | |||
| @@ -443,7 +443,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev, | |||
| 443 | goto err_iomap; | 443 | goto err_iomap; |
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | chip_save = kzalloc(sizeof(*chip) * 8, GFP_KERNEL); | 446 | chip_save = kcalloc(8, sizeof(*chip), GFP_KERNEL); |
| 447 | if (chip_save == NULL) { | 447 | if (chip_save == NULL) { |
| 448 | ret = -ENOMEM; | 448 | ret = -ENOMEM; |
| 449 | goto err_kzalloc; | 449 | goto err_kzalloc; |
diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index d16e9d4a129b..1306722faa5a 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c | |||
| @@ -504,16 +504,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev, | |||
| 504 | txgpio->base_msi = (c >> 8) & 0xff; | 504 | txgpio->base_msi = (c >> 8) & 0xff; |
| 505 | } | 505 | } |
| 506 | 506 | ||
| 507 | txgpio->msix_entries = devm_kzalloc(dev, | 507 | txgpio->msix_entries = devm_kcalloc(dev, |
| 508 | sizeof(struct msix_entry) * ngpio, | 508 | ngpio, sizeof(struct msix_entry), |
| 509 | GFP_KERNEL); | 509 | GFP_KERNEL); |
| 510 | if (!txgpio->msix_entries) { | 510 | if (!txgpio->msix_entries) { |
| 511 | err = -ENOMEM; | 511 | err = -ENOMEM; |
| 512 | goto out; | 512 | goto out; |
| 513 | } | 513 | } |
| 514 | 514 | ||
| 515 | txgpio->line_entries = devm_kzalloc(dev, | 515 | txgpio->line_entries = devm_kcalloc(dev, |
| 516 | sizeof(struct thunderx_line) * ngpio, | 516 | ngpio, |
| 517 | sizeof(struct thunderx_line), | ||
| 517 | GFP_KERNEL); | 518 | GFP_KERNEL); |
| 518 | if (!txgpio->line_entries) { | 519 | if (!txgpio->line_entries) { |
| 519 | err = -ENOMEM; | 520 | err = -ENOMEM; |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c index 428e5eb3444f..f4c474a95875 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c | |||
| @@ -310,20 +310,20 @@ static int acp_hw_init(void *handle) | |||
| 310 | pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false); | 310 | pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false); |
| 311 | } | 311 | } |
| 312 | 312 | ||
| 313 | adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS, | 313 | adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell), |
| 314 | GFP_KERNEL); | 314 | GFP_KERNEL); |
| 315 | 315 | ||
| 316 | if (adev->acp.acp_cell == NULL) | 316 | if (adev->acp.acp_cell == NULL) |
| 317 | return -ENOMEM; | 317 | return -ENOMEM; |
| 318 | 318 | ||
| 319 | adev->acp.acp_res = kzalloc(sizeof(struct resource) * 4, GFP_KERNEL); | 319 | adev->acp.acp_res = kcalloc(4, sizeof(struct resource), GFP_KERNEL); |
| 320 | 320 | ||
| 321 | if (adev->acp.acp_res == NULL) { | 321 | if (adev->acp.acp_res == NULL) { |
| 322 | kfree(adev->acp.acp_cell); | 322 | kfree(adev->acp.acp_cell); |
| 323 | return -ENOMEM; | 323 | return -ENOMEM; |
| 324 | } | 324 | } |
| 325 | 325 | ||
| 326 | i2s_pdata = kzalloc(sizeof(struct i2s_platform_data) * 2, GFP_KERNEL); | 326 | i2s_pdata = kcalloc(2, sizeof(struct i2s_platform_data), GFP_KERNEL); |
| 327 | if (i2s_pdata == NULL) { | 327 | if (i2s_pdata == NULL) { |
| 328 | kfree(adev->acp.acp_res); | 328 | kfree(adev->acp.acp_res); |
| 329 | kfree(adev->acp.acp_cell); | 329 | kfree(adev->acp.acp_cell); |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c index 0ff36d45a597..ea79908dac4c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c | |||
| @@ -407,7 +407,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, | |||
| 407 | (*dump)[i++][1] = RREG32(addr); \ | 407 | (*dump)[i++][1] = RREG32(addr); \ |
| 408 | } while (0) | 408 | } while (0) |
| 409 | 409 | ||
| 410 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 410 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 411 | if (*dump == NULL) | 411 | if (*dump == NULL) |
| 412 | return -ENOMEM; | 412 | return -ENOMEM; |
| 413 | 413 | ||
| @@ -504,7 +504,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, | |||
| 504 | #undef HQD_N_REGS | 504 | #undef HQD_N_REGS |
| 505 | #define HQD_N_REGS (19+4) | 505 | #define HQD_N_REGS (19+4) |
| 506 | 506 | ||
| 507 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 507 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 508 | if (*dump == NULL) | 508 | if (*dump == NULL) |
| 509 | return -ENOMEM; | 509 | return -ENOMEM; |
| 510 | 510 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c index 6ef9762b4b00..19dd665e7307 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c | |||
| @@ -395,7 +395,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, | |||
| 395 | (*dump)[i++][1] = RREG32(addr); \ | 395 | (*dump)[i++][1] = RREG32(addr); \ |
| 396 | } while (0) | 396 | } while (0) |
| 397 | 397 | ||
| 398 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 398 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 399 | if (*dump == NULL) | 399 | if (*dump == NULL) |
| 400 | return -ENOMEM; | 400 | return -ENOMEM; |
| 401 | 401 | ||
| @@ -491,7 +491,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, | |||
| 491 | #undef HQD_N_REGS | 491 | #undef HQD_N_REGS |
| 492 | #define HQD_N_REGS (19+4+2+3+7) | 492 | #define HQD_N_REGS (19+4+2+3+7) |
| 493 | 493 | ||
| 494 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 494 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 495 | if (*dump == NULL) | 495 | if (*dump == NULL) |
| 496 | return -ENOMEM; | 496 | return -ENOMEM; |
| 497 | 497 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c index f0c0d3953f69..1db60aa5b7f0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c | |||
| @@ -504,7 +504,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, | |||
| 504 | (*dump)[i++][1] = RREG32(addr); \ | 504 | (*dump)[i++][1] = RREG32(addr); \ |
| 505 | } while (0) | 505 | } while (0) |
| 506 | 506 | ||
| 507 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 507 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 508 | if (*dump == NULL) | 508 | if (*dump == NULL) |
| 509 | return -ENOMEM; | 509 | return -ENOMEM; |
| 510 | 510 | ||
| @@ -606,7 +606,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, | |||
| 606 | #undef HQD_N_REGS | 606 | #undef HQD_N_REGS |
| 607 | #define HQD_N_REGS (19+6+7+10) | 607 | #define HQD_N_REGS (19+6+7+10) |
| 608 | 608 | ||
| 609 | *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL); | 609 | *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL); |
| 610 | if (*dump == NULL) | 610 | if (*dump == NULL) |
| 611 | return -ENOMEM; | 611 | return -ENOMEM; |
| 612 | 612 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c index def1010ac05e..77ad59ade85c 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c | |||
| @@ -452,7 +452,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev) | |||
| 452 | ATOM_PPLIB_PhaseSheddingLimits_Record *entry; | 452 | ATOM_PPLIB_PhaseSheddingLimits_Record *entry; |
| 453 | 453 | ||
| 454 | adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = | 454 | adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = |
| 455 | kzalloc(psl->ucNumEntries * | 455 | kcalloc(psl->ucNumEntries, |
| 456 | sizeof(struct amdgpu_phase_shedding_limits_entry), | 456 | sizeof(struct amdgpu_phase_shedding_limits_entry), |
| 457 | GFP_KERNEL); | 457 | GFP_KERNEL); |
| 458 | if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { | 458 | if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c index 17d6b9fb6d77..dd11b7313ca0 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c | |||
| @@ -369,7 +369,8 @@ int amdgpu_gart_init(struct amdgpu_device *adev) | |||
| 369 | 369 | ||
| 370 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS | 370 | #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS |
| 371 | /* Allocate pages table */ | 371 | /* Allocate pages table */ |
| 372 | adev->gart.pages = vzalloc(sizeof(void *) * adev->gart.num_cpu_pages); | 372 | adev->gart.pages = vzalloc(array_size(sizeof(void *), |
| 373 | adev->gart.num_cpu_pages)); | ||
| 373 | if (adev->gart.pages == NULL) | 374 | if (adev->gart.pages == NULL) |
| 374 | return -ENOMEM; | 375 | return -ENOMEM; |
| 375 | #endif | 376 | #endif |
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c index d167e8ab76d3..e3878256743a 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_test.c | |||
| @@ -53,7 +53,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) | |||
| 53 | n -= adev->irq.ih.ring_size; | 53 | n -= adev->irq.ih.ring_size; |
| 54 | n /= size; | 54 | n /= size; |
| 55 | 55 | ||
| 56 | gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL); | 56 | gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL); |
| 57 | if (!gtt_obj) { | 57 | if (!gtt_obj) { |
| 58 | DRM_ERROR("Failed to allocate %d pointers\n", n); | 58 | DRM_ERROR("Failed to allocate %d pointers\n", n); |
| 59 | r = 1; | 59 | r = 1; |
diff --git a/drivers/gpu/drm/amd/amdgpu/atom.c b/drivers/gpu/drm/amd/amdgpu/atom.c index 69500a8b4e2d..e9934de1b9cf 100644 --- a/drivers/gpu/drm/amd/amdgpu/atom.c +++ b/drivers/gpu/drm/amd/amdgpu/atom.c | |||
| @@ -1221,7 +1221,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, | |||
| 1221 | ectx.abort = false; | 1221 | ectx.abort = false; |
| 1222 | ectx.last_jump = 0; | 1222 | ectx.last_jump = 0; |
| 1223 | if (ws) | 1223 | if (ws) |
| 1224 | ectx.ws = kzalloc(4 * ws, GFP_KERNEL); | 1224 | ectx.ws = kcalloc(4, ws, GFP_KERNEL); |
| 1225 | else | 1225 | else |
| 1226 | ectx.ws = NULL; | 1226 | ectx.ws = NULL; |
| 1227 | 1227 | ||
diff --git a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c index a266dcf5daed..7fbad2f5f0bd 100644 --- a/drivers/gpu/drm/amd/amdgpu/ci_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/ci_dpm.c | |||
| @@ -5679,8 +5679,9 @@ static int ci_parse_power_table(struct amdgpu_device *adev) | |||
| 5679 | (mode_info->atom_context->bios + data_offset + | 5679 | (mode_info->atom_context->bios + data_offset + |
| 5680 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 5680 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 5681 | 5681 | ||
| 5682 | adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) * | 5682 | adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 5683 | state_array->ucNumEntries, GFP_KERNEL); | 5683 | sizeof(struct amdgpu_ps), |
| 5684 | GFP_KERNEL); | ||
| 5684 | if (!adev->pm.dpm.ps) | 5685 | if (!adev->pm.dpm.ps) |
| 5685 | return -ENOMEM; | 5686 | return -ENOMEM; |
| 5686 | power_state_offset = (u8 *)state_array->states; | 5687 | power_state_offset = (u8 *)state_array->states; |
| @@ -5927,7 +5928,9 @@ static int ci_dpm_init(struct amdgpu_device *adev) | |||
| 5927 | ci_set_private_data_variables_based_on_pptable(adev); | 5928 | ci_set_private_data_variables_based_on_pptable(adev); |
| 5928 | 5929 | ||
| 5929 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 5930 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 5930 | kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL); | 5931 | kcalloc(4, |
| 5932 | sizeof(struct amdgpu_clock_voltage_dependency_entry), | ||
| 5933 | GFP_KERNEL); | ||
| 5931 | if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 5934 | if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 5932 | ci_dpm_fini(adev); | 5935 | ci_dpm_fini(adev); |
| 5933 | return -ENOMEM; | 5936 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c index 17f7f074cedc..7a1e77c93bf1 100644 --- a/drivers/gpu/drm/amd/amdgpu/kv_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/kv_dpm.c | |||
| @@ -2727,8 +2727,9 @@ static int kv_parse_power_table(struct amdgpu_device *adev) | |||
| 2727 | (mode_info->atom_context->bios + data_offset + | 2727 | (mode_info->atom_context->bios + data_offset + |
| 2728 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 2728 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 2729 | 2729 | ||
| 2730 | adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) * | 2730 | adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 2731 | state_array->ucNumEntries, GFP_KERNEL); | 2731 | sizeof(struct amdgpu_ps), |
| 2732 | GFP_KERNEL); | ||
| 2732 | if (!adev->pm.dpm.ps) | 2733 | if (!adev->pm.dpm.ps) |
| 2733 | return -ENOMEM; | 2734 | return -ENOMEM; |
| 2734 | power_state_offset = (u8 *)state_array->states; | 2735 | power_state_offset = (u8 *)state_array->states; |
diff --git a/drivers/gpu/drm/amd/amdgpu/si_dpm.c b/drivers/gpu/drm/amd/amdgpu/si_dpm.c index b12d7c9d42a0..5c97a3671726 100644 --- a/drivers/gpu/drm/amd/amdgpu/si_dpm.c +++ b/drivers/gpu/drm/amd/amdgpu/si_dpm.c | |||
| @@ -7242,8 +7242,9 @@ static int si_parse_power_table(struct amdgpu_device *adev) | |||
| 7242 | (mode_info->atom_context->bios + data_offset + | 7242 | (mode_info->atom_context->bios + data_offset + |
| 7243 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 7243 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 7244 | 7244 | ||
| 7245 | adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) * | 7245 | adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 7246 | state_array->ucNumEntries, GFP_KERNEL); | 7246 | sizeof(struct amdgpu_ps), |
| 7247 | GFP_KERNEL); | ||
| 7247 | if (!adev->pm.dpm.ps) | 7248 | if (!adev->pm.dpm.ps) |
| 7248 | return -ENOMEM; | 7249 | return -ENOMEM; |
| 7249 | power_state_offset = (u8 *)state_array->states; | 7250 | power_state_offset = (u8 *)state_array->states; |
| @@ -7346,7 +7347,9 @@ static int si_dpm_init(struct amdgpu_device *adev) | |||
| 7346 | return ret; | 7347 | return ret; |
| 7347 | 7348 | ||
| 7348 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 7349 | adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 7349 | kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL); | 7350 | kcalloc(4, |
| 7351 | sizeof(struct amdgpu_clock_voltage_dependency_entry), | ||
| 7352 | GFP_KERNEL); | ||
| 7350 | if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 7353 | if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 7351 | amdgpu_free_extended_power_table(adev); | 7354 | amdgpu_free_extended_power_table(adev); |
| 7352 | return -ENOMEM; | 7355 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c index bd449351803f..ec304b1a5973 100644 --- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c | |||
| @@ -435,7 +435,7 @@ bool dm_helpers_submit_i2c( | |||
| 435 | return false; | 435 | return false; |
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | msgs = kzalloc(num * sizeof(struct i2c_msg), GFP_KERNEL); | 438 | msgs = kcalloc(num, sizeof(struct i2c_msg), GFP_KERNEL); |
| 439 | 439 | ||
| 440 | if (!msgs) | 440 | if (!msgs) |
| 441 | return false; | 441 | return false; |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/logger.c b/drivers/gpu/drm/amd/display/dc/basics/logger.c index 738a818d58d1..0866874ae8c6 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/logger.c +++ b/drivers/gpu/drm/amd/display/dc/basics/logger.c | |||
| @@ -364,7 +364,7 @@ void dm_logger_open( | |||
| 364 | entry->type = log_type; | 364 | entry->type = log_type; |
| 365 | entry->logger = logger; | 365 | entry->logger = logger; |
| 366 | 366 | ||
| 367 | entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE * sizeof(char), | 367 | entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE, |
| 368 | GFP_KERNEL); | 368 | GFP_KERNEL); |
| 369 | 369 | ||
| 370 | entry->buf_offset = 0; | 370 | entry->buf_offset = 0; |
diff --git a/drivers/gpu/drm/amd/display/dc/basics/vector.c b/drivers/gpu/drm/amd/display/dc/basics/vector.c index 217b8f1f7bf6..d28e9cf0e961 100644 --- a/drivers/gpu/drm/amd/display/dc/basics/vector.c +++ b/drivers/gpu/drm/amd/display/dc/basics/vector.c | |||
| @@ -40,7 +40,7 @@ bool dal_vector_construct( | |||
| 40 | return false; | 40 | return false; |
| 41 | } | 41 | } |
| 42 | 42 | ||
| 43 | vector->container = kzalloc(struct_size * capacity, GFP_KERNEL); | 43 | vector->container = kcalloc(capacity, struct_size, GFP_KERNEL); |
| 44 | if (vector->container == NULL) | 44 | if (vector->container == NULL) |
| 45 | return false; | 45 | return false; |
| 46 | vector->capacity = capacity; | 46 | vector->capacity = capacity; |
| @@ -67,7 +67,7 @@ bool dal_vector_presized_costruct( | |||
| 67 | return false; | 67 | return false; |
| 68 | } | 68 | } |
| 69 | 69 | ||
| 70 | vector->container = kzalloc(struct_size * count, GFP_KERNEL); | 70 | vector->container = kcalloc(count, struct_size, GFP_KERNEL); |
| 71 | 71 | ||
| 72 | if (vector->container == NULL) | 72 | if (vector->container == NULL) |
| 73 | return false; | 73 | return false; |
diff --git a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c index 599c7ab6befe..88b09dd758ba 100644 --- a/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +++ b/drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c | |||
| @@ -1079,13 +1079,15 @@ static void get_ss_info_from_atombios( | |||
| 1079 | if (*ss_entries_num == 0) | 1079 | if (*ss_entries_num == 0) |
| 1080 | return; | 1080 | return; |
| 1081 | 1081 | ||
| 1082 | ss_info = kzalloc(sizeof(struct spread_spectrum_info) * (*ss_entries_num), | 1082 | ss_info = kcalloc(*ss_entries_num, |
| 1083 | sizeof(struct spread_spectrum_info), | ||
| 1083 | GFP_KERNEL); | 1084 | GFP_KERNEL); |
| 1084 | ss_info_cur = ss_info; | 1085 | ss_info_cur = ss_info; |
| 1085 | if (ss_info == NULL) | 1086 | if (ss_info == NULL) |
| 1086 | return; | 1087 | return; |
| 1087 | 1088 | ||
| 1088 | ss_data = kzalloc(sizeof(struct spread_spectrum_data) * (*ss_entries_num), | 1089 | ss_data = kcalloc(*ss_entries_num, |
| 1090 | sizeof(struct spread_spectrum_data), | ||
| 1089 | GFP_KERNEL); | 1091 | GFP_KERNEL); |
| 1090 | if (ss_data == NULL) | 1092 | if (ss_data == NULL) |
| 1091 | goto out_free_info; | 1093 | goto out_free_info; |
diff --git a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c index 80038e0e610f..ab5483c0c502 100644 --- a/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +++ b/drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c | |||
| @@ -98,7 +98,8 @@ struct gpio_service *dal_gpio_service_create( | |||
| 98 | if (number_of_bits) { | 98 | if (number_of_bits) { |
| 99 | uint32_t index_of_uint = 0; | 99 | uint32_t index_of_uint = 0; |
| 100 | 100 | ||
| 101 | slot = kzalloc(number_of_uints * sizeof(uint32_t), | 101 | slot = kcalloc(number_of_uints, |
| 102 | sizeof(uint32_t), | ||
| 102 | GFP_KERNEL); | 103 | GFP_KERNEL); |
| 103 | 104 | ||
| 104 | if (!slot) { | 105 | if (!slot) { |
diff --git a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c index 0cd111d59018..eee0dfad6962 100644 --- a/drivers/gpu/drm/amd/display/modules/color/color_gamma.c +++ b/drivers/gpu/drm/amd/display/modules/color/color_gamma.c | |||
| @@ -1274,19 +1274,22 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, | |||
| 1274 | 1274 | ||
| 1275 | output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; | 1275 | output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; |
| 1276 | 1276 | ||
| 1277 | rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS), | 1277 | rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS, |
| 1278 | sizeof(*rgb_user), | ||
| 1278 | GFP_KERNEL); | 1279 | GFP_KERNEL); |
| 1279 | if (!rgb_user) | 1280 | if (!rgb_user) |
| 1280 | goto rgb_user_alloc_fail; | 1281 | goto rgb_user_alloc_fail; |
| 1281 | rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS), | 1282 | rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1283 | sizeof(*rgb_regamma), | ||
| 1282 | GFP_KERNEL); | 1284 | GFP_KERNEL); |
| 1283 | if (!rgb_regamma) | 1285 | if (!rgb_regamma) |
| 1284 | goto rgb_regamma_alloc_fail; | 1286 | goto rgb_regamma_alloc_fail; |
| 1285 | axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + 3), | 1287 | axix_x = kvcalloc(ramp->num_entries + 3, sizeof(*axix_x), |
| 1286 | GFP_KERNEL); | 1288 | GFP_KERNEL); |
| 1287 | if (!axix_x) | 1289 | if (!axix_x) |
| 1288 | goto axix_x_alloc_fail; | 1290 | goto axix_x_alloc_fail; |
| 1289 | coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL); | 1291 | coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff), |
| 1292 | GFP_KERNEL); | ||
| 1290 | if (!coeff) | 1293 | if (!coeff) |
| 1291 | goto coeff_alloc_fail; | 1294 | goto coeff_alloc_fail; |
| 1292 | 1295 | ||
| @@ -1413,13 +1416,15 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, | |||
| 1413 | 1416 | ||
| 1414 | output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; | 1417 | output_tf->type = TF_TYPE_DISTRIBUTED_POINTS; |
| 1415 | 1418 | ||
| 1416 | rgb_user = kzalloc(sizeof(*rgb_user) * (GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS), | 1419 | rgb_user = kcalloc(GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS, |
| 1417 | GFP_KERNEL); | 1420 | sizeof(*rgb_user), |
| 1421 | GFP_KERNEL); | ||
| 1418 | if (!rgb_user) | 1422 | if (!rgb_user) |
| 1419 | goto rgb_user_alloc_fail; | 1423 | goto rgb_user_alloc_fail; |
| 1420 | 1424 | ||
| 1421 | rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS), | 1425 | rgb_regamma = kcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1422 | GFP_KERNEL); | 1426 | sizeof(*rgb_regamma), |
| 1427 | GFP_KERNEL); | ||
| 1423 | if (!rgb_regamma) | 1428 | if (!rgb_regamma) |
| 1424 | goto rgb_regamma_alloc_fail; | 1429 | goto rgb_regamma_alloc_fail; |
| 1425 | 1430 | ||
| @@ -1480,19 +1485,21 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, | |||
| 1480 | 1485 | ||
| 1481 | input_tf->type = TF_TYPE_DISTRIBUTED_POINTS; | 1486 | input_tf->type = TF_TYPE_DISTRIBUTED_POINTS; |
| 1482 | 1487 | ||
| 1483 | rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS), | 1488 | rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS, |
| 1489 | sizeof(*rgb_user), | ||
| 1484 | GFP_KERNEL); | 1490 | GFP_KERNEL); |
| 1485 | if (!rgb_user) | 1491 | if (!rgb_user) |
| 1486 | goto rgb_user_alloc_fail; | 1492 | goto rgb_user_alloc_fail; |
| 1487 | curve = kvzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS), | 1493 | curve = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*curve), |
| 1488 | GFP_KERNEL); | 1494 | GFP_KERNEL); |
| 1489 | if (!curve) | 1495 | if (!curve) |
| 1490 | goto curve_alloc_fail; | 1496 | goto curve_alloc_fail; |
| 1491 | axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS), | 1497 | axix_x = kvcalloc(ramp->num_entries + _EXTRA_POINTS, sizeof(*axix_x), |
| 1492 | GFP_KERNEL); | 1498 | GFP_KERNEL); |
| 1493 | if (!axix_x) | 1499 | if (!axix_x) |
| 1494 | goto axix_x_alloc_fail; | 1500 | goto axix_x_alloc_fail; |
| 1495 | coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL); | 1501 | coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff), |
| 1502 | GFP_KERNEL); | ||
| 1496 | if (!coeff) | 1503 | if (!coeff) |
| 1497 | goto coeff_alloc_fail; | 1504 | goto coeff_alloc_fail; |
| 1498 | 1505 | ||
| @@ -1569,8 +1576,8 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, | |||
| 1569 | } | 1576 | } |
| 1570 | ret = true; | 1577 | ret = true; |
| 1571 | } else if (trans == TRANSFER_FUNCTION_PQ) { | 1578 | } else if (trans == TRANSFER_FUNCTION_PQ) { |
| 1572 | rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * | 1579 | rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1573 | (MAX_HW_POINTS + _EXTRA_POINTS), | 1580 | sizeof(*rgb_regamma), |
| 1574 | GFP_KERNEL); | 1581 | GFP_KERNEL); |
| 1575 | if (!rgb_regamma) | 1582 | if (!rgb_regamma) |
| 1576 | goto rgb_regamma_alloc_fail; | 1583 | goto rgb_regamma_alloc_fail; |
| @@ -1594,8 +1601,8 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, | |||
| 1594 | kvfree(rgb_regamma); | 1601 | kvfree(rgb_regamma); |
| 1595 | } else if (trans == TRANSFER_FUNCTION_SRGB || | 1602 | } else if (trans == TRANSFER_FUNCTION_SRGB || |
| 1596 | trans == TRANSFER_FUNCTION_BT709) { | 1603 | trans == TRANSFER_FUNCTION_BT709) { |
| 1597 | rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * | 1604 | rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1598 | (MAX_HW_POINTS + _EXTRA_POINTS), | 1605 | sizeof(*rgb_regamma), |
| 1599 | GFP_KERNEL); | 1606 | GFP_KERNEL); |
| 1600 | if (!rgb_regamma) | 1607 | if (!rgb_regamma) |
| 1601 | goto rgb_regamma_alloc_fail; | 1608 | goto rgb_regamma_alloc_fail; |
| @@ -1638,8 +1645,8 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, | |||
| 1638 | } | 1645 | } |
| 1639 | ret = true; | 1646 | ret = true; |
| 1640 | } else if (trans == TRANSFER_FUNCTION_PQ) { | 1647 | } else if (trans == TRANSFER_FUNCTION_PQ) { |
| 1641 | rgb_degamma = kvzalloc(sizeof(*rgb_degamma) * | 1648 | rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1642 | (MAX_HW_POINTS + _EXTRA_POINTS), | 1649 | sizeof(*rgb_degamma), |
| 1643 | GFP_KERNEL); | 1650 | GFP_KERNEL); |
| 1644 | if (!rgb_degamma) | 1651 | if (!rgb_degamma) |
| 1645 | goto rgb_degamma_alloc_fail; | 1652 | goto rgb_degamma_alloc_fail; |
| @@ -1658,8 +1665,8 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, | |||
| 1658 | kvfree(rgb_degamma); | 1665 | kvfree(rgb_degamma); |
| 1659 | } else if (trans == TRANSFER_FUNCTION_SRGB || | 1666 | } else if (trans == TRANSFER_FUNCTION_SRGB || |
| 1660 | trans == TRANSFER_FUNCTION_BT709) { | 1667 | trans == TRANSFER_FUNCTION_BT709) { |
| 1661 | rgb_degamma = kvzalloc(sizeof(*rgb_degamma) * | 1668 | rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, |
| 1662 | (MAX_HW_POINTS + _EXTRA_POINTS), | 1669 | sizeof(*rgb_degamma), |
| 1663 | GFP_KERNEL); | 1670 | GFP_KERNEL); |
| 1664 | if (!rgb_degamma) | 1671 | if (!rgb_degamma) |
| 1665 | goto rgb_degamma_alloc_fail; | 1672 | goto rgb_degamma_alloc_fail; |
diff --git a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c index 27d4003aa2c7..fa344ceafc17 100644 --- a/drivers/gpu/drm/amd/display/modules/freesync/freesync.c +++ b/drivers/gpu/drm/amd/display/modules/freesync/freesync.c | |||
| @@ -155,7 +155,8 @@ struct mod_freesync *mod_freesync_create(struct dc *dc) | |||
| 155 | if (core_freesync == NULL) | 155 | if (core_freesync == NULL) |
| 156 | goto fail_alloc_context; | 156 | goto fail_alloc_context; |
| 157 | 157 | ||
| 158 | core_freesync->map = kzalloc(sizeof(struct freesync_entity) * MOD_FREESYNC_MAX_CONCURRENT_STREAMS, | 158 | core_freesync->map = kcalloc(MOD_FREESYNC_MAX_CONCURRENT_STREAMS, |
| 159 | sizeof(struct freesync_entity), | ||
| 159 | GFP_KERNEL); | 160 | GFP_KERNEL); |
| 160 | 161 | ||
| 161 | if (core_freesync->map == NULL) | 162 | if (core_freesync->map == NULL) |
diff --git a/drivers/gpu/drm/amd/display/modules/stats/stats.c b/drivers/gpu/drm/amd/display/modules/stats/stats.c index 3f7d47fdc367..710852ad03f3 100644 --- a/drivers/gpu/drm/amd/display/modules/stats/stats.c +++ b/drivers/gpu/drm/amd/display/modules/stats/stats.c | |||
| @@ -141,19 +141,17 @@ struct mod_stats *mod_stats_create(struct dc *dc) | |||
| 141 | else | 141 | else |
| 142 | core_stats->entries = reg_data; | 142 | core_stats->entries = reg_data; |
| 143 | } | 143 | } |
| 144 | core_stats->time = kzalloc( | 144 | core_stats->time = kcalloc(core_stats->entries, |
| 145 | sizeof(struct stats_time_cache) * | 145 | sizeof(struct stats_time_cache), |
| 146 | core_stats->entries, | ||
| 147 | GFP_KERNEL); | 146 | GFP_KERNEL); |
| 148 | 147 | ||
| 149 | if (core_stats->time == NULL) | 148 | if (core_stats->time == NULL) |
| 150 | goto fail_construct_time; | 149 | goto fail_construct_time; |
| 151 | 150 | ||
| 152 | core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT; | 151 | core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT; |
| 153 | core_stats->events = kzalloc( | 152 | core_stats->events = kcalloc(core_stats->event_entries, |
| 154 | sizeof(struct stats_event_cache) * | 153 | sizeof(struct stats_event_cache), |
| 155 | core_stats->event_entries, | 154 | GFP_KERNEL); |
| 156 | GFP_KERNEL); | ||
| 157 | 155 | ||
| 158 | if (core_stats->events == NULL) | 156 | if (core_stats->events == NULL) |
| 159 | goto fail_construct_events; | 157 | goto fail_construct_events; |
diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c index 0af13c154328..e45a1fcc7f08 100644 --- a/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +++ b/drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c | |||
| @@ -50,7 +50,7 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) | |||
| 50 | return 0; | 50 | return 0; |
| 51 | } | 51 | } |
| 52 | 52 | ||
| 53 | hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL); | 53 | hwmgr->ps = kcalloc(table_entries, size, GFP_KERNEL); |
| 54 | if (hwmgr->ps == NULL) | 54 | if (hwmgr->ps == NULL) |
| 55 | return -ENOMEM; | 55 | return -ENOMEM; |
| 56 | 56 | ||
diff --git a/drivers/gpu/drm/drm_edid.c b/drivers/gpu/drm/drm_edid.c index 40e1e24f2ff0..a5808382bdf0 100644 --- a/drivers/gpu/drm/drm_edid.c +++ b/drivers/gpu/drm/drm_edid.c | |||
| @@ -1633,7 +1633,8 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, | |||
| 1633 | edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions; | 1633 | edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions; |
| 1634 | edid[0x7e] = valid_extensions; | 1634 | edid[0x7e] = valid_extensions; |
| 1635 | 1635 | ||
| 1636 | new = kmalloc((valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL); | 1636 | new = kmalloc_array(valid_extensions + 1, EDID_LENGTH, |
| 1637 | GFP_KERNEL); | ||
| 1637 | if (!new) | 1638 | if (!new) |
| 1638 | goto out; | 1639 | goto out; |
| 1639 | 1640 | ||
diff --git a/drivers/gpu/drm/drm_hashtab.c b/drivers/gpu/drm/drm_hashtab.c index dae18e58e79b..c92b00d42ece 100644 --- a/drivers/gpu/drm/drm_hashtab.c +++ b/drivers/gpu/drm/drm_hashtab.c | |||
| @@ -47,7 +47,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order) | |||
| 47 | if (size <= PAGE_SIZE / sizeof(*ht->table)) | 47 | if (size <= PAGE_SIZE / sizeof(*ht->table)) |
| 48 | ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL); | 48 | ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL); |
| 49 | else | 49 | else |
| 50 | ht->table = vzalloc(size*sizeof(*ht->table)); | 50 | ht->table = vzalloc(array_size(size, sizeof(*ht->table))); |
| 51 | if (!ht->table) { | 51 | if (!ht->table) { |
| 52 | DRM_ERROR("Out of memory for hash table\n"); | 52 | DRM_ERROR("Out of memory for hash table\n"); |
| 53 | return -ENOMEM; | 53 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c index 3c54044214db..d69e4fc1ee77 100644 --- a/drivers/gpu/drm/drm_memory.c +++ b/drivers/gpu/drm/drm_memory.c | |||
| @@ -80,7 +80,7 @@ static void *agp_remap(unsigned long offset, unsigned long size, | |||
| 80 | * page-table instead (that's probably faster anyhow...). | 80 | * page-table instead (that's probably faster anyhow...). |
| 81 | */ | 81 | */ |
| 82 | /* note: use vmalloc() because num_pages could be large... */ | 82 | /* note: use vmalloc() because num_pages could be large... */ |
| 83 | page_map = vmalloc(num_pages * sizeof(struct page *)); | 83 | page_map = vmalloc(array_size(num_pages, sizeof(struct page *))); |
| 84 | if (!page_map) | 84 | if (!page_map) |
| 85 | return NULL; | 85 | return NULL; |
| 86 | 86 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 7c3030b7e586..6d29777884f9 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c | |||
| @@ -1723,8 +1723,8 @@ static int exynos_dsi_probe(struct platform_device *pdev) | |||
| 1723 | return -EPROBE_DEFER; | 1723 | return -EPROBE_DEFER; |
| 1724 | } | 1724 | } |
| 1725 | 1725 | ||
| 1726 | dsi->clks = devm_kzalloc(dev, | 1726 | dsi->clks = devm_kcalloc(dev, |
| 1727 | sizeof(*dsi->clks) * dsi->driver_data->num_clks, | 1727 | dsi->driver_data->num_clks, sizeof(*dsi->clks), |
| 1728 | GFP_KERNEL); | 1728 | GFP_KERNEL); |
| 1729 | if (!dsi->clks) | 1729 | if (!dsi->clks) |
| 1730 | return -ENOMEM; | 1730 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/exynos/exynos_drm_fimc.c b/drivers/gpu/drm/exynos/exynos_drm_fimc.c index 5ce84025d1cb..6127ef25acd6 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_fimc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_fimc.c | |||
| @@ -1271,7 +1271,8 @@ static int fimc_probe(struct platform_device *pdev) | |||
| 1271 | 1271 | ||
| 1272 | /* construct formats/limits array */ | 1272 | /* construct formats/limits array */ |
| 1273 | num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats); | 1273 | num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats); |
| 1274 | formats = devm_kzalloc(dev, sizeof(*formats) * num_formats, GFP_KERNEL); | 1274 | formats = devm_kcalloc(dev, num_formats, sizeof(*formats), |
| 1275 | GFP_KERNEL); | ||
| 1275 | if (!formats) | 1276 | if (!formats) |
| 1276 | return -ENOMEM; | 1277 | return -ENOMEM; |
| 1277 | 1278 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_drm_gsc.c b/drivers/gpu/drm/exynos/exynos_drm_gsc.c index e99dd1e4ba65..35ac66730563 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_gsc.c +++ b/drivers/gpu/drm/exynos/exynos_drm_gsc.c | |||
| @@ -1202,8 +1202,9 @@ static int gsc_probe(struct platform_device *pdev) | |||
| 1202 | if (!ctx) | 1202 | if (!ctx) |
| 1203 | return -ENOMEM; | 1203 | return -ENOMEM; |
| 1204 | 1204 | ||
| 1205 | formats = devm_kzalloc(dev, sizeof(*formats) * | 1205 | formats = devm_kcalloc(dev, |
| 1206 | (ARRAY_SIZE(gsc_formats)), GFP_KERNEL); | 1206 | ARRAY_SIZE(gsc_formats), sizeof(*formats), |
| 1207 | GFP_KERNEL); | ||
| 1207 | if (!formats) | 1208 | if (!formats) |
| 1208 | return -ENOMEM; | 1209 | return -ENOMEM; |
| 1209 | 1210 | ||
diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 09c4bc0b1859..db91932550cf 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c | |||
| @@ -1692,7 +1692,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata) | |||
| 1692 | if (!count) | 1692 | if (!count) |
| 1693 | return 0; | 1693 | return 0; |
| 1694 | 1694 | ||
| 1695 | clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL); | 1695 | clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL); |
| 1696 | if (!clks) | 1696 | if (!clks) |
| 1697 | return -ENOMEM; | 1697 | return -ENOMEM; |
| 1698 | 1698 | ||
diff --git a/drivers/gpu/drm/gma500/mid_bios.c b/drivers/gpu/drm/gma500/mid_bios.c index 7171b7475f58..237041a37532 100644 --- a/drivers/gpu/drm/gma500/mid_bios.c +++ b/drivers/gpu/drm/gma500/mid_bios.c | |||
| @@ -239,7 +239,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr) | |||
| 239 | if (read_vbt_r10(addr, &vbt)) | 239 | if (read_vbt_r10(addr, &vbt)) |
| 240 | return -1; | 240 | return -1; |
| 241 | 241 | ||
| 242 | gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL); | 242 | gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL); |
| 243 | if (!gct) | 243 | if (!gct) |
| 244 | return -ENOMEM; | 244 | return -ENOMEM; |
| 245 | 245 | ||
diff --git a/drivers/gpu/drm/i915/gvt/gtt.c b/drivers/gpu/drm/i915/gvt/gtt.c index 78e55aafc8bc..23296547da95 100644 --- a/drivers/gpu/drm/i915/gvt/gtt.c +++ b/drivers/gpu/drm/i915/gvt/gtt.c | |||
| @@ -1585,8 +1585,9 @@ static struct intel_vgpu_mm *intel_vgpu_create_ggtt_mm(struct intel_vgpu *vgpu) | |||
| 1585 | mm->type = INTEL_GVT_MM_GGTT; | 1585 | mm->type = INTEL_GVT_MM_GGTT; |
| 1586 | 1586 | ||
| 1587 | nr_entries = gvt_ggtt_gm_sz(vgpu->gvt) >> I915_GTT_PAGE_SHIFT; | 1587 | nr_entries = gvt_ggtt_gm_sz(vgpu->gvt) >> I915_GTT_PAGE_SHIFT; |
| 1588 | mm->ggtt_mm.virtual_ggtt = vzalloc(nr_entries * | 1588 | mm->ggtt_mm.virtual_ggtt = |
| 1589 | vgpu->gvt->device_info.gtt_entry_size); | 1589 | vzalloc(array_size(nr_entries, |
| 1590 | vgpu->gvt->device_info.gtt_entry_size)); | ||
| 1590 | if (!mm->ggtt_mm.virtual_ggtt) { | 1591 | if (!mm->ggtt_mm.virtual_ggtt) { |
| 1591 | vgpu_free_mm(mm); | 1592 | vgpu_free_mm(mm); |
| 1592 | return ERR_PTR(-ENOMEM); | 1593 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/gpu/drm/i915/gvt/mmio.c b/drivers/gpu/drm/i915/gvt/mmio.c index e4960aff68bd..b31eb36fc102 100644 --- a/drivers/gpu/drm/i915/gvt/mmio.c +++ b/drivers/gpu/drm/i915/gvt/mmio.c | |||
| @@ -267,7 +267,7 @@ int intel_vgpu_init_mmio(struct intel_vgpu *vgpu) | |||
| 267 | { | 267 | { |
| 268 | const struct intel_gvt_device_info *info = &vgpu->gvt->device_info; | 268 | const struct intel_gvt_device_info *info = &vgpu->gvt->device_info; |
| 269 | 269 | ||
| 270 | vgpu->mmio.vreg = vzalloc(info->mmio_size * 2); | 270 | vgpu->mmio.vreg = vzalloc(array_size(info->mmio_size, 2)); |
| 271 | if (!vgpu->mmio.vreg) | 271 | if (!vgpu->mmio.vreg) |
| 272 | return -ENOMEM; | 272 | return -ENOMEM; |
| 273 | 273 | ||
diff --git a/drivers/gpu/drm/i915/gvt/vgpu.c b/drivers/gpu/drm/i915/gvt/vgpu.c index 2e0a02a80fe4..572a18c2bfb5 100644 --- a/drivers/gpu/drm/i915/gvt/vgpu.c +++ b/drivers/gpu/drm/i915/gvt/vgpu.c | |||
| @@ -121,7 +121,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt) | |||
| 121 | high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE; | 121 | high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE; |
| 122 | num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]); | 122 | num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]); |
| 123 | 123 | ||
| 124 | gvt->types = kzalloc(num_types * sizeof(struct intel_vgpu_type), | 124 | gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type), |
| 125 | GFP_KERNEL); | 125 | GFP_KERNEL); |
| 126 | if (!gvt->types) | 126 | if (!gvt->types) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/i915/intel_hdcp.c b/drivers/gpu/drm/i915/intel_hdcp.c index 2db5da550a1c..0cc6a861bcf8 100644 --- a/drivers/gpu/drm/i915/intel_hdcp.c +++ b/drivers/gpu/drm/i915/intel_hdcp.c | |||
| @@ -429,7 +429,7 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port, | |||
| 429 | if (num_downstream == 0) | 429 | if (num_downstream == 0) |
| 430 | return -EINVAL; | 430 | return -EINVAL; |
| 431 | 431 | ||
| 432 | ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL); | 432 | ksv_fifo = kcalloc(DRM_HDCP_KSV_LEN, num_downstream, GFP_KERNEL); |
| 433 | if (!ksv_fifo) | 433 | if (!ksv_fifo) |
| 434 | return -ENOMEM; | 434 | return -ENOMEM; |
| 435 | 435 | ||
diff --git a/drivers/gpu/drm/i915/selftests/intel_uncore.c b/drivers/gpu/drm/i915/selftests/intel_uncore.c index f76f2597df5c..47bc5b2ddb56 100644 --- a/drivers/gpu/drm/i915/selftests/intel_uncore.c +++ b/drivers/gpu/drm/i915/selftests/intel_uncore.c | |||
| @@ -137,7 +137,7 @@ static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_pri | |||
| 137 | if (!IS_ENABLED(CONFIG_DRM_I915_SELFTEST_BROKEN)) | 137 | if (!IS_ENABLED(CONFIG_DRM_I915_SELFTEST_BROKEN)) |
| 138 | return 0; | 138 | return 0; |
| 139 | 139 | ||
| 140 | valid = kzalloc(BITS_TO_LONGS(FW_RANGE) * sizeof(*valid), | 140 | valid = kcalloc(BITS_TO_LONGS(FW_RANGE), sizeof(*valid), |
| 141 | GFP_KERNEL); | 141 | GFP_KERNEL); |
| 142 | if (!valid) | 142 | if (!valid) |
| 143 | return -ENOMEM; | 143 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index e63dc0fb55f8..c79659ca5706 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c | |||
| @@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) | |||
| 157 | hdmi->qfprom_mmio = NULL; | 157 | hdmi->qfprom_mmio = NULL; |
| 158 | } | 158 | } |
| 159 | 159 | ||
| 160 | hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) * | 160 | hdmi->hpd_regs = devm_kcalloc(&pdev->dev, |
| 161 | config->hpd_reg_cnt, GFP_KERNEL); | 161 | config->hpd_reg_cnt, |
| 162 | sizeof(hdmi->hpd_regs[0]), | ||
| 163 | GFP_KERNEL); | ||
| 162 | if (!hdmi->hpd_regs) { | 164 | if (!hdmi->hpd_regs) { |
| 163 | ret = -ENOMEM; | 165 | ret = -ENOMEM; |
| 164 | goto fail; | 166 | goto fail; |
| @@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) | |||
| 178 | hdmi->hpd_regs[i] = reg; | 180 | hdmi->hpd_regs[i] = reg; |
| 179 | } | 181 | } |
| 180 | 182 | ||
| 181 | hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) * | 183 | hdmi->pwr_regs = devm_kcalloc(&pdev->dev, |
| 182 | config->pwr_reg_cnt, GFP_KERNEL); | 184 | config->pwr_reg_cnt, |
| 185 | sizeof(hdmi->pwr_regs[0]), | ||
| 186 | GFP_KERNEL); | ||
| 183 | if (!hdmi->pwr_regs) { | 187 | if (!hdmi->pwr_regs) { |
| 184 | ret = -ENOMEM; | 188 | ret = -ENOMEM; |
| 185 | goto fail; | 189 | goto fail; |
| @@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) | |||
| 199 | hdmi->pwr_regs[i] = reg; | 203 | hdmi->pwr_regs[i] = reg; |
| 200 | } | 204 | } |
| 201 | 205 | ||
| 202 | hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) * | 206 | hdmi->hpd_clks = devm_kcalloc(&pdev->dev, |
| 203 | config->hpd_clk_cnt, GFP_KERNEL); | 207 | config->hpd_clk_cnt, |
| 208 | sizeof(hdmi->hpd_clks[0]), | ||
| 209 | GFP_KERNEL); | ||
| 204 | if (!hdmi->hpd_clks) { | 210 | if (!hdmi->hpd_clks) { |
| 205 | ret = -ENOMEM; | 211 | ret = -ENOMEM; |
| 206 | goto fail; | 212 | goto fail; |
| @@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) | |||
| 219 | hdmi->hpd_clks[i] = clk; | 225 | hdmi->hpd_clks[i] = clk; |
| 220 | } | 226 | } |
| 221 | 227 | ||
| 222 | hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) * | 228 | hdmi->pwr_clks = devm_kcalloc(&pdev->dev, |
| 223 | config->pwr_clk_cnt, GFP_KERNEL); | 229 | config->pwr_clk_cnt, |
| 230 | sizeof(hdmi->pwr_clks[0]), | ||
| 231 | GFP_KERNEL); | ||
| 224 | if (!hdmi->pwr_clks) { | 232 | if (!hdmi->pwr_clks) { |
| 225 | ret = -ENOMEM; | 233 | ret = -ENOMEM; |
| 226 | goto fail; | 234 | goto fail; |
diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c index 5e631392dc85..4157722d6b4d 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c | |||
| @@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy) | |||
| 21 | struct device *dev = &phy->pdev->dev; | 21 | struct device *dev = &phy->pdev->dev; |
| 22 | int i, ret; | 22 | int i, ret; |
| 23 | 23 | ||
| 24 | phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs, | 24 | phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]), |
| 25 | GFP_KERNEL); | 25 | GFP_KERNEL); |
| 26 | if (!phy->regs) | 26 | if (!phy->regs) |
| 27 | return -ENOMEM; | 27 | return -ENOMEM; |
| 28 | 28 | ||
| 29 | phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks, | 29 | phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]), |
| 30 | GFP_KERNEL); | 30 | GFP_KERNEL); |
| 31 | if (!phy->clks) | 31 | if (!phy->clks) |
| 32 | return -ENOMEM; | 32 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c index 090664899247..e721bb2163a0 100644 --- a/drivers/gpu/drm/nouveau/nv84_fence.c +++ b/drivers/gpu/drm/nouveau/nv84_fence.c | |||
| @@ -141,7 +141,7 @@ nv84_fence_suspend(struct nouveau_drm *drm) | |||
| 141 | struct nv84_fence_priv *priv = drm->fence; | 141 | struct nv84_fence_priv *priv = drm->fence; |
| 142 | int i; | 142 | int i; |
| 143 | 143 | ||
| 144 | priv->suspend = vmalloc(drm->chan.nr * sizeof(u32)); | 144 | priv->suspend = vmalloc(array_size(sizeof(u32), drm->chan.nr)); |
| 145 | if (priv->suspend) { | 145 | if (priv->suspend) { |
| 146 | for (i = 0; i < drm->chan.nr; i++) | 146 | for (i = 0; i < drm->chan.nr; i++) |
| 147 | priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4); | 147 | priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4); |
diff --git a/drivers/gpu/drm/nouveau/nvif/fifo.c b/drivers/gpu/drm/nouveau/nvif/fifo.c index 99d4fd17543c..e84a2e2ff043 100644 --- a/drivers/gpu/drm/nouveau/nvif/fifo.c +++ b/drivers/gpu/drm/nouveau/nvif/fifo.c | |||
| @@ -50,8 +50,8 @@ nvif_fifo_runlists(struct nvif_device *device) | |||
| 50 | goto done; | 50 | goto done; |
| 51 | 51 | ||
| 52 | device->runlists = fls64(a->v.runlists.data); | 52 | device->runlists = fls64(a->v.runlists.data); |
| 53 | device->runlist = kzalloc(sizeof(*device->runlist) * | 53 | device->runlist = kcalloc(device->runlists, sizeof(*device->runlist), |
| 54 | device->runlists, GFP_KERNEL); | 54 | GFP_KERNEL); |
| 55 | if (!device->runlist) { | 55 | if (!device->runlist) { |
| 56 | ret = -ENOMEM; | 56 | ret = -ENOMEM; |
| 57 | goto done; | 57 | goto done; |
diff --git a/drivers/gpu/drm/nouveau/nvif/mmu.c b/drivers/gpu/drm/nouveau/nvif/mmu.c index 358ac4f3cf91..ae08a1ca8044 100644 --- a/drivers/gpu/drm/nouveau/nvif/mmu.c +++ b/drivers/gpu/drm/nouveau/nvif/mmu.c | |||
| @@ -65,12 +65,15 @@ nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu) | |||
| 65 | goto done; | 65 | goto done; |
| 66 | mmu->mem = mems[ret].oclass; | 66 | mmu->mem = mems[ret].oclass; |
| 67 | 67 | ||
| 68 | mmu->heap = kmalloc(sizeof(*mmu->heap) * mmu->heap_nr, GFP_KERNEL); | 68 | mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap), |
| 69 | mmu->type = kmalloc(sizeof(*mmu->type) * mmu->type_nr, GFP_KERNEL); | 69 | GFP_KERNEL); |
| 70 | mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type), | ||
| 71 | GFP_KERNEL); | ||
| 70 | if (ret = -ENOMEM, !mmu->heap || !mmu->type) | 72 | if (ret = -ENOMEM, !mmu->heap || !mmu->type) |
| 71 | goto done; | 73 | goto done; |
| 72 | 74 | ||
| 73 | mmu->kind = kmalloc(sizeof(*mmu->kind) * mmu->kind_nr, GFP_KERNEL); | 75 | mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind), |
| 76 | GFP_KERNEL); | ||
| 74 | if (!mmu->kind && mmu->kind_nr) | 77 | if (!mmu->kind && mmu->kind_nr) |
| 75 | goto done; | 78 | goto done; |
| 76 | 79 | ||
diff --git a/drivers/gpu/drm/nouveau/nvif/object.c b/drivers/gpu/drm/nouveau/nvif/object.c index 40adfe9b334b..ef3f62840e83 100644 --- a/drivers/gpu/drm/nouveau/nvif/object.c +++ b/drivers/gpu/drm/nouveau/nvif/object.c | |||
| @@ -83,7 +83,7 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass) | |||
| 83 | return ret; | 83 | return ret; |
| 84 | } | 84 | } |
| 85 | 85 | ||
| 86 | *psclass = kzalloc(sizeof(**psclass) * args->sclass.count, GFP_KERNEL); | 86 | *psclass = kcalloc(args->sclass.count, sizeof(**psclass), GFP_KERNEL); |
| 87 | if (*psclass) { | 87 | if (*psclass) { |
| 88 | for (i = 0; i < args->sclass.count; i++) { | 88 | for (i = 0; i < args->sclass.count; i++) { |
| 89 | (*psclass)[i].oclass = args->sclass.oclass[i].oclass; | 89 | (*psclass)[i].oclass = args->sclass.oclass[i].oclass; |
diff --git a/drivers/gpu/drm/nouveau/nvif/vmm.c b/drivers/gpu/drm/nouveau/nvif/vmm.c index 191832be6c65..6b9c5776547f 100644 --- a/drivers/gpu/drm/nouveau/nvif/vmm.c +++ b/drivers/gpu/drm/nouveau/nvif/vmm.c | |||
| @@ -138,7 +138,8 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size, | |||
| 138 | vmm->limit = args->size; | 138 | vmm->limit = args->size; |
| 139 | 139 | ||
| 140 | vmm->page_nr = args->page_nr; | 140 | vmm->page_nr = args->page_nr; |
| 141 | vmm->page = kmalloc(sizeof(*vmm->page) * vmm->page_nr, GFP_KERNEL); | 141 | vmm->page = kmalloc_array(vmm->page_nr, sizeof(*vmm->page), |
| 142 | GFP_KERNEL); | ||
| 142 | if (!vmm->page) { | 143 | if (!vmm->page) { |
| 143 | ret = -ENOMEM; | 144 | ret = -ENOMEM; |
| 144 | goto done; | 145 | goto done; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/core/event.c b/drivers/gpu/drm/nouveau/nvkm/core/event.c index 4e8d3fa042df..006618d77aa4 100644 --- a/drivers/gpu/drm/nouveau/nvkm/core/event.c +++ b/drivers/gpu/drm/nouveau/nvkm/core/event.c | |||
| @@ -84,7 +84,8 @@ int | |||
| 84 | nvkm_event_init(const struct nvkm_event_func *func, int types_nr, int index_nr, | 84 | nvkm_event_init(const struct nvkm_event_func *func, int types_nr, int index_nr, |
| 85 | struct nvkm_event *event) | 85 | struct nvkm_event *event) |
| 86 | { | 86 | { |
| 87 | event->refs = kzalloc(sizeof(*event->refs) * index_nr * types_nr, | 87 | event->refs = kzalloc(array3_size(index_nr, types_nr, |
| 88 | sizeof(*event->refs)), | ||
| 88 | GFP_KERNEL); | 89 | GFP_KERNEL); |
| 89 | if (!event->refs) | 90 | if (!event->refs) |
| 90 | return -ENOMEM; | 91 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c index a99046414a18..afccf9721cf0 100644 --- a/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c +++ b/drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c | |||
| @@ -910,7 +910,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base) | |||
| 910 | nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr); | 910 | nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr); |
| 911 | 911 | ||
| 912 | /* Read PBDMA->runlist(s) mapping from HW. */ | 912 | /* Read PBDMA->runlist(s) mapping from HW. */ |
| 913 | if (!(map = kzalloc(sizeof(*map) * fifo->pbdma_nr, GFP_KERNEL))) | 913 | if (!(map = kcalloc(fifo->pbdma_nr, sizeof(*map), GFP_KERNEL))) |
| 914 | return -ENOMEM; | 914 | return -ENOMEM; |
| 915 | 915 | ||
| 916 | for (i = 0; i < fifo->pbdma_nr; i++) | 916 | for (i = 0; i < fifo->pbdma_nr; i++) |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c index 73e463ed55c3..dea444d48f94 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c | |||
| @@ -73,7 +73,8 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense) | |||
| 73 | } | 73 | } |
| 74 | 74 | ||
| 75 | iccsense->nr_entry = cnt; | 75 | iccsense->nr_entry = cnt; |
| 76 | iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL); | 76 | iccsense->rail = kmalloc_array(cnt, sizeof(struct pwr_rail_t), |
| 77 | GFP_KERNEL); | ||
| 77 | if (!iccsense->rail) | 78 | if (!iccsense->rail) |
| 78 | return -ENOMEM; | 79 | return -ENOMEM; |
| 79 | 80 | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c index 920b3d347803..bbfde1cb3a17 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c | |||
| @@ -171,7 +171,7 @@ gt215_link_train(struct gt215_ram *ram) | |||
| 171 | return -ENOSYS; | 171 | return -ENOSYS; |
| 172 | 172 | ||
| 173 | /* XXX: Multiple partitions? */ | 173 | /* XXX: Multiple partitions? */ |
| 174 | result = kmalloc(64 * sizeof(u32), GFP_KERNEL); | 174 | result = kmalloc_array(64, sizeof(u32), GFP_KERNEL); |
| 175 | if (!result) | 175 | if (!result) |
| 176 | return -ENOMEM; | 176 | return -ENOMEM; |
| 177 | 177 | ||
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c index 39808489f21d..92e363dbbc5a 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c | |||
| @@ -191,9 +191,9 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size, | |||
| 191 | nvkm_memory_ctor(&nvkm_mem_dma, &mem->memory); | 191 | nvkm_memory_ctor(&nvkm_mem_dma, &mem->memory); |
| 192 | size = ALIGN(size, PAGE_SIZE) >> PAGE_SHIFT; | 192 | size = ALIGN(size, PAGE_SIZE) >> PAGE_SHIFT; |
| 193 | 193 | ||
| 194 | if (!(mem->mem = kvmalloc(sizeof(*mem->mem) * size, GFP_KERNEL))) | 194 | if (!(mem->mem = kvmalloc_array(size, sizeof(*mem->mem), GFP_KERNEL))) |
| 195 | return -ENOMEM; | 195 | return -ENOMEM; |
| 196 | if (!(mem->dma = kvmalloc(sizeof(*mem->dma) * size, GFP_KERNEL))) | 196 | if (!(mem->dma = kvmalloc_array(size, sizeof(*mem->dma), GFP_KERNEL))) |
| 197 | return -ENOMEM; | 197 | return -ENOMEM; |
| 198 | 198 | ||
| 199 | if (mmu->dma_bits > 32) | 199 | if (mmu->dma_bits > 32) |
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c index 1c12e58f44c2..de269eb482dd 100644 --- a/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +++ b/drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | |||
| @@ -59,7 +59,7 @@ nvkm_vmm_pt_new(const struct nvkm_vmm_desc *desc, bool sparse, | |||
| 59 | pgt->sparse = sparse; | 59 | pgt->sparse = sparse; |
| 60 | 60 | ||
| 61 | if (desc->type == PGD) { | 61 | if (desc->type == PGD) { |
| 62 | pgt->pde = kvzalloc(sizeof(*pgt->pde) * pten, GFP_KERNEL); | 62 | pgt->pde = kvcalloc(pten, sizeof(*pgt->pde), GFP_KERNEL); |
| 63 | if (!pgt->pde) { | 63 | if (!pgt->pde) { |
| 64 | kfree(pgt); | 64 | kfree(pgt); |
| 65 | return NULL; | 65 | return NULL; |
diff --git a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c index 401c02e9e6b2..f92fe205550b 100644 --- a/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +++ b/drivers/gpu/drm/omapdrm/omap_dmm_tiler.c | |||
| @@ -940,8 +940,8 @@ int tiler_map_show(struct seq_file *s, void *arg) | |||
| 940 | h_adj = omap_dmm->container_height / ydiv; | 940 | h_adj = omap_dmm->container_height / ydiv; |
| 941 | w_adj = omap_dmm->container_width / xdiv; | 941 | w_adj = omap_dmm->container_width / xdiv; |
| 942 | 942 | ||
| 943 | map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL); | 943 | map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL); |
| 944 | global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL); | 944 | global_map = kmalloc_array(w_adj + 1, h_adj, GFP_KERNEL); |
| 945 | 945 | ||
| 946 | if (!map || !global_map) | 946 | if (!map || !global_map) |
| 947 | goto error; | 947 | goto error; |
diff --git a/drivers/gpu/drm/omapdrm/omap_gem.c b/drivers/gpu/drm/omapdrm/omap_gem.c index 0faf042b82e1..17a53d207978 100644 --- a/drivers/gpu/drm/omapdrm/omap_gem.c +++ b/drivers/gpu/drm/omapdrm/omap_gem.c | |||
| @@ -244,7 +244,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj) | |||
| 244 | * DSS, GPU, etc. are not cache coherent: | 244 | * DSS, GPU, etc. are not cache coherent: |
| 245 | */ | 245 | */ |
| 246 | if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) { | 246 | if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) { |
| 247 | addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL); | 247 | addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL); |
| 248 | if (!addrs) { | 248 | if (!addrs) { |
| 249 | ret = -ENOMEM; | 249 | ret = -ENOMEM; |
| 250 | goto free_pages; | 250 | goto free_pages; |
| @@ -268,7 +268,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj) | |||
| 268 | } | 268 | } |
| 269 | } | 269 | } |
| 270 | } else { | 270 | } else { |
| 271 | addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL); | 271 | addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL); |
| 272 | if (!addrs) { | 272 | if (!addrs) { |
| 273 | ret = -ENOMEM; | 273 | ret = -ENOMEM; |
| 274 | goto free_pages; | 274 | goto free_pages; |
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c index 9a6752606079..ca465c0d49fa 100644 --- a/drivers/gpu/drm/qxl/qxl_fb.c +++ b/drivers/gpu/drm/qxl/qxl_fb.c | |||
| @@ -241,7 +241,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev, | |||
| 241 | DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width, | 241 | DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width, |
| 242 | mode_cmd.height, mode_cmd.pitches[0]); | 242 | mode_cmd.height, mode_cmd.pitches[0]); |
| 243 | 243 | ||
| 244 | shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height); | 244 | shadow = vmalloc(array_size(mode_cmd.pitches[0], mode_cmd.height)); |
| 245 | /* TODO: what's the usual response to memory allocation errors? */ | 245 | /* TODO: what's the usual response to memory allocation errors? */ |
| 246 | BUG_ON(!shadow); | 246 | BUG_ON(!shadow); |
| 247 | DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n", | 247 | DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n", |
diff --git a/drivers/gpu/drm/qxl/qxl_kms.c b/drivers/gpu/drm/qxl/qxl_kms.c index c5716a0ca3b8..771250aed78d 100644 --- a/drivers/gpu/drm/qxl/qxl_kms.c +++ b/drivers/gpu/drm/qxl/qxl_kms.c | |||
| @@ -200,8 +200,8 @@ int qxl_device_init(struct qxl_device *qdev, | |||
| 200 | (~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits); | 200 | (~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits); |
| 201 | 201 | ||
| 202 | qdev->mem_slots = | 202 | qdev->mem_slots = |
| 203 | kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot), | 203 | kmalloc_array(qdev->n_mem_slots, sizeof(struct qxl_memslot), |
| 204 | GFP_KERNEL); | 204 | GFP_KERNEL); |
| 205 | 205 | ||
| 206 | idr_init(&qdev->release_idr); | 206 | idr_init(&qdev->release_idr); |
| 207 | spin_lock_init(&qdev->release_idr_lock); | 207 | spin_lock_init(&qdev->release_idr_lock); |
diff --git a/drivers/gpu/drm/radeon/atom.c b/drivers/gpu/drm/radeon/atom.c index 6a2e091aa7b6..e55cbeee7a53 100644 --- a/drivers/gpu/drm/radeon/atom.c +++ b/drivers/gpu/drm/radeon/atom.c | |||
| @@ -1176,7 +1176,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32 | |||
| 1176 | ectx.abort = false; | 1176 | ectx.abort = false; |
| 1177 | ectx.last_jump = 0; | 1177 | ectx.last_jump = 0; |
| 1178 | if (ws) | 1178 | if (ws) |
| 1179 | ectx.ws = kzalloc(4 * ws, GFP_KERNEL); | 1179 | ectx.ws = kcalloc(4, ws, GFP_KERNEL); |
| 1180 | else | 1180 | else |
| 1181 | ectx.ws = NULL; | 1181 | ectx.ws = NULL; |
| 1182 | 1182 | ||
diff --git a/drivers/gpu/drm/radeon/btc_dpm.c b/drivers/gpu/drm/radeon/btc_dpm.c index 95652e643da1..0aef4937c901 100644 --- a/drivers/gpu/drm/radeon/btc_dpm.c +++ b/drivers/gpu/drm/radeon/btc_dpm.c | |||
| @@ -2581,7 +2581,9 @@ int btc_dpm_init(struct radeon_device *rdev) | |||
| 2581 | return ret; | 2581 | return ret; |
| 2582 | 2582 | ||
| 2583 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 2583 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 2584 | kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL); | 2584 | kcalloc(4, |
| 2585 | sizeof(struct radeon_clock_voltage_dependency_entry), | ||
| 2586 | GFP_KERNEL); | ||
| 2585 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 2587 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 2586 | r600_free_extended_power_table(rdev); | 2588 | r600_free_extended_power_table(rdev); |
| 2587 | return -ENOMEM; | 2589 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/radeon/ci_dpm.c b/drivers/gpu/drm/radeon/ci_dpm.c index 7e1b04dc5593..b9302c918271 100644 --- a/drivers/gpu/drm/radeon/ci_dpm.c +++ b/drivers/gpu/drm/radeon/ci_dpm.c | |||
| @@ -5568,8 +5568,9 @@ static int ci_parse_power_table(struct radeon_device *rdev) | |||
| 5568 | (mode_info->atom_context->bios + data_offset + | 5568 | (mode_info->atom_context->bios + data_offset + |
| 5569 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 5569 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 5570 | 5570 | ||
| 5571 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 5571 | rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 5572 | state_array->ucNumEntries, GFP_KERNEL); | 5572 | sizeof(struct radeon_ps), |
| 5573 | GFP_KERNEL); | ||
| 5573 | if (!rdev->pm.dpm.ps) | 5574 | if (!rdev->pm.dpm.ps) |
| 5574 | return -ENOMEM; | 5575 | return -ENOMEM; |
| 5575 | power_state_offset = (u8 *)state_array->states; | 5576 | power_state_offset = (u8 *)state_array->states; |
| @@ -5770,7 +5771,9 @@ int ci_dpm_init(struct radeon_device *rdev) | |||
| 5770 | ci_set_private_data_variables_based_on_pptable(rdev); | 5771 | ci_set_private_data_variables_based_on_pptable(rdev); |
| 5771 | 5772 | ||
| 5772 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 5773 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 5773 | kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL); | 5774 | kcalloc(4, |
| 5775 | sizeof(struct radeon_clock_voltage_dependency_entry), | ||
| 5776 | GFP_KERNEL); | ||
| 5774 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 5777 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 5775 | ci_dpm_fini(rdev); | 5778 | ci_dpm_fini(rdev); |
| 5776 | return -ENOMEM; | 5779 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/radeon/kv_dpm.c b/drivers/gpu/drm/radeon/kv_dpm.c index ae1529b0ef6f..f055d6ea3522 100644 --- a/drivers/gpu/drm/radeon/kv_dpm.c +++ b/drivers/gpu/drm/radeon/kv_dpm.c | |||
| @@ -2660,8 +2660,9 @@ static int kv_parse_power_table(struct radeon_device *rdev) | |||
| 2660 | (mode_info->atom_context->bios + data_offset + | 2660 | (mode_info->atom_context->bios + data_offset + |
| 2661 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 2661 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 2662 | 2662 | ||
| 2663 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 2663 | rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 2664 | state_array->ucNumEntries, GFP_KERNEL); | 2664 | sizeof(struct radeon_ps), |
| 2665 | GFP_KERNEL); | ||
| 2665 | if (!rdev->pm.dpm.ps) | 2666 | if (!rdev->pm.dpm.ps) |
| 2666 | return -ENOMEM; | 2667 | return -ENOMEM; |
| 2667 | power_state_offset = (u8 *)state_array->states; | 2668 | power_state_offset = (u8 *)state_array->states; |
diff --git a/drivers/gpu/drm/radeon/ni_dpm.c b/drivers/gpu/drm/radeon/ni_dpm.c index 9416e72f86aa..0fd8d6ba9828 100644 --- a/drivers/gpu/drm/radeon/ni_dpm.c +++ b/drivers/gpu/drm/radeon/ni_dpm.c | |||
| @@ -3998,8 +3998,9 @@ static int ni_parse_power_table(struct radeon_device *rdev) | |||
| 3998 | return -EINVAL; | 3998 | return -EINVAL; |
| 3999 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | 3999 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
| 4000 | 4000 | ||
| 4001 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 4001 | rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates, |
| 4002 | power_info->pplib.ucNumStates, GFP_KERNEL); | 4002 | sizeof(struct radeon_ps), |
| 4003 | GFP_KERNEL); | ||
| 4003 | if (!rdev->pm.dpm.ps) | 4004 | if (!rdev->pm.dpm.ps) |
| 4004 | return -ENOMEM; | 4005 | return -ENOMEM; |
| 4005 | 4006 | ||
| @@ -4075,7 +4076,9 @@ int ni_dpm_init(struct radeon_device *rdev) | |||
| 4075 | return ret; | 4076 | return ret; |
| 4076 | 4077 | ||
| 4077 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 4078 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 4078 | kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL); | 4079 | kcalloc(4, |
| 4080 | sizeof(struct radeon_clock_voltage_dependency_entry), | ||
| 4081 | GFP_KERNEL); | ||
| 4079 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 4082 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 4080 | r600_free_extended_power_table(rdev); | 4083 | r600_free_extended_power_table(rdev); |
| 4081 | return -ENOMEM; | 4084 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/radeon/r600_dpm.c b/drivers/gpu/drm/radeon/r600_dpm.c index 31d1b4710844..73d4c5348116 100644 --- a/drivers/gpu/drm/radeon/r600_dpm.c +++ b/drivers/gpu/drm/radeon/r600_dpm.c | |||
| @@ -991,7 +991,7 @@ int r600_parse_extended_power_table(struct radeon_device *rdev) | |||
| 991 | ATOM_PPLIB_PhaseSheddingLimits_Record *entry; | 991 | ATOM_PPLIB_PhaseSheddingLimits_Record *entry; |
| 992 | 992 | ||
| 993 | rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = | 993 | rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries = |
| 994 | kzalloc(psl->ucNumEntries * | 994 | kcalloc(psl->ucNumEntries, |
| 995 | sizeof(struct radeon_phase_shedding_limits_entry), | 995 | sizeof(struct radeon_phase_shedding_limits_entry), |
| 996 | GFP_KERNEL); | 996 | GFP_KERNEL); |
| 997 | if (!rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { | 997 | if (!rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) { |
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c b/drivers/gpu/drm/radeon/radeon_atombios.c index 4134759a6823..f422a8d6aec4 100644 --- a/drivers/gpu/drm/radeon/radeon_atombios.c +++ b/drivers/gpu/drm/radeon/radeon_atombios.c | |||
| @@ -2126,13 +2126,16 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev) | |||
| 2126 | num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK; | 2126 | num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK; |
| 2127 | if (num_modes == 0) | 2127 | if (num_modes == 0) |
| 2128 | return state_index; | 2128 | return state_index; |
| 2129 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * num_modes, GFP_KERNEL); | 2129 | rdev->pm.power_state = kcalloc(num_modes, |
| 2130 | sizeof(struct radeon_power_state), | ||
| 2131 | GFP_KERNEL); | ||
| 2130 | if (!rdev->pm.power_state) | 2132 | if (!rdev->pm.power_state) |
| 2131 | return state_index; | 2133 | return state_index; |
| 2132 | /* last mode is usually default, array is low to high */ | 2134 | /* last mode is usually default, array is low to high */ |
| 2133 | for (i = 0; i < num_modes; i++) { | 2135 | for (i = 0; i < num_modes; i++) { |
| 2134 | rdev->pm.power_state[state_index].clock_info = | 2136 | rdev->pm.power_state[state_index].clock_info = |
| 2135 | kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); | 2137 | kcalloc(1, sizeof(struct radeon_pm_clock_info), |
| 2138 | GFP_KERNEL); | ||
| 2136 | if (!rdev->pm.power_state[state_index].clock_info) | 2139 | if (!rdev->pm.power_state[state_index].clock_info) |
| 2137 | return state_index; | 2140 | return state_index; |
| 2138 | rdev->pm.power_state[state_index].num_clock_modes = 1; | 2141 | rdev->pm.power_state[state_index].num_clock_modes = 1; |
| @@ -2587,8 +2590,9 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev) | |||
| 2587 | radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController); | 2590 | radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController); |
| 2588 | if (power_info->pplib.ucNumStates == 0) | 2591 | if (power_info->pplib.ucNumStates == 0) |
| 2589 | return state_index; | 2592 | return state_index; |
| 2590 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * | 2593 | rdev->pm.power_state = kcalloc(power_info->pplib.ucNumStates, |
| 2591 | power_info->pplib.ucNumStates, GFP_KERNEL); | 2594 | sizeof(struct radeon_power_state), |
| 2595 | GFP_KERNEL); | ||
| 2592 | if (!rdev->pm.power_state) | 2596 | if (!rdev->pm.power_state) |
| 2593 | return state_index; | 2597 | return state_index; |
| 2594 | /* first mode is usually default, followed by low to high */ | 2598 | /* first mode is usually default, followed by low to high */ |
| @@ -2603,10 +2607,11 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev) | |||
| 2603 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset) + | 2607 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset) + |
| 2604 | (power_state->v1.ucNonClockStateIndex * | 2608 | (power_state->v1.ucNonClockStateIndex * |
| 2605 | power_info->pplib.ucNonClockSize)); | 2609 | power_info->pplib.ucNonClockSize)); |
| 2606 | rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) * | 2610 | rdev->pm.power_state[i].clock_info = |
| 2607 | ((power_info->pplib.ucStateEntrySize - 1) ? | 2611 | kcalloc((power_info->pplib.ucStateEntrySize - 1) ? |
| 2608 | (power_info->pplib.ucStateEntrySize - 1) : 1), | 2612 | (power_info->pplib.ucStateEntrySize - 1) : 1, |
| 2609 | GFP_KERNEL); | 2613 | sizeof(struct radeon_pm_clock_info), |
| 2614 | GFP_KERNEL); | ||
| 2610 | if (!rdev->pm.power_state[i].clock_info) | 2615 | if (!rdev->pm.power_state[i].clock_info) |
| 2611 | return state_index; | 2616 | return state_index; |
| 2612 | if (power_info->pplib.ucStateEntrySize - 1) { | 2617 | if (power_info->pplib.ucStateEntrySize - 1) { |
| @@ -2688,8 +2693,9 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev) | |||
| 2688 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 2693 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 2689 | if (state_array->ucNumEntries == 0) | 2694 | if (state_array->ucNumEntries == 0) |
| 2690 | return state_index; | 2695 | return state_index; |
| 2691 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * | 2696 | rdev->pm.power_state = kcalloc(state_array->ucNumEntries, |
| 2692 | state_array->ucNumEntries, GFP_KERNEL); | 2697 | sizeof(struct radeon_power_state), |
| 2698 | GFP_KERNEL); | ||
| 2693 | if (!rdev->pm.power_state) | 2699 | if (!rdev->pm.power_state) |
| 2694 | return state_index; | 2700 | return state_index; |
| 2695 | power_state_offset = (u8 *)state_array->states; | 2701 | power_state_offset = (u8 *)state_array->states; |
| @@ -2699,10 +2705,11 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev) | |||
| 2699 | non_clock_array_index = power_state->v2.nonClockInfoIndex; | 2705 | non_clock_array_index = power_state->v2.nonClockInfoIndex; |
| 2700 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) | 2706 | non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *) |
| 2701 | &non_clock_info_array->nonClockInfo[non_clock_array_index]; | 2707 | &non_clock_info_array->nonClockInfo[non_clock_array_index]; |
| 2702 | rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) * | 2708 | rdev->pm.power_state[i].clock_info = |
| 2703 | (power_state->v2.ucNumDPMLevels ? | 2709 | kcalloc(power_state->v2.ucNumDPMLevels ? |
| 2704 | power_state->v2.ucNumDPMLevels : 1), | 2710 | power_state->v2.ucNumDPMLevels : 1, |
| 2705 | GFP_KERNEL); | 2711 | sizeof(struct radeon_pm_clock_info), |
| 2712 | GFP_KERNEL); | ||
| 2706 | if (!rdev->pm.power_state[i].clock_info) | 2713 | if (!rdev->pm.power_state[i].clock_info) |
| 2707 | return state_index; | 2714 | return state_index; |
| 2708 | if (power_state->v2.ucNumDPMLevels) { | 2715 | if (power_state->v2.ucNumDPMLevels) { |
| @@ -2782,7 +2789,9 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) | |||
| 2782 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL); | 2789 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL); |
| 2783 | if (rdev->pm.power_state) { | 2790 | if (rdev->pm.power_state) { |
| 2784 | rdev->pm.power_state[0].clock_info = | 2791 | rdev->pm.power_state[0].clock_info = |
| 2785 | kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); | 2792 | kcalloc(1, |
| 2793 | sizeof(struct radeon_pm_clock_info), | ||
| 2794 | GFP_KERNEL); | ||
| 2786 | if (rdev->pm.power_state[0].clock_info) { | 2795 | if (rdev->pm.power_state[0].clock_info) { |
| 2787 | /* add the default mode */ | 2796 | /* add the default mode */ |
| 2788 | rdev->pm.power_state[state_index].type = | 2797 | rdev->pm.power_state[state_index].type = |
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c b/drivers/gpu/drm/radeon/radeon_combios.c index 3178ba0c537c..60a61d33f607 100644 --- a/drivers/gpu/drm/radeon/radeon_combios.c +++ b/drivers/gpu/drm/radeon/radeon_combios.c | |||
| @@ -2642,13 +2642,16 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev) | |||
| 2642 | rdev->pm.default_power_state_index = -1; | 2642 | rdev->pm.default_power_state_index = -1; |
| 2643 | 2643 | ||
| 2644 | /* allocate 2 power states */ | 2644 | /* allocate 2 power states */ |
| 2645 | rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL); | 2645 | rdev->pm.power_state = kcalloc(2, sizeof(struct radeon_power_state), |
| 2646 | GFP_KERNEL); | ||
| 2646 | if (rdev->pm.power_state) { | 2647 | if (rdev->pm.power_state) { |
| 2647 | /* allocate 1 clock mode per state */ | 2648 | /* allocate 1 clock mode per state */ |
| 2648 | rdev->pm.power_state[0].clock_info = | 2649 | rdev->pm.power_state[0].clock_info = |
| 2649 | kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); | 2650 | kcalloc(1, sizeof(struct radeon_pm_clock_info), |
| 2651 | GFP_KERNEL); | ||
| 2650 | rdev->pm.power_state[1].clock_info = | 2652 | rdev->pm.power_state[1].clock_info = |
| 2651 | kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL); | 2653 | kcalloc(1, sizeof(struct radeon_pm_clock_info), |
| 2654 | GFP_KERNEL); | ||
| 2652 | if (!rdev->pm.power_state[0].clock_info || | 2655 | if (!rdev->pm.power_state[0].clock_info || |
| 2653 | !rdev->pm.power_state[1].clock_info) | 2656 | !rdev->pm.power_state[1].clock_info) |
| 2654 | goto pm_failed; | 2657 | goto pm_failed; |
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c index 0b3ec35515f3..1cef155cc933 100644 --- a/drivers/gpu/drm/radeon/radeon_gart.c +++ b/drivers/gpu/drm/radeon/radeon_gart.c | |||
| @@ -347,13 +347,14 @@ int radeon_gart_init(struct radeon_device *rdev) | |||
| 347 | DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", | 347 | DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n", |
| 348 | rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages); | 348 | rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages); |
| 349 | /* Allocate pages table */ | 349 | /* Allocate pages table */ |
| 350 | rdev->gart.pages = vzalloc(sizeof(void *) * rdev->gart.num_cpu_pages); | 350 | rdev->gart.pages = vzalloc(array_size(sizeof(void *), |
| 351 | rdev->gart.num_cpu_pages)); | ||
| 351 | if (rdev->gart.pages == NULL) { | 352 | if (rdev->gart.pages == NULL) { |
| 352 | radeon_gart_fini(rdev); | 353 | radeon_gart_fini(rdev); |
| 353 | return -ENOMEM; | 354 | return -ENOMEM; |
| 354 | } | 355 | } |
| 355 | rdev->gart.pages_entry = vmalloc(sizeof(uint64_t) * | 356 | rdev->gart.pages_entry = vmalloc(array_size(sizeof(uint64_t), |
| 356 | rdev->gart.num_gpu_pages); | 357 | rdev->gart.num_gpu_pages)); |
| 357 | if (rdev->gart.pages_entry == NULL) { | 358 | if (rdev->gart.pages_entry == NULL) { |
| 358 | radeon_gart_fini(rdev); | 359 | radeon_gart_fini(rdev); |
| 359 | return -ENOMEM; | 360 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/radeon/radeon_test.c b/drivers/gpu/drm/radeon/radeon_test.c index f5e9abfadb56..48f4b273e316 100644 --- a/drivers/gpu/drm/radeon/radeon_test.c +++ b/drivers/gpu/drm/radeon/radeon_test.c | |||
| @@ -59,7 +59,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) | |||
| 59 | n = rdev->mc.gtt_size - rdev->gart_pin_size; | 59 | n = rdev->mc.gtt_size - rdev->gart_pin_size; |
| 60 | n /= size; | 60 | n /= size; |
| 61 | 61 | ||
| 62 | gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL); | 62 | gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL); |
| 63 | if (!gtt_obj) { | 63 | if (!gtt_obj) { |
| 64 | DRM_ERROR("Failed to allocate %d pointers\n", n); | 64 | DRM_ERROR("Failed to allocate %d pointers\n", n); |
| 65 | r = 1; | 65 | r = 1; |
diff --git a/drivers/gpu/drm/radeon/rs780_dpm.c b/drivers/gpu/drm/radeon/rs780_dpm.c index b5e4e09a8996..694b7b3e9799 100644 --- a/drivers/gpu/drm/radeon/rs780_dpm.c +++ b/drivers/gpu/drm/radeon/rs780_dpm.c | |||
| @@ -804,8 +804,9 @@ static int rs780_parse_power_table(struct radeon_device *rdev) | |||
| 804 | return -EINVAL; | 804 | return -EINVAL; |
| 805 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | 805 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
| 806 | 806 | ||
| 807 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 807 | rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates, |
| 808 | power_info->pplib.ucNumStates, GFP_KERNEL); | 808 | sizeof(struct radeon_ps), |
| 809 | GFP_KERNEL); | ||
| 809 | if (!rdev->pm.dpm.ps) | 810 | if (!rdev->pm.dpm.ps) |
| 810 | return -ENOMEM; | 811 | return -ENOMEM; |
| 811 | 812 | ||
diff --git a/drivers/gpu/drm/radeon/rv6xx_dpm.c b/drivers/gpu/drm/radeon/rv6xx_dpm.c index d91aa3944593..6986051fbb89 100644 --- a/drivers/gpu/drm/radeon/rv6xx_dpm.c +++ b/drivers/gpu/drm/radeon/rv6xx_dpm.c | |||
| @@ -1888,8 +1888,9 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev) | |||
| 1888 | return -EINVAL; | 1888 | return -EINVAL; |
| 1889 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | 1889 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
| 1890 | 1890 | ||
| 1891 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 1891 | rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates, |
| 1892 | power_info->pplib.ucNumStates, GFP_KERNEL); | 1892 | sizeof(struct radeon_ps), |
| 1893 | GFP_KERNEL); | ||
| 1893 | if (!rdev->pm.dpm.ps) | 1894 | if (!rdev->pm.dpm.ps) |
| 1894 | return -ENOMEM; | 1895 | return -ENOMEM; |
| 1895 | 1896 | ||
diff --git a/drivers/gpu/drm/radeon/rv770_dpm.c b/drivers/gpu/drm/radeon/rv770_dpm.c index cb2a7ec4e217..c765ae7ea806 100644 --- a/drivers/gpu/drm/radeon/rv770_dpm.c +++ b/drivers/gpu/drm/radeon/rv770_dpm.c | |||
| @@ -2282,8 +2282,9 @@ int rv7xx_parse_power_table(struct radeon_device *rdev) | |||
| 2282 | return -EINVAL; | 2282 | return -EINVAL; |
| 2283 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); | 2283 | power_info = (union power_info *)(mode_info->atom_context->bios + data_offset); |
| 2284 | 2284 | ||
| 2285 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 2285 | rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates, |
| 2286 | power_info->pplib.ucNumStates, GFP_KERNEL); | 2286 | sizeof(struct radeon_ps), |
| 2287 | GFP_KERNEL); | ||
| 2287 | if (!rdev->pm.dpm.ps) | 2288 | if (!rdev->pm.dpm.ps) |
| 2288 | return -ENOMEM; | 2289 | return -ENOMEM; |
| 2289 | 2290 | ||
diff --git a/drivers/gpu/drm/radeon/si_dpm.c b/drivers/gpu/drm/radeon/si_dpm.c index 90d5b41007bf..fea88078cf8e 100644 --- a/drivers/gpu/drm/radeon/si_dpm.c +++ b/drivers/gpu/drm/radeon/si_dpm.c | |||
| @@ -6832,8 +6832,9 @@ static int si_parse_power_table(struct radeon_device *rdev) | |||
| 6832 | (mode_info->atom_context->bios + data_offset + | 6832 | (mode_info->atom_context->bios + data_offset + |
| 6833 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 6833 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 6834 | 6834 | ||
| 6835 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 6835 | rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 6836 | state_array->ucNumEntries, GFP_KERNEL); | 6836 | sizeof(struct radeon_ps), |
| 6837 | GFP_KERNEL); | ||
| 6837 | if (!rdev->pm.dpm.ps) | 6838 | if (!rdev->pm.dpm.ps) |
| 6838 | return -ENOMEM; | 6839 | return -ENOMEM; |
| 6839 | power_state_offset = (u8 *)state_array->states; | 6840 | power_state_offset = (u8 *)state_array->states; |
| @@ -6941,7 +6942,9 @@ int si_dpm_init(struct radeon_device *rdev) | |||
| 6941 | return ret; | 6942 | return ret; |
| 6942 | 6943 | ||
| 6943 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = | 6944 | rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries = |
| 6944 | kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL); | 6945 | kcalloc(4, |
| 6946 | sizeof(struct radeon_clock_voltage_dependency_entry), | ||
| 6947 | GFP_KERNEL); | ||
| 6945 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { | 6948 | if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) { |
| 6946 | r600_free_extended_power_table(rdev); | 6949 | r600_free_extended_power_table(rdev); |
| 6947 | return -ENOMEM; | 6950 | return -ENOMEM; |
diff --git a/drivers/gpu/drm/radeon/sumo_dpm.c b/drivers/gpu/drm/radeon/sumo_dpm.c index fd4804829e46..1e4975f3374c 100644 --- a/drivers/gpu/drm/radeon/sumo_dpm.c +++ b/drivers/gpu/drm/radeon/sumo_dpm.c | |||
| @@ -1482,8 +1482,9 @@ static int sumo_parse_power_table(struct radeon_device *rdev) | |||
| 1482 | (mode_info->atom_context->bios + data_offset + | 1482 | (mode_info->atom_context->bios + data_offset + |
| 1483 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 1483 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 1484 | 1484 | ||
| 1485 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 1485 | rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 1486 | state_array->ucNumEntries, GFP_KERNEL); | 1486 | sizeof(struct radeon_ps), |
| 1487 | GFP_KERNEL); | ||
| 1487 | if (!rdev->pm.dpm.ps) | 1488 | if (!rdev->pm.dpm.ps) |
| 1488 | return -ENOMEM; | 1489 | return -ENOMEM; |
| 1489 | power_state_offset = (u8 *)state_array->states; | 1490 | power_state_offset = (u8 *)state_array->states; |
diff --git a/drivers/gpu/drm/radeon/trinity_dpm.c b/drivers/gpu/drm/radeon/trinity_dpm.c index 2ef7c4e5e495..5d317f763eea 100644 --- a/drivers/gpu/drm/radeon/trinity_dpm.c +++ b/drivers/gpu/drm/radeon/trinity_dpm.c | |||
| @@ -1757,8 +1757,9 @@ static int trinity_parse_power_table(struct radeon_device *rdev) | |||
| 1757 | (mode_info->atom_context->bios + data_offset + | 1757 | (mode_info->atom_context->bios + data_offset + |
| 1758 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); | 1758 | le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset)); |
| 1759 | 1759 | ||
| 1760 | rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) * | 1760 | rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries, |
| 1761 | state_array->ucNumEntries, GFP_KERNEL); | 1761 | sizeof(struct radeon_ps), |
| 1762 | GFP_KERNEL); | ||
| 1762 | if (!rdev->pm.dpm.ps) | 1763 | if (!rdev->pm.dpm.ps) |
| 1763 | return -ENOMEM; | 1764 | return -ENOMEM; |
| 1764 | power_state_offset = (u8 *)state_array->states; | 1765 | power_state_offset = (u8 *)state_array->states; |
diff --git a/drivers/gpu/drm/savage/savage_bci.c b/drivers/gpu/drm/savage/savage_bci.c index 2a5b8466d806..35dc74883f83 100644 --- a/drivers/gpu/drm/savage/savage_bci.c +++ b/drivers/gpu/drm/savage/savage_bci.c | |||
| @@ -298,8 +298,9 @@ static int savage_dma_init(drm_savage_private_t * dev_priv) | |||
| 298 | 298 | ||
| 299 | dev_priv->nr_dma_pages = dev_priv->cmd_dma->size / | 299 | dev_priv->nr_dma_pages = dev_priv->cmd_dma->size / |
| 300 | (SAVAGE_DMA_PAGE_SIZE * 4); | 300 | (SAVAGE_DMA_PAGE_SIZE * 4); |
| 301 | dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) * | 301 | dev_priv->dma_pages = kmalloc_array(dev_priv->nr_dma_pages, |
| 302 | dev_priv->nr_dma_pages, GFP_KERNEL); | 302 | sizeof(drm_savage_dma_page_t), |
| 303 | GFP_KERNEL); | ||
| 303 | if (dev_priv->dma_pages == NULL) | 304 | if (dev_priv->dma_pages == NULL) |
| 304 | return -ENOMEM; | 305 | return -ENOMEM; |
| 305 | 306 | ||
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c index 7cc935d7b7aa..933af1c25387 100644 --- a/drivers/gpu/drm/selftests/test-drm_mm.c +++ b/drivers/gpu/drm/selftests/test-drm_mm.c | |||
| @@ -389,7 +389,7 @@ static int __igt_reserve(unsigned int count, u64 size) | |||
| 389 | if (!order) | 389 | if (!order) |
| 390 | goto err; | 390 | goto err; |
| 391 | 391 | ||
| 392 | nodes = vzalloc(sizeof(*nodes) * count); | 392 | nodes = vzalloc(array_size(count, sizeof(*nodes))); |
| 393 | if (!nodes) | 393 | if (!nodes) |
| 394 | goto err_order; | 394 | goto err_order; |
| 395 | 395 | ||
| @@ -579,7 +579,7 @@ static int __igt_insert(unsigned int count, u64 size, bool replace) | |||
| 579 | DRM_MM_BUG_ON(!size); | 579 | DRM_MM_BUG_ON(!size); |
| 580 | 580 | ||
| 581 | ret = -ENOMEM; | 581 | ret = -ENOMEM; |
| 582 | nodes = vmalloc(count * sizeof(*nodes)); | 582 | nodes = vmalloc(array_size(count, sizeof(*nodes))); |
| 583 | if (!nodes) | 583 | if (!nodes) |
| 584 | goto err; | 584 | goto err; |
| 585 | 585 | ||
| @@ -889,7 +889,7 @@ static int __igt_insert_range(unsigned int count, u64 size, u64 start, u64 end) | |||
| 889 | */ | 889 | */ |
| 890 | 890 | ||
| 891 | ret = -ENOMEM; | 891 | ret = -ENOMEM; |
| 892 | nodes = vzalloc(count * sizeof(*nodes)); | 892 | nodes = vzalloc(array_size(count, sizeof(*nodes))); |
| 893 | if (!nodes) | 893 | if (!nodes) |
| 894 | goto err; | 894 | goto err; |
| 895 | 895 | ||
| @@ -1046,7 +1046,7 @@ static int igt_align(void *ignored) | |||
| 1046 | * meets our requirements. | 1046 | * meets our requirements. |
| 1047 | */ | 1047 | */ |
| 1048 | 1048 | ||
| 1049 | nodes = vzalloc(max_count * sizeof(*nodes)); | 1049 | nodes = vzalloc(array_size(max_count, sizeof(*nodes))); |
| 1050 | if (!nodes) | 1050 | if (!nodes) |
| 1051 | goto err; | 1051 | goto err; |
| 1052 | 1052 | ||
| @@ -1416,7 +1416,7 @@ static int igt_evict(void *ignored) | |||
| 1416 | */ | 1416 | */ |
| 1417 | 1417 | ||
| 1418 | ret = -ENOMEM; | 1418 | ret = -ENOMEM; |
| 1419 | nodes = vzalloc(size * sizeof(*nodes)); | 1419 | nodes = vzalloc(array_size(size, sizeof(*nodes))); |
| 1420 | if (!nodes) | 1420 | if (!nodes) |
| 1421 | goto err; | 1421 | goto err; |
| 1422 | 1422 | ||
| @@ -1526,7 +1526,7 @@ static int igt_evict_range(void *ignored) | |||
| 1526 | */ | 1526 | */ |
| 1527 | 1527 | ||
| 1528 | ret = -ENOMEM; | 1528 | ret = -ENOMEM; |
| 1529 | nodes = vzalloc(size * sizeof(*nodes)); | 1529 | nodes = vzalloc(array_size(size, sizeof(*nodes))); |
| 1530 | if (!nodes) | 1530 | if (!nodes) |
| 1531 | goto err; | 1531 | goto err; |
| 1532 | 1532 | ||
| @@ -1627,11 +1627,11 @@ static int igt_topdown(void *ignored) | |||
| 1627 | */ | 1627 | */ |
| 1628 | 1628 | ||
| 1629 | ret = -ENOMEM; | 1629 | ret = -ENOMEM; |
| 1630 | nodes = vzalloc(count * sizeof(*nodes)); | 1630 | nodes = vzalloc(array_size(count, sizeof(*nodes))); |
| 1631 | if (!nodes) | 1631 | if (!nodes) |
| 1632 | goto err; | 1632 | goto err; |
| 1633 | 1633 | ||
| 1634 | bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long), | 1634 | bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long), |
| 1635 | GFP_KERNEL); | 1635 | GFP_KERNEL); |
| 1636 | if (!bitmap) | 1636 | if (!bitmap) |
| 1637 | goto err_nodes; | 1637 | goto err_nodes; |
| @@ -1741,11 +1741,11 @@ static int igt_bottomup(void *ignored) | |||
| 1741 | */ | 1741 | */ |
| 1742 | 1742 | ||
| 1743 | ret = -ENOMEM; | 1743 | ret = -ENOMEM; |
| 1744 | nodes = vzalloc(count * sizeof(*nodes)); | 1744 | nodes = vzalloc(array_size(count, sizeof(*nodes))); |
| 1745 | if (!nodes) | 1745 | if (!nodes) |
| 1746 | goto err; | 1746 | goto err; |
| 1747 | 1747 | ||
| 1748 | bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long), | 1748 | bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long), |
| 1749 | GFP_KERNEL); | 1749 | GFP_KERNEL); |
| 1750 | if (!bitmap) | 1750 | if (!bitmap) |
| 1751 | goto err_nodes; | 1751 | goto err_nodes; |
| @@ -2098,7 +2098,7 @@ static int igt_color_evict(void *ignored) | |||
| 2098 | */ | 2098 | */ |
| 2099 | 2099 | ||
| 2100 | ret = -ENOMEM; | 2100 | ret = -ENOMEM; |
| 2101 | nodes = vzalloc(total_size * sizeof(*nodes)); | 2101 | nodes = vzalloc(array_size(total_size, sizeof(*nodes))); |
| 2102 | if (!nodes) | 2102 | if (!nodes) |
| 2103 | goto err; | 2103 | goto err; |
| 2104 | 2104 | ||
| @@ -2199,7 +2199,7 @@ static int igt_color_evict_range(void *ignored) | |||
| 2199 | */ | 2199 | */ |
| 2200 | 2200 | ||
| 2201 | ret = -ENOMEM; | 2201 | ret = -ENOMEM; |
| 2202 | nodes = vzalloc(total_size * sizeof(*nodes)); | 2202 | nodes = vzalloc(array_size(total_size, sizeof(*nodes))); |
| 2203 | if (!nodes) | 2203 | if (!nodes) |
| 2204 | goto err; | 2204 | goto err; |
| 2205 | 2205 | ||
diff --git a/drivers/gpu/drm/tinydrm/repaper.c b/drivers/gpu/drm/tinydrm/repaper.c index 1ee6855212a0..50a1d4216ce7 100644 --- a/drivers/gpu/drm/tinydrm/repaper.c +++ b/drivers/gpu/drm/tinydrm/repaper.c | |||
| @@ -548,7 +548,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb, | |||
| 548 | DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id, | 548 | DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id, |
| 549 | epd->factored_stage_time); | 549 | epd->factored_stage_time); |
| 550 | 550 | ||
| 551 | buf = kmalloc(fb->width * fb->height, GFP_KERNEL); | 551 | buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL); |
| 552 | if (!buf) | 552 | if (!buf) |
| 553 | return -ENOMEM; | 553 | return -ENOMEM; |
| 554 | 554 | ||
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc.c b/drivers/gpu/drm/ttm/ttm_page_alloc.c index 06c94e3a5f15..6e2d1300b457 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc.c | |||
| @@ -348,8 +348,9 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, | |||
| 348 | if (use_static) | 348 | if (use_static) |
| 349 | pages_to_free = static_buf; | 349 | pages_to_free = static_buf; |
| 350 | else | 350 | else |
| 351 | pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), | 351 | pages_to_free = kmalloc_array(npages_to_free, |
| 352 | GFP_KERNEL); | 352 | sizeof(struct page *), |
| 353 | GFP_KERNEL); | ||
| 353 | if (!pages_to_free) { | 354 | if (!pages_to_free) { |
| 354 | pr_debug("Failed to allocate memory for pool free operation\n"); | 355 | pr_debug("Failed to allocate memory for pool free operation\n"); |
| 355 | return 0; | 356 | return 0; |
| @@ -547,7 +548,8 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags, | |||
| 547 | unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC); | 548 | unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC); |
| 548 | 549 | ||
| 549 | /* allocate array for page caching change */ | 550 | /* allocate array for page caching change */ |
| 550 | caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); | 551 | caching_array = kmalloc_array(max_cpages, sizeof(struct page *), |
| 552 | GFP_KERNEL); | ||
| 551 | 553 | ||
| 552 | if (!caching_array) { | 554 | if (!caching_array) { |
| 553 | pr_debug("Unable to allocate table for new pages\n"); | 555 | pr_debug("Unable to allocate table for new pages\n"); |
diff --git a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c index f63d99c302e4..3f14c1cc0789 100644 --- a/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +++ b/drivers/gpu/drm/ttm/ttm_page_alloc_dma.c | |||
| @@ -463,8 +463,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free, | |||
| 463 | if (use_static) | 463 | if (use_static) |
| 464 | pages_to_free = static_buf; | 464 | pages_to_free = static_buf; |
| 465 | else | 465 | else |
| 466 | pages_to_free = kmalloc(npages_to_free * sizeof(struct page *), | 466 | pages_to_free = kmalloc_array(npages_to_free, |
| 467 | GFP_KERNEL); | 467 | sizeof(struct page *), |
| 468 | GFP_KERNEL); | ||
| 468 | 469 | ||
| 469 | if (!pages_to_free) { | 470 | if (!pages_to_free) { |
| 470 | pr_debug("%s: Failed to allocate memory for pool free operation\n", | 471 | pr_debug("%s: Failed to allocate memory for pool free operation\n", |
| @@ -753,7 +754,8 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool, | |||
| 753 | (unsigned)(PAGE_SIZE/sizeof(struct page *))); | 754 | (unsigned)(PAGE_SIZE/sizeof(struct page *))); |
| 754 | 755 | ||
| 755 | /* allocate array for page caching change */ | 756 | /* allocate array for page caching change */ |
| 756 | caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL); | 757 | caching_array = kmalloc_array(max_cpages, sizeof(struct page *), |
| 758 | GFP_KERNEL); | ||
| 757 | 759 | ||
| 758 | if (!caching_array) { | 760 | if (!caching_array) { |
| 759 | pr_debug("%s: Unable to allocate table for new pages\n", | 761 | pr_debug("%s: Unable to allocate table for new pages\n", |
diff --git a/drivers/gpu/drm/vc4/vc4_plane.c b/drivers/gpu/drm/vc4/vc4_plane.c index 71d44c357d35..1d34619eb3fe 100644 --- a/drivers/gpu/drm/vc4/vc4_plane.c +++ b/drivers/gpu/drm/vc4/vc4_plane.c | |||
| @@ -209,7 +209,7 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val) | |||
| 209 | { | 209 | { |
| 210 | if (vc4_state->dlist_count == vc4_state->dlist_size) { | 210 | if (vc4_state->dlist_count == vc4_state->dlist_size) { |
| 211 | u32 new_size = max(4u, vc4_state->dlist_count * 2); | 211 | u32 new_size = max(4u, vc4_state->dlist_count * 2); |
| 212 | u32 *new_dlist = kmalloc(new_size * 4, GFP_KERNEL); | 212 | u32 *new_dlist = kmalloc_array(new_size, 4, GFP_KERNEL); |
| 213 | 213 | ||
| 214 | if (!new_dlist) | 214 | if (!new_dlist) |
| 215 | return; | 215 | return; |
diff --git a/drivers/gpu/drm/via/via_dmablit.c b/drivers/gpu/drm/via/via_dmablit.c index d6e84a589ef1..345bda4494e1 100644 --- a/drivers/gpu/drm/via/via_dmablit.c +++ b/drivers/gpu/drm/via/via_dmablit.c | |||
| @@ -235,7 +235,7 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) | |||
| 235 | vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) - | 235 | vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) - |
| 236 | first_pfn + 1; | 236 | first_pfn + 1; |
| 237 | 237 | ||
| 238 | vsg->pages = vzalloc(sizeof(struct page *) * vsg->num_pages); | 238 | vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages)); |
| 239 | if (NULL == vsg->pages) | 239 | if (NULL == vsg->pages) |
| 240 | return -ENOMEM; | 240 | return -ENOMEM; |
| 241 | ret = get_user_pages_fast((unsigned long)xfer->mem_addr, | 241 | ret = get_user_pages_fast((unsigned long)xfer->mem_addr, |
diff --git a/drivers/hid/hid-core.c b/drivers/hid/hid-core.c index 355dc7e49562..f858cc72011d 100644 --- a/drivers/hid/hid-core.c +++ b/drivers/hid/hid-core.c | |||
| @@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type) | |||
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | if (parser->device->maxcollection == parser->device->collection_size) { | 136 | if (parser->device->maxcollection == parser->device->collection_size) { |
| 137 | collection = kmalloc(sizeof(struct hid_collection) * | 137 | collection = kmalloc( |
| 138 | parser->device->collection_size * 2, GFP_KERNEL); | 138 | array3_size(sizeof(struct hid_collection), |
| 139 | parser->device->collection_size, | ||
| 140 | 2), | ||
| 141 | GFP_KERNEL); | ||
| 139 | if (collection == NULL) { | 142 | if (collection == NULL) { |
| 140 | hid_err(parser->device, "failed to reallocate collection array\n"); | 143 | hid_err(parser->device, "failed to reallocate collection array\n"); |
| 141 | return -ENOMEM; | 144 | return -ENOMEM; |
| @@ -1278,7 +1281,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, | |||
| 1278 | __s32 max = field->logical_maximum; | 1281 | __s32 max = field->logical_maximum; |
| 1279 | __s32 *value; | 1282 | __s32 *value; |
| 1280 | 1283 | ||
| 1281 | value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC); | 1284 | value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC); |
| 1282 | if (!value) | 1285 | if (!value) |
| 1283 | return; | 1286 | return; |
| 1284 | 1287 | ||
diff --git a/drivers/hid/hid-debug.c b/drivers/hid/hid-debug.c index 4f4e7a08a07b..8469b6964ff6 100644 --- a/drivers/hid/hid-debug.c +++ b/drivers/hid/hid-debug.c | |||
| @@ -457,7 +457,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) { | |||
| 457 | char *buf = NULL; | 457 | char *buf = NULL; |
| 458 | 458 | ||
| 459 | if (!f) { | 459 | if (!f) { |
| 460 | buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); | 460 | buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC); |
| 461 | if (!buf) | 461 | if (!buf) |
| 462 | return ERR_PTR(-ENOMEM); | 462 | return ERR_PTR(-ENOMEM); |
| 463 | } | 463 | } |
| @@ -685,7 +685,7 @@ void hid_dump_report(struct hid_device *hid, int type, u8 *data, | |||
| 685 | char *buf; | 685 | char *buf; |
| 686 | unsigned int i; | 686 | unsigned int i; |
| 687 | 687 | ||
| 688 | buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC); | 688 | buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC); |
| 689 | 689 | ||
| 690 | if (!buf) | 690 | if (!buf) |
| 691 | return; | 691 | return; |
| @@ -1088,7 +1088,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file) | |||
| 1088 | goto out; | 1088 | goto out; |
| 1089 | } | 1089 | } |
| 1090 | 1090 | ||
| 1091 | if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) { | 1091 | if (!(list->hid_debug_buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_KERNEL))) { |
| 1092 | err = -ENOMEM; | 1092 | err = -ENOMEM; |
| 1093 | kfree(list); | 1093 | kfree(list); |
| 1094 | goto out; | 1094 | goto out; |
diff --git a/drivers/hid/hid-picolcd_fb.c b/drivers/hid/hid-picolcd_fb.c index 7f965e231433..864a084b6cba 100644 --- a/drivers/hid/hid-picolcd_fb.c +++ b/drivers/hid/hid-picolcd_fb.c | |||
| @@ -394,7 +394,8 @@ static int picolcd_set_par(struct fb_info *info) | |||
| 394 | return -EINVAL; | 394 | return -EINVAL; |
| 395 | 395 | ||
| 396 | o_fb = fbdata->bitmap; | 396 | o_fb = fbdata->bitmap; |
| 397 | tmp_fb = kmalloc(PICOLCDFB_SIZE*info->var.bits_per_pixel, GFP_KERNEL); | 397 | tmp_fb = kmalloc_array(PICOLCDFB_SIZE, info->var.bits_per_pixel, |
| 398 | GFP_KERNEL); | ||
| 398 | if (!tmp_fb) | 399 | if (!tmp_fb) |
| 399 | return -ENOMEM; | 400 | return -ENOMEM; |
| 400 | 401 | ||
diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index 25363fc571bc..50af72baa5ca 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c | |||
| @@ -624,7 +624,8 @@ static int sensor_hub_probe(struct hid_device *hdev, | |||
| 624 | ret = -EINVAL; | 624 | ret = -EINVAL; |
| 625 | goto err_stop_hw; | 625 | goto err_stop_hw; |
| 626 | } | 626 | } |
| 627 | sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt * | 627 | sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev, |
| 628 | dev_cnt, | ||
| 628 | sizeof(struct mfd_cell), | 629 | sizeof(struct mfd_cell), |
| 629 | GFP_KERNEL); | 630 | GFP_KERNEL); |
| 630 | if (sd->hid_sensor_hub_client_devs == NULL) { | 631 | if (sd->hid_sensor_hub_client_devs == NULL) { |
diff --git a/drivers/hid/hidraw.c b/drivers/hid/hidraw.c index b39844adea47..4a44e48e08b2 100644 --- a/drivers/hid/hidraw.c +++ b/drivers/hid/hidraw.c | |||
| @@ -218,7 +218,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t | |||
| 218 | goto out; | 218 | goto out; |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | buf = kmalloc(count * sizeof(__u8), GFP_KERNEL); | 221 | buf = kmalloc(count, GFP_KERNEL); |
| 222 | if (!buf) { | 222 | if (!buf) { |
| 223 | ret = -ENOMEM; | 223 | ret = -ENOMEM; |
| 224 | goto out; | 224 | goto out; |
diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index acc2536c8094..2d28cffc1404 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c | |||
| @@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, | |||
| 121 | } | 121 | } |
| 122 | client_data->hid_dev_count = (unsigned int)*payload; | 122 | client_data->hid_dev_count = (unsigned int)*payload; |
| 123 | if (!client_data->hid_devices) | 123 | if (!client_data->hid_devices) |
| 124 | client_data->hid_devices = devm_kzalloc( | 124 | client_data->hid_devices = devm_kcalloc( |
| 125 | &client_data->cl_device->dev, | 125 | &client_data->cl_device->dev, |
| 126 | client_data->hid_dev_count * | 126 | client_data->hid_dev_count, |
| 127 | sizeof(struct device_info), | 127 | sizeof(struct device_info), |
| 128 | GFP_KERNEL); | 128 | GFP_KERNEL); |
| 129 | if (!client_data->hid_devices) { | 129 | if (!client_data->hid_devices) { |
diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index ee7a37eb159a..c101369b51de 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c | |||
| @@ -1363,7 +1363,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev, | |||
| 1363 | if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) | 1363 | if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) |
| 1364 | return -ENOMEM; | 1364 | return -ENOMEM; |
| 1365 | 1365 | ||
| 1366 | leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL); | 1366 | leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL); |
| 1367 | if (!leds) { | 1367 | if (!leds) { |
| 1368 | error = -ENOMEM; | 1368 | error = -ENOMEM; |
| 1369 | goto err; | 1369 | goto err; |
| @@ -1463,7 +1463,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count) | |||
| 1463 | struct wacom_group_leds *groups; | 1463 | struct wacom_group_leds *groups; |
| 1464 | int error; | 1464 | int error; |
| 1465 | 1465 | ||
| 1466 | groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count, | 1466 | groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds), |
| 1467 | GFP_KERNEL); | 1467 | GFP_KERNEL); |
| 1468 | if (!groups) | 1468 | if (!groups) |
| 1469 | return -ENOMEM; | 1469 | return -ENOMEM; |
diff --git a/drivers/hv/hv.c b/drivers/hv/hv.c index 9b82549cbbc8..658dc765753b 100644 --- a/drivers/hv/hv.c +++ b/drivers/hv/hv.c | |||
| @@ -190,7 +190,7 @@ int hv_synic_alloc(void) | |||
| 190 | { | 190 | { |
| 191 | int cpu; | 191 | int cpu; |
| 192 | 192 | ||
| 193 | hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids, | 193 | hv_context.hv_numa_map = kcalloc(nr_node_ids, sizeof(struct cpumask), |
| 194 | GFP_KERNEL); | 194 | GFP_KERNEL); |
| 195 | if (hv_context.hv_numa_map == NULL) { | 195 | if (hv_context.hv_numa_map == NULL) { |
| 196 | pr_err("Unable to allocate NUMA map\n"); | 196 | pr_err("Unable to allocate NUMA map\n"); |
diff --git a/drivers/hv/ring_buffer.c b/drivers/hv/ring_buffer.c index 3c836c099a8f..be3c8b10b84a 100644 --- a/drivers/hv/ring_buffer.c +++ b/drivers/hv/ring_buffer.c | |||
| @@ -202,7 +202,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, | |||
| 202 | * First page holds struct hv_ring_buffer, do wraparound mapping for | 202 | * First page holds struct hv_ring_buffer, do wraparound mapping for |
| 203 | * the rest. | 203 | * the rest. |
| 204 | */ | 204 | */ |
| 205 | pages_wraparound = kzalloc(sizeof(struct page *) * (page_cnt * 2 - 1), | 205 | pages_wraparound = kcalloc(page_cnt * 2 - 1, sizeof(struct page *), |
| 206 | GFP_KERNEL); | 206 | GFP_KERNEL); |
| 207 | if (!pages_wraparound) | 207 | if (!pages_wraparound) |
| 208 | return -ENOMEM; | 208 | return -ENOMEM; |
diff --git a/drivers/hwmon/acpi_power_meter.c b/drivers/hwmon/acpi_power_meter.c index 14a94d90c028..34e45b97629e 100644 --- a/drivers/hwmon/acpi_power_meter.c +++ b/drivers/hwmon/acpi_power_meter.c | |||
| @@ -575,8 +575,9 @@ static int read_domain_devices(struct acpi_power_meter_resource *resource) | |||
| 575 | if (!pss->package.count) | 575 | if (!pss->package.count) |
| 576 | goto end; | 576 | goto end; |
| 577 | 577 | ||
| 578 | resource->domain_devices = kzalloc(sizeof(struct acpi_device *) * | 578 | resource->domain_devices = kcalloc(pss->package.count, |
| 579 | pss->package.count, GFP_KERNEL); | 579 | sizeof(struct acpi_device *), |
| 580 | GFP_KERNEL); | ||
| 580 | if (!resource->domain_devices) { | 581 | if (!resource->domain_devices) { |
| 581 | res = -ENOMEM; | 582 | res = -ENOMEM; |
| 582 | goto end; | 583 | goto end; |
| @@ -796,7 +797,7 @@ static int read_capabilities(struct acpi_power_meter_resource *resource) | |||
| 796 | goto error; | 797 | goto error; |
| 797 | } | 798 | } |
| 798 | 799 | ||
| 799 | *str = kzalloc(sizeof(u8) * (element->string.length + 1), | 800 | *str = kcalloc(element->string.length + 1, sizeof(u8), |
| 800 | GFP_KERNEL); | 801 | GFP_KERNEL); |
| 801 | if (!*str) { | 802 | if (!*str) { |
| 802 | res = -ENOMEM; | 803 | res = -ENOMEM; |
diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index 693a3d53cab5..5e449eac788a 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c | |||
| @@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev, | |||
| 894 | count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch"); | 894 | count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch"); |
| 895 | if (count < 1) | 895 | if (count < 1) |
| 896 | return -EINVAL; | 896 | return -EINVAL; |
| 897 | fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count, | 897 | fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch), |
| 898 | GFP_KERNEL); | 898 | GFP_KERNEL); |
| 899 | if (!fan_tach_ch) | 899 | if (!fan_tach_ch) |
| 900 | return -ENOMEM; | 900 | return -ENOMEM; |
diff --git a/drivers/hwmon/coretemp.c b/drivers/hwmon/coretemp.c index 72c338eb5fae..10645c9bb7be 100644 --- a/drivers/hwmon/coretemp.c +++ b/drivers/hwmon/coretemp.c | |||
| @@ -742,7 +742,7 @@ static int __init coretemp_init(void) | |||
| 742 | return -ENODEV; | 742 | return -ENODEV; |
| 743 | 743 | ||
| 744 | max_packages = topology_max_packages(); | 744 | max_packages = topology_max_packages(); |
| 745 | pkg_devices = kzalloc(max_packages * sizeof(struct platform_device *), | 745 | pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *), |
| 746 | GFP_KERNEL); | 746 | GFP_KERNEL); |
| 747 | if (!pkg_devices) | 747 | if (!pkg_devices) |
| 748 | return -ENOMEM; | 748 | return -ENOMEM; |
diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 5c9a52599cf6..a3974cddef07 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c | |||
| @@ -441,8 +441,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data) | |||
| 441 | dev_err(dev, "DT properties empty / missing"); | 441 | dev_err(dev, "DT properties empty / missing"); |
| 442 | return -ENODEV; | 442 | return -ENODEV; |
| 443 | } | 443 | } |
| 444 | gpios = devm_kzalloc(dev, | 444 | gpios = devm_kcalloc(dev, |
| 445 | fan_data->num_gpios * sizeof(struct gpio_desc *), | 445 | fan_data->num_gpios, sizeof(struct gpio_desc *), |
| 446 | GFP_KERNEL); | 446 | GFP_KERNEL); |
| 447 | if (!gpios) | 447 | if (!gpios) |
| 448 | return -ENOMEM; | 448 | return -ENOMEM; |
| @@ -471,8 +471,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data) | |||
| 471 | * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...> | 471 | * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...> |
| 472 | * this needs splitting into pairs to create gpio_fan_speed structs | 472 | * this needs splitting into pairs to create gpio_fan_speed structs |
| 473 | */ | 473 | */ |
| 474 | speed = devm_kzalloc(dev, | 474 | speed = devm_kcalloc(dev, |
| 475 | fan_data->num_speed * sizeof(struct gpio_fan_speed), | 475 | fan_data->num_speed, sizeof(struct gpio_fan_speed), |
| 476 | GFP_KERNEL); | 476 | GFP_KERNEL); |
| 477 | if (!speed) | 477 | if (!speed) |
| 478 | return -ENOMEM; | 478 | return -ENOMEM; |
diff --git a/drivers/hwmon/i5k_amb.c b/drivers/hwmon/i5k_amb.c index 9397d2f0e79a..a4edc43dd060 100644 --- a/drivers/hwmon/i5k_amb.c +++ b/drivers/hwmon/i5k_amb.c | |||
| @@ -274,8 +274,9 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) | |||
| 274 | num_ambs += hweight16(data->amb_present[i] & 0x7fff); | 274 | num_ambs += hweight16(data->amb_present[i] & 0x7fff); |
| 275 | 275 | ||
| 276 | /* Set up sysfs stuff */ | 276 | /* Set up sysfs stuff */ |
| 277 | data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB, | 277 | data->attrs = kzalloc(array3_size(num_ambs, KNOBS_PER_AMB, |
| 278 | GFP_KERNEL); | 278 | sizeof(*data->attrs)), |
| 279 | GFP_KERNEL); | ||
| 279 | if (!data->attrs) | 280 | if (!data->attrs) |
| 280 | return -ENOMEM; | 281 | return -ENOMEM; |
| 281 | data->num_attrs = 0; | 282 | data->num_attrs = 0; |
diff --git a/drivers/hwmon/ibmpex.c b/drivers/hwmon/ibmpex.c index 21b9c72f16bd..ab72cabf5a95 100644 --- a/drivers/hwmon/ibmpex.c +++ b/drivers/hwmon/ibmpex.c | |||
| @@ -387,7 +387,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) | |||
| 387 | return -ENOENT; | 387 | return -ENOENT; |
| 388 | data->num_sensors = err; | 388 | data->num_sensors = err; |
| 389 | 389 | ||
| 390 | data->sensors = kzalloc(data->num_sensors * sizeof(*data->sensors), | 390 | data->sensors = kcalloc(data->num_sensors, sizeof(*data->sensors), |
| 391 | GFP_KERNEL); | 391 | GFP_KERNEL); |
| 392 | if (!data->sensors) | 392 | if (!data->sensors) |
| 393 | return -ENOMEM; | 393 | return -ENOMEM; |
diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index 0298745d46e4..f829dadfd5a0 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c | |||
| @@ -326,9 +326,9 @@ static int populate_attr_groups(struct platform_device *pdev) | |||
| 326 | of_node_put(opal); | 326 | of_node_put(opal); |
| 327 | 327 | ||
| 328 | for (type = 0; type < MAX_SENSOR_TYPE; type++) { | 328 | for (type = 0; type < MAX_SENSOR_TYPE; type++) { |
| 329 | sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev, | 329 | sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev, |
| 330 | sizeof(struct attribute *) * | 330 | sensor_groups[type].attr_count + 1, |
| 331 | (sensor_groups[type].attr_count + 1), | 331 | sizeof(struct attribute *), |
| 332 | GFP_KERNEL); | 332 | GFP_KERNEL); |
| 333 | if (!sensor_groups[type].group.attrs) | 333 | if (!sensor_groups[type].group.attrs) |
| 334 | return -ENOMEM; | 334 | return -ENOMEM; |
| @@ -409,7 +409,8 @@ static int create_device_attrs(struct platform_device *pdev) | |||
| 409 | int err = 0; | 409 | int err = 0; |
| 410 | 410 | ||
| 411 | opal = of_find_node_by_path("/ibm,opal/sensors"); | 411 | opal = of_find_node_by_path("/ibm,opal/sensors"); |
| 412 | sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata), | 412 | sdata = devm_kcalloc(&pdev->dev, |
| 413 | pdata->sensors_count, sizeof(*sdata), | ||
| 413 | GFP_KERNEL); | 414 | GFP_KERNEL); |
| 414 | if (!sdata) { | 415 | if (!sdata) { |
| 415 | err = -ENOMEM; | 416 | err = -ENOMEM; |
diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c index 5e5b32a1ec4b..69031a0f7ed2 100644 --- a/drivers/hwmon/iio_hwmon.c +++ b/drivers/hwmon/iio_hwmon.c | |||
| @@ -92,8 +92,8 @@ static int iio_hwmon_probe(struct platform_device *pdev) | |||
| 92 | while (st->channels[st->num_channels].indio_dev) | 92 | while (st->channels[st->num_channels].indio_dev) |
| 93 | st->num_channels++; | 93 | st->num_channels++; |
| 94 | 94 | ||
| 95 | st->attrs = devm_kzalloc(dev, | 95 | st->attrs = devm_kcalloc(dev, |
| 96 | sizeof(*st->attrs) * (st->num_channels + 1), | 96 | st->num_channels + 1, sizeof(*st->attrs), |
| 97 | GFP_KERNEL); | 97 | GFP_KERNEL); |
| 98 | if (st->attrs == NULL) { | 98 | if (st->attrs == NULL) { |
| 99 | ret = -ENOMEM; | 99 | ret = -ENOMEM; |
diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c index b0bc77bf2cd9..a753464a1a33 100644 --- a/drivers/hwmon/nct6683.c +++ b/drivers/hwmon/nct6683.c | |||
| @@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev, | |||
| 426 | if (group == NULL) | 426 | if (group == NULL) |
| 427 | return ERR_PTR(-ENOMEM); | 427 | return ERR_PTR(-ENOMEM); |
| 428 | 428 | ||
| 429 | attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1), | 429 | attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs), |
| 430 | GFP_KERNEL); | 430 | GFP_KERNEL); |
| 431 | if (attrs == NULL) | 431 | if (attrs == NULL) |
| 432 | return ERR_PTR(-ENOMEM); | 432 | return ERR_PTR(-ENOMEM); |
| 433 | 433 | ||
| 434 | su = devm_kzalloc(dev, sizeof(*su) * repeat * count, | 434 | su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)), |
| 435 | GFP_KERNEL); | 435 | GFP_KERNEL); |
| 436 | if (su == NULL) | 436 | if (su == NULL) |
| 437 | return ERR_PTR(-ENOMEM); | 437 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index aebce560bfaf..155d4d1d1585 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c | |||
| @@ -1190,12 +1190,12 @@ nct6775_create_attr_group(struct device *dev, | |||
| 1190 | if (group == NULL) | 1190 | if (group == NULL) |
| 1191 | return ERR_PTR(-ENOMEM); | 1191 | return ERR_PTR(-ENOMEM); |
| 1192 | 1192 | ||
| 1193 | attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1), | 1193 | attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs), |
| 1194 | GFP_KERNEL); | 1194 | GFP_KERNEL); |
| 1195 | if (attrs == NULL) | 1195 | if (attrs == NULL) |
| 1196 | return ERR_PTR(-ENOMEM); | 1196 | return ERR_PTR(-ENOMEM); |
| 1197 | 1197 | ||
| 1198 | su = devm_kzalloc(dev, sizeof(*su) * repeat * count, | 1198 | su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)), |
| 1199 | GFP_KERNEL); | 1199 | GFP_KERNEL); |
| 1200 | if (su == NULL) | 1200 | if (su == NULL) |
| 1201 | return ERR_PTR(-ENOMEM); | 1201 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index f7c47d7994e7..82c3754e21e3 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c | |||
| @@ -2176,8 +2176,8 @@ static int pmbus_init_debugfs(struct i2c_client *client, | |||
| 2176 | } | 2176 | } |
| 2177 | 2177 | ||
| 2178 | /* Allocate the max possible entries we need. */ | 2178 | /* Allocate the max possible entries we need. */ |
| 2179 | entries = devm_kzalloc(data->dev, | 2179 | entries = devm_kcalloc(data->dev, |
| 2180 | sizeof(*entries) * (data->info->pages * 10), | 2180 | data->info->pages * 10, sizeof(*entries), |
| 2181 | GFP_KERNEL); | 2181 | GFP_KERNEL); |
| 2182 | if (!entries) | 2182 | if (!entries) |
| 2183 | return -ENOMEM; | 2183 | return -ENOMEM; |
diff --git a/drivers/hwmon/pmbus/ucd9000.c b/drivers/hwmon/pmbus/ucd9000.c index 70cecb06f93c..ae93885fccd8 100644 --- a/drivers/hwmon/pmbus/ucd9000.c +++ b/drivers/hwmon/pmbus/ucd9000.c | |||
| @@ -454,8 +454,8 @@ static int ucd9000_init_debugfs(struct i2c_client *client, | |||
| 454 | */ | 454 | */ |
| 455 | if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 || | 455 | if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 || |
| 456 | mid->driver_data == ucd90910) { | 456 | mid->driver_data == ucd90910) { |
| 457 | entries = devm_kzalloc(&client->dev, | 457 | entries = devm_kcalloc(&client->dev, |
| 458 | sizeof(*entries) * UCD9000_GPI_COUNT, | 458 | UCD9000_GPI_COUNT, sizeof(*entries), |
| 459 | GFP_KERNEL); | 459 | GFP_KERNEL); |
| 460 | if (!entries) | 460 | if (!entries) |
| 461 | return -ENOMEM; | 461 | return -ENOMEM; |
diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index 70cc0d134f3c..7838af58f92d 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c | |||
| @@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev, | |||
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | num = ret; | 182 | num = ret; |
| 183 | ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32), | 183 | ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32), |
| 184 | GFP_KERNEL); | 184 | GFP_KERNEL); |
| 185 | if (!ctx->pwm_fan_cooling_levels) | 185 | if (!ctx->pwm_fan_cooling_levels) |
| 186 | return -ENOMEM; | 186 | return -ENOMEM; |
diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index 9b6c55523c58..320d29df17e1 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c | |||
| @@ -683,8 +683,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 683 | if (drvdata->buffer_depth & 0x80000000) | 683 | if (drvdata->buffer_depth & 0x80000000) |
| 684 | return -EINVAL; | 684 | return -EINVAL; |
| 685 | 685 | ||
| 686 | drvdata->buf = devm_kzalloc(dev, | 686 | drvdata->buf = devm_kcalloc(dev, |
| 687 | drvdata->buffer_depth * 4, GFP_KERNEL); | 687 | drvdata->buffer_depth, 4, GFP_KERNEL); |
| 688 | if (!drvdata->buf) | 688 | if (!drvdata->buf) |
| 689 | return -ENOMEM; | 689 | return -ENOMEM; |
| 690 | 690 | ||
diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index a33a92ebe74b..6880bee195c8 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c | |||
| @@ -71,21 +71,24 @@ static int of_coresight_alloc_memory(struct device *dev, | |||
| 71 | struct coresight_platform_data *pdata) | 71 | struct coresight_platform_data *pdata) |
| 72 | { | 72 | { |
| 73 | /* List of output port on this component */ | 73 | /* List of output port on this component */ |
| 74 | pdata->outports = devm_kzalloc(dev, pdata->nr_outport * | 74 | pdata->outports = devm_kcalloc(dev, |
| 75 | pdata->nr_outport, | ||
| 75 | sizeof(*pdata->outports), | 76 | sizeof(*pdata->outports), |
| 76 | GFP_KERNEL); | 77 | GFP_KERNEL); |
| 77 | if (!pdata->outports) | 78 | if (!pdata->outports) |
| 78 | return -ENOMEM; | 79 | return -ENOMEM; |
| 79 | 80 | ||
| 80 | /* Children connected to this component via @outports */ | 81 | /* Children connected to this component via @outports */ |
| 81 | pdata->child_names = devm_kzalloc(dev, pdata->nr_outport * | 82 | pdata->child_names = devm_kcalloc(dev, |
| 83 | pdata->nr_outport, | ||
| 82 | sizeof(*pdata->child_names), | 84 | sizeof(*pdata->child_names), |
| 83 | GFP_KERNEL); | 85 | GFP_KERNEL); |
| 84 | if (!pdata->child_names) | 86 | if (!pdata->child_names) |
| 85 | return -ENOMEM; | 87 | return -ENOMEM; |
| 86 | 88 | ||
| 87 | /* Port number on the child this component is connected to */ | 89 | /* Port number on the child this component is connected to */ |
| 88 | pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport * | 90 | pdata->child_ports = devm_kcalloc(dev, |
| 91 | pdata->nr_outport, | ||
| 89 | sizeof(*pdata->child_ports), | 92 | sizeof(*pdata->child_ports), |
| 90 | GFP_KERNEL); | 93 | GFP_KERNEL); |
| 91 | if (!pdata->child_ports) | 94 | if (!pdata->child_ports) |
diff --git a/drivers/i2c/busses/i2c-amd756-s4882.c b/drivers/i2c/busses/i2c-amd756-s4882.c index 65e324054970..a2f5f992af7a 100644 --- a/drivers/i2c/busses/i2c-amd756-s4882.c +++ b/drivers/i2c/busses/i2c-amd756-s4882.c | |||
| @@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void) | |||
| 169 | 169 | ||
| 170 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); | 170 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n"); |
| 171 | /* Define the 5 virtual adapters and algorithms structures */ | 171 | /* Define the 5 virtual adapters and algorithms structures */ |
| 172 | if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter), | 172 | if (!(s4882_adapter = kcalloc(5, sizeof(struct i2c_adapter), |
| 173 | GFP_KERNEL))) { | 173 | GFP_KERNEL))) { |
| 174 | error = -ENOMEM; | 174 | error = -ENOMEM; |
| 175 | goto ERROR1; | 175 | goto ERROR1; |
| 176 | } | 176 | } |
| 177 | if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm), | 177 | if (!(s4882_algo = kcalloc(5, sizeof(struct i2c_algorithm), |
| 178 | GFP_KERNEL))) { | 178 | GFP_KERNEL))) { |
| 179 | error = -ENOMEM; | 179 | error = -ENOMEM; |
| 180 | goto ERROR2; | 180 | goto ERROR2; |
diff --git a/drivers/i2c/busses/i2c-nforce2-s4985.c b/drivers/i2c/busses/i2c-nforce2-s4985.c index 88eda09e73c0..58a0fbf0e074 100644 --- a/drivers/i2c/busses/i2c-nforce2-s4985.c +++ b/drivers/i2c/busses/i2c-nforce2-s4985.c | |||
| @@ -164,12 +164,12 @@ static int __init nforce2_s4985_init(void) | |||
| 164 | 164 | ||
| 165 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n"); | 165 | printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n"); |
| 166 | /* Define the 5 virtual adapters and algorithms structures */ | 166 | /* Define the 5 virtual adapters and algorithms structures */ |
| 167 | s4985_adapter = kzalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL); | 167 | s4985_adapter = kcalloc(5, sizeof(struct i2c_adapter), GFP_KERNEL); |
| 168 | if (!s4985_adapter) { | 168 | if (!s4985_adapter) { |
| 169 | error = -ENOMEM; | 169 | error = -ENOMEM; |
| 170 | goto ERROR1; | 170 | goto ERROR1; |
| 171 | } | 171 | } |
| 172 | s4985_algo = kzalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL); | 172 | s4985_algo = kcalloc(5, sizeof(struct i2c_algorithm), GFP_KERNEL); |
| 173 | if (!s4985_algo) { | 173 | if (!s4985_algo) { |
| 174 | error = -ENOMEM; | 174 | error = -ENOMEM; |
| 175 | goto ERROR2; | 175 | goto ERROR2; |
diff --git a/drivers/i2c/busses/i2c-nforce2.c b/drivers/i2c/busses/i2c-nforce2.c index 3241bb9d6c18..f6a1272c5854 100644 --- a/drivers/i2c/busses/i2c-nforce2.c +++ b/drivers/i2c/busses/i2c-nforce2.c | |||
| @@ -381,7 +381,7 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 381 | int res1, res2; | 381 | int res1, res2; |
| 382 | 382 | ||
| 383 | /* we support 2 SMBus adapters */ | 383 | /* we support 2 SMBus adapters */ |
| 384 | smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL); | 384 | smbuses = kcalloc(2, sizeof(struct nforce2_smbus), GFP_KERNEL); |
| 385 | if (!smbuses) | 385 | if (!smbuses) |
| 386 | return -ENOMEM; | 386 | return -ENOMEM; |
| 387 | pci_set_drvdata(dev, smbuses); | 387 | pci_set_drvdata(dev, smbuses); |
diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index 904dfec7ab96..ebbf9cdec86b 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c | |||
| @@ -1691,8 +1691,8 @@ static int qup_i2c_probe(struct platform_device *pdev) | |||
| 1691 | 1691 | ||
| 1692 | qup->max_xfer_sg_len = (MX_BLOCKS << 1); | 1692 | qup->max_xfer_sg_len = (MX_BLOCKS << 1); |
| 1693 | blocks = (MX_DMA_BLOCKS << 1) + 1; | 1693 | blocks = (MX_DMA_BLOCKS << 1) + 1; |
| 1694 | qup->btx.sg = devm_kzalloc(&pdev->dev, | 1694 | qup->btx.sg = devm_kcalloc(&pdev->dev, |
| 1695 | sizeof(*qup->btx.sg) * blocks, | 1695 | blocks, sizeof(*qup->btx.sg), |
| 1696 | GFP_KERNEL); | 1696 | GFP_KERNEL); |
| 1697 | if (!qup->btx.sg) { | 1697 | if (!qup->btx.sg) { |
| 1698 | ret = -ENOMEM; | 1698 | ret = -ENOMEM; |
| @@ -1700,8 +1700,8 @@ static int qup_i2c_probe(struct platform_device *pdev) | |||
| 1700 | } | 1700 | } |
| 1701 | sg_init_table(qup->btx.sg, blocks); | 1701 | sg_init_table(qup->btx.sg, blocks); |
| 1702 | 1702 | ||
| 1703 | qup->brx.sg = devm_kzalloc(&pdev->dev, | 1703 | qup->brx.sg = devm_kcalloc(&pdev->dev, |
| 1704 | sizeof(*qup->brx.sg) * blocks, | 1704 | blocks, sizeof(*qup->brx.sg), |
| 1705 | GFP_KERNEL); | 1705 | GFP_KERNEL); |
| 1706 | if (!qup->brx.sg) { | 1706 | if (!qup->brx.sg) { |
| 1707 | ret = -ENOMEM; | 1707 | ret = -ENOMEM; |
diff --git a/drivers/i2c/i2c-dev.c b/drivers/i2c/i2c-dev.c index 1667b6e7674f..1aca742fde4a 100644 --- a/drivers/i2c/i2c-dev.c +++ b/drivers/i2c/i2c-dev.c | |||
| @@ -244,7 +244,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, | |||
| 244 | u8 __user **data_ptrs; | 244 | u8 __user **data_ptrs; |
| 245 | int i, res; | 245 | int i, res; |
| 246 | 246 | ||
| 247 | data_ptrs = kmalloc(nmsgs * sizeof(u8 __user *), GFP_KERNEL); | 247 | data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL); |
| 248 | if (data_ptrs == NULL) { | 248 | if (data_ptrs == NULL) { |
| 249 | kfree(msgs); | 249 | kfree(msgs); |
| 250 | return -ENOMEM; | 250 | return -ENOMEM; |
diff --git a/drivers/i2c/i2c-stub.c b/drivers/i2c/i2c-stub.c index 4a9ad91c5ba3..f31ec0861979 100644 --- a/drivers/i2c/i2c-stub.c +++ b/drivers/i2c/i2c-stub.c | |||
| @@ -338,8 +338,9 @@ static int __init i2c_stub_allocate_banks(int i) | |||
| 338 | chip->bank_mask >>= 1; | 338 | chip->bank_mask >>= 1; |
| 339 | } | 339 | } |
| 340 | 340 | ||
| 341 | chip->bank_words = kzalloc(chip->bank_mask * chip->bank_size * | 341 | chip->bank_words = kcalloc(chip->bank_mask * chip->bank_size, |
| 342 | sizeof(u16), GFP_KERNEL); | 342 | sizeof(u16), |
| 343 | GFP_KERNEL); | ||
| 343 | if (!chip->bank_words) | 344 | if (!chip->bank_words) |
| 344 | return -ENOMEM; | 345 | return -ENOMEM; |
| 345 | 346 | ||
diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 1a9973ede443..ddc4bd4ca13b 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c | |||
| @@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, | |||
| 88 | 88 | ||
| 89 | mux->data.n_values = of_get_child_count(np); | 89 | mux->data.n_values = of_get_child_count(np); |
| 90 | 90 | ||
| 91 | values = devm_kzalloc(&pdev->dev, | 91 | values = devm_kcalloc(&pdev->dev, |
| 92 | sizeof(*mux->data.values) * mux->data.n_values, | 92 | mux->data.n_values, sizeof(*mux->data.values), |
| 93 | GFP_KERNEL); | 93 | GFP_KERNEL); |
| 94 | if (!values) { | 94 | if (!values) { |
| 95 | dev_err(&pdev->dev, "Cannot allocate values array"); | 95 | dev_err(&pdev->dev, "Cannot allocate values array"); |
| @@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, | |||
| 111 | return -EINVAL; | 111 | return -EINVAL; |
| 112 | } | 112 | } |
| 113 | 113 | ||
| 114 | gpios = devm_kzalloc(&pdev->dev, | 114 | gpios = devm_kcalloc(&pdev->dev, |
| 115 | sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL); | 115 | mux->data.n_gpios, sizeof(*mux->data.gpios), |
| 116 | GFP_KERNEL); | ||
| 116 | if (!gpios) { | 117 | if (!gpios) { |
| 117 | dev_err(&pdev->dev, "Cannot allocate gpios array"); | 118 | dev_err(&pdev->dev, "Cannot allocate gpios array"); |
| 118 | return -ENOMEM; | 119 | return -ENOMEM; |
diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c index c948e5a4cb04..f583f805fee9 100644 --- a/drivers/i2c/muxes/i2c-mux-reg.c +++ b/drivers/i2c/muxes/i2c-mux-reg.c | |||
| @@ -124,8 +124,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, | |||
| 124 | } | 124 | } |
| 125 | mux->data.write_only = of_property_read_bool(np, "write-only"); | 125 | mux->data.write_only = of_property_read_bool(np, "write-only"); |
| 126 | 126 | ||
| 127 | values = devm_kzalloc(&pdev->dev, | 127 | values = devm_kcalloc(&pdev->dev, |
| 128 | sizeof(*mux->data.values) * mux->data.n_values, | 128 | mux->data.n_values, sizeof(*mux->data.values), |
| 129 | GFP_KERNEL); | 129 | GFP_KERNEL); |
| 130 | if (!values) { | 130 | if (!values) { |
| 131 | dev_err(&pdev->dev, "Cannot allocate values array"); | 131 | dev_err(&pdev->dev, "Cannot allocate values array"); |
diff --git a/drivers/ide/hpt366.c b/drivers/ide/hpt366.c index 4b5dc0162e67..e52c58c29d9a 100644 --- a/drivers/ide/hpt366.c +++ b/drivers/ide/hpt366.c | |||
| @@ -1455,7 +1455,7 @@ static int hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 1455 | if (info == &hpt36x || info == &hpt374) | 1455 | if (info == &hpt36x || info == &hpt374) |
| 1456 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); | 1456 | dev2 = pci_get_slot(dev->bus, dev->devfn + 1); |
| 1457 | 1457 | ||
| 1458 | dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL); | 1458 | dyn_info = kcalloc(dev2 ? 2 : 1, sizeof(*dyn_info), GFP_KERNEL); |
| 1459 | if (dyn_info == NULL) { | 1459 | if (dyn_info == NULL) { |
| 1460 | printk(KERN_ERR "%s %s: out of memory!\n", | 1460 | printk(KERN_ERR "%s %s: out of memory!\n", |
| 1461 | d.name, pci_name(dev)); | 1461 | d.name, pci_name(dev)); |
diff --git a/drivers/ide/ide-probe.c b/drivers/ide/ide-probe.c index 56d7bc228cb3..416a2f353071 100644 --- a/drivers/ide/ide-probe.c +++ b/drivers/ide/ide-probe.c | |||
| @@ -985,8 +985,9 @@ static int hwif_init(ide_hwif_t *hwif) | |||
| 985 | if (!hwif->sg_max_nents) | 985 | if (!hwif->sg_max_nents) |
| 986 | hwif->sg_max_nents = PRD_ENTRIES; | 986 | hwif->sg_max_nents = PRD_ENTRIES; |
| 987 | 987 | ||
| 988 | hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents, | 988 | hwif->sg_table = kmalloc_array(hwif->sg_max_nents, |
| 989 | GFP_KERNEL); | 989 | sizeof(struct scatterlist), |
| 990 | GFP_KERNEL); | ||
| 990 | if (!hwif->sg_table) { | 991 | if (!hwif->sg_table) { |
| 991 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); | 992 | printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name); |
| 992 | goto out; | 993 | goto out; |
diff --git a/drivers/ide/it821x.c b/drivers/ide/it821x.c index 04029d18a696..36a64c8ea575 100644 --- a/drivers/ide/it821x.c +++ b/drivers/ide/it821x.c | |||
| @@ -652,7 +652,7 @@ static int it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) | |||
| 652 | struct it821x_dev *itdevs; | 652 | struct it821x_dev *itdevs; |
| 653 | int rc; | 653 | int rc; |
| 654 | 654 | ||
| 655 | itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL); | 655 | itdevs = kcalloc(2, sizeof(*itdevs), GFP_KERNEL); |
| 656 | if (itdevs == NULL) { | 656 | if (itdevs == NULL) { |
| 657 | printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev)); | 657 | printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev)); |
| 658 | return -ENOMEM; | 658 | return -ENOMEM; |
diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 71a5ee652b79..44b516863c9d 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c | |||
| @@ -624,8 +624,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev) | |||
| 624 | struct at91_adc_state *st = iio_priv(idev); | 624 | struct at91_adc_state *st = iio_priv(idev); |
| 625 | int i, ret; | 625 | int i, ret; |
| 626 | 626 | ||
| 627 | st->trig = devm_kzalloc(&idev->dev, | 627 | st->trig = devm_kcalloc(&idev->dev, |
| 628 | st->trigger_number * sizeof(*st->trig), | 628 | st->trigger_number, sizeof(*st->trig), |
| 629 | GFP_KERNEL); | 629 | GFP_KERNEL); |
| 630 | 630 | ||
| 631 | if (st->trig == NULL) { | 631 | if (st->trig == NULL) { |
| @@ -908,7 +908,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, | |||
| 908 | st->registers = &st->caps->registers; | 908 | st->registers = &st->caps->registers; |
| 909 | st->num_channels = st->caps->num_channels; | 909 | st->num_channels = st->caps->num_channels; |
| 910 | st->trigger_number = of_get_child_count(node); | 910 | st->trigger_number = of_get_child_count(node); |
| 911 | st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number * | 911 | st->trigger_list = devm_kcalloc(&idev->dev, |
| 912 | st->trigger_number, | ||
| 912 | sizeof(struct at91_adc_trigger), | 913 | sizeof(struct at91_adc_trigger), |
| 913 | GFP_KERNEL); | 914 | GFP_KERNEL); |
| 914 | if (!st->trigger_list) { | 915 | if (!st->trigger_list) { |
diff --git a/drivers/iio/adc/max1027.c b/drivers/iio/adc/max1027.c index 375da6491499..311c1a89c329 100644 --- a/drivers/iio/adc/max1027.c +++ b/drivers/iio/adc/max1027.c | |||
| @@ -422,8 +422,8 @@ static int max1027_probe(struct spi_device *spi) | |||
| 422 | indio_dev->num_channels = st->info->num_channels; | 422 | indio_dev->num_channels = st->info->num_channels; |
| 423 | indio_dev->available_scan_masks = st->info->available_scan_masks; | 423 | indio_dev->available_scan_masks = st->info->available_scan_masks; |
| 424 | 424 | ||
| 425 | st->buffer = devm_kmalloc(&indio_dev->dev, | 425 | st->buffer = devm_kmalloc_array(&indio_dev->dev, |
| 426 | indio_dev->num_channels * 2, | 426 | indio_dev->num_channels, 2, |
| 427 | GFP_KERNEL); | 427 | GFP_KERNEL); |
| 428 | if (st->buffer == NULL) { | 428 | if (st->buffer == NULL) { |
| 429 | dev_err(&indio_dev->dev, "Can't allocate buffer\n"); | 429 | dev_err(&indio_dev->dev, "Can't allocate buffer\n"); |
diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 7f1848dac9bf..7fb4f525714a 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c | |||
| @@ -1453,8 +1453,10 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev) | |||
| 1453 | int i; | 1453 | int i; |
| 1454 | 1454 | ||
| 1455 | masks = devm_kzalloc(&indio_dev->dev, | 1455 | masks = devm_kzalloc(&indio_dev->dev, |
| 1456 | BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) * | 1456 | array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS), |
| 1457 | (st->chip_info->num_modes + 1), GFP_KERNEL); | 1457 | sizeof(long), |
| 1458 | st->chip_info->num_modes + 1), | ||
| 1459 | GFP_KERNEL); | ||
| 1458 | if (!masks) | 1460 | if (!masks) |
| 1459 | return -ENOMEM; | 1461 | return -ENOMEM; |
| 1460 | 1462 | ||
diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index dc83f8f6c3d3..e470510e76ea 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c | |||
| @@ -898,9 +898,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) | |||
| 898 | 898 | ||
| 899 | gpadc = iio_priv(indio_dev); | 899 | gpadc = iio_priv(indio_dev); |
| 900 | 900 | ||
| 901 | gpadc->twl6030_cal_tbl = devm_kzalloc(dev, | 901 | gpadc->twl6030_cal_tbl = devm_kcalloc(dev, |
| 902 | sizeof(*gpadc->twl6030_cal_tbl) * | 902 | pdata->nchannels, |
| 903 | pdata->nchannels, GFP_KERNEL); | 903 | sizeof(*gpadc->twl6030_cal_tbl), |
| 904 | GFP_KERNEL); | ||
| 904 | if (!gpadc->twl6030_cal_tbl) | 905 | if (!gpadc->twl6030_cal_tbl) |
| 905 | return -ENOMEM; | 906 | return -ENOMEM; |
| 906 | 907 | ||
diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c index 9234c6a09a93..095530c233e4 100644 --- a/drivers/iio/dac/ad5592r-base.c +++ b/drivers/iio/dac/ad5592r-base.c | |||
| @@ -536,8 +536,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st) | |||
| 536 | st->channel_offstate[reg] = tmp; | 536 | st->channel_offstate[reg] = tmp; |
| 537 | } | 537 | } |
| 538 | 538 | ||
| 539 | channels = devm_kzalloc(st->dev, | 539 | channels = devm_kcalloc(st->dev, |
| 540 | (1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL); | 540 | 1 + 2 * num_channels, sizeof(*channels), |
| 541 | GFP_KERNEL); | ||
| 541 | if (!channels) | 542 | if (!channels) |
| 542 | return -ENOMEM; | 543 | return -ENOMEM; |
| 543 | 544 | ||
diff --git a/drivers/iio/imu/adis_buffer.c b/drivers/iio/imu/adis_buffer.c index 36607d52fee0..76643c5571aa 100644 --- a/drivers/iio/imu/adis_buffer.c +++ b/drivers/iio/imu/adis_buffer.c | |||
| @@ -38,7 +38,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, | |||
| 38 | if (!adis->xfer) | 38 | if (!adis->xfer) |
| 39 | return -ENOMEM; | 39 | return -ENOMEM; |
| 40 | 40 | ||
| 41 | adis->buffer = kzalloc(indio_dev->scan_bytes * 2, GFP_KERNEL); | 41 | adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL); |
| 42 | if (!adis->buffer) | 42 | if (!adis->buffer) |
| 43 | return -ENOMEM; | 43 | return -ENOMEM; |
| 44 | 44 | ||
diff --git a/drivers/iio/inkern.c b/drivers/iio/inkern.c index ec98790e2a28..06ca3f7fcc44 100644 --- a/drivers/iio/inkern.c +++ b/drivers/iio/inkern.c | |||
| @@ -436,7 +436,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) | |||
| 436 | } | 436 | } |
| 437 | 437 | ||
| 438 | /* NULL terminated array to save passing size */ | 438 | /* NULL terminated array to save passing size */ |
| 439 | chans = kzalloc(sizeof(*chans)*(nummaps + 1), GFP_KERNEL); | 439 | chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL); |
| 440 | if (chans == NULL) { | 440 | if (chans == NULL) { |
| 441 | ret = -ENOMEM; | 441 | ret = -ENOMEM; |
| 442 | goto error_ret; | 442 | goto error_ret; |
diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c index 60621ccd67e4..e1f44cecdef4 100644 --- a/drivers/iio/multiplexer/iio-mux.c +++ b/drivers/iio/multiplexer/iio-mux.c | |||
| @@ -281,9 +281,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux, | |||
| 281 | if (!page) | 281 | if (!page) |
| 282 | return -ENOMEM; | 282 | return -ENOMEM; |
| 283 | } | 283 | } |
| 284 | child->ext_info_cache = devm_kzalloc(dev, | 284 | child->ext_info_cache = devm_kcalloc(dev, |
| 285 | sizeof(*child->ext_info_cache) * | 285 | num_ext_info, |
| 286 | num_ext_info, GFP_KERNEL); | 286 | sizeof(*child->ext_info_cache), |
| 287 | GFP_KERNEL); | ||
| 287 | if (!child->ext_info_cache) | 288 | if (!child->ext_info_cache) |
| 288 | return -ENOMEM; | 289 | return -ENOMEM; |
| 289 | 290 | ||
diff --git a/drivers/infiniband/core/cache.c b/drivers/infiniband/core/cache.c index 71a34bee453d..81d66f56e38f 100644 --- a/drivers/infiniband/core/cache.c +++ b/drivers/infiniband/core/cache.c | |||
| @@ -1245,8 +1245,9 @@ int ib_cache_setup_one(struct ib_device *device) | |||
| 1245 | rwlock_init(&device->cache.lock); | 1245 | rwlock_init(&device->cache.lock); |
| 1246 | 1246 | ||
| 1247 | device->cache.ports = | 1247 | device->cache.ports = |
| 1248 | kzalloc(sizeof(*device->cache.ports) * | 1248 | kcalloc(rdma_end_port(device) - rdma_start_port(device) + 1, |
| 1249 | (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL); | 1249 | sizeof(*device->cache.ports), |
| 1250 | GFP_KERNEL); | ||
| 1250 | if (!device->cache.ports) | 1251 | if (!device->cache.ports) |
| 1251 | return -ENOMEM; | 1252 | return -ENOMEM; |
| 1252 | 1253 | ||
diff --git a/drivers/infiniband/core/cma.c b/drivers/infiniband/core/cma.c index 6813ee717a38..bff10ab141b0 100644 --- a/drivers/infiniband/core/cma.c +++ b/drivers/infiniband/core/cma.c | |||
| @@ -1855,8 +1855,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, | |||
| 1855 | 1855 | ||
| 1856 | rt = &id->route; | 1856 | rt = &id->route; |
| 1857 | rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1; | 1857 | rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1; |
| 1858 | rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths, | 1858 | rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec), |
| 1859 | GFP_KERNEL); | 1859 | GFP_KERNEL); |
| 1860 | if (!rt->path_rec) | 1860 | if (!rt->path_rec) |
| 1861 | goto err; | 1861 | goto err; |
| 1862 | 1862 | ||
diff --git a/drivers/infiniband/core/device.c b/drivers/infiniband/core/device.c index 84f51386e1e3..6fa4c59dc7a7 100644 --- a/drivers/infiniband/core/device.c +++ b/drivers/infiniband/core/device.c | |||
| @@ -336,8 +336,8 @@ static int read_port_immutable(struct ib_device *device) | |||
| 336 | * Therefore port_immutable is declared as a 1 based array with | 336 | * Therefore port_immutable is declared as a 1 based array with |
| 337 | * potential empty slots at the beginning. | 337 | * potential empty slots at the beginning. |
| 338 | */ | 338 | */ |
| 339 | device->port_immutable = kzalloc(sizeof(*device->port_immutable) | 339 | device->port_immutable = kcalloc(end_port + 1, |
| 340 | * (end_port + 1), | 340 | sizeof(*device->port_immutable), |
| 341 | GFP_KERNEL); | 341 | GFP_KERNEL); |
| 342 | if (!device->port_immutable) | 342 | if (!device->port_immutable) |
| 343 | return -ENOMEM; | 343 | return -ENOMEM; |
diff --git a/drivers/infiniband/core/fmr_pool.c b/drivers/infiniband/core/fmr_pool.c index a0a9ed719031..a077500f7f32 100644 --- a/drivers/infiniband/core/fmr_pool.c +++ b/drivers/infiniband/core/fmr_pool.c | |||
| @@ -235,8 +235,9 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, | |||
| 235 | 235 | ||
| 236 | if (params->cache) { | 236 | if (params->cache) { |
| 237 | pool->cache_bucket = | 237 | pool->cache_bucket = |
| 238 | kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket, | 238 | kmalloc_array(IB_FMR_HASH_SIZE, |
| 239 | GFP_KERNEL); | 239 | sizeof(*pool->cache_bucket), |
| 240 | GFP_KERNEL); | ||
| 240 | if (!pool->cache_bucket) { | 241 | if (!pool->cache_bucket) { |
| 241 | ret = -ENOMEM; | 242 | ret = -ENOMEM; |
| 242 | goto out_free_pool; | 243 | goto out_free_pool; |
diff --git a/drivers/infiniband/core/iwpm_util.c b/drivers/infiniband/core/iwpm_util.c index da12da1c36f6..cdb63f3f4de7 100644 --- a/drivers/infiniband/core/iwpm_util.c +++ b/drivers/infiniband/core/iwpm_util.c | |||
| @@ -56,14 +56,16 @@ int iwpm_init(u8 nl_client) | |||
| 56 | int ret = 0; | 56 | int ret = 0; |
| 57 | mutex_lock(&iwpm_admin_lock); | 57 | mutex_lock(&iwpm_admin_lock); |
| 58 | if (atomic_read(&iwpm_admin.refcount) == 0) { | 58 | if (atomic_read(&iwpm_admin.refcount) == 0) { |
| 59 | iwpm_hash_bucket = kzalloc(IWPM_MAPINFO_HASH_SIZE * | 59 | iwpm_hash_bucket = kcalloc(IWPM_MAPINFO_HASH_SIZE, |
| 60 | sizeof(struct hlist_head), GFP_KERNEL); | 60 | sizeof(struct hlist_head), |
| 61 | GFP_KERNEL); | ||
| 61 | if (!iwpm_hash_bucket) { | 62 | if (!iwpm_hash_bucket) { |
| 62 | ret = -ENOMEM; | 63 | ret = -ENOMEM; |
| 63 | goto init_exit; | 64 | goto init_exit; |
| 64 | } | 65 | } |
| 65 | iwpm_reminfo_bucket = kzalloc(IWPM_REMINFO_HASH_SIZE * | 66 | iwpm_reminfo_bucket = kcalloc(IWPM_REMINFO_HASH_SIZE, |
| 66 | sizeof(struct hlist_head), GFP_KERNEL); | 67 | sizeof(struct hlist_head), |
| 68 | GFP_KERNEL); | ||
| 67 | if (!iwpm_reminfo_bucket) { | 69 | if (!iwpm_reminfo_bucket) { |
| 68 | kfree(iwpm_hash_bucket); | 70 | kfree(iwpm_hash_bucket); |
| 69 | ret = -ENOMEM; | 71 | ret = -ENOMEM; |
diff --git a/drivers/infiniband/core/umem_odp.c b/drivers/infiniband/core/umem_odp.c index 2aadf5813a40..182436b92ba9 100644 --- a/drivers/infiniband/core/umem_odp.c +++ b/drivers/infiniband/core/umem_odp.c | |||
| @@ -285,13 +285,15 @@ struct ib_umem *ib_alloc_odp_umem(struct ib_ucontext *context, | |||
| 285 | mutex_init(&odp_data->umem_mutex); | 285 | mutex_init(&odp_data->umem_mutex); |
| 286 | init_completion(&odp_data->notifier_completion); | 286 | init_completion(&odp_data->notifier_completion); |
| 287 | 287 | ||
| 288 | odp_data->page_list = vzalloc(pages * sizeof(*odp_data->page_list)); | 288 | odp_data->page_list = |
| 289 | vzalloc(array_size(pages, sizeof(*odp_data->page_list))); | ||
| 289 | if (!odp_data->page_list) { | 290 | if (!odp_data->page_list) { |
| 290 | ret = -ENOMEM; | 291 | ret = -ENOMEM; |
| 291 | goto out_odp_data; | 292 | goto out_odp_data; |
| 292 | } | 293 | } |
| 293 | 294 | ||
| 294 | odp_data->dma_list = vzalloc(pages * sizeof(*odp_data->dma_list)); | 295 | odp_data->dma_list = |
| 296 | vzalloc(array_size(pages, sizeof(*odp_data->dma_list))); | ||
| 295 | if (!odp_data->dma_list) { | 297 | if (!odp_data->dma_list) { |
| 296 | ret = -ENOMEM; | 298 | ret = -ENOMEM; |
| 297 | goto out_page_list; | 299 | goto out_page_list; |
| @@ -371,15 +373,17 @@ int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem, | |||
| 371 | init_completion(&umem->odp_data->notifier_completion); | 373 | init_completion(&umem->odp_data->notifier_completion); |
| 372 | 374 | ||
| 373 | if (ib_umem_num_pages(umem)) { | 375 | if (ib_umem_num_pages(umem)) { |
| 374 | umem->odp_data->page_list = vzalloc(ib_umem_num_pages(umem) * | 376 | umem->odp_data->page_list = |
| 375 | sizeof(*umem->odp_data->page_list)); | 377 | vzalloc(array_size(sizeof(*umem->odp_data->page_list), |
| 378 | ib_umem_num_pages(umem))); | ||
| 376 | if (!umem->odp_data->page_list) { | 379 | if (!umem->odp_data->page_list) { |
| 377 | ret_val = -ENOMEM; | 380 | ret_val = -ENOMEM; |
| 378 | goto out_odp_data; | 381 | goto out_odp_data; |
| 379 | } | 382 | } |
| 380 | 383 | ||
| 381 | umem->odp_data->dma_list = vzalloc(ib_umem_num_pages(umem) * | 384 | umem->odp_data->dma_list = |
| 382 | sizeof(*umem->odp_data->dma_list)); | 385 | vzalloc(array_size(sizeof(*umem->odp_data->dma_list), |
| 386 | ib_umem_num_pages(umem))); | ||
| 383 | if (!umem->odp_data->dma_list) { | 387 | if (!umem->odp_data->dma_list) { |
| 384 | ret_val = -ENOMEM; | 388 | ret_val = -ENOMEM; |
| 385 | goto out_page_list; | 389 | goto out_page_list; |
diff --git a/drivers/infiniband/core/uverbs_cmd.c b/drivers/infiniband/core/uverbs_cmd.c index 3179a95c6f5e..3e90b6a1d9d2 100644 --- a/drivers/infiniband/core/uverbs_cmd.c +++ b/drivers/infiniband/core/uverbs_cmd.c | |||
| @@ -3559,8 +3559,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, | |||
| 3559 | goto err_uobj; | 3559 | goto err_uobj; |
| 3560 | } | 3560 | } |
| 3561 | 3561 | ||
| 3562 | flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs * | 3562 | flow_attr = kzalloc(struct_size(flow_attr, flows, |
| 3563 | sizeof(union ib_flow_spec), GFP_KERNEL); | 3563 | cmd.flow_attr.num_of_specs), GFP_KERNEL); |
| 3564 | if (!flow_attr) { | 3564 | if (!flow_attr) { |
| 3565 | err = -ENOMEM; | 3565 | err = -ENOMEM; |
| 3566 | goto err_put; | 3566 | goto err_put; |
diff --git a/drivers/infiniband/hw/cxgb3/cxio_hal.c b/drivers/infiniband/hw/cxgb3/cxio_hal.c index 3328acc53c2a..dcb4bba522ba 100644 --- a/drivers/infiniband/hw/cxgb3/cxio_hal.c +++ b/drivers/infiniband/hw/cxgb3/cxio_hal.c | |||
| @@ -279,7 +279,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, | |||
| 279 | if (!wq->qpid) | 279 | if (!wq->qpid) |
| 280 | return -ENOMEM; | 280 | return -ENOMEM; |
| 281 | 281 | ||
| 282 | wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL); | 282 | wq->rq = kcalloc(depth, sizeof(struct t3_swrq), GFP_KERNEL); |
| 283 | if (!wq->rq) | 283 | if (!wq->rq) |
| 284 | goto err1; | 284 | goto err1; |
| 285 | 285 | ||
| @@ -287,7 +287,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, | |||
| 287 | if (!wq->rq_addr) | 287 | if (!wq->rq_addr) |
| 288 | goto err2; | 288 | goto err2; |
| 289 | 289 | ||
| 290 | wq->sq = kzalloc(depth * sizeof(struct t3_swsq), GFP_KERNEL); | 290 | wq->sq = kcalloc(depth, sizeof(struct t3_swsq), GFP_KERNEL); |
| 291 | if (!wq->sq) | 291 | if (!wq->sq) |
| 292 | goto err3; | 292 | goto err3; |
| 293 | 293 | ||
diff --git a/drivers/infiniband/hw/cxgb4/device.c b/drivers/infiniband/hw/cxgb4/device.c index 44161ca4d2a8..a3c3418afd73 100644 --- a/drivers/infiniband/hw/cxgb4/device.c +++ b/drivers/infiniband/hw/cxgb4/device.c | |||
| @@ -859,8 +859,9 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev) | |||
| 859 | rdev->status_page->cq_size = rdev->lldi.vr->cq.size; | 859 | rdev->status_page->cq_size = rdev->lldi.vr->cq.size; |
| 860 | 860 | ||
| 861 | if (c4iw_wr_log) { | 861 | if (c4iw_wr_log) { |
| 862 | rdev->wr_log = kzalloc((1 << c4iw_wr_log_size_order) * | 862 | rdev->wr_log = kcalloc(1 << c4iw_wr_log_size_order, |
| 863 | sizeof(*rdev->wr_log), GFP_KERNEL); | 863 | sizeof(*rdev->wr_log), |
| 864 | GFP_KERNEL); | ||
| 864 | if (rdev->wr_log) { | 865 | if (rdev->wr_log) { |
| 865 | rdev->wr_log_size = 1 << c4iw_wr_log_size_order; | 866 | rdev->wr_log_size = 1 << c4iw_wr_log_size_order; |
| 866 | atomic_set(&rdev->wr_log_idx, 0); | 867 | atomic_set(&rdev->wr_log_idx, 0); |
| @@ -1445,7 +1446,7 @@ static void recover_queues(struct uld_ctx *ctx) | |||
| 1445 | ctx->dev->db_state = RECOVERY; | 1446 | ctx->dev->db_state = RECOVERY; |
| 1446 | idr_for_each(&ctx->dev->qpidr, count_qps, &count); | 1447 | idr_for_each(&ctx->dev->qpidr, count_qps, &count); |
| 1447 | 1448 | ||
| 1448 | qp_list.qps = kzalloc(count * sizeof *qp_list.qps, GFP_ATOMIC); | 1449 | qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC); |
| 1449 | if (!qp_list.qps) { | 1450 | if (!qp_list.qps) { |
| 1450 | spin_unlock_irq(&ctx->dev->lock); | 1451 | spin_unlock_irq(&ctx->dev->lock); |
| 1451 | return; | 1452 | return; |
diff --git a/drivers/infiniband/hw/cxgb4/id_table.c b/drivers/infiniband/hw/cxgb4/id_table.c index 5c2cfdea06ad..724d23297b35 100644 --- a/drivers/infiniband/hw/cxgb4/id_table.c +++ b/drivers/infiniband/hw/cxgb4/id_table.c | |||
| @@ -92,8 +92,8 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num, | |||
| 92 | alloc->last = 0; | 92 | alloc->last = 0; |
| 93 | alloc->max = num; | 93 | alloc->max = num; |
| 94 | spin_lock_init(&alloc->lock); | 94 | spin_lock_init(&alloc->lock); |
| 95 | alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long), | 95 | alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long), |
| 96 | GFP_KERNEL); | 96 | GFP_KERNEL); |
| 97 | if (!alloc->table) | 97 | if (!alloc->table) |
| 98 | return -ENOMEM; | 98 | return -ENOMEM; |
| 99 | 99 | ||
diff --git a/drivers/infiniband/hw/cxgb4/qp.c b/drivers/infiniband/hw/cxgb4/qp.c index 4106eed1b8fb..aef53305f1c3 100644 --- a/drivers/infiniband/hw/cxgb4/qp.c +++ b/drivers/infiniband/hw/cxgb4/qp.c | |||
| @@ -216,15 +216,15 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | if (!user) { | 218 | if (!user) { |
| 219 | wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq, | 219 | wq->sq.sw_sq = kcalloc(wq->sq.size, sizeof(*wq->sq.sw_sq), |
| 220 | GFP_KERNEL); | 220 | GFP_KERNEL); |
| 221 | if (!wq->sq.sw_sq) { | 221 | if (!wq->sq.sw_sq) { |
| 222 | ret = -ENOMEM; | 222 | ret = -ENOMEM; |
| 223 | goto free_rq_qid; | 223 | goto free_rq_qid; |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq, | 226 | wq->rq.sw_rq = kcalloc(wq->rq.size, sizeof(*wq->rq.sw_rq), |
| 227 | GFP_KERNEL); | 227 | GFP_KERNEL); |
| 228 | if (!wq->rq.sw_rq) { | 228 | if (!wq->rq.sw_rq) { |
| 229 | ret = -ENOMEM; | 229 | ret = -ENOMEM; |
| 230 | goto free_sw_sq; | 230 | goto free_sw_sq; |
diff --git a/drivers/infiniband/hw/hfi1/sdma.c b/drivers/infiniband/hw/hfi1/sdma.c index 298e0e3fc0c9..7fb350b87b49 100644 --- a/drivers/infiniband/hw/hfi1/sdma.c +++ b/drivers/infiniband/hw/hfi1/sdma.c | |||
| @@ -1461,7 +1461,8 @@ int sdma_init(struct hfi1_devdata *dd, u8 port) | |||
| 1461 | if (!sde->descq) | 1461 | if (!sde->descq) |
| 1462 | goto bail; | 1462 | goto bail; |
| 1463 | sde->tx_ring = | 1463 | sde->tx_ring = |
| 1464 | kvzalloc_node(sizeof(struct sdma_txreq *) * descq_cnt, | 1464 | kvzalloc_node(array_size(descq_cnt, |
| 1465 | sizeof(struct sdma_txreq *)), | ||
| 1465 | GFP_KERNEL, dd->node); | 1466 | GFP_KERNEL, dd->node); |
| 1466 | if (!sde->tx_ring) | 1467 | if (!sde->tx_ring) |
| 1467 | goto bail; | 1468 | goto bail; |
diff --git a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c index 0e8dad68910a..a6e11be0ea0f 100644 --- a/drivers/infiniband/hw/hns/hns_roce_hw_v2.c +++ b/drivers/infiniband/hw/hns/hns_roce_hw_v2.c | |||
| @@ -3177,7 +3177,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, | |||
| 3177 | struct device *dev = hr_dev->dev; | 3177 | struct device *dev = hr_dev->dev; |
| 3178 | int ret = -EINVAL; | 3178 | int ret = -EINVAL; |
| 3179 | 3179 | ||
| 3180 | context = kzalloc(2 * sizeof(*context), GFP_KERNEL); | 3180 | context = kcalloc(2, sizeof(*context), GFP_KERNEL); |
| 3181 | if (!context) | 3181 | if (!context) |
| 3182 | return -ENOMEM; | 3182 | return -ENOMEM; |
| 3183 | 3183 | ||
diff --git a/drivers/infiniband/hw/hns/hns_roce_mr.c b/drivers/infiniband/hw/hns/hns_roce_mr.c index d1fe0e7957e3..eb26a5f6fc58 100644 --- a/drivers/infiniband/hw/hns/hns_roce_mr.c +++ b/drivers/infiniband/hw/hns/hns_roce_mr.c | |||
| @@ -144,7 +144,7 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order) | |||
| 144 | buddy->bits[i] = kcalloc(s, sizeof(long), GFP_KERNEL | | 144 | buddy->bits[i] = kcalloc(s, sizeof(long), GFP_KERNEL | |
| 145 | __GFP_NOWARN); | 145 | __GFP_NOWARN); |
| 146 | if (!buddy->bits[i]) { | 146 | if (!buddy->bits[i]) { |
| 147 | buddy->bits[i] = vzalloc(s * sizeof(long)); | 147 | buddy->bits[i] = vzalloc(array_size(s, sizeof(long))); |
| 148 | if (!buddy->bits[i]) | 148 | if (!buddy->bits[i]) |
| 149 | goto err_out_free; | 149 | goto err_out_free; |
| 150 | } | 150 | } |
diff --git a/drivers/infiniband/hw/mlx4/mad.c b/drivers/infiniband/hw/mlx4/mad.c index d604b3d5aa3e..90a3e2642c2e 100644 --- a/drivers/infiniband/hw/mlx4/mad.c +++ b/drivers/infiniband/hw/mlx4/mad.c | |||
| @@ -1613,7 +1613,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx, | |||
| 1613 | 1613 | ||
| 1614 | tun_qp = &ctx->qp[qp_type]; | 1614 | tun_qp = &ctx->qp[qp_type]; |
| 1615 | 1615 | ||
| 1616 | tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS, | 1616 | tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS, |
| 1617 | sizeof(struct mlx4_ib_buf), | ||
| 1617 | GFP_KERNEL); | 1618 | GFP_KERNEL); |
| 1618 | if (!tun_qp->ring) | 1619 | if (!tun_qp->ring) |
| 1619 | return -ENOMEM; | 1620 | return -ENOMEM; |
diff --git a/drivers/infiniband/hw/mlx4/main.c b/drivers/infiniband/hw/mlx4/main.c index f839bf3b1497..4ec519afc45b 100644 --- a/drivers/infiniband/hw/mlx4/main.c +++ b/drivers/infiniband/hw/mlx4/main.c | |||
| @@ -302,7 +302,8 @@ static int mlx4_ib_add_gid(const union ib_gid *gid, | |||
| 302 | ctx->refcount++; | 302 | ctx->refcount++; |
| 303 | } | 303 | } |
| 304 | if (!ret && hw_update) { | 304 | if (!ret && hw_update) { |
| 305 | gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC); | 305 | gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids), |
| 306 | GFP_ATOMIC); | ||
| 306 | if (!gids) { | 307 | if (!gids) { |
| 307 | ret = -ENOMEM; | 308 | ret = -ENOMEM; |
| 308 | } else { | 309 | } else { |
| @@ -355,7 +356,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context) | |||
| 355 | if (!ret && hw_update) { | 356 | if (!ret && hw_update) { |
| 356 | int i; | 357 | int i; |
| 357 | 358 | ||
| 358 | gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC); | 359 | gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids), |
| 360 | GFP_ATOMIC); | ||
| 359 | if (!gids) { | 361 | if (!gids) { |
| 360 | ret = -ENOMEM; | 362 | ret = -ENOMEM; |
| 361 | } else { | 363 | } else { |
| @@ -2872,9 +2874,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) | |||
| 2872 | goto err_counter; | 2874 | goto err_counter; |
| 2873 | 2875 | ||
| 2874 | ibdev->ib_uc_qpns_bitmap = | 2876 | ibdev->ib_uc_qpns_bitmap = |
| 2875 | kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) * | 2877 | kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count), |
| 2876 | sizeof(long), | 2878 | sizeof(long), |
| 2877 | GFP_KERNEL); | 2879 | GFP_KERNEL); |
| 2878 | if (!ibdev->ib_uc_qpns_bitmap) | 2880 | if (!ibdev->ib_uc_qpns_bitmap) |
| 2879 | goto err_steer_qp_release; | 2881 | goto err_steer_qp_release; |
| 2880 | 2882 | ||
diff --git a/drivers/infiniband/hw/mlx4/qp.c b/drivers/infiniband/hw/mlx4/qp.c index cd2c08c45334..3b8045fd23ed 100644 --- a/drivers/infiniband/hw/mlx4/qp.c +++ b/drivers/infiniband/hw/mlx4/qp.c | |||
| @@ -573,8 +573,8 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp) | |||
| 573 | int i; | 573 | int i; |
| 574 | 574 | ||
| 575 | qp->sqp_proxy_rcv = | 575 | qp->sqp_proxy_rcv = |
| 576 | kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt, | 576 | kmalloc_array(qp->rq.wqe_cnt, sizeof(struct mlx4_ib_buf), |
| 577 | GFP_KERNEL); | 577 | GFP_KERNEL); |
| 578 | if (!qp->sqp_proxy_rcv) | 578 | if (!qp->sqp_proxy_rcv) |
| 579 | return -ENOMEM; | 579 | return -ENOMEM; |
| 580 | for (i = 0; i < qp->rq.wqe_cnt; i++) { | 580 | for (i = 0; i < qp->rq.wqe_cnt; i++) { |
diff --git a/drivers/infiniband/hw/mlx5/srq.c b/drivers/infiniband/hw/mlx5/srq.c index 3c7522d025f2..0af7b7905550 100644 --- a/drivers/infiniband/hw/mlx5/srq.c +++ b/drivers/infiniband/hw/mlx5/srq.c | |||
| @@ -127,7 +127,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, | |||
| 127 | goto err_umem; | 127 | goto err_umem; |
| 128 | } | 128 | } |
| 129 | 129 | ||
| 130 | in->pas = kvzalloc(sizeof(*in->pas) * ncont, GFP_KERNEL); | 130 | in->pas = kvcalloc(ncont, sizeof(*in->pas), GFP_KERNEL); |
| 131 | if (!in->pas) { | 131 | if (!in->pas) { |
| 132 | err = -ENOMEM; | 132 | err = -ENOMEM; |
| 133 | goto err_umem; | 133 | goto err_umem; |
| @@ -189,7 +189,7 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | mlx5_ib_dbg(dev, "srq->buf.page_shift = %d\n", srq->buf.page_shift); | 191 | mlx5_ib_dbg(dev, "srq->buf.page_shift = %d\n", srq->buf.page_shift); |
| 192 | in->pas = kvzalloc(sizeof(*in->pas) * srq->buf.npages, GFP_KERNEL); | 192 | in->pas = kvcalloc(srq->buf.npages, sizeof(*in->pas), GFP_KERNEL); |
| 193 | if (!in->pas) { | 193 | if (!in->pas) { |
| 194 | err = -ENOMEM; | 194 | err = -ENOMEM; |
| 195 | goto err_buf; | 195 | goto err_buf; |
diff --git a/drivers/infiniband/hw/mthca/mthca_allocator.c b/drivers/infiniband/hw/mthca/mthca_allocator.c index b4e0cf4e95cd..aaf10dd5364d 100644 --- a/drivers/infiniband/hw/mthca/mthca_allocator.c +++ b/drivers/infiniband/hw/mthca/mthca_allocator.c | |||
| @@ -90,8 +90,8 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask, | |||
| 90 | alloc->max = num; | 90 | alloc->max = num; |
| 91 | alloc->mask = mask; | 91 | alloc->mask = mask; |
| 92 | spin_lock_init(&alloc->lock); | 92 | spin_lock_init(&alloc->lock); |
| 93 | alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long), | 93 | alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long), |
| 94 | GFP_KERNEL); | 94 | GFP_KERNEL); |
| 95 | if (!alloc->table) | 95 | if (!alloc->table) |
| 96 | return -ENOMEM; | 96 | return -ENOMEM; |
| 97 | 97 | ||
| @@ -162,7 +162,8 @@ int mthca_array_init(struct mthca_array *array, int nent) | |||
| 162 | int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE; | 162 | int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE; |
| 163 | int i; | 163 | int i; |
| 164 | 164 | ||
| 165 | array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL); | 165 | array->page_list = kmalloc_array(npage, sizeof(*array->page_list), |
| 166 | GFP_KERNEL); | ||
| 166 | if (!array->page_list) | 167 | if (!array->page_list) |
| 167 | return -ENOMEM; | 168 | return -ENOMEM; |
| 168 | 169 | ||
| @@ -220,7 +221,8 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, | |||
| 220 | npages *= 2; | 221 | npages *= 2; |
| 221 | } | 222 | } |
| 222 | 223 | ||
| 223 | dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL); | 224 | dma_list = kmalloc_array(npages, sizeof(*dma_list), |
| 225 | GFP_KERNEL); | ||
| 224 | if (!dma_list) | 226 | if (!dma_list) |
| 225 | goto err_free; | 227 | goto err_free; |
| 226 | 228 | ||
| @@ -231,12 +233,14 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, | |||
| 231 | npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; | 233 | npages = (size + PAGE_SIZE - 1) / PAGE_SIZE; |
| 232 | shift = PAGE_SHIFT; | 234 | shift = PAGE_SHIFT; |
| 233 | 235 | ||
| 234 | dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL); | 236 | dma_list = kmalloc_array(npages, sizeof(*dma_list), |
| 237 | GFP_KERNEL); | ||
| 235 | if (!dma_list) | 238 | if (!dma_list) |
| 236 | return -ENOMEM; | 239 | return -ENOMEM; |
| 237 | 240 | ||
| 238 | buf->page_list = kmalloc(npages * sizeof *buf->page_list, | 241 | buf->page_list = kmalloc_array(npages, |
| 239 | GFP_KERNEL); | 242 | sizeof(*buf->page_list), |
| 243 | GFP_KERNEL); | ||
| 240 | if (!buf->page_list) | 244 | if (!buf->page_list) |
| 241 | goto err_out; | 245 | goto err_out; |
| 242 | 246 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_cmd.c b/drivers/infiniband/hw/mthca/mthca_cmd.c index 419a2a20c047..83aa47eb81a9 100644 --- a/drivers/infiniband/hw/mthca/mthca_cmd.c +++ b/drivers/infiniband/hw/mthca/mthca_cmd.c | |||
| @@ -565,9 +565,9 @@ int mthca_cmd_use_events(struct mthca_dev *dev) | |||
| 565 | { | 565 | { |
| 566 | int i; | 566 | int i; |
| 567 | 567 | ||
| 568 | dev->cmd.context = kmalloc(dev->cmd.max_cmds * | 568 | dev->cmd.context = kmalloc_array(dev->cmd.max_cmds, |
| 569 | sizeof (struct mthca_cmd_context), | 569 | sizeof(struct mthca_cmd_context), |
| 570 | GFP_KERNEL); | 570 | GFP_KERNEL); |
| 571 | if (!dev->cmd.context) | 571 | if (!dev->cmd.context) |
| 572 | return -ENOMEM; | 572 | return -ENOMEM; |
| 573 | 573 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_eq.c b/drivers/infiniband/hw/mthca/mthca_eq.c index 690201738993..30400ea4808b 100644 --- a/drivers/infiniband/hw/mthca/mthca_eq.c +++ b/drivers/infiniband/hw/mthca/mthca_eq.c | |||
| @@ -479,15 +479,15 @@ static int mthca_create_eq(struct mthca_dev *dev, | |||
| 479 | eq->nent = roundup_pow_of_two(max(nent, 2)); | 479 | eq->nent = roundup_pow_of_two(max(nent, 2)); |
| 480 | npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE; | 480 | npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE; |
| 481 | 481 | ||
| 482 | eq->page_list = kmalloc(npages * sizeof *eq->page_list, | 482 | eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list), |
| 483 | GFP_KERNEL); | 483 | GFP_KERNEL); |
| 484 | if (!eq->page_list) | 484 | if (!eq->page_list) |
| 485 | goto err_out; | 485 | goto err_out; |
| 486 | 486 | ||
| 487 | for (i = 0; i < npages; ++i) | 487 | for (i = 0; i < npages; ++i) |
| 488 | eq->page_list[i].buf = NULL; | 488 | eq->page_list[i].buf = NULL; |
| 489 | 489 | ||
| 490 | dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL); | 490 | dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL); |
| 491 | if (!dma_list) | 491 | if (!dma_list) |
| 492 | goto err_out_free; | 492 | goto err_out_free; |
| 493 | 493 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_memfree.c b/drivers/infiniband/hw/mthca/mthca_memfree.c index 7a31be3c3e73..cc9c0c8ccba3 100644 --- a/drivers/infiniband/hw/mthca/mthca_memfree.c +++ b/drivers/infiniband/hw/mthca/mthca_memfree.c | |||
| @@ -712,9 +712,9 @@ int mthca_init_db_tab(struct mthca_dev *dev) | |||
| 712 | dev->db_tab->max_group1 = 0; | 712 | dev->db_tab->max_group1 = 0; |
| 713 | dev->db_tab->min_group2 = dev->db_tab->npages - 1; | 713 | dev->db_tab->min_group2 = dev->db_tab->npages - 1; |
| 714 | 714 | ||
| 715 | dev->db_tab->page = kmalloc(dev->db_tab->npages * | 715 | dev->db_tab->page = kmalloc_array(dev->db_tab->npages, |
| 716 | sizeof *dev->db_tab->page, | 716 | sizeof(*dev->db_tab->page), |
| 717 | GFP_KERNEL); | 717 | GFP_KERNEL); |
| 718 | if (!dev->db_tab->page) { | 718 | if (!dev->db_tab->page) { |
| 719 | kfree(dev->db_tab); | 719 | kfree(dev->db_tab); |
| 720 | return -ENOMEM; | 720 | return -ENOMEM; |
diff --git a/drivers/infiniband/hw/mthca/mthca_mr.c b/drivers/infiniband/hw/mthca/mthca_mr.c index ed9a989e501b..6686042aafb4 100644 --- a/drivers/infiniband/hw/mthca/mthca_mr.c +++ b/drivers/infiniband/hw/mthca/mthca_mr.c | |||
| @@ -144,7 +144,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) | |||
| 144 | buddy->max_order = max_order; | 144 | buddy->max_order = max_order; |
| 145 | spin_lock_init(&buddy->lock); | 145 | spin_lock_init(&buddy->lock); |
| 146 | 146 | ||
| 147 | buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *), | 147 | buddy->bits = kcalloc(buddy->max_order + 1, sizeof(long *), |
| 148 | GFP_KERNEL); | 148 | GFP_KERNEL); |
| 149 | buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free, | 149 | buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free, |
| 150 | GFP_KERNEL); | 150 | GFP_KERNEL); |
| @@ -153,7 +153,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) | |||
| 153 | 153 | ||
| 154 | for (i = 0; i <= buddy->max_order; ++i) { | 154 | for (i = 0; i <= buddy->max_order; ++i) { |
| 155 | s = BITS_TO_LONGS(1 << (buddy->max_order - i)); | 155 | s = BITS_TO_LONGS(1 << (buddy->max_order - i)); |
| 156 | buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL); | 156 | buddy->bits[i] = kmalloc_array(s, sizeof(long), GFP_KERNEL); |
| 157 | if (!buddy->bits[i]) | 157 | if (!buddy->bits[i]) |
| 158 | goto err_out_free; | 158 | goto err_out_free; |
| 159 | bitmap_zero(buddy->bits[i], | 159 | bitmap_zero(buddy->bits[i], |
diff --git a/drivers/infiniband/hw/mthca/mthca_profile.c b/drivers/infiniband/hw/mthca/mthca_profile.c index 15d064479ef6..7ea970774839 100644 --- a/drivers/infiniband/hw/mthca/mthca_profile.c +++ b/drivers/infiniband/hw/mthca/mthca_profile.c | |||
| @@ -79,7 +79,7 @@ s64 mthca_make_profile(struct mthca_dev *dev, | |||
| 79 | struct mthca_resource *profile; | 79 | struct mthca_resource *profile; |
| 80 | int i, j; | 80 | int i, j; |
| 81 | 81 | ||
| 82 | profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL); | 82 | profile = kcalloc(MTHCA_RES_NUM, sizeof(*profile), GFP_KERNEL); |
| 83 | if (!profile) | 83 | if (!profile) |
| 84 | return -ENOMEM; | 84 | return -ENOMEM; |
| 85 | 85 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_qp.c b/drivers/infiniband/hw/mthca/mthca_qp.c index d21960cd9a49..af1c49d70b89 100644 --- a/drivers/infiniband/hw/mthca/mthca_qp.c +++ b/drivers/infiniband/hw/mthca/mthca_qp.c | |||
| @@ -1054,8 +1054,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, | |||
| 1054 | size = PAGE_ALIGN(qp->send_wqe_offset + | 1054 | size = PAGE_ALIGN(qp->send_wqe_offset + |
| 1055 | (qp->sq.max << qp->sq.wqe_shift)); | 1055 | (qp->sq.max << qp->sq.wqe_shift)); |
| 1056 | 1056 | ||
| 1057 | qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64), | 1057 | qp->wrid = kmalloc_array(qp->rq.max + qp->sq.max, sizeof(u64), |
| 1058 | GFP_KERNEL); | 1058 | GFP_KERNEL); |
| 1059 | if (!qp->wrid) | 1059 | if (!qp->wrid) |
| 1060 | goto err_out; | 1060 | goto err_out; |
| 1061 | 1061 | ||
diff --git a/drivers/infiniband/hw/mthca/mthca_srq.c b/drivers/infiniband/hw/mthca/mthca_srq.c index d22f970480c0..f79732bc73b4 100644 --- a/drivers/infiniband/hw/mthca/mthca_srq.c +++ b/drivers/infiniband/hw/mthca/mthca_srq.c | |||
| @@ -155,7 +155,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, | |||
| 155 | if (pd->ibpd.uobject) | 155 | if (pd->ibpd.uobject) |
| 156 | return 0; | 156 | return 0; |
| 157 | 157 | ||
| 158 | srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL); | 158 | srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL); |
| 159 | if (!srq->wrid) | 159 | if (!srq->wrid) |
| 160 | return -ENOMEM; | 160 | return -ENOMEM; |
| 161 | 161 | ||
diff --git a/drivers/infiniband/hw/nes/nes_mgt.c b/drivers/infiniband/hw/nes/nes_mgt.c index 21e0ebd39a05..9bdb84dc225c 100644 --- a/drivers/infiniband/hw/nes/nes_mgt.c +++ b/drivers/infiniband/hw/nes/nes_mgt.c | |||
| @@ -878,7 +878,8 @@ int nes_init_mgt_qp(struct nes_device *nesdev, struct net_device *netdev, struct | |||
| 878 | int ret; | 878 | int ret; |
| 879 | 879 | ||
| 880 | /* Allocate space the all mgt QPs once */ | 880 | /* Allocate space the all mgt QPs once */ |
| 881 | mgtvnic = kzalloc(NES_MGT_QP_COUNT * sizeof(struct nes_vnic_mgt), GFP_KERNEL); | 881 | mgtvnic = kcalloc(NES_MGT_QP_COUNT, sizeof(struct nes_vnic_mgt), |
| 882 | GFP_KERNEL); | ||
| 882 | if (!mgtvnic) | 883 | if (!mgtvnic) |
| 883 | return -ENOMEM; | 884 | return -ENOMEM; |
| 884 | 885 | ||
diff --git a/drivers/infiniband/hw/nes/nes_nic.c b/drivers/infiniband/hw/nes/nes_nic.c index 007d5e8a0121..61014e251555 100644 --- a/drivers/infiniband/hw/nes/nes_nic.c +++ b/drivers/infiniband/hw/nes/nes_nic.c | |||
| @@ -904,7 +904,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev) | |||
| 904 | int i; | 904 | int i; |
| 905 | struct netdev_hw_addr *ha; | 905 | struct netdev_hw_addr *ha; |
| 906 | 906 | ||
| 907 | addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC); | 907 | addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC); |
| 908 | if (!addrs) { | 908 | if (!addrs) { |
| 909 | set_allmulti(nesdev, nic_active_bit); | 909 | set_allmulti(nesdev, nic_active_bit); |
| 910 | goto unlock; | 910 | goto unlock; |
diff --git a/drivers/infiniband/hw/nes/nes_verbs.c b/drivers/infiniband/hw/nes/nes_verbs.c index 1040a6e34230..32f26556c808 100644 --- a/drivers/infiniband/hw/nes/nes_verbs.c +++ b/drivers/infiniband/hw/nes/nes_verbs.c | |||
| @@ -2254,8 +2254,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, | |||
| 2254 | ibmr = ERR_PTR(-ENOMEM); | 2254 | ibmr = ERR_PTR(-ENOMEM); |
| 2255 | goto reg_user_mr_err; | 2255 | goto reg_user_mr_err; |
| 2256 | } | 2256 | } |
| 2257 | root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024, | 2257 | root_vpbl.leaf_vpbl = kcalloc(1024, |
| 2258 | GFP_KERNEL); | 2258 | sizeof(*root_vpbl.leaf_vpbl), |
| 2259 | GFP_KERNEL); | ||
| 2259 | if (!root_vpbl.leaf_vpbl) { | 2260 | if (!root_vpbl.leaf_vpbl) { |
| 2260 | ib_umem_release(region); | 2261 | ib_umem_release(region); |
| 2261 | pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase, | 2262 | pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase, |
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c index 2c260e1c29d1..6c136e5017fe 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_hw.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_hw.c | |||
| @@ -3096,7 +3096,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev) | |||
| 3096 | if (!num_eq) | 3096 | if (!num_eq) |
| 3097 | return -EINVAL; | 3097 | return -EINVAL; |
| 3098 | 3098 | ||
| 3099 | dev->eq_tbl = kzalloc(sizeof(struct ocrdma_eq) * num_eq, GFP_KERNEL); | 3099 | dev->eq_tbl = kcalloc(num_eq, sizeof(struct ocrdma_eq), GFP_KERNEL); |
| 3100 | if (!dev->eq_tbl) | 3100 | if (!dev->eq_tbl) |
| 3101 | return -ENOMEM; | 3101 | return -ENOMEM; |
| 3102 | 3102 | ||
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_main.c b/drivers/infiniband/hw/ocrdma/ocrdma_main.c index eb8b6a935016..5962c0ed9847 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_main.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_main.c | |||
| @@ -221,19 +221,20 @@ static int ocrdma_register_device(struct ocrdma_dev *dev) | |||
| 221 | static int ocrdma_alloc_resources(struct ocrdma_dev *dev) | 221 | static int ocrdma_alloc_resources(struct ocrdma_dev *dev) |
| 222 | { | 222 | { |
| 223 | mutex_init(&dev->dev_lock); | 223 | mutex_init(&dev->dev_lock); |
| 224 | dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) * | 224 | dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(struct ocrdma_cq *), |
| 225 | OCRDMA_MAX_CQ, GFP_KERNEL); | 225 | GFP_KERNEL); |
| 226 | if (!dev->cq_tbl) | 226 | if (!dev->cq_tbl) |
| 227 | goto alloc_err; | 227 | goto alloc_err; |
| 228 | 228 | ||
| 229 | if (dev->attr.max_qp) { | 229 | if (dev->attr.max_qp) { |
| 230 | dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) * | 230 | dev->qp_tbl = kcalloc(OCRDMA_MAX_QP, |
| 231 | OCRDMA_MAX_QP, GFP_KERNEL); | 231 | sizeof(struct ocrdma_qp *), |
| 232 | GFP_KERNEL); | ||
| 232 | if (!dev->qp_tbl) | 233 | if (!dev->qp_tbl) |
| 233 | goto alloc_err; | 234 | goto alloc_err; |
| 234 | } | 235 | } |
| 235 | 236 | ||
| 236 | dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL); | 237 | dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(u64), GFP_KERNEL); |
| 237 | if (dev->stag_arr == NULL) | 238 | if (dev->stag_arr == NULL) |
| 238 | goto alloc_err; | 239 | goto alloc_err; |
| 239 | 240 | ||
diff --git a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c index 784ed6b09a46..82e20fc32890 100644 --- a/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +++ b/drivers/infiniband/hw/ocrdma/ocrdma_verbs.c | |||
| @@ -843,8 +843,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr) | |||
| 843 | void *va; | 843 | void *va; |
| 844 | dma_addr_t pa; | 844 | dma_addr_t pa; |
| 845 | 845 | ||
| 846 | mr->pbl_table = kzalloc(sizeof(struct ocrdma_pbl) * | 846 | mr->pbl_table = kcalloc(mr->num_pbls, sizeof(struct ocrdma_pbl), |
| 847 | mr->num_pbls, GFP_KERNEL); | 847 | GFP_KERNEL); |
| 848 | 848 | ||
| 849 | if (!mr->pbl_table) | 849 | if (!mr->pbl_table) |
| 850 | return -ENOMEM; | 850 | return -ENOMEM; |
| @@ -1323,12 +1323,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp, | |||
| 1323 | static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) | 1323 | static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp) |
| 1324 | { | 1324 | { |
| 1325 | qp->wqe_wr_id_tbl = | 1325 | qp->wqe_wr_id_tbl = |
| 1326 | kzalloc(sizeof(*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt, | 1326 | kcalloc(qp->sq.max_cnt, sizeof(*(qp->wqe_wr_id_tbl)), |
| 1327 | GFP_KERNEL); | 1327 | GFP_KERNEL); |
| 1328 | if (qp->wqe_wr_id_tbl == NULL) | 1328 | if (qp->wqe_wr_id_tbl == NULL) |
| 1329 | return -ENOMEM; | 1329 | return -ENOMEM; |
| 1330 | qp->rqe_wr_id_tbl = | 1330 | qp->rqe_wr_id_tbl = |
| 1331 | kzalloc(sizeof(u64) * qp->rq.max_cnt, GFP_KERNEL); | 1331 | kcalloc(qp->rq.max_cnt, sizeof(u64), GFP_KERNEL); |
| 1332 | if (qp->rqe_wr_id_tbl == NULL) | 1332 | if (qp->rqe_wr_id_tbl == NULL) |
| 1333 | return -ENOMEM; | 1333 | return -ENOMEM; |
| 1334 | 1334 | ||
| @@ -1865,15 +1865,16 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, | |||
| 1865 | 1865 | ||
| 1866 | if (udata == NULL) { | 1866 | if (udata == NULL) { |
| 1867 | status = -ENOMEM; | 1867 | status = -ENOMEM; |
| 1868 | srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt, | 1868 | srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, sizeof(u64), |
| 1869 | GFP_KERNEL); | 1869 | GFP_KERNEL); |
| 1870 | if (srq->rqe_wr_id_tbl == NULL) | 1870 | if (srq->rqe_wr_id_tbl == NULL) |
| 1871 | goto arm_err; | 1871 | goto arm_err; |
| 1872 | 1872 | ||
| 1873 | srq->bit_fields_len = (srq->rq.max_cnt / 32) + | 1873 | srq->bit_fields_len = (srq->rq.max_cnt / 32) + |
| 1874 | (srq->rq.max_cnt % 32 ? 1 : 0); | 1874 | (srq->rq.max_cnt % 32 ? 1 : 0); |
| 1875 | srq->idx_bit_fields = | 1875 | srq->idx_bit_fields = |
| 1876 | kmalloc(srq->bit_fields_len * sizeof(u32), GFP_KERNEL); | 1876 | kmalloc_array(srq->bit_fields_len, sizeof(u32), |
| 1877 | GFP_KERNEL); | ||
| 1877 | if (srq->idx_bit_fields == NULL) | 1878 | if (srq->idx_bit_fields == NULL) |
| 1878 | goto arm_err; | 1879 | goto arm_err; |
| 1879 | memset(srq->idx_bit_fields, 0xff, | 1880 | memset(srq->idx_bit_fields, 0xff, |
diff --git a/drivers/infiniband/hw/qedr/main.c b/drivers/infiniband/hw/qedr/main.c index f4cb60b658ea..ad22b32bbd9c 100644 --- a/drivers/infiniband/hw/qedr/main.c +++ b/drivers/infiniband/hw/qedr/main.c | |||
| @@ -317,8 +317,8 @@ static int qedr_alloc_resources(struct qedr_dev *dev) | |||
| 317 | u16 n_entries; | 317 | u16 n_entries; |
| 318 | int i, rc; | 318 | int i, rc; |
| 319 | 319 | ||
| 320 | dev->sgid_tbl = kzalloc(sizeof(union ib_gid) * | 320 | dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid), |
| 321 | QEDR_MAX_SGID, GFP_KERNEL); | 321 | GFP_KERNEL); |
| 322 | if (!dev->sgid_tbl) | 322 | if (!dev->sgid_tbl) |
| 323 | return -ENOMEM; | 323 | return -ENOMEM; |
| 324 | 324 | ||
diff --git a/drivers/infiniband/hw/qedr/verbs.c b/drivers/infiniband/hw/qedr/verbs.c index 710032f1fad7..f7ac8fc9b531 100644 --- a/drivers/infiniband/hw/qedr/verbs.c +++ b/drivers/infiniband/hw/qedr/verbs.c | |||
| @@ -1614,7 +1614,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev, | |||
| 1614 | qp->sq.max_wr = min_t(u32, attrs->cap.max_send_wr * dev->wq_multiplier, | 1614 | qp->sq.max_wr = min_t(u32, attrs->cap.max_send_wr * dev->wq_multiplier, |
| 1615 | dev->attr.max_sqe); | 1615 | dev->attr.max_sqe); |
| 1616 | 1616 | ||
| 1617 | qp->wqe_wr_id = kzalloc(qp->sq.max_wr * sizeof(*qp->wqe_wr_id), | 1617 | qp->wqe_wr_id = kcalloc(qp->sq.max_wr, sizeof(*qp->wqe_wr_id), |
| 1618 | GFP_KERNEL); | 1618 | GFP_KERNEL); |
| 1619 | if (!qp->wqe_wr_id) { | 1619 | if (!qp->wqe_wr_id) { |
| 1620 | DP_ERR(dev, "create qp: failed SQ shadow memory allocation\n"); | 1620 | DP_ERR(dev, "create qp: failed SQ shadow memory allocation\n"); |
| @@ -1632,7 +1632,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev, | |||
| 1632 | qp->rq.max_wr = (u16) max_t(u32, attrs->cap.max_recv_wr, 1); | 1632 | qp->rq.max_wr = (u16) max_t(u32, attrs->cap.max_recv_wr, 1); |
| 1633 | 1633 | ||
| 1634 | /* Allocate driver internal RQ array */ | 1634 | /* Allocate driver internal RQ array */ |
| 1635 | qp->rqe_wr_id = kzalloc(qp->rq.max_wr * sizeof(*qp->rqe_wr_id), | 1635 | qp->rqe_wr_id = kcalloc(qp->rq.max_wr, sizeof(*qp->rqe_wr_id), |
| 1636 | GFP_KERNEL); | 1636 | GFP_KERNEL); |
| 1637 | if (!qp->rqe_wr_id) { | 1637 | if (!qp->rqe_wr_id) { |
| 1638 | DP_ERR(dev, | 1638 | DP_ERR(dev, |
diff --git a/drivers/infiniband/hw/qib/qib_iba6120.c b/drivers/infiniband/hw/qib/qib_iba6120.c index 8a15e5c7dd91..fb1ff59f40bd 100644 --- a/drivers/infiniband/hw/qib/qib_iba6120.c +++ b/drivers/infiniband/hw/qib/qib_iba6120.c | |||
| @@ -2496,15 +2496,16 @@ static void init_6120_cntrnames(struct qib_devdata *dd) | |||
| 2496 | dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1; | 2496 | dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1; |
| 2497 | else | 2497 | else |
| 2498 | dd->cspec->cntrnamelen = 1 + s - cntr6120names; | 2498 | dd->cspec->cntrnamelen = 1 + s - cntr6120names; |
| 2499 | dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs | 2499 | dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64), |
| 2500 | * sizeof(u64), GFP_KERNEL); | 2500 | GFP_KERNEL); |
| 2501 | 2501 | ||
| 2502 | for (i = 0, s = (char *)portcntr6120names; s; i++) | 2502 | for (i = 0, s = (char *)portcntr6120names; s; i++) |
| 2503 | s = strchr(s + 1, '\n'); | 2503 | s = strchr(s + 1, '\n'); |
| 2504 | dd->cspec->nportcntrs = i - 1; | 2504 | dd->cspec->nportcntrs = i - 1; |
| 2505 | dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1; | 2505 | dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1; |
| 2506 | dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs | 2506 | dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs, |
| 2507 | * sizeof(u64), GFP_KERNEL); | 2507 | sizeof(u64), |
| 2508 | GFP_KERNEL); | ||
| 2508 | } | 2509 | } |
| 2509 | 2510 | ||
| 2510 | static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep, | 2511 | static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep, |
diff --git a/drivers/infiniband/hw/qib/qib_iba7220.c b/drivers/infiniband/hw/qib/qib_iba7220.c index bdff2326731e..163a57a88742 100644 --- a/drivers/infiniband/hw/qib/qib_iba7220.c +++ b/drivers/infiniband/hw/qib/qib_iba7220.c | |||
| @@ -3147,15 +3147,16 @@ static void init_7220_cntrnames(struct qib_devdata *dd) | |||
| 3147 | dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1; | 3147 | dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1; |
| 3148 | else | 3148 | else |
| 3149 | dd->cspec->cntrnamelen = 1 + s - cntr7220names; | 3149 | dd->cspec->cntrnamelen = 1 + s - cntr7220names; |
| 3150 | dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs | 3150 | dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64), |
| 3151 | * sizeof(u64), GFP_KERNEL); | 3151 | GFP_KERNEL); |
| 3152 | 3152 | ||
| 3153 | for (i = 0, s = (char *)portcntr7220names; s; i++) | 3153 | for (i = 0, s = (char *)portcntr7220names; s; i++) |
| 3154 | s = strchr(s + 1, '\n'); | 3154 | s = strchr(s + 1, '\n'); |
| 3155 | dd->cspec->nportcntrs = i - 1; | 3155 | dd->cspec->nportcntrs = i - 1; |
| 3156 | dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1; | 3156 | dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1; |
| 3157 | dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs | 3157 | dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs, |
| 3158 | * sizeof(u64), GFP_KERNEL); | 3158 | sizeof(u64), |
| 3159 | GFP_KERNEL); | ||
| 3159 | } | 3160 | } |
| 3160 | 3161 | ||
| 3161 | static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep, | 3162 | static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep, |
diff --git a/drivers/infiniband/hw/qib/qib_iba7322.c b/drivers/infiniband/hw/qib/qib_iba7322.c index 8414ae44a518..bf5e222eed8e 100644 --- a/drivers/infiniband/hw/qib/qib_iba7322.c +++ b/drivers/infiniband/hw/qib/qib_iba7322.c | |||
| @@ -3648,8 +3648,9 @@ static int qib_do_7322_reset(struct qib_devdata *dd) | |||
| 3648 | 3648 | ||
| 3649 | if (msix_entries) { | 3649 | if (msix_entries) { |
| 3650 | /* can be up to 512 bytes, too big for stack */ | 3650 | /* can be up to 512 bytes, too big for stack */ |
| 3651 | msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries * | 3651 | msix_vecsave = kmalloc_array(2 * dd->cspec->num_msix_entries, |
| 3652 | sizeof(u64), GFP_KERNEL); | 3652 | sizeof(u64), |
| 3653 | GFP_KERNEL); | ||
| 3653 | } | 3654 | } |
| 3654 | 3655 | ||
| 3655 | /* | 3656 | /* |
| @@ -5009,16 +5010,17 @@ static void init_7322_cntrnames(struct qib_devdata *dd) | |||
| 5009 | dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1; | 5010 | dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1; |
| 5010 | else | 5011 | else |
| 5011 | dd->cspec->cntrnamelen = 1 + s - cntr7322names; | 5012 | dd->cspec->cntrnamelen = 1 + s - cntr7322names; |
| 5012 | dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs | 5013 | dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64), |
| 5013 | * sizeof(u64), GFP_KERNEL); | 5014 | GFP_KERNEL); |
| 5014 | 5015 | ||
| 5015 | for (i = 0, s = (char *)portcntr7322names; s; i++) | 5016 | for (i = 0, s = (char *)portcntr7322names; s; i++) |
| 5016 | s = strchr(s + 1, '\n'); | 5017 | s = strchr(s + 1, '\n'); |
| 5017 | dd->cspec->nportcntrs = i - 1; | 5018 | dd->cspec->nportcntrs = i - 1; |
| 5018 | dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1; | 5019 | dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1; |
| 5019 | for (i = 0; i < dd->num_pports; ++i) { | 5020 | for (i = 0; i < dd->num_pports; ++i) { |
| 5020 | dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs | 5021 | dd->pport[i].cpspec->portcntrs = |
| 5021 | * sizeof(u64), GFP_KERNEL); | 5022 | kmalloc_array(dd->cspec->nportcntrs, sizeof(u64), |
| 5023 | GFP_KERNEL); | ||
| 5022 | } | 5024 | } |
| 5023 | } | 5025 | } |
| 5024 | 5026 | ||
| @@ -6412,12 +6414,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd) | |||
| 6412 | sbufcnt = dd->piobcnt2k + dd->piobcnt4k + | 6414 | sbufcnt = dd->piobcnt2k + dd->piobcnt4k + |
| 6413 | NUM_VL15_BUFS + BITS_PER_LONG - 1; | 6415 | NUM_VL15_BUFS + BITS_PER_LONG - 1; |
| 6414 | sbufcnt /= BITS_PER_LONG; | 6416 | sbufcnt /= BITS_PER_LONG; |
| 6415 | dd->cspec->sendchkenable = kmalloc(sbufcnt * | 6417 | dd->cspec->sendchkenable = |
| 6416 | sizeof(*dd->cspec->sendchkenable), GFP_KERNEL); | 6418 | kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable), |
| 6417 | dd->cspec->sendgrhchk = kmalloc(sbufcnt * | 6419 | GFP_KERNEL); |
| 6418 | sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL); | 6420 | dd->cspec->sendgrhchk = |
| 6419 | dd->cspec->sendibchk = kmalloc(sbufcnt * | 6421 | kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk), |
| 6420 | sizeof(*dd->cspec->sendibchk), GFP_KERNEL); | 6422 | GFP_KERNEL); |
| 6423 | dd->cspec->sendibchk = | ||
| 6424 | kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk), | ||
| 6425 | GFP_KERNEL); | ||
| 6421 | if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk || | 6426 | if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk || |
| 6422 | !dd->cspec->sendibchk) { | 6427 | !dd->cspec->sendibchk) { |
| 6423 | ret = -ENOMEM; | 6428 | ret = -ENOMEM; |
| @@ -7290,8 +7295,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, | |||
| 7290 | actual_cnt -= dd->num_pports; | 7295 | actual_cnt -= dd->num_pports; |
| 7291 | 7296 | ||
| 7292 | tabsize = actual_cnt; | 7297 | tabsize = actual_cnt; |
| 7293 | dd->cspec->msix_entries = kzalloc(tabsize * | 7298 | dd->cspec->msix_entries = kcalloc(tabsize, |
| 7294 | sizeof(struct qib_msix_entry), GFP_KERNEL); | 7299 | sizeof(struct qib_msix_entry), |
| 7300 | GFP_KERNEL); | ||
| 7295 | if (!dd->cspec->msix_entries) | 7301 | if (!dd->cspec->msix_entries) |
| 7296 | tabsize = 0; | 7302 | tabsize = 0; |
| 7297 | 7303 | ||
diff --git a/drivers/infiniband/hw/qib/qib_init.c b/drivers/infiniband/hw/qib/qib_init.c index 015520289735..d7cdc77d6306 100644 --- a/drivers/infiniband/hw/qib/qib_init.c +++ b/drivers/infiniband/hw/qib/qib_init.c | |||
| @@ -369,11 +369,13 @@ static void init_shadow_tids(struct qib_devdata *dd) | |||
| 369 | struct page **pages; | 369 | struct page **pages; |
| 370 | dma_addr_t *addrs; | 370 | dma_addr_t *addrs; |
| 371 | 371 | ||
| 372 | pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *)); | 372 | pages = vzalloc(array_size(sizeof(struct page *), |
| 373 | dd->cfgctxts * dd->rcvtidcnt)); | ||
| 373 | if (!pages) | 374 | if (!pages) |
| 374 | goto bail; | 375 | goto bail; |
| 375 | 376 | ||
| 376 | addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t)); | 377 | addrs = vzalloc(array_size(sizeof(dma_addr_t), |
| 378 | dd->cfgctxts * dd->rcvtidcnt)); | ||
| 377 | if (!addrs) | 379 | if (!addrs) |
| 378 | goto bail_free; | 380 | goto bail_free; |
| 379 | 381 | ||
| @@ -1134,8 +1136,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) | |||
| 1134 | if (!qib_cpulist_count) { | 1136 | if (!qib_cpulist_count) { |
| 1135 | u32 count = num_online_cpus(); | 1137 | u32 count = num_online_cpus(); |
| 1136 | 1138 | ||
| 1137 | qib_cpulist = kzalloc(BITS_TO_LONGS(count) * | 1139 | qib_cpulist = kcalloc(BITS_TO_LONGS(count), sizeof(long), |
| 1138 | sizeof(long), GFP_KERNEL); | 1140 | GFP_KERNEL); |
| 1139 | if (qib_cpulist) | 1141 | if (qib_cpulist) |
| 1140 | qib_cpulist_count = count; | 1142 | qib_cpulist_count = count; |
| 1141 | } | 1143 | } |
| @@ -1673,8 +1675,8 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd) | |||
| 1673 | size = rcd->rcvegrbuf_size; | 1675 | size = rcd->rcvegrbuf_size; |
| 1674 | if (!rcd->rcvegrbuf) { | 1676 | if (!rcd->rcvegrbuf) { |
| 1675 | rcd->rcvegrbuf = | 1677 | rcd->rcvegrbuf = |
| 1676 | kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]), | 1678 | kcalloc_node(chunk, sizeof(rcd->rcvegrbuf[0]), |
| 1677 | GFP_KERNEL, rcd->node_id); | 1679 | GFP_KERNEL, rcd->node_id); |
| 1678 | if (!rcd->rcvegrbuf) | 1680 | if (!rcd->rcvegrbuf) |
| 1679 | goto bail; | 1681 | goto bail; |
| 1680 | } | 1682 | } |
diff --git a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c index 912d8ef04352..bf5136533d49 100644 --- a/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +++ b/drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c | |||
| @@ -543,7 +543,7 @@ alloc_res_chunk_list(struct usnic_vnic *vnic, | |||
| 543 | /* Do Nothing */ | 543 | /* Do Nothing */ |
| 544 | } | 544 | } |
| 545 | 545 | ||
| 546 | res_chunk_list = kzalloc(sizeof(*res_chunk_list)*(res_lst_sz+1), | 546 | res_chunk_list = kcalloc(res_lst_sz + 1, sizeof(*res_chunk_list), |
| 547 | GFP_ATOMIC); | 547 | GFP_ATOMIC); |
| 548 | if (!res_chunk_list) | 548 | if (!res_chunk_list) |
| 549 | return ERR_PTR(-ENOMEM); | 549 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/infiniband/hw/usnic/usnic_vnic.c b/drivers/infiniband/hw/usnic/usnic_vnic.c index e7b0030254da..ebe08f348453 100644 --- a/drivers/infiniband/hw/usnic/usnic_vnic.c +++ b/drivers/infiniband/hw/usnic/usnic_vnic.c | |||
| @@ -312,7 +312,7 @@ static int usnic_vnic_alloc_res_chunk(struct usnic_vnic *vnic, | |||
| 312 | } | 312 | } |
| 313 | 313 | ||
| 314 | chunk->cnt = chunk->free_cnt = cnt; | 314 | chunk->cnt = chunk->free_cnt = cnt; |
| 315 | chunk->res = kzalloc(sizeof(*(chunk->res))*cnt, GFP_KERNEL); | 315 | chunk->res = kcalloc(cnt, sizeof(*(chunk->res)), GFP_KERNEL); |
| 316 | if (!chunk->res) | 316 | if (!chunk->res) |
| 317 | return -ENOMEM; | 317 | return -ENOMEM; |
| 318 | 318 | ||
diff --git a/drivers/infiniband/sw/rdmavt/qp.c b/drivers/infiniband/sw/rdmavt/qp.c index 40046135c509..41183bd665ca 100644 --- a/drivers/infiniband/sw/rdmavt/qp.c +++ b/drivers/infiniband/sw/rdmavt/qp.c | |||
| @@ -813,7 +813,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
| 813 | sz = sizeof(struct rvt_sge) * | 813 | sz = sizeof(struct rvt_sge) * |
| 814 | init_attr->cap.max_send_sge + | 814 | init_attr->cap.max_send_sge + |
| 815 | sizeof(struct rvt_swqe); | 815 | sizeof(struct rvt_swqe); |
| 816 | swq = vzalloc_node(sqsize * sz, rdi->dparms.node); | 816 | swq = vzalloc_node(array_size(sz, sqsize), rdi->dparms.node); |
| 817 | if (!swq) | 817 | if (!swq) |
| 818 | return ERR_PTR(-ENOMEM); | 818 | return ERR_PTR(-ENOMEM); |
| 819 | 819 | ||
| @@ -836,11 +836,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, | |||
| 836 | RCU_INIT_POINTER(qp->next, NULL); | 836 | RCU_INIT_POINTER(qp->next, NULL); |
| 837 | if (init_attr->qp_type == IB_QPT_RC) { | 837 | if (init_attr->qp_type == IB_QPT_RC) { |
| 838 | qp->s_ack_queue = | 838 | qp->s_ack_queue = |
| 839 | kzalloc_node( | 839 | kcalloc_node(rvt_max_atomic(rdi), |
| 840 | sizeof(*qp->s_ack_queue) * | 840 | sizeof(*qp->s_ack_queue), |
| 841 | rvt_max_atomic(rdi), | 841 | GFP_KERNEL, |
| 842 | GFP_KERNEL, | 842 | rdi->dparms.node); |
| 843 | rdi->dparms.node); | ||
| 844 | if (!qp->s_ack_queue) | 843 | if (!qp->s_ack_queue) |
| 845 | goto bail_qp; | 844 | goto bail_qp; |
| 846 | } | 845 | } |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_cm.c b/drivers/infiniband/ulp/ipoib/ipoib_cm.c index 962fbcb57dc7..6535d9beb24d 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_cm.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_cm.c | |||
| @@ -358,7 +358,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i | |||
| 358 | int ret; | 358 | int ret; |
| 359 | int i; | 359 | int i; |
| 360 | 360 | ||
| 361 | rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring); | 361 | rx->rx_ring = vzalloc(array_size(ipoib_recvq_size, |
| 362 | sizeof(*rx->rx_ring))); | ||
| 362 | if (!rx->rx_ring) | 363 | if (!rx->rx_ring) |
| 363 | return -ENOMEM; | 364 | return -ENOMEM; |
| 364 | 365 | ||
| @@ -1145,7 +1146,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, | |||
| 1145 | int ret; | 1146 | int ret; |
| 1146 | 1147 | ||
| 1147 | noio_flag = memalloc_noio_save(); | 1148 | noio_flag = memalloc_noio_save(); |
| 1148 | p->tx_ring = vzalloc(ipoib_sendq_size * sizeof(*p->tx_ring)); | 1149 | p->tx_ring = vzalloc(array_size(ipoib_sendq_size, sizeof(*p->tx_ring))); |
| 1149 | if (!p->tx_ring) { | 1150 | if (!p->tx_ring) { |
| 1150 | memalloc_noio_restore(noio_flag); | 1151 | memalloc_noio_restore(noio_flag); |
| 1151 | ret = -ENOMEM; | 1152 | ret = -ENOMEM; |
| @@ -1570,7 +1571,8 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge) | |||
| 1570 | return; | 1571 | return; |
| 1571 | } | 1572 | } |
| 1572 | 1573 | ||
| 1573 | priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring); | 1574 | priv->cm.srq_ring = vzalloc(array_size(ipoib_recvq_size, |
| 1575 | sizeof(*priv->cm.srq_ring))); | ||
| 1574 | if (!priv->cm.srq_ring) { | 1576 | if (!priv->cm.srq_ring) { |
| 1575 | ib_destroy_srq(priv->cm.srq); | 1577 | ib_destroy_srq(priv->cm.srq); |
| 1576 | priv->cm.srq = NULL; | 1578 | priv->cm.srq = NULL; |
diff --git a/drivers/infiniband/ulp/ipoib/ipoib_main.c b/drivers/infiniband/ulp/ipoib/ipoib_main.c index 2ce40a7ff604..26cde95bc0f3 100644 --- a/drivers/infiniband/ulp/ipoib/ipoib_main.c +++ b/drivers/infiniband/ulp/ipoib/ipoib_main.c | |||
| @@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv) | |||
| 1526 | return -ENOMEM; | 1526 | return -ENOMEM; |
| 1527 | set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags); | 1527 | set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags); |
| 1528 | size = roundup_pow_of_two(arp_tbl.gc_thresh3); | 1528 | size = roundup_pow_of_two(arp_tbl.gc_thresh3); |
| 1529 | buckets = kzalloc(size * sizeof(*buckets), GFP_KERNEL); | 1529 | buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL); |
| 1530 | if (!buckets) { | 1530 | if (!buckets) { |
| 1531 | kfree(htbl); | 1531 | kfree(htbl); |
| 1532 | return -ENOMEM; | 1532 | return -ENOMEM; |
| @@ -1704,12 +1704,14 @@ static int ipoib_dev_init_default(struct net_device *dev) | |||
| 1704 | ipoib_napi_add(dev); | 1704 | ipoib_napi_add(dev); |
| 1705 | 1705 | ||
| 1706 | /* Allocate RX/TX "rings" to hold queued skbs */ | 1706 | /* Allocate RX/TX "rings" to hold queued skbs */ |
| 1707 | priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring, | 1707 | priv->rx_ring = kcalloc(ipoib_recvq_size, |
| 1708 | GFP_KERNEL); | 1708 | sizeof(*priv->rx_ring), |
| 1709 | GFP_KERNEL); | ||
| 1709 | if (!priv->rx_ring) | 1710 | if (!priv->rx_ring) |
| 1710 | goto out; | 1711 | goto out; |
| 1711 | 1712 | ||
| 1712 | priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring); | 1713 | priv->tx_ring = vzalloc(array_size(ipoib_sendq_size, |
| 1714 | sizeof(*priv->tx_ring))); | ||
| 1713 | if (!priv->tx_ring) { | 1715 | if (!priv->tx_ring) { |
| 1714 | pr_warn("%s: failed to allocate TX ring (%d entries)\n", | 1716 | pr_warn("%s: failed to allocate TX ring (%d entries)\n", |
| 1715 | priv->ca->name, ipoib_sendq_size); | 1717 | priv->ca->name, ipoib_sendq_size); |
diff --git a/drivers/infiniband/ulp/iser/iser_initiator.c b/drivers/infiniband/ulp/iser/iser_initiator.c index ca858d6bd37a..2f6388596f88 100644 --- a/drivers/infiniband/ulp/iser/iser_initiator.c +++ b/drivers/infiniband/ulp/iser/iser_initiator.c | |||
| @@ -258,8 +258,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn, | |||
| 258 | goto alloc_login_buf_fail; | 258 | goto alloc_login_buf_fail; |
| 259 | 259 | ||
| 260 | iser_conn->num_rx_descs = session->cmds_max; | 260 | iser_conn->num_rx_descs = session->cmds_max; |
| 261 | iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs * | 261 | iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs, |
| 262 | sizeof(struct iser_rx_desc), GFP_KERNEL); | 262 | sizeof(struct iser_rx_desc), |
| 263 | GFP_KERNEL); | ||
| 263 | if (!iser_conn->rx_descs) | 264 | if (!iser_conn->rx_descs) |
| 264 | goto rx_desc_alloc_fail; | 265 | goto rx_desc_alloc_fail; |
| 265 | 266 | ||
diff --git a/drivers/infiniband/ulp/isert/ib_isert.c b/drivers/infiniband/ulp/isert/ib_isert.c index f2f9318e1f49..cccbcf0eb035 100644 --- a/drivers/infiniband/ulp/isert/ib_isert.c +++ b/drivers/infiniband/ulp/isert/ib_isert.c | |||
| @@ -181,8 +181,9 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn) | |||
| 181 | u64 dma_addr; | 181 | u64 dma_addr; |
| 182 | int i, j; | 182 | int i, j; |
| 183 | 183 | ||
| 184 | isert_conn->rx_descs = kzalloc(ISERT_QP_MAX_RECV_DTOS * | 184 | isert_conn->rx_descs = kcalloc(ISERT_QP_MAX_RECV_DTOS, |
| 185 | sizeof(struct iser_rx_desc), GFP_KERNEL); | 185 | sizeof(struct iser_rx_desc), |
| 186 | GFP_KERNEL); | ||
| 186 | if (!isert_conn->rx_descs) | 187 | if (!isert_conn->rx_descs) |
| 187 | return -ENOMEM; | 188 | return -ENOMEM; |
| 188 | 189 | ||
diff --git a/drivers/infiniband/ulp/srp/ib_srp.c b/drivers/infiniband/ulp/srp/ib_srp.c index c35d2cd37d70..9786b24b956f 100644 --- a/drivers/infiniband/ulp/srp/ib_srp.c +++ b/drivers/infiniband/ulp/srp/ib_srp.c | |||
| @@ -1035,16 +1035,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) | |||
| 1035 | 1035 | ||
| 1036 | for (i = 0; i < target->req_ring_size; ++i) { | 1036 | for (i = 0; i < target->req_ring_size; ++i) { |
| 1037 | req = &ch->req_ring[i]; | 1037 | req = &ch->req_ring[i]; |
| 1038 | mr_list = kmalloc(target->mr_per_cmd * sizeof(void *), | 1038 | mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *), |
| 1039 | GFP_KERNEL); | 1039 | GFP_KERNEL); |
| 1040 | if (!mr_list) | 1040 | if (!mr_list) |
| 1041 | goto out; | 1041 | goto out; |
| 1042 | if (srp_dev->use_fast_reg) { | 1042 | if (srp_dev->use_fast_reg) { |
| 1043 | req->fr_list = mr_list; | 1043 | req->fr_list = mr_list; |
| 1044 | } else { | 1044 | } else { |
| 1045 | req->fmr_list = mr_list; | 1045 | req->fmr_list = mr_list; |
| 1046 | req->map_page = kmalloc(srp_dev->max_pages_per_mr * | 1046 | req->map_page = kmalloc_array(srp_dev->max_pages_per_mr, |
| 1047 | sizeof(void *), GFP_KERNEL); | 1047 | sizeof(void *), |
| 1048 | GFP_KERNEL); | ||
| 1048 | if (!req->map_page) | 1049 | if (!req->map_page) |
| 1049 | goto out; | 1050 | goto out; |
| 1050 | } | 1051 | } |
diff --git a/drivers/infiniband/ulp/srpt/ib_srpt.c b/drivers/infiniband/ulp/srpt/ib_srpt.c index dfec0e1fac29..3081c629a7f7 100644 --- a/drivers/infiniband/ulp/srpt/ib_srpt.c +++ b/drivers/infiniband/ulp/srpt/ib_srpt.c | |||
| @@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, | |||
| 720 | WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx) | 720 | WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx) |
| 721 | && ioctx_size != sizeof(struct srpt_send_ioctx)); | 721 | && ioctx_size != sizeof(struct srpt_send_ioctx)); |
| 722 | 722 | ||
| 723 | ring = kmalloc(ring_size * sizeof(ring[0]), GFP_KERNEL); | 723 | ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL); |
| 724 | if (!ring) | 724 | if (!ring) |
| 725 | goto out; | 725 | goto out; |
| 726 | for (i = 0; i < ring_size; ++i) { | 726 | for (i = 0; i < ring_size; ++i) { |
diff --git a/drivers/input/joystick/joydump.c b/drivers/input/joystick/joydump.c index d1c6e4846a4a..7f4dff9a566f 100644 --- a/drivers/input/joystick/joydump.c +++ b/drivers/input/joystick/joydump.c | |||
| @@ -80,7 +80,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr | |||
| 80 | 80 | ||
| 81 | timeout = gameport_time(gameport, 10000); /* 10 ms */ | 81 | timeout = gameport_time(gameport, 10000); /* 10 ms */ |
| 82 | 82 | ||
| 83 | buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL); | 83 | buf = kmalloc_array(BUF_SIZE, sizeof(struct joydump), GFP_KERNEL); |
| 84 | if (!buf) { | 84 | if (!buf) { |
| 85 | printk(KERN_INFO "joydump: no memory for testing\n"); | 85 | printk(KERN_INFO "joydump: no memory for testing\n"); |
| 86 | goto jd_end; | 86 | goto jd_end; |
diff --git a/drivers/input/keyboard/clps711x-keypad.c b/drivers/input/keyboard/clps711x-keypad.c index 997e3e97f573..e319f745771a 100644 --- a/drivers/input/keyboard/clps711x-keypad.c +++ b/drivers/input/keyboard/clps711x-keypad.c | |||
| @@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev) | |||
| 109 | if (priv->row_count < 1) | 109 | if (priv->row_count < 1) |
| 110 | return -EINVAL; | 110 | return -EINVAL; |
| 111 | 111 | ||
| 112 | priv->gpio_data = devm_kzalloc(dev, | 112 | priv->gpio_data = devm_kcalloc(dev, |
| 113 | sizeof(*priv->gpio_data) * priv->row_count, | 113 | priv->row_count, sizeof(*priv->gpio_data), |
| 114 | GFP_KERNEL); | 114 | GFP_KERNEL); |
| 115 | if (!priv->gpio_data) | 115 | if (!priv->gpio_data) |
| 116 | return -ENOMEM; | 116 | return -ENOMEM; |
diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index 41614c185918..f51ae09596ef 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c | |||
| @@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev) | |||
| 443 | of_property_read_u32(np, "col-scan-delay-us", | 443 | of_property_read_u32(np, "col-scan-delay-us", |
| 444 | &pdata->col_scan_delay_us); | 444 | &pdata->col_scan_delay_us); |
| 445 | 445 | ||
| 446 | gpios = devm_kzalloc(dev, | 446 | gpios = devm_kcalloc(dev, |
| 447 | sizeof(unsigned int) * | 447 | pdata->num_row_gpios + pdata->num_col_gpios, |
| 448 | (pdata->num_row_gpios + pdata->num_col_gpios), | 448 | sizeof(unsigned int), |
| 449 | GFP_KERNEL); | 449 | GFP_KERNEL); |
| 450 | if (!gpios) { | 450 | if (!gpios) { |
| 451 | dev_err(dev, "could not allocate memory for gpios\n"); | 451 | dev_err(dev, "could not allocate memory for gpios\n"); |
diff --git a/drivers/input/keyboard/omap4-keypad.c b/drivers/input/keyboard/omap4-keypad.c index 940d38b08e6b..46406345742b 100644 --- a/drivers/input/keyboard/omap4-keypad.c +++ b/drivers/input/keyboard/omap4-keypad.c | |||
| @@ -337,7 +337,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) | |||
| 337 | 337 | ||
| 338 | keypad_data->row_shift = get_count_order(keypad_data->cols); | 338 | keypad_data->row_shift = get_count_order(keypad_data->cols); |
| 339 | max_keys = keypad_data->rows << keypad_data->row_shift; | 339 | max_keys = keypad_data->rows << keypad_data->row_shift; |
| 340 | keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]), | 340 | keypad_data->keymap = kcalloc(max_keys, |
| 341 | sizeof(keypad_data->keymap[0]), | ||
| 341 | GFP_KERNEL); | 342 | GFP_KERNEL); |
| 342 | if (!keypad_data->keymap) { | 343 | if (!keypad_data->keymap) { |
| 343 | dev_err(&pdev->dev, "Not enough memory for keymap\n"); | 344 | dev_err(&pdev->dev, "Not enough memory for keymap\n"); |
diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 316414465c77..1fe1aa2adf85 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c | |||
| @@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev) | |||
| 281 | 281 | ||
| 282 | key_count = of_get_child_count(np); | 282 | key_count = of_get_child_count(np); |
| 283 | keymap_data->keymap_size = key_count; | 283 | keymap_data->keymap_size = key_count; |
| 284 | keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); | 284 | keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL); |
| 285 | if (!keymap) { | 285 | if (!keymap) { |
| 286 | dev_err(dev, "could not allocate memory for keymap\n"); | 286 | dev_err(dev, "could not allocate memory for keymap\n"); |
| 287 | return ERR_PTR(-ENOMEM); | 287 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c index 8ccefc15c7a4..8b3a5758451e 100644 --- a/drivers/input/matrix-keymap.c +++ b/drivers/input/matrix-keymap.c | |||
| @@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, | |||
| 170 | return -EINVAL; | 170 | return -EINVAL; |
| 171 | 171 | ||
| 172 | if (!keymap) { | 172 | if (!keymap) { |
| 173 | keymap = devm_kzalloc(input_dev->dev.parent, | 173 | keymap = devm_kcalloc(input_dev->dev.parent, |
| 174 | max_keys * sizeof(*keymap), | 174 | max_keys, sizeof(*keymap), |
| 175 | GFP_KERNEL); | 175 | GFP_KERNEL); |
| 176 | if (!keymap) { | 176 | if (!keymap) { |
| 177 | dev_err(input_dev->dev.parent, | 177 | dev_err(input_dev->dev.parent, |
diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 1588aecafff7..6d304381fc30 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c | |||
| @@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) | |||
| 283 | } | 283 | } |
| 284 | 284 | ||
| 285 | encoder->irq = | 285 | encoder->irq = |
| 286 | devm_kzalloc(dev, | 286 | devm_kcalloc(dev, |
| 287 | sizeof(*encoder->irq) * encoder->gpios->ndescs, | 287 | encoder->gpios->ndescs, sizeof(*encoder->irq), |
| 288 | GFP_KERNEL); | 288 | GFP_KERNEL); |
| 289 | if (!encoder->irq) | 289 | if (!encoder->irq) |
| 290 | return -ENOMEM; | 290 | return -ENOMEM; |
diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index f5954981e9ee..7d29053dfb0f 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c | |||
| @@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, | |||
| 636 | rdesc->num_registers = bitmap_weight(rdesc->presense_map, | 636 | rdesc->num_registers = bitmap_weight(rdesc->presense_map, |
| 637 | RMI_REG_DESC_PRESENSE_BITS); | 637 | RMI_REG_DESC_PRESENSE_BITS); |
| 638 | 638 | ||
| 639 | rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers * | 639 | rdesc->registers = devm_kcalloc(&d->dev, |
| 640 | sizeof(struct rmi_register_desc_item), | 640 | rdesc->num_registers, |
| 641 | GFP_KERNEL); | 641 | sizeof(struct rmi_register_desc_item), |
| 642 | GFP_KERNEL); | ||
| 642 | if (!rdesc->registers) | 643 | if (!rdesc->registers) |
| 643 | return -ENOMEM; | 644 | return -ENOMEM; |
| 644 | 645 | ||
| @@ -1061,7 +1062,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data) | |||
| 1061 | data->num_of_irq_regs = (data->irq_count + 7) / 8; | 1062 | data->num_of_irq_regs = (data->irq_count + 7) / 8; |
| 1062 | 1063 | ||
| 1063 | size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long); | 1064 | size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long); |
| 1064 | data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL); | 1065 | data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL); |
| 1065 | if (!data->irq_memory) { | 1066 | if (!data->irq_memory) { |
| 1066 | dev_err(dev, "Failed to allocate memory for irq masks.\n"); | 1067 | dev_err(dev, "Failed to allocate memory for irq masks.\n"); |
| 1067 | return -ENOMEM; | 1068 | return -ENOMEM; |
diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index bc5e37f30ac1..12a233251793 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c | |||
| @@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn) | |||
| 1190 | f11->sensor.attn_size += f11->sensor.nbr_fingers * 2; | 1190 | f11->sensor.attn_size += f11->sensor.nbr_fingers * 2; |
| 1191 | 1191 | ||
| 1192 | /* allocate the in-kernel tracking buffers */ | 1192 | /* allocate the in-kernel tracking buffers */ |
| 1193 | sensor->tracking_pos = devm_kzalloc(&fn->dev, | 1193 | sensor->tracking_pos = devm_kcalloc(&fn->dev, |
| 1194 | sizeof(struct input_mt_pos) * sensor->nbr_fingers, | 1194 | sensor->nbr_fingers, sizeof(struct input_mt_pos), |
| 1195 | GFP_KERNEL); | ||
| 1196 | sensor->tracking_slots = devm_kcalloc(&fn->dev, | ||
| 1197 | sensor->nbr_fingers, sizeof(int), GFP_KERNEL); | ||
| 1198 | sensor->objs = devm_kcalloc(&fn->dev, | ||
| 1199 | sensor->nbr_fingers, | ||
| 1200 | sizeof(struct rmi_2d_sensor_abs_object), | ||
| 1195 | GFP_KERNEL); | 1201 | GFP_KERNEL); |
| 1196 | sensor->tracking_slots = devm_kzalloc(&fn->dev, | ||
| 1197 | sizeof(int) * sensor->nbr_fingers, GFP_KERNEL); | ||
| 1198 | sensor->objs = devm_kzalloc(&fn->dev, | ||
| 1199 | sizeof(struct rmi_2d_sensor_abs_object) | ||
| 1200 | * sensor->nbr_fingers, GFP_KERNEL); | ||
| 1201 | if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) | 1202 | if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) |
| 1202 | return -ENOMEM; | 1203 | return -ENOMEM; |
| 1203 | 1204 | ||
diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index 8b0db086d68a..a3d1aa88f2a9 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c | |||
| @@ -502,14 +502,15 @@ static int rmi_f12_probe(struct rmi_function *fn) | |||
| 502 | } | 502 | } |
| 503 | 503 | ||
| 504 | /* allocate the in-kernel tracking buffers */ | 504 | /* allocate the in-kernel tracking buffers */ |
| 505 | sensor->tracking_pos = devm_kzalloc(&fn->dev, | 505 | sensor->tracking_pos = devm_kcalloc(&fn->dev, |
| 506 | sizeof(struct input_mt_pos) * sensor->nbr_fingers, | 506 | sensor->nbr_fingers, sizeof(struct input_mt_pos), |
| 507 | GFP_KERNEL); | ||
| 508 | sensor->tracking_slots = devm_kcalloc(&fn->dev, | ||
| 509 | sensor->nbr_fingers, sizeof(int), GFP_KERNEL); | ||
| 510 | sensor->objs = devm_kcalloc(&fn->dev, | ||
| 511 | sensor->nbr_fingers, | ||
| 512 | sizeof(struct rmi_2d_sensor_abs_object), | ||
| 507 | GFP_KERNEL); | 513 | GFP_KERNEL); |
| 508 | sensor->tracking_slots = devm_kzalloc(&fn->dev, | ||
| 509 | sizeof(int) * sensor->nbr_fingers, GFP_KERNEL); | ||
| 510 | sensor->objs = devm_kzalloc(&fn->dev, | ||
| 511 | sizeof(struct rmi_2d_sensor_abs_object) | ||
| 512 | * sensor->nbr_fingers, GFP_KERNEL); | ||
| 513 | if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) | 514 | if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) |
| 514 | return -ENOMEM; | 515 | return -ENOMEM; |
| 515 | 516 | ||
diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c index 5343f2c08f15..e8a59d164019 100644 --- a/drivers/input/rmi4/rmi_f54.c +++ b/drivers/input/rmi4/rmi_f54.c | |||
| @@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn) | |||
| 685 | rx = f54->num_rx_electrodes; | 685 | rx = f54->num_rx_electrodes; |
| 686 | tx = f54->num_tx_electrodes; | 686 | tx = f54->num_tx_electrodes; |
| 687 | f54->report_data = devm_kzalloc(&fn->dev, | 687 | f54->report_data = devm_kzalloc(&fn->dev, |
| 688 | sizeof(u16) * tx * rx, | 688 | array3_size(tx, rx, sizeof(u16)), |
| 689 | GFP_KERNEL); | 689 | GFP_KERNEL); |
| 690 | if (f54->report_data == NULL) | 690 | if (f54->report_data == NULL) |
| 691 | return -ENOMEM; | 691 | return -ENOMEM; |
diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c index 082defc329a8..33b8c6e7ac0a 100644 --- a/drivers/input/rmi4/rmi_spi.c +++ b/drivers/input/rmi4/rmi_spi.c | |||
| @@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) | |||
| 69 | buf_size = RMI_SPI_XFER_SIZE_LIMIT; | 69 | buf_size = RMI_SPI_XFER_SIZE_LIMIT; |
| 70 | 70 | ||
| 71 | tmp = rmi_spi->rx_buf; | 71 | tmp = rmi_spi->rx_buf; |
| 72 | buf = devm_kzalloc(&spi->dev, buf_size * 2, | 72 | buf = devm_kcalloc(&spi->dev, buf_size, 2, |
| 73 | GFP_KERNEL | GFP_DMA); | 73 | GFP_KERNEL | GFP_DMA); |
| 74 | if (!buf) | 74 | if (!buf) |
| 75 | return -ENOMEM; | 75 | return -ENOMEM; |
| @@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) | |||
| 96 | * per byte delays. | 96 | * per byte delays. |
| 97 | */ | 97 | */ |
| 98 | tmp = rmi_spi->rx_xfers; | 98 | tmp = rmi_spi->rx_xfers; |
| 99 | xfer_buf = devm_kzalloc(&spi->dev, | 99 | xfer_buf = devm_kcalloc(&spi->dev, |
| 100 | (rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count) | 100 | rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count, |
| 101 | * sizeof(struct spi_transfer), GFP_KERNEL); | 101 | sizeof(struct spi_transfer), |
| 102 | GFP_KERNEL); | ||
| 102 | if (!xfer_buf) | 103 | if (!xfer_buf) |
| 103 | return -ENOMEM; | 104 | return -ENOMEM; |
| 104 | 105 | ||
diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 69e7c60792a8..f7a96bcf94a6 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c | |||
| @@ -2082,7 +2082,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) | |||
| 2082 | return -ENODEV; | 2082 | return -ENODEV; |
| 2083 | } | 2083 | } |
| 2084 | 2084 | ||
| 2085 | smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs, | 2085 | smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs), |
| 2086 | GFP_KERNEL); | 2086 | GFP_KERNEL); |
| 2087 | if (!smmu->irqs) { | 2087 | if (!smmu->irqs) { |
| 2088 | dev_err(dev, "failed to allocate %d irqs\n", num_irqs); | 2088 | dev_err(dev, "failed to allocate %d irqs\n", num_irqs); |
diff --git a/drivers/iommu/dmar.c b/drivers/iommu/dmar.c index 4321f7704b23..75456b5aa825 100644 --- a/drivers/iommu/dmar.c +++ b/drivers/iommu/dmar.c | |||
| @@ -1458,7 +1458,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) | |||
| 1458 | 1458 | ||
| 1459 | qi->desc = page_address(desc_page); | 1459 | qi->desc = page_address(desc_page); |
| 1460 | 1460 | ||
| 1461 | qi->desc_status = kzalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC); | 1461 | qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC); |
| 1462 | if (!qi->desc_status) { | 1462 | if (!qi->desc_status) { |
| 1463 | free_page((unsigned long) qi->desc); | 1463 | free_page((unsigned long) qi->desc); |
| 1464 | kfree(qi); | 1464 | kfree(qi); |
diff --git a/drivers/iommu/intel-iommu.c b/drivers/iommu/intel-iommu.c index 89e49a429c57..14e4b3722428 100644 --- a/drivers/iommu/intel-iommu.c +++ b/drivers/iommu/intel-iommu.c | |||
| @@ -3189,7 +3189,7 @@ static int copy_translation_tables(struct intel_iommu *iommu) | |||
| 3189 | /* This is too big for the stack - allocate it from slab */ | 3189 | /* This is too big for the stack - allocate it from slab */ |
| 3190 | ctxt_table_entries = ext ? 512 : 256; | 3190 | ctxt_table_entries = ext ? 512 : 256; |
| 3191 | ret = -ENOMEM; | 3191 | ret = -ENOMEM; |
| 3192 | ctxt_tbls = kzalloc(ctxt_table_entries * sizeof(void *), GFP_KERNEL); | 3192 | ctxt_tbls = kcalloc(ctxt_table_entries, sizeof(void *), GFP_KERNEL); |
| 3193 | if (!ctxt_tbls) | 3193 | if (!ctxt_tbls) |
| 3194 | goto out_unmap; | 3194 | goto out_unmap; |
| 3195 | 3195 | ||
| @@ -4032,7 +4032,7 @@ static int iommu_suspend(void) | |||
| 4032 | unsigned long flag; | 4032 | unsigned long flag; |
| 4033 | 4033 | ||
| 4034 | for_each_active_iommu(iommu, drhd) { | 4034 | for_each_active_iommu(iommu, drhd) { |
| 4035 | iommu->iommu_state = kzalloc(sizeof(u32) * MAX_SR_DMAR_REGS, | 4035 | iommu->iommu_state = kcalloc(MAX_SR_DMAR_REGS, sizeof(u32), |
| 4036 | GFP_ATOMIC); | 4036 | GFP_ATOMIC); |
| 4037 | if (!iommu->iommu_state) | 4037 | if (!iommu->iommu_state) |
| 4038 | goto nomem; | 4038 | goto nomem; |
diff --git a/drivers/iommu/omap-iommu.c b/drivers/iommu/omap-iommu.c index c33b7b104e72..af4a8e7fcd27 100644 --- a/drivers/iommu/omap-iommu.c +++ b/drivers/iommu/omap-iommu.c | |||
| @@ -1455,7 +1455,7 @@ static int omap_iommu_add_device(struct device *dev) | |||
| 1455 | if (num_iommus < 0) | 1455 | if (num_iommus < 0) |
| 1456 | return 0; | 1456 | return 0; |
| 1457 | 1457 | ||
| 1458 | arch_data = kzalloc((num_iommus + 1) * sizeof(*arch_data), GFP_KERNEL); | 1458 | arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL); |
| 1459 | if (!arch_data) | 1459 | if (!arch_data) |
| 1460 | return -ENOMEM; | 1460 | return -ENOMEM; |
| 1461 | 1461 | ||
diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 0468acfa131f..054cd2c8e9c8 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c | |||
| @@ -1135,7 +1135,7 @@ static int rk_iommu_probe(struct platform_device *pdev) | |||
| 1135 | iommu->dev = dev; | 1135 | iommu->dev = dev; |
| 1136 | iommu->num_mmu = 0; | 1136 | iommu->num_mmu = 0; |
| 1137 | 1137 | ||
| 1138 | iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res, | 1138 | iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases), |
| 1139 | GFP_KERNEL); | 1139 | GFP_KERNEL); |
| 1140 | if (!iommu->bases) | 1140 | if (!iommu->bases) |
| 1141 | return -ENOMEM; | 1141 | return -ENOMEM; |
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c index 89ec24c6952c..a004f6da35f2 100644 --- a/drivers/iommu/tegra-gart.c +++ b/drivers/iommu/tegra-gart.c | |||
| @@ -465,7 +465,7 @@ static int tegra_gart_probe(struct platform_device *pdev) | |||
| 465 | gart->iovmm_base = (dma_addr_t)res_remap->start; | 465 | gart->iovmm_base = (dma_addr_t)res_remap->start; |
| 466 | gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT); | 466 | gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT); |
| 467 | 467 | ||
| 468 | gart->savedata = vmalloc(sizeof(u32) * gart->page_count); | 468 | gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count)); |
| 469 | if (!gart->savedata) { | 469 | if (!gart->savedata) { |
| 470 | dev_err(dev, "failed to allocate context save area\n"); | 470 | dev_err(dev, "failed to allocate context save area\n"); |
| 471 | return -ENOMEM; | 471 | return -ENOMEM; |
diff --git a/drivers/ipack/carriers/tpci200.c b/drivers/ipack/carriers/tpci200.c index 9b23843dcad4..a16b320739b4 100644 --- a/drivers/ipack/carriers/tpci200.c +++ b/drivers/ipack/carriers/tpci200.c | |||
| @@ -457,8 +457,8 @@ static int tpci200_install(struct tpci200_board *tpci200) | |||
| 457 | { | 457 | { |
| 458 | int res; | 458 | int res; |
| 459 | 459 | ||
| 460 | tpci200->slots = kzalloc( | 460 | tpci200->slots = kcalloc(TPCI200_NB_SLOT, sizeof(struct tpci200_slot), |
| 461 | TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL); | 461 | GFP_KERNEL); |
| 462 | if (tpci200->slots == NULL) | 462 | if (tpci200->slots == NULL) |
| 463 | return -ENOMEM; | 463 | return -ENOMEM; |
| 464 | 464 | ||
diff --git a/drivers/irqchip/irq-alpine-msi.c b/drivers/irqchip/irq-alpine-msi.c index 63d980995d17..23a3b877f7f1 100644 --- a/drivers/irqchip/irq-alpine-msi.c +++ b/drivers/irqchip/irq-alpine-msi.c | |||
| @@ -268,7 +268,8 @@ static int alpine_msix_init(struct device_node *node, | |||
| 268 | goto err_priv; | 268 | goto err_priv; |
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | priv->msi_map = kzalloc(sizeof(*priv->msi_map) * BITS_TO_LONGS(priv->num_spis), | 271 | priv->msi_map = kcalloc(BITS_TO_LONGS(priv->num_spis), |
| 272 | sizeof(*priv->msi_map), | ||
| 272 | GFP_KERNEL); | 273 | GFP_KERNEL); |
| 273 | if (!priv->msi_map) { | 274 | if (!priv->msi_map) { |
| 274 | ret = -ENOMEM; | 275 | ret = -ENOMEM; |
diff --git a/drivers/irqchip/irq-gic-v2m.c b/drivers/irqchip/irq-gic-v2m.c index 1ff38aff9f29..0f52d44b3f69 100644 --- a/drivers/irqchip/irq-gic-v2m.c +++ b/drivers/irqchip/irq-gic-v2m.c | |||
| @@ -361,7 +361,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, | |||
| 361 | break; | 361 | break; |
| 362 | } | 362 | } |
| 363 | 363 | ||
| 364 | v2m->bm = kzalloc(sizeof(long) * BITS_TO_LONGS(v2m->nr_spis), | 364 | v2m->bm = kcalloc(BITS_TO_LONGS(v2m->nr_spis), sizeof(long), |
| 365 | GFP_KERNEL); | 365 | GFP_KERNEL); |
| 366 | if (!v2m->bm) { | 366 | if (!v2m->bm) { |
| 367 | ret = -ENOMEM; | 367 | ret = -ENOMEM; |
diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index 5416f2b2ac21..5377d7e2afba 100644 --- a/drivers/irqchip/irq-gic-v3-its.c +++ b/drivers/irqchip/irq-gic-v3-its.c | |||
| @@ -1239,7 +1239,7 @@ static int its_vlpi_map(struct irq_data *d, struct its_cmd_info *info) | |||
| 1239 | if (!its_dev->event_map.vm) { | 1239 | if (!its_dev->event_map.vm) { |
| 1240 | struct its_vlpi_map *maps; | 1240 | struct its_vlpi_map *maps; |
| 1241 | 1241 | ||
| 1242 | maps = kzalloc(sizeof(*maps) * its_dev->event_map.nr_lpis, | 1242 | maps = kcalloc(its_dev->event_map.nr_lpis, sizeof(*maps), |
| 1243 | GFP_KERNEL); | 1243 | GFP_KERNEL); |
| 1244 | if (!maps) { | 1244 | if (!maps) { |
| 1245 | ret = -ENOMEM; | 1245 | ret = -ENOMEM; |
| @@ -1437,7 +1437,7 @@ static int __init its_lpi_init(u32 id_bits) | |||
| 1437 | { | 1437 | { |
| 1438 | lpi_chunks = its_lpi_to_chunk(1UL << id_bits); | 1438 | lpi_chunks = its_lpi_to_chunk(1UL << id_bits); |
| 1439 | 1439 | ||
| 1440 | lpi_bitmap = kzalloc(BITS_TO_LONGS(lpi_chunks) * sizeof(long), | 1440 | lpi_bitmap = kcalloc(BITS_TO_LONGS(lpi_chunks), sizeof(long), |
| 1441 | GFP_KERNEL); | 1441 | GFP_KERNEL); |
| 1442 | if (!lpi_bitmap) { | 1442 | if (!lpi_bitmap) { |
| 1443 | lpi_chunks = 0; | 1443 | lpi_chunks = 0; |
| @@ -1471,7 +1471,8 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, int *base, int *nr_ids) | |||
| 1471 | if (!nr_chunks) | 1471 | if (!nr_chunks) |
| 1472 | goto out; | 1472 | goto out; |
| 1473 | 1473 | ||
| 1474 | bitmap = kzalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK) * sizeof (long), | 1474 | bitmap = kcalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK), |
| 1475 | sizeof(long), | ||
| 1475 | GFP_ATOMIC); | 1476 | GFP_ATOMIC); |
| 1476 | if (!bitmap) | 1477 | if (!bitmap) |
| 1477 | goto out; | 1478 | goto out; |
| @@ -1823,7 +1824,7 @@ static int its_alloc_tables(struct its_node *its) | |||
| 1823 | 1824 | ||
| 1824 | static int its_alloc_collections(struct its_node *its) | 1825 | static int its_alloc_collections(struct its_node *its) |
| 1825 | { | 1826 | { |
| 1826 | its->collections = kzalloc(nr_cpu_ids * sizeof(*its->collections), | 1827 | its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections), |
| 1827 | GFP_KERNEL); | 1828 | GFP_KERNEL); |
| 1828 | if (!its->collections) | 1829 | if (!its->collections) |
| 1829 | return -ENOMEM; | 1830 | return -ENOMEM; |
| @@ -2124,10 +2125,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, | |||
| 2124 | if (alloc_lpis) { | 2125 | if (alloc_lpis) { |
| 2125 | lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); | 2126 | lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis); |
| 2126 | if (lpi_map) | 2127 | if (lpi_map) |
| 2127 | col_map = kzalloc(sizeof(*col_map) * nr_lpis, | 2128 | col_map = kcalloc(nr_lpis, sizeof(*col_map), |
| 2128 | GFP_KERNEL); | 2129 | GFP_KERNEL); |
| 2129 | } else { | 2130 | } else { |
| 2130 | col_map = kzalloc(sizeof(*col_map) * nr_ites, GFP_KERNEL); | 2131 | col_map = kcalloc(nr_ites, sizeof(*col_map), GFP_KERNEL); |
| 2131 | nr_lpis = 0; | 2132 | nr_lpis = 0; |
| 2132 | lpi_base = 0; | 2133 | lpi_base = 0; |
| 2133 | } | 2134 | } |
| @@ -3183,7 +3184,7 @@ static int its_init_vpe_domain(void) | |||
| 3183 | its = list_first_entry(&its_nodes, struct its_node, entry); | 3184 | its = list_first_entry(&its_nodes, struct its_node, entry); |
| 3184 | 3185 | ||
| 3185 | entries = roundup_pow_of_two(nr_cpu_ids); | 3186 | entries = roundup_pow_of_two(nr_cpu_ids); |
| 3186 | vpe_proxy.vpes = kzalloc(sizeof(*vpe_proxy.vpes) * entries, | 3187 | vpe_proxy.vpes = kcalloc(entries, sizeof(*vpe_proxy.vpes), |
| 3187 | GFP_KERNEL); | 3188 | GFP_KERNEL); |
| 3188 | if (!vpe_proxy.vpes) { | 3189 | if (!vpe_proxy.vpes) { |
| 3189 | pr_err("ITS: Can't allocate GICv4 proxy device array\n"); | 3190 | pr_err("ITS: Can't allocate GICv4 proxy device array\n"); |
| @@ -3567,8 +3568,8 @@ static void __init acpi_table_parse_srat_its(void) | |||
| 3567 | if (count <= 0) | 3568 | if (count <= 0) |
| 3568 | return; | 3569 | return; |
| 3569 | 3570 | ||
| 3570 | its_srat_maps = kmalloc(count * sizeof(struct its_srat_map), | 3571 | its_srat_maps = kmalloc_array(count, sizeof(struct its_srat_map), |
| 3571 | GFP_KERNEL); | 3572 | GFP_KERNEL); |
| 3572 | if (!its_srat_maps) { | 3573 | if (!its_srat_maps) { |
| 3573 | pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n"); | 3574 | pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n"); |
| 3574 | return; | 3575 | return; |
diff --git a/drivers/irqchip/irq-gic-v3.c b/drivers/irqchip/irq-gic-v3.c index 5a67ec084588..76ea56d779a1 100644 --- a/drivers/irqchip/irq-gic-v3.c +++ b/drivers/irqchip/irq-gic-v3.c | |||
| @@ -1167,7 +1167,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) | |||
| 1167 | if (!nr_parts) | 1167 | if (!nr_parts) |
| 1168 | goto out_put_node; | 1168 | goto out_put_node; |
| 1169 | 1169 | ||
| 1170 | parts = kzalloc(sizeof(*parts) * nr_parts, GFP_KERNEL); | 1170 | parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL); |
| 1171 | if (WARN_ON(!parts)) | 1171 | if (WARN_ON(!parts)) |
| 1172 | goto out_put_node; | 1172 | goto out_put_node; |
| 1173 | 1173 | ||
| @@ -1289,7 +1289,8 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare | |||
| 1289 | if (of_property_read_u32(node, "#redistributor-regions", &nr_redist_regions)) | 1289 | if (of_property_read_u32(node, "#redistributor-regions", &nr_redist_regions)) |
| 1290 | nr_redist_regions = 1; | 1290 | nr_redist_regions = 1; |
| 1291 | 1291 | ||
| 1292 | rdist_regs = kzalloc(sizeof(*rdist_regs) * nr_redist_regions, GFP_KERNEL); | 1292 | rdist_regs = kcalloc(nr_redist_regions, sizeof(*rdist_regs), |
| 1293 | GFP_KERNEL); | ||
| 1293 | if (!rdist_regs) { | 1294 | if (!rdist_regs) { |
| 1294 | err = -ENOMEM; | 1295 | err = -ENOMEM; |
| 1295 | goto out_unmap_dist; | 1296 | goto out_unmap_dist; |
diff --git a/drivers/irqchip/irq-imgpdc.c b/drivers/irqchip/irq-imgpdc.c index e80263e16c4c..d00489a4b54f 100644 --- a/drivers/irqchip/irq-imgpdc.c +++ b/drivers/irqchip/irq-imgpdc.c | |||
| @@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev) | |||
| 354 | priv->nr_syswakes = val; | 354 | priv->nr_syswakes = val; |
| 355 | 355 | ||
| 356 | /* Get peripheral IRQ numbers */ | 356 | /* Get peripheral IRQ numbers */ |
| 357 | priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips, | 357 | priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips, |
| 358 | GFP_KERNEL); | 358 | GFP_KERNEL); |
| 359 | if (!priv->perip_irqs) { | 359 | if (!priv->perip_irqs) { |
| 360 | dev_err(&pdev->dev, "cannot allocate perip IRQ list\n"); | 360 | dev_err(&pdev->dev, "cannot allocate perip IRQ list\n"); |
diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c index 4e17f7081efc..3be5c5dba1da 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c | |||
| @@ -191,8 +191,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) | |||
| 191 | gicp->spi_ranges_cnt = ret / 2; | 191 | gicp->spi_ranges_cnt = ret / 2; |
| 192 | 192 | ||
| 193 | gicp->spi_ranges = | 193 | gicp->spi_ranges = |
| 194 | devm_kzalloc(&pdev->dev, | 194 | devm_kcalloc(&pdev->dev, |
| 195 | gicp->spi_ranges_cnt * | 195 | gicp->spi_ranges_cnt, |
| 196 | sizeof(struct mvebu_gicp_spi_range), | 196 | sizeof(struct mvebu_gicp_spi_range), |
| 197 | GFP_KERNEL); | 197 | GFP_KERNEL); |
| 198 | if (!gicp->spi_ranges) | 198 | if (!gicp->spi_ranges) |
| @@ -210,8 +210,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) | |||
| 210 | gicp->spi_cnt += gicp->spi_ranges[i].count; | 210 | gicp->spi_cnt += gicp->spi_ranges[i].count; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | gicp->spi_bitmap = devm_kzalloc(&pdev->dev, | 213 | gicp->spi_bitmap = devm_kcalloc(&pdev->dev, |
| 214 | BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long), | 214 | BITS_TO_LONGS(gicp->spi_cnt), sizeof(long), |
| 215 | GFP_KERNEL); | 215 | GFP_KERNEL); |
| 216 | if (!gicp->spi_bitmap) | 216 | if (!gicp->spi_bitmap) |
| 217 | return -ENOMEM; | 217 | return -ENOMEM; |
diff --git a/drivers/irqchip/irq-partition-percpu.c b/drivers/irqchip/irq-partition-percpu.c index ccd72c2cbc23..1f7cc5933cd5 100644 --- a/drivers/irqchip/irq-partition-percpu.c +++ b/drivers/irqchip/irq-partition-percpu.c | |||
| @@ -229,7 +229,7 @@ struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode, | |||
| 229 | goto out; | 229 | goto out; |
| 230 | desc->domain = d; | 230 | desc->domain = d; |
| 231 | 231 | ||
| 232 | desc->bitmap = kzalloc(sizeof(long) * BITS_TO_LONGS(nr_parts), | 232 | desc->bitmap = kcalloc(BITS_TO_LONGS(nr_parts), sizeof(long), |
| 233 | GFP_KERNEL); | 233 | GFP_KERNEL); |
| 234 | if (WARN_ON(!desc->bitmap)) | 234 | if (WARN_ON(!desc->bitmap)) |
| 235 | goto out; | 235 | goto out; |
diff --git a/drivers/irqchip/irq-s3c24xx.c b/drivers/irqchip/irq-s3c24xx.c index ec0e6a8cdb75..f6fd57ebe6e6 100644 --- a/drivers/irqchip/irq-s3c24xx.c +++ b/drivers/irqchip/irq-s3c24xx.c | |||
| @@ -1261,7 +1261,7 @@ static int __init s3c_init_intc_of(struct device_node *np, | |||
| 1261 | return -ENOMEM; | 1261 | return -ENOMEM; |
| 1262 | 1262 | ||
| 1263 | intc->domain = domain; | 1263 | intc->domain = domain; |
| 1264 | intc->irqs = kzalloc(sizeof(struct s3c_irq_data) * 32, | 1264 | intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data), |
| 1265 | GFP_KERNEL); | 1265 | GFP_KERNEL); |
| 1266 | if (!intc->irqs) { | 1266 | if (!intc->irqs) { |
| 1267 | kfree(intc); | 1267 | kfree(intc); |
diff --git a/drivers/isdn/capi/capi.c b/drivers/isdn/capi/capi.c index baa1ee2bc2ac..6e0c2814d032 100644 --- a/drivers/isdn/capi/capi.c +++ b/drivers/isdn/capi/capi.c | |||
| @@ -1260,7 +1260,7 @@ static int __init capinc_tty_init(void) | |||
| 1260 | if (capi_ttyminors <= 0) | 1260 | if (capi_ttyminors <= 0) |
| 1261 | capi_ttyminors = CAPINC_NR_PORTS; | 1261 | capi_ttyminors = CAPINC_NR_PORTS; |
| 1262 | 1262 | ||
| 1263 | capiminors = kzalloc(sizeof(struct capiminor *) * capi_ttyminors, | 1263 | capiminors = kcalloc(capi_ttyminors, sizeof(struct capiminor *), |
| 1264 | GFP_KERNEL); | 1264 | GFP_KERNEL); |
| 1265 | if (!capiminors) | 1265 | if (!capiminors) |
| 1266 | return -ENOMEM; | 1266 | return -ENOMEM; |
diff --git a/drivers/isdn/capi/capidrv.c b/drivers/isdn/capi/capidrv.c index 7ac51798949d..ee510f901720 100644 --- a/drivers/isdn/capi/capidrv.c +++ b/drivers/isdn/capi/capidrv.c | |||
| @@ -2268,7 +2268,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) | |||
| 2268 | strcpy(card->name, id); | 2268 | strcpy(card->name, id); |
| 2269 | card->contrnr = contr; | 2269 | card->contrnr = contr; |
| 2270 | card->nbchan = profp->nbchannel; | 2270 | card->nbchan = profp->nbchannel; |
| 2271 | card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC); | 2271 | card->bchans = kmalloc_array(card->nbchan, sizeof(capidrv_bchan), |
| 2272 | GFP_ATOMIC); | ||
| 2272 | if (!card->bchans) { | 2273 | if (!card->bchans) { |
| 2273 | printk(KERN_WARNING | 2274 | printk(KERN_WARNING |
| 2274 | "capidrv: (%s) Could not allocate bchan-structs.\n", id); | 2275 | "capidrv: (%s) Could not allocate bchan-structs.\n", id); |
diff --git a/drivers/isdn/gigaset/capi.c b/drivers/isdn/gigaset/capi.c index 56748af78c04..9cb2ab57fa4a 100644 --- a/drivers/isdn/gigaset/capi.c +++ b/drivers/isdn/gigaset/capi.c | |||
| @@ -252,7 +252,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, | |||
| 252 | return; | 252 | return; |
| 253 | if (l > 64) | 253 | if (l > 64) |
| 254 | l = 64; /* arbitrary limit */ | 254 | l = 64; /* arbitrary limit */ |
| 255 | dbgline = kmalloc(3 * l, GFP_ATOMIC); | 255 | dbgline = kmalloc_array(3, l, GFP_ATOMIC); |
| 256 | if (!dbgline) | 256 | if (!dbgline) |
| 257 | return; | 257 | return; |
| 258 | for (i = 0; i < l; i++) { | 258 | for (i = 0; i < l; i++) { |
| @@ -272,7 +272,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, | |||
| 272 | return; | 272 | return; |
| 273 | if (l > 64) | 273 | if (l > 64) |
| 274 | l = 64; /* arbitrary limit */ | 274 | l = 64; /* arbitrary limit */ |
| 275 | dbgline = kmalloc(3 * l, GFP_ATOMIC); | 275 | dbgline = kmalloc_array(3, l, GFP_ATOMIC); |
| 276 | if (!dbgline) | 276 | if (!dbgline) |
| 277 | return; | 277 | return; |
| 278 | data += CAPIMSG_LEN(data); | 278 | data += CAPIMSG_LEN(data); |
| @@ -1370,7 +1370,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, | |||
| 1370 | cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8; | 1370 | cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8; |
| 1371 | 1371 | ||
| 1372 | /* build command table */ | 1372 | /* build command table */ |
| 1373 | commands = kzalloc(AT_NUM * (sizeof *commands), GFP_KERNEL); | 1373 | commands = kcalloc(AT_NUM, sizeof(*commands), GFP_KERNEL); |
| 1374 | if (!commands) | 1374 | if (!commands) |
| 1375 | goto oom; | 1375 | goto oom; |
| 1376 | 1376 | ||
diff --git a/drivers/isdn/gigaset/common.c b/drivers/isdn/gigaset/common.c index 15482c5de33c..76b5407b5277 100644 --- a/drivers/isdn/gigaset/common.c +++ b/drivers/isdn/gigaset/common.c | |||
| @@ -710,7 +710,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, | |||
| 710 | cs->mode = M_UNKNOWN; | 710 | cs->mode = M_UNKNOWN; |
| 711 | cs->mstate = MS_UNINITIALIZED; | 711 | cs->mstate = MS_UNINITIALIZED; |
| 712 | 712 | ||
| 713 | cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL); | 713 | cs->bcs = kmalloc_array(channels, sizeof(struct bc_state), GFP_KERNEL); |
| 714 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); | 714 | cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL); |
| 715 | if (!cs->bcs || !cs->inbuf) { | 715 | if (!cs->bcs || !cs->inbuf) { |
| 716 | pr_err("out of memory\n"); | 716 | pr_err("out of memory\n"); |
| @@ -1089,7 +1089,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, | |||
| 1089 | drv->owner = owner; | 1089 | drv->owner = owner; |
| 1090 | INIT_LIST_HEAD(&drv->list); | 1090 | INIT_LIST_HEAD(&drv->list); |
| 1091 | 1091 | ||
| 1092 | drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL); | 1092 | drv->cs = kmalloc_array(minors, sizeof(*drv->cs), GFP_KERNEL); |
| 1093 | if (!drv->cs) | 1093 | if (!drv->cs) |
| 1094 | goto error; | 1094 | goto error; |
| 1095 | 1095 | ||
diff --git a/drivers/isdn/gigaset/i4l.c b/drivers/isdn/gigaset/i4l.c index 2d75329007f1..b5b389e95edd 100644 --- a/drivers/isdn/gigaset/i4l.c +++ b/drivers/isdn/gigaset/i4l.c | |||
| @@ -243,7 +243,7 @@ static int command_from_LL(isdn_ctrl *cntrl) | |||
| 243 | dev_kfree_skb(bcs->rx_skb); | 243 | dev_kfree_skb(bcs->rx_skb); |
| 244 | gigaset_new_rx_skb(bcs); | 244 | gigaset_new_rx_skb(bcs); |
| 245 | 245 | ||
| 246 | commands = kzalloc(AT_NUM * (sizeof *commands), GFP_ATOMIC); | 246 | commands = kcalloc(AT_NUM, sizeof(*commands), GFP_ATOMIC); |
| 247 | if (!commands) { | 247 | if (!commands) { |
| 248 | gigaset_free_channel(bcs); | 248 | gigaset_free_channel(bcs); |
| 249 | dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n"); | 249 | dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n"); |
diff --git a/drivers/isdn/hardware/avm/b1.c b/drivers/isdn/hardware/avm/b1.c index 5ee5489d3f15..4ac378e48902 100644 --- a/drivers/isdn/hardware/avm/b1.c +++ b/drivers/isdn/hardware/avm/b1.c | |||
| @@ -72,7 +72,7 @@ avmcard *b1_alloc_card(int nr_controllers) | |||
| 72 | if (!card) | 72 | if (!card) |
| 73 | return NULL; | 73 | return NULL; |
| 74 | 74 | ||
| 75 | cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL); | 75 | cinfo = kcalloc(nr_controllers, sizeof(*cinfo), GFP_KERNEL); |
| 76 | if (!cinfo) { | 76 | if (!cinfo) { |
| 77 | kfree(card); | 77 | kfree(card); |
| 78 | return NULL; | 78 | return NULL; |
diff --git a/drivers/isdn/hisax/fsm.c b/drivers/isdn/hisax/fsm.c index 3e020ec0f65e..80ba82f77c63 100644 --- a/drivers/isdn/hisax/fsm.c +++ b/drivers/isdn/hisax/fsm.c | |||
| @@ -27,7 +27,9 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount) | |||
| 27 | int i; | 27 | int i; |
| 28 | 28 | ||
| 29 | fsm->jumpmatrix = | 29 | fsm->jumpmatrix = |
| 30 | kzalloc(sizeof(FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL); | 30 | kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count, |
| 31 | fsm->event_count), | ||
| 32 | GFP_KERNEL); | ||
| 31 | if (!fsm->jumpmatrix) | 33 | if (!fsm->jumpmatrix) |
| 32 | return -ENOMEM; | 34 | return -ENOMEM; |
| 33 | 35 | ||
diff --git a/drivers/isdn/hisax/hfc_2bds0.c b/drivers/isdn/hisax/hfc_2bds0.c index 86b82172e992..3715fa0343db 100644 --- a/drivers/isdn/hisax/hfc_2bds0.c +++ b/drivers/isdn/hisax/hfc_2bds0.c | |||
| @@ -1024,7 +1024,7 @@ static unsigned int | |||
| 1024 | int i; | 1024 | int i; |
| 1025 | unsigned *send; | 1025 | unsigned *send; |
| 1026 | 1026 | ||
| 1027 | if (!(send = kmalloc(cnt * sizeof(unsigned int), GFP_ATOMIC))) { | 1027 | if (!(send = kmalloc_array(cnt, sizeof(unsigned int), GFP_ATOMIC))) { |
| 1028 | printk(KERN_WARNING | 1028 | printk(KERN_WARNING |
| 1029 | "HiSax: No memory for hfcd.send\n"); | 1029 | "HiSax: No memory for hfcd.send\n"); |
| 1030 | return (NULL); | 1030 | return (NULL); |
diff --git a/drivers/isdn/hisax/hfc_2bs0.c b/drivers/isdn/hisax/hfc_2bs0.c index 14dada42874e..34d59992839a 100644 --- a/drivers/isdn/hisax/hfc_2bs0.c +++ b/drivers/isdn/hisax/hfc_2bs0.c | |||
| @@ -557,7 +557,8 @@ init_send(struct BCState *bcs) | |||
| 557 | { | 557 | { |
| 558 | int i; | 558 | int i; |
| 559 | 559 | ||
| 560 | if (!(bcs->hw.hfc.send = kmalloc(32 * sizeof(unsigned int), GFP_ATOMIC))) { | 560 | bcs->hw.hfc.send = kmalloc_array(32, sizeof(unsigned int), GFP_ATOMIC); |
| 561 | if (!bcs->hw.hfc.send) { | ||
| 561 | printk(KERN_WARNING | 562 | printk(KERN_WARNING |
| 562 | "HiSax: No memory for hfc.send\n"); | 563 | "HiSax: No memory for hfc.send\n"); |
| 563 | return; | 564 | return; |
diff --git a/drivers/isdn/hisax/netjet.c b/drivers/isdn/hisax/netjet.c index b7f54fa29228..e932a152c405 100644 --- a/drivers/isdn/hisax/netjet.c +++ b/drivers/isdn/hisax/netjet.c | |||
| @@ -912,8 +912,10 @@ setstack_tiger(struct PStack *st, struct BCState *bcs) | |||
| 912 | void | 912 | void |
| 913 | inittiger(struct IsdnCardState *cs) | 913 | inittiger(struct IsdnCardState *cs) |
| 914 | { | 914 | { |
| 915 | if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int), | 915 | cs->bcs[0].hw.tiger.send = kmalloc_array(NETJET_DMA_TXSIZE, |
| 916 | GFP_KERNEL | GFP_DMA))) { | 916 | sizeof(unsigned int), |
| 917 | GFP_KERNEL | GFP_DMA); | ||
| 918 | if (!cs->bcs[0].hw.tiger.send) { | ||
| 917 | printk(KERN_WARNING | 919 | printk(KERN_WARNING |
| 918 | "HiSax: No memory for tiger.send\n"); | 920 | "HiSax: No memory for tiger.send\n"); |
| 919 | return; | 921 | return; |
| @@ -933,8 +935,10 @@ inittiger(struct IsdnCardState *cs) | |||
| 933 | cs->hw.njet.base + NETJET_DMA_READ_IRQ); | 935 | cs->hw.njet.base + NETJET_DMA_READ_IRQ); |
| 934 | outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end), | 936 | outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end), |
| 935 | cs->hw.njet.base + NETJET_DMA_READ_END); | 937 | cs->hw.njet.base + NETJET_DMA_READ_END); |
| 936 | if (!(cs->bcs[0].hw.tiger.rec = kmalloc(NETJET_DMA_RXSIZE * sizeof(unsigned int), | 938 | cs->bcs[0].hw.tiger.rec = kmalloc_array(NETJET_DMA_RXSIZE, |
| 937 | GFP_KERNEL | GFP_DMA))) { | 939 | sizeof(unsigned int), |
| 940 | GFP_KERNEL | GFP_DMA); | ||
| 941 | if (!cs->bcs[0].hw.tiger.rec) { | ||
| 938 | printk(KERN_WARNING | 942 | printk(KERN_WARNING |
| 939 | "HiSax: No memory for tiger.rec\n"); | 943 | "HiSax: No memory for tiger.rec\n"); |
| 940 | return; | 944 | return; |
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c index 99012c047751..7f28b967ed19 100644 --- a/drivers/isdn/i4l/isdn_bsdcomp.c +++ b/drivers/isdn/i4l/isdn_bsdcomp.c | |||
| @@ -340,7 +340,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data) | |||
| 340 | * Allocate space for the dictionary. This may be more than one page in | 340 | * Allocate space for the dictionary. This may be more than one page in |
| 341 | * length. | 341 | * length. |
| 342 | */ | 342 | */ |
| 343 | db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); | 343 | db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict))); |
| 344 | if (!db->dict) { | 344 | if (!db->dict) { |
| 345 | bsd_free(db); | 345 | bsd_free(db); |
| 346 | return NULL; | 346 | return NULL; |
| @@ -353,7 +353,8 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data) | |||
| 353 | if (!decomp) | 353 | if (!decomp) |
| 354 | db->lens = NULL; | 354 | db->lens = NULL; |
| 355 | else { | 355 | else { |
| 356 | db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); | 356 | db->lens = vmalloc(array_size(sizeof(db->lens[0]), |
| 357 | maxmaxcode + 1)); | ||
| 357 | if (!db->lens) { | 358 | if (!db->lens) { |
| 358 | bsd_free(db); | 359 | bsd_free(db); |
| 359 | return (NULL); | 360 | return (NULL); |
diff --git a/drivers/isdn/i4l/isdn_common.c b/drivers/isdn/i4l/isdn_common.c index 7c6f3f5d9d9a..7a501dbe7123 100644 --- a/drivers/isdn/i4l/isdn_common.c +++ b/drivers/isdn/i4l/isdn_common.c | |||
| @@ -2070,14 +2070,14 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) | |||
| 2070 | 2070 | ||
| 2071 | if ((adding) && (d->rcverr)) | 2071 | if ((adding) && (d->rcverr)) |
| 2072 | kfree(d->rcverr); | 2072 | kfree(d->rcverr); |
| 2073 | if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) { | 2073 | if (!(d->rcverr = kcalloc(m, sizeof(int), GFP_ATOMIC))) { |
| 2074 | printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n"); | 2074 | printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n"); |
| 2075 | return -1; | 2075 | return -1; |
| 2076 | } | 2076 | } |
| 2077 | 2077 | ||
| 2078 | if ((adding) && (d->rcvcount)) | 2078 | if ((adding) && (d->rcvcount)) |
| 2079 | kfree(d->rcvcount); | 2079 | kfree(d->rcvcount); |
| 2080 | if (!(d->rcvcount = kzalloc(sizeof(int) * m, GFP_ATOMIC))) { | 2080 | if (!(d->rcvcount = kcalloc(m, sizeof(int), GFP_ATOMIC))) { |
| 2081 | printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); | 2081 | printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n"); |
| 2082 | if (!adding) | 2082 | if (!adding) |
| 2083 | kfree(d->rcverr); | 2083 | kfree(d->rcverr); |
| @@ -2089,7 +2089,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) | |||
| 2089 | skb_queue_purge(&d->rpqueue[j]); | 2089 | skb_queue_purge(&d->rpqueue[j]); |
| 2090 | kfree(d->rpqueue); | 2090 | kfree(d->rpqueue); |
| 2091 | } | 2091 | } |
| 2092 | if (!(d->rpqueue = kmalloc(sizeof(struct sk_buff_head) * m, GFP_ATOMIC))) { | 2092 | d->rpqueue = kmalloc_array(m, sizeof(struct sk_buff_head), GFP_ATOMIC); |
| 2093 | if (!d->rpqueue) { | ||
| 2093 | printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n"); | 2094 | printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n"); |
| 2094 | if (!adding) { | 2095 | if (!adding) { |
| 2095 | kfree(d->rcvcount); | 2096 | kfree(d->rcvcount); |
| @@ -2103,7 +2104,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) | |||
| 2103 | 2104 | ||
| 2104 | if ((adding) && (d->rcv_waitq)) | 2105 | if ((adding) && (d->rcv_waitq)) |
| 2105 | kfree(d->rcv_waitq); | 2106 | kfree(d->rcv_waitq); |
| 2106 | d->rcv_waitq = kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_ATOMIC); | 2107 | d->rcv_waitq = kmalloc(array3_size(sizeof(wait_queue_head_t), 2, m), |
| 2108 | GFP_ATOMIC); | ||
| 2107 | if (!d->rcv_waitq) { | 2109 | if (!d->rcv_waitq) { |
| 2108 | printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n"); | 2110 | printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n"); |
| 2109 | if (!adding) { | 2111 | if (!adding) { |
diff --git a/drivers/isdn/mISDN/fsm.c b/drivers/isdn/mISDN/fsm.c index cabcb906e0b5..9a8d08d677a4 100644 --- a/drivers/isdn/mISDN/fsm.c +++ b/drivers/isdn/mISDN/fsm.c | |||
| @@ -32,8 +32,10 @@ mISDN_FsmNew(struct Fsm *fsm, | |||
| 32 | { | 32 | { |
| 33 | int i; | 33 | int i; |
| 34 | 34 | ||
| 35 | fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count * | 35 | fsm->jumpmatrix = |
| 36 | fsm->event_count, GFP_KERNEL); | 36 | kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count, |
| 37 | fsm->event_count), | ||
| 38 | GFP_KERNEL); | ||
| 37 | if (fsm->jumpmatrix == NULL) | 39 | if (fsm->jumpmatrix == NULL) |
| 38 | return -ENOMEM; | 40 | return -ENOMEM; |
| 39 | 41 | ||
diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c index 853b2d3bdb17..7ecf080f73ad 100644 --- a/drivers/leds/leds-adp5520.c +++ b/drivers/leds/leds-adp5520.c | |||
| @@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev) | |||
| 108 | return -EFAULT; | 108 | return -EFAULT; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds, | 111 | led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led), |
| 112 | GFP_KERNEL); | 112 | GFP_KERNEL); |
| 113 | if (!led) | 113 | if (!led) |
| 114 | return -ENOMEM; | 114 | return -ENOMEM; |
diff --git a/drivers/leds/leds-apu.c b/drivers/leds/leds-apu.c index 90eeedcbf371..8c93d68964c7 100644 --- a/drivers/leds/leds-apu.c +++ b/drivers/leds/leds-apu.c | |||
| @@ -171,8 +171,8 @@ static int apu_led_config(struct device *dev, struct apu_led_pdata *apuld) | |||
| 171 | int i; | 171 | int i; |
| 172 | int err; | 172 | int err; |
| 173 | 173 | ||
| 174 | apu_led->pled = devm_kzalloc(dev, | 174 | apu_led->pled = devm_kcalloc(dev, |
| 175 | sizeof(struct apu_led_priv) * apu_led->num_led_instances, | 175 | apu_led->num_led_instances, sizeof(struct apu_led_priv), |
| 176 | GFP_KERNEL); | 176 | GFP_KERNEL); |
| 177 | 177 | ||
| 178 | if (!apu_led->pled) | 178 | if (!apu_led->pled) |
diff --git a/drivers/leds/leds-cr0014114.c b/drivers/leds/leds-cr0014114.c index a4b1c1dcce7f..0e4262462cb9 100644 --- a/drivers/leds/leds-cr0014114.c +++ b/drivers/leds/leds-cr0014114.c | |||
| @@ -237,8 +237,7 @@ static int cr0014114_probe(struct spi_device *spi) | |||
| 237 | return -ENODEV; | 237 | return -ENODEV; |
| 238 | } | 238 | } |
| 239 | 239 | ||
| 240 | priv = devm_kzalloc(&spi->dev, | 240 | priv = devm_kzalloc(&spi->dev, struct_size(priv, leds, count), |
| 241 | sizeof(*priv) + sizeof(*priv->leds) * count, | ||
| 242 | GFP_KERNEL); | 241 | GFP_KERNEL); |
| 243 | if (!priv) | 242 | if (!priv) |
| 244 | return -ENOMEM; | 243 | return -ENOMEM; |
diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c index f8c7d82c2652..31d4c94e6fd8 100644 --- a/drivers/leds/leds-da9052.c +++ b/drivers/leds/leds-da9052.c | |||
| @@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev) | |||
| 113 | goto err; | 113 | goto err; |
| 114 | } | 114 | } |
| 115 | 115 | ||
| 116 | led = devm_kzalloc(&pdev->dev, | 116 | led = devm_kcalloc(&pdev->dev, |
| 117 | sizeof(struct da9052_led) * pled->num_leds, | 117 | pled->num_leds, sizeof(struct da9052_led), |
| 118 | GFP_KERNEL); | 118 | GFP_KERNEL); |
| 119 | if (!led) { | 119 | if (!led) { |
| 120 | error = -ENOMEM; | 120 | error = -ENOMEM; |
diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 55c0517fbe03..99689b51a73d 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c | |||
| @@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client, | |||
| 533 | if (!chip) | 533 | if (!chip) |
| 534 | return -ENOMEM; | 534 | return -ENOMEM; |
| 535 | 535 | ||
| 536 | led = devm_kzalloc(&client->dev, | 536 | led = devm_kcalloc(&client->dev, |
| 537 | sizeof(*led) * pdata->num_channels, GFP_KERNEL); | 537 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
| 538 | if (!led) | 538 | if (!led) |
| 539 | return -ENOMEM; | 539 | return -ENOMEM; |
| 540 | 540 | ||
diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 52b6f529e278..a2e74feee2b2 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c | |||
| @@ -898,8 +898,8 @@ static int lp5523_probe(struct i2c_client *client, | |||
| 898 | if (!chip) | 898 | if (!chip) |
| 899 | return -ENOMEM; | 899 | return -ENOMEM; |
| 900 | 900 | ||
| 901 | led = devm_kzalloc(&client->dev, | 901 | led = devm_kcalloc(&client->dev, |
| 902 | sizeof(*led) * pdata->num_channels, GFP_KERNEL); | 902 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
| 903 | if (!led) | 903 | if (!led) |
| 904 | return -ENOMEM; | 904 | return -ENOMEM; |
| 905 | 905 | ||
diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c index 05ffa34fb6ad..2a9009fe5545 100644 --- a/drivers/leds/leds-lp5562.c +++ b/drivers/leds/leds-lp5562.c | |||
| @@ -534,8 +534,8 @@ static int lp5562_probe(struct i2c_client *client, | |||
| 534 | if (!chip) | 534 | if (!chip) |
| 535 | return -ENOMEM; | 535 | return -ENOMEM; |
| 536 | 536 | ||
| 537 | led = devm_kzalloc(&client->dev, | 537 | led = devm_kcalloc(&client->dev, |
| 538 | sizeof(*led) * pdata->num_channels, GFP_KERNEL); | 538 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
| 539 | if (!led) | 539 | if (!led) |
| 540 | return -ENOMEM; | 540 | return -ENOMEM; |
| 541 | 541 | ||
diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index 5377f22ff994..3d79a6380761 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c | |||
| @@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, | |||
| 560 | return ERR_PTR(-EINVAL); | 560 | return ERR_PTR(-EINVAL); |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL); | 563 | cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL); |
| 564 | if (!cfg) | 564 | if (!cfg) |
| 565 | return ERR_PTR(-ENOMEM); | 565 | return ERR_PTR(-ENOMEM); |
| 566 | 566 | ||
diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c index 3adb113cf02e..4c800b5989a9 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c | |||
| @@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client, | |||
| 327 | if (!chip) | 327 | if (!chip) |
| 328 | return -ENOMEM; | 328 | return -ENOMEM; |
| 329 | 329 | ||
| 330 | led = devm_kzalloc(&client->dev, | 330 | led = devm_kcalloc(&client->dev, |
| 331 | sizeof(*led) * pdata->num_channels, GFP_KERNEL); | 331 | pdata->num_channels, sizeof(*led), GFP_KERNEL); |
| 332 | if (!led) | 332 | if (!led) |
| 333 | return -ENOMEM; | 333 | return -ENOMEM; |
| 334 | 334 | ||
diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index a7ff510cbdd0..5ec730a31b65 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c | |||
| @@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev) | |||
| 128 | if (!pdata) | 128 | if (!pdata) |
| 129 | return -EBUSY; | 129 | return -EBUSY; |
| 130 | 130 | ||
| 131 | leds_data = devm_kzalloc(&pdev->dev, | 131 | leds_data = devm_kcalloc(&pdev->dev, |
| 132 | sizeof(struct lt3593_led_data) * pdata->num_leds, | 132 | pdata->num_leds, sizeof(struct lt3593_led_data), |
| 133 | GFP_KERNEL); | 133 | GFP_KERNEL); |
| 134 | if (!leds_data) | 134 | if (!leds_data) |
| 135 | return -ENOMEM; | 135 | return -ENOMEM; |
diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index 2421cf104991..47ad7de9553c 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c | |||
| @@ -136,7 +136,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( | |||
| 136 | 136 | ||
| 137 | pdata->num_leds = of_get_child_count(parent); | 137 | pdata->num_leds = of_get_child_count(parent); |
| 138 | 138 | ||
| 139 | pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led), | 139 | pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), |
| 140 | GFP_KERNEL); | 140 | GFP_KERNEL); |
| 141 | if (!pdata->led) { | 141 | if (!pdata->led) { |
| 142 | ret = -ENOMEM; | 142 | ret = -ENOMEM; |
| @@ -210,7 +210,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) | |||
| 210 | return -EINVAL; | 210 | return -EINVAL; |
| 211 | } | 211 | } |
| 212 | 212 | ||
| 213 | leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led), | 213 | leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led), |
| 214 | GFP_KERNEL); | 214 | GFP_KERNEL); |
| 215 | if (!leds->led) | 215 | if (!leds->led) |
| 216 | return -ENOMEM; | 216 | return -ENOMEM; |
diff --git a/drivers/leds/leds-mlxcpld.c b/drivers/leds/leds-mlxcpld.c index 281482e1d50f..f4721f8065f0 100644 --- a/drivers/leds/leds-mlxcpld.c +++ b/drivers/leds/leds-mlxcpld.c | |||
| @@ -329,8 +329,10 @@ static int mlxcpld_led_config(struct device *dev, | |||
| 329 | int i; | 329 | int i; |
| 330 | int err; | 330 | int err; |
| 331 | 331 | ||
| 332 | cpld->pled = devm_kzalloc(dev, sizeof(struct mlxcpld_led_priv) * | 332 | cpld->pled = devm_kcalloc(dev, |
| 333 | cpld->num_led_instances, GFP_KERNEL); | 333 | cpld->num_led_instances, |
| 334 | sizeof(struct mlxcpld_led_priv), | ||
| 335 | GFP_KERNEL); | ||
| 334 | if (!cpld->pled) | 336 | if (!cpld->pled) |
| 335 | return -ENOMEM; | 337 | return -ENOMEM; |
| 336 | 338 | ||
diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index f48b1aed9b4e..62fa0de526ee 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c | |||
| @@ -335,7 +335,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, | |||
| 335 | return ret; | 335 | return ret; |
| 336 | } | 336 | } |
| 337 | num_addr = ret; | 337 | num_addr = ret; |
| 338 | addr = devm_kzalloc(dev, num_addr * sizeof(*addr), GFP_KERNEL); | 338 | addr = devm_kcalloc(dev, num_addr, sizeof(*addr), GFP_KERNEL); |
| 339 | if (!addr) | 339 | if (!addr) |
| 340 | return -ENOMEM; | 340 | return -ENOMEM; |
| 341 | 341 | ||
| @@ -355,7 +355,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, | |||
| 355 | return ret; | 355 | return ret; |
| 356 | } | 356 | } |
| 357 | num_data = ret; | 357 | num_data = ret; |
| 358 | data = devm_kzalloc(dev, num_data * sizeof(*data), GFP_KERNEL); | 358 | data = devm_kcalloc(dev, num_data, sizeof(*data), GFP_KERNEL); |
| 359 | if (!data) | 359 | if (!data) |
| 360 | return -ENOMEM; | 360 | return -ENOMEM; |
| 361 | 361 | ||
| @@ -415,7 +415,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, | |||
| 415 | if (ret % 3) | 415 | if (ret % 3) |
| 416 | return -EINVAL; | 416 | return -EINVAL; |
| 417 | num_timers = ret / 3; | 417 | num_timers = ret / 3; |
| 418 | timers = devm_kzalloc(dev, num_timers * sizeof(*timers), | 418 | timers = devm_kcalloc(dev, num_timers, sizeof(*timers), |
| 419 | GFP_KERNEL); | 419 | GFP_KERNEL); |
| 420 | if (!timers) | 420 | if (!timers) |
| 421 | return -ENOMEM; | 421 | return -ENOMEM; |
| @@ -444,7 +444,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, | |||
| 444 | return -ENODEV; | 444 | return -ENODEV; |
| 445 | } | 445 | } |
| 446 | 446 | ||
| 447 | leds = devm_kzalloc(dev, num_leds * sizeof(*leds), GFP_KERNEL); | 447 | leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL); |
| 448 | if (!leds) | 448 | if (!leds) |
| 449 | return -ENOMEM; | 449 | return -ENOMEM; |
| 450 | 450 | ||
| @@ -470,8 +470,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev, | |||
| 470 | goto err_node_put; | 470 | goto err_node_put; |
| 471 | 471 | ||
| 472 | mode_val = | 472 | mode_val = |
| 473 | devm_kzalloc(dev, | 473 | devm_kcalloc(dev, |
| 474 | NETXBIG_LED_MODE_NUM * sizeof(*mode_val), | 474 | NETXBIG_LED_MODE_NUM, sizeof(*mode_val), |
| 475 | GFP_KERNEL); | 475 | GFP_KERNEL); |
| 476 | if (!mode_val) { | 476 | if (!mode_val) { |
| 477 | ret = -ENOMEM; | 477 | ret = -ENOMEM; |
| @@ -560,8 +560,8 @@ static int netxbig_led_probe(struct platform_device *pdev) | |||
| 560 | return ret; | 560 | return ret; |
| 561 | } | 561 | } |
| 562 | 562 | ||
| 563 | leds_data = devm_kzalloc(&pdev->dev, | 563 | leds_data = devm_kcalloc(&pdev->dev, |
| 564 | pdata->num_leds * sizeof(*leds_data), | 564 | pdata->num_leds, sizeof(*leds_data), |
| 565 | GFP_KERNEL); | 565 | GFP_KERNEL); |
| 566 | if (!leds_data) | 566 | if (!leds_data) |
| 567 | return -ENOMEM; | 567 | return -ENOMEM; |
diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 506b75b190e7..14fe5cd43232 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c | |||
| @@ -264,7 +264,7 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) | |||
| 264 | if (!num_leds) | 264 | if (!num_leds) |
| 265 | return -ENODEV; | 265 | return -ENODEV; |
| 266 | 266 | ||
| 267 | leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led), | 267 | leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led), |
| 268 | GFP_KERNEL); | 268 | GFP_KERNEL); |
| 269 | if (!leds) | 269 | if (!leds) |
| 270 | return -ENOMEM; | 270 | return -ENOMEM; |
| @@ -298,8 +298,9 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) | |||
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | num_modes = ret / 3; | 300 | num_modes = ret / 3; |
| 301 | modval = devm_kzalloc(dev, | 301 | modval = devm_kcalloc(dev, |
| 302 | num_modes * sizeof(struct ns2_led_modval), | 302 | num_modes, |
| 303 | sizeof(struct ns2_led_modval), | ||
| 303 | GFP_KERNEL); | 304 | GFP_KERNEL); |
| 304 | if (!modval) | 305 | if (!modval) |
| 305 | return -ENOMEM; | 306 | return -ENOMEM; |
diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 78183f90820e..f51b356d4426 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c | |||
| @@ -390,8 +390,8 @@ pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip) | |||
| 390 | if (!pdata) | 390 | if (!pdata) |
| 391 | return ERR_PTR(-ENOMEM); | 391 | return ERR_PTR(-ENOMEM); |
| 392 | 392 | ||
| 393 | pdata->leds = devm_kzalloc(&client->dev, | 393 | pdata->leds = devm_kcalloc(&client->dev, |
| 394 | sizeof(struct pca955x_led) * chip->bits, | 394 | chip->bits, sizeof(struct pca955x_led), |
| 395 | GFP_KERNEL); | 395 | GFP_KERNEL); |
| 396 | if (!pdata->leds) | 396 | if (!pdata->leds) |
| 397 | return ERR_PTR(-ENOMEM); | 397 | return ERR_PTR(-ENOMEM); |
| @@ -494,8 +494,8 @@ static int pca955x_probe(struct i2c_client *client, | |||
| 494 | if (!pca955x) | 494 | if (!pca955x) |
| 495 | return -ENOMEM; | 495 | return -ENOMEM; |
| 496 | 496 | ||
| 497 | pca955x->leds = devm_kzalloc(&client->dev, | 497 | pca955x->leds = devm_kcalloc(&client->dev, |
| 498 | sizeof(*pca955x_led) * chip->bits, GFP_KERNEL); | 498 | chip->bits, sizeof(*pca955x_led), GFP_KERNEL); |
| 499 | if (!pca955x->leds) | 499 | if (!pca955x->leds) |
| 500 | return -ENOMEM; | 500 | return -ENOMEM; |
| 501 | 501 | ||
diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 3bf9a1271819..5c0908113e38 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c | |||
| @@ -300,8 +300,8 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) | |||
| 300 | if (!count || count > chip->n_leds) | 300 | if (!count || count > chip->n_leds) |
| 301 | return ERR_PTR(-ENODEV); | 301 | return ERR_PTR(-ENODEV); |
| 302 | 302 | ||
| 303 | pca963x_leds = devm_kzalloc(&client->dev, | 303 | pca963x_leds = devm_kcalloc(&client->dev, |
| 304 | sizeof(struct led_info) * chip->n_leds, GFP_KERNEL); | 304 | chip->n_leds, sizeof(struct led_info), GFP_KERNEL); |
| 305 | if (!pca963x_leds) | 305 | if (!pca963x_leds) |
| 306 | return ERR_PTR(-ENOMEM); | 306 | return ERR_PTR(-ENOMEM); |
| 307 | 307 | ||
| @@ -407,7 +407,7 @@ static int pca963x_probe(struct i2c_client *client, | |||
| 407 | GFP_KERNEL); | 407 | GFP_KERNEL); |
| 408 | if (!pca963x_chip) | 408 | if (!pca963x_chip) |
| 409 | return -ENOMEM; | 409 | return -ENOMEM; |
| 410 | pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x), | 410 | pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x), |
| 411 | GFP_KERNEL); | 411 | GFP_KERNEL); |
| 412 | if (!pca963x) | 412 | if (!pca963x) |
| 413 | return -ENOMEM; | 413 | return -ENOMEM; |
diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index c12c16fb1b9c..8f343afa4787 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c | |||
| @@ -697,8 +697,8 @@ tca6507_led_dt_init(struct i2c_client *client) | |||
| 697 | if (!count || count > NUM_LEDS) | 697 | if (!count || count > NUM_LEDS) |
| 698 | return ERR_PTR(-ENODEV); | 698 | return ERR_PTR(-ENODEV); |
| 699 | 699 | ||
| 700 | tca_leds = devm_kzalloc(&client->dev, | 700 | tca_leds = devm_kcalloc(&client->dev, |
| 701 | sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL); | 701 | NUM_LEDS, sizeof(struct led_info), GFP_KERNEL); |
| 702 | if (!tca_leds) | 702 | if (!tca_leds) |
| 703 | return ERR_PTR(-ENOMEM); | 703 | return ERR_PTR(-ENOMEM); |
| 704 | 704 | ||
diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c index 6a4883e40cc0..080469d90b40 100644 --- a/drivers/lightnvm/pblk-gc.c +++ b/drivers/lightnvm/pblk-gc.c | |||
| @@ -88,7 +88,7 @@ static void pblk_gc_line_ws(struct work_struct *work) | |||
| 88 | 88 | ||
| 89 | up(&gc->gc_sem); | 89 | up(&gc->gc_sem); |
| 90 | 90 | ||
| 91 | gc_rq->data = vmalloc(gc_rq->nr_secs * geo->csecs); | 91 | gc_rq->data = vmalloc(array_size(gc_rq->nr_secs, geo->csecs)); |
| 92 | if (!gc_rq->data) { | 92 | if (!gc_rq->data) { |
| 93 | pr_err("pblk: could not GC line:%d (%d/%d)\n", | 93 | pr_err("pblk: could not GC line:%d (%d/%d)\n", |
| 94 | line->id, *line->vsc, gc_rq->nr_secs); | 94 | line->id, *line->vsc, gc_rq->nr_secs); |
diff --git a/drivers/lightnvm/pblk-init.c b/drivers/lightnvm/pblk-init.c index 491df0fa0835..b57f764d6a16 100644 --- a/drivers/lightnvm/pblk-init.c +++ b/drivers/lightnvm/pblk-init.c | |||
| @@ -187,7 +187,7 @@ static int pblk_rwb_init(struct pblk *pblk) | |||
| 187 | 187 | ||
| 188 | nr_entries = pblk_rb_calculate_size(buffer_size); | 188 | nr_entries = pblk_rb_calculate_size(buffer_size); |
| 189 | 189 | ||
| 190 | entries = vzalloc(nr_entries * sizeof(struct pblk_rb_entry)); | 190 | entries = vzalloc(array_size(nr_entries, sizeof(struct pblk_rb_entry))); |
| 191 | if (!entries) | 191 | if (!entries) |
| 192 | return -ENOMEM; | 192 | return -ENOMEM; |
| 193 | 193 | ||
| @@ -379,7 +379,7 @@ static int pblk_core_init(struct pblk *pblk) | |||
| 379 | return -EINVAL; | 379 | return -EINVAL; |
| 380 | } | 380 | } |
| 381 | 381 | ||
| 382 | pblk->pad_dist = kzalloc((pblk->min_write_pgs - 1) * sizeof(atomic64_t), | 382 | pblk->pad_dist = kcalloc(pblk->min_write_pgs - 1, sizeof(atomic64_t), |
| 383 | GFP_KERNEL); | 383 | GFP_KERNEL); |
| 384 | if (!pblk->pad_dist) | 384 | if (!pblk->pad_dist) |
| 385 | return -ENOMEM; | 385 | return -ENOMEM; |
| @@ -833,8 +833,8 @@ static int pblk_alloc_line_meta(struct pblk *pblk, struct pblk_line *line) | |||
| 833 | goto free_blk_bitmap; | 833 | goto free_blk_bitmap; |
| 834 | 834 | ||
| 835 | 835 | ||
| 836 | line->chks = kmalloc(lm->blk_per_line * sizeof(struct nvm_chk_meta), | 836 | line->chks = kmalloc_array(lm->blk_per_line, |
| 837 | GFP_KERNEL); | 837 | sizeof(struct nvm_chk_meta), GFP_KERNEL); |
| 838 | if (!line->chks) | 838 | if (!line->chks) |
| 839 | goto free_erase_bitmap; | 839 | goto free_erase_bitmap; |
| 840 | 840 | ||
diff --git a/drivers/lightnvm/pblk-recovery.c b/drivers/lightnvm/pblk-recovery.c index 598342833d0d..3a5069183859 100644 --- a/drivers/lightnvm/pblk-recovery.c +++ b/drivers/lightnvm/pblk-recovery.c | |||
| @@ -260,7 +260,7 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line, | |||
| 260 | if (!pad_rq) | 260 | if (!pad_rq) |
| 261 | return -ENOMEM; | 261 | return -ENOMEM; |
| 262 | 262 | ||
| 263 | data = vzalloc(pblk->max_write_pgs * geo->csecs); | 263 | data = vzalloc(array_size(pblk->max_write_pgs, geo->csecs)); |
| 264 | if (!data) { | 264 | if (!data) { |
| 265 | ret = -ENOMEM; | 265 | ret = -ENOMEM; |
| 266 | goto free_rq; | 266 | goto free_rq; |
diff --git a/drivers/mailbox/hi6220-mailbox.c b/drivers/mailbox/hi6220-mailbox.c index 519376d3534c..4fa9803cd204 100644 --- a/drivers/mailbox/hi6220-mailbox.c +++ b/drivers/mailbox/hi6220-mailbox.c | |||
| @@ -282,13 +282,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev) | |||
| 282 | 282 | ||
| 283 | mbox->dev = dev; | 283 | mbox->dev = dev; |
| 284 | mbox->chan_num = MBOX_CHAN_MAX; | 284 | mbox->chan_num = MBOX_CHAN_MAX; |
| 285 | mbox->mchan = devm_kzalloc(dev, | 285 | mbox->mchan = devm_kcalloc(dev, |
| 286 | mbox->chan_num * sizeof(*mbox->mchan), GFP_KERNEL); | 286 | mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL); |
| 287 | if (!mbox->mchan) | 287 | if (!mbox->mchan) |
| 288 | return -ENOMEM; | 288 | return -ENOMEM; |
| 289 | 289 | ||
| 290 | mbox->chan = devm_kzalloc(dev, | 290 | mbox->chan = devm_kcalloc(dev, |
| 291 | mbox->chan_num * sizeof(*mbox->chan), GFP_KERNEL); | 291 | mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL); |
| 292 | if (!mbox->chan) | 292 | if (!mbox->chan) |
| 293 | return -ENOMEM; | 293 | return -ENOMEM; |
| 294 | 294 | ||
diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c index 41bcd339b68a..779d41262ef0 100644 --- a/drivers/mailbox/mailbox-sti.c +++ b/drivers/mailbox/mailbox-sti.c | |||
| @@ -442,8 +442,8 @@ static int sti_mbox_probe(struct platform_device *pdev) | |||
| 442 | if (!mbox) | 442 | if (!mbox) |
| 443 | return -ENOMEM; | 443 | return -ENOMEM; |
| 444 | 444 | ||
| 445 | chans = devm_kzalloc(&pdev->dev, | 445 | chans = devm_kcalloc(&pdev->dev, |
| 446 | sizeof(*chans) * STI_MBOX_CHAN_MAX, GFP_KERNEL); | 446 | STI_MBOX_CHAN_MAX, sizeof(*chans), GFP_KERNEL); |
| 447 | if (!chans) | 447 | if (!chans) |
| 448 | return -ENOMEM; | 448 | return -ENOMEM; |
| 449 | 449 | ||
diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index 2517038a8452..e1e2c085e68e 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c | |||
| @@ -729,7 +729,7 @@ static int omap_mbox_probe(struct platform_device *pdev) | |||
| 729 | return -ENODEV; | 729 | return -ENODEV; |
| 730 | } | 730 | } |
| 731 | 731 | ||
| 732 | finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk), | 732 | finfoblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*finfoblk), |
| 733 | GFP_KERNEL); | 733 | GFP_KERNEL); |
| 734 | if (!finfoblk) | 734 | if (!finfoblk) |
| 735 | return -ENOMEM; | 735 | return -ENOMEM; |
| @@ -773,23 +773,23 @@ static int omap_mbox_probe(struct platform_device *pdev) | |||
| 773 | if (IS_ERR(mdev->mbox_base)) | 773 | if (IS_ERR(mdev->mbox_base)) |
| 774 | return PTR_ERR(mdev->mbox_base); | 774 | return PTR_ERR(mdev->mbox_base); |
| 775 | 775 | ||
| 776 | mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32), | 776 | mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32), |
| 777 | GFP_KERNEL); | 777 | GFP_KERNEL); |
| 778 | if (!mdev->irq_ctx) | 778 | if (!mdev->irq_ctx) |
| 779 | return -ENOMEM; | 779 | return -ENOMEM; |
| 780 | 780 | ||
| 781 | /* allocate one extra for marking end of list */ | 781 | /* allocate one extra for marking end of list */ |
| 782 | list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list), | 782 | list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list), |
| 783 | GFP_KERNEL); | 783 | GFP_KERNEL); |
| 784 | if (!list) | 784 | if (!list) |
| 785 | return -ENOMEM; | 785 | return -ENOMEM; |
| 786 | 786 | ||
| 787 | chnls = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*chnls), | 787 | chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls), |
| 788 | GFP_KERNEL); | 788 | GFP_KERNEL); |
| 789 | if (!chnls) | 789 | if (!chnls) |
| 790 | return -ENOMEM; | 790 | return -ENOMEM; |
| 791 | 791 | ||
| 792 | mboxblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*mbox), | 792 | mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox), |
| 793 | GFP_KERNEL); | 793 | GFP_KERNEL); |
| 794 | if (!mboxblk) | 794 | if (!mboxblk) |
| 795 | return -ENOMEM; | 795 | return -ENOMEM; |
diff --git a/drivers/mailbox/pcc.c b/drivers/mailbox/pcc.c index fc3c237daef2..311e91b1a14f 100644 --- a/drivers/mailbox/pcc.c +++ b/drivers/mailbox/pcc.c | |||
| @@ -466,7 +466,8 @@ static int __init acpi_pcc_probe(void) | |||
| 466 | return -EINVAL; | 466 | return -EINVAL; |
| 467 | } | 467 | } |
| 468 | 468 | ||
| 469 | pcc_mbox_channels = kzalloc(sizeof(struct mbox_chan) * count, GFP_KERNEL); | 469 | pcc_mbox_channels = kcalloc(count, sizeof(struct mbox_chan), |
| 470 | GFP_KERNEL); | ||
| 470 | if (!pcc_mbox_channels) { | 471 | if (!pcc_mbox_channels) { |
| 471 | pr_err("Could not allocate space for PCC mbox channels\n"); | 472 | pr_err("Could not allocate space for PCC mbox channels\n"); |
| 472 | return -ENOMEM; | 473 | return -ENOMEM; |
diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c index 78753a87ba4d..5d04738c3c8a 100644 --- a/drivers/mailbox/ti-msgmgr.c +++ b/drivers/mailbox/ti-msgmgr.c | |||
| @@ -568,12 +568,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev) | |||
| 568 | } | 568 | } |
| 569 | inst->num_valid_queues = queue_count; | 569 | inst->num_valid_queues = queue_count; |
| 570 | 570 | ||
| 571 | qinst = devm_kzalloc(dev, sizeof(*qinst) * queue_count, GFP_KERNEL); | 571 | qinst = devm_kcalloc(dev, queue_count, sizeof(*qinst), GFP_KERNEL); |
| 572 | if (!qinst) | 572 | if (!qinst) |
| 573 | return -ENOMEM; | 573 | return -ENOMEM; |
| 574 | inst->qinsts = qinst; | 574 | inst->qinsts = qinst; |
| 575 | 575 | ||
| 576 | chans = devm_kzalloc(dev, sizeof(*chans) * queue_count, GFP_KERNEL); | 576 | chans = devm_kcalloc(dev, queue_count, sizeof(*chans), GFP_KERNEL); |
| 577 | if (!chans) | 577 | if (!chans) |
| 578 | return -ENOMEM; | 578 | return -ENOMEM; |
| 579 | inst->chans = chans; | 579 | inst->chans = chans; |
diff --git a/drivers/md/bcache/super.c b/drivers/md/bcache/super.c index a31e55bcc4e5..fa4058e43202 100644 --- a/drivers/md/bcache/super.c +++ b/drivers/md/bcache/super.c | |||
| @@ -1715,7 +1715,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) | |||
| 1715 | iter_size = (sb->bucket_size / sb->block_size + 1) * | 1715 | iter_size = (sb->bucket_size / sb->block_size + 1) * |
| 1716 | sizeof(struct btree_iter_set); | 1716 | sizeof(struct btree_iter_set); |
| 1717 | 1717 | ||
| 1718 | if (!(c->devices = kzalloc(c->nr_uuids * sizeof(void *), GFP_KERNEL)) || | 1718 | if (!(c->devices = kcalloc(c->nr_uuids, sizeof(void *), GFP_KERNEL)) || |
| 1719 | mempool_init_slab_pool(&c->search, 32, bch_search_cache) || | 1719 | mempool_init_slab_pool(&c->search, 32, bch_search_cache) || |
| 1720 | mempool_init_kmalloc_pool(&c->bio_meta, 2, | 1720 | mempool_init_kmalloc_pool(&c->bio_meta, 2, |
| 1721 | sizeof(struct bbio) + sizeof(struct bio_vec) * | 1721 | sizeof(struct bbio) + sizeof(struct bio_vec) * |
| @@ -2041,10 +2041,11 @@ static int cache_alloc(struct cache *ca) | |||
| 2041 | !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || | 2041 | !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) || |
| 2042 | !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || | 2042 | !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) || |
| 2043 | !init_heap(&ca->heap, free << 3, GFP_KERNEL) || | 2043 | !init_heap(&ca->heap, free << 3, GFP_KERNEL) || |
| 2044 | !(ca->buckets = vzalloc(sizeof(struct bucket) * | 2044 | !(ca->buckets = vzalloc(array_size(sizeof(struct bucket), |
| 2045 | ca->sb.nbuckets)) || | 2045 | ca->sb.nbuckets))) || |
| 2046 | !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) * | 2046 | !(ca->prio_buckets = kzalloc(array3_size(sizeof(uint64_t), |
| 2047 | 2, GFP_KERNEL)) || | 2047 | prio_buckets(ca), 2), |
| 2048 | GFP_KERNEL)) || | ||
| 2048 | !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) | 2049 | !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca))) |
| 2049 | return -ENOMEM; | 2050 | return -ENOMEM; |
| 2050 | 2051 | ||
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c index 8ccbc8f3b3af..225b15aa0340 100644 --- a/drivers/md/bcache/sysfs.c +++ b/drivers/md/bcache/sysfs.c | |||
| @@ -881,7 +881,8 @@ SHOW(__bch_cache) | |||
| 881 | uint16_t q[31], *p, *cached; | 881 | uint16_t q[31], *p, *cached; |
| 882 | ssize_t ret; | 882 | ssize_t ret; |
| 883 | 883 | ||
| 884 | cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t)); | 884 | cached = p = vmalloc(array_size(sizeof(uint16_t), |
| 885 | ca->sb.nbuckets)); | ||
| 885 | if (!p) | 886 | if (!p) |
| 886 | return -ENOMEM; | 887 | return -ENOMEM; |
| 887 | 888 | ||
diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c index 4ab23d0075f6..1b5b9ad9e492 100644 --- a/drivers/md/dm-cache-policy-smq.c +++ b/drivers/md/dm-cache-policy-smq.c | |||
| @@ -69,7 +69,7 @@ static int space_init(struct entry_space *es, unsigned nr_entries) | |||
| 69 | return 0; | 69 | return 0; |
| 70 | } | 70 | } |
| 71 | 71 | ||
| 72 | es->begin = vzalloc(sizeof(struct entry) * nr_entries); | 72 | es->begin = vzalloc(array_size(nr_entries, sizeof(struct entry))); |
| 73 | if (!es->begin) | 73 | if (!es->begin) |
| 74 | return -ENOMEM; | 74 | return -ENOMEM; |
| 75 | 75 | ||
| @@ -588,7 +588,7 @@ static int h_init(struct smq_hash_table *ht, struct entry_space *es, unsigned nr | |||
| 588 | nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u)); | 588 | nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u)); |
| 589 | ht->hash_bits = __ffs(nr_buckets); | 589 | ht->hash_bits = __ffs(nr_buckets); |
| 590 | 590 | ||
| 591 | ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets); | 591 | ht->buckets = vmalloc(array_size(nr_buckets, sizeof(*ht->buckets))); |
| 592 | if (!ht->buckets) | 592 | if (!ht->buckets) |
| 593 | return -ENOMEM; | 593 | return -ENOMEM; |
| 594 | 594 | ||
diff --git a/drivers/md/dm-crypt.c b/drivers/md/dm-crypt.c index 4939fbc34ff2..b61b069c33af 100644 --- a/drivers/md/dm-crypt.c +++ b/drivers/md/dm-crypt.c | |||
| @@ -1878,8 +1878,9 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode) | |||
| 1878 | unsigned i; | 1878 | unsigned i; |
| 1879 | int err; | 1879 | int err; |
| 1880 | 1880 | ||
| 1881 | cc->cipher_tfm.tfms = kzalloc(cc->tfms_count * | 1881 | cc->cipher_tfm.tfms = kcalloc(cc->tfms_count, |
| 1882 | sizeof(struct crypto_skcipher *), GFP_KERNEL); | 1882 | sizeof(struct crypto_skcipher *), |
| 1883 | GFP_KERNEL); | ||
| 1883 | if (!cc->cipher_tfm.tfms) | 1884 | if (!cc->cipher_tfm.tfms) |
| 1884 | return -ENOMEM; | 1885 | return -ENOMEM; |
| 1885 | 1886 | ||
diff --git a/drivers/md/dm-integrity.c b/drivers/md/dm-integrity.c index fc68c7aaef8e..86438b2f10dd 100644 --- a/drivers/md/dm-integrity.c +++ b/drivers/md/dm-integrity.c | |||
| @@ -2448,7 +2448,9 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int | |||
| 2448 | struct scatterlist **sl; | 2448 | struct scatterlist **sl; |
| 2449 | unsigned i; | 2449 | unsigned i; |
| 2450 | 2450 | ||
| 2451 | sl = kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), GFP_KERNEL | __GFP_ZERO); | 2451 | sl = kvmalloc_array(ic->journal_sections, |
| 2452 | sizeof(struct scatterlist *), | ||
| 2453 | GFP_KERNEL | __GFP_ZERO); | ||
| 2452 | if (!sl) | 2454 | if (!sl) |
| 2453 | return NULL; | 2455 | return NULL; |
| 2454 | 2456 | ||
| @@ -2464,7 +2466,8 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int | |||
| 2464 | 2466 | ||
| 2465 | n_pages = (end_index - start_index + 1); | 2467 | n_pages = (end_index - start_index + 1); |
| 2466 | 2468 | ||
| 2467 | s = kvmalloc(n_pages * sizeof(struct scatterlist), GFP_KERNEL); | 2469 | s = kvmalloc_array(n_pages, sizeof(struct scatterlist), |
| 2470 | GFP_KERNEL); | ||
| 2468 | if (!s) { | 2471 | if (!s) { |
| 2469 | dm_integrity_free_journal_scatterlist(ic, sl); | 2472 | dm_integrity_free_journal_scatterlist(ic, sl); |
| 2470 | return NULL; | 2473 | return NULL; |
| @@ -2643,7 +2646,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error) | |||
| 2643 | goto bad; | 2646 | goto bad; |
| 2644 | } | 2647 | } |
| 2645 | 2648 | ||
| 2646 | sg = kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), GFP_KERNEL); | 2649 | sg = kvmalloc_array(ic->journal_pages + 1, |
| 2650 | sizeof(struct scatterlist), | ||
| 2651 | GFP_KERNEL); | ||
| 2647 | if (!sg) { | 2652 | if (!sg) { |
| 2648 | *error = "Unable to allocate sg list"; | 2653 | *error = "Unable to allocate sg list"; |
| 2649 | r = -ENOMEM; | 2654 | r = -ENOMEM; |
| @@ -2709,7 +2714,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error) | |||
| 2709 | r = -ENOMEM; | 2714 | r = -ENOMEM; |
| 2710 | goto bad; | 2715 | goto bad; |
| 2711 | } | 2716 | } |
| 2712 | ic->sk_requests = kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), GFP_KERNEL | __GFP_ZERO); | 2717 | ic->sk_requests = kvmalloc_array(ic->journal_sections, |
| 2718 | sizeof(struct skcipher_request *), | ||
| 2719 | GFP_KERNEL | __GFP_ZERO); | ||
| 2713 | if (!ic->sk_requests) { | 2720 | if (!ic->sk_requests) { |
| 2714 | *error = "Unable to allocate sk requests"; | 2721 | *error = "Unable to allocate sk requests"; |
| 2715 | r = -ENOMEM; | 2722 | r = -ENOMEM; |
| @@ -2743,7 +2750,8 @@ static int create_journal(struct dm_integrity_c *ic, char **error) | |||
| 2743 | r = -ENOMEM; | 2750 | r = -ENOMEM; |
| 2744 | goto bad; | 2751 | goto bad; |
| 2745 | } | 2752 | } |
| 2746 | section_req->iv = kmalloc(ivsize * 2, GFP_KERNEL); | 2753 | section_req->iv = kmalloc_array(ivsize, 2, |
| 2754 | GFP_KERNEL); | ||
| 2747 | if (!section_req->iv) { | 2755 | if (!section_req->iv) { |
| 2748 | skcipher_request_free(section_req); | 2756 | skcipher_request_free(section_req); |
| 2749 | *error = "Unable to allocate iv"; | 2757 | *error = "Unable to allocate iv"; |
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c index c832ec398f02..1f760451e6f4 100644 --- a/drivers/md/dm-region-hash.c +++ b/drivers/md/dm-region-hash.c | |||
| @@ -203,7 +203,7 @@ struct dm_region_hash *dm_region_hash_create( | |||
| 203 | rh->shift = RH_HASH_SHIFT; | 203 | rh->shift = RH_HASH_SHIFT; |
| 204 | rh->prime = RH_HASH_MULT; | 204 | rh->prime = RH_HASH_MULT; |
| 205 | 205 | ||
| 206 | rh->buckets = vmalloc(nr_buckets * sizeof(*rh->buckets)); | 206 | rh->buckets = vmalloc(array_size(nr_buckets, sizeof(*rh->buckets))); |
| 207 | if (!rh->buckets) { | 207 | if (!rh->buckets) { |
| 208 | DMERR("unable to allocate region hash bucket memory"); | 208 | DMERR("unable to allocate region hash bucket memory"); |
| 209 | kfree(rh); | 209 | kfree(rh); |
diff --git a/drivers/md/dm-snap.c b/drivers/md/dm-snap.c index f745404da721..97de7a7334d4 100644 --- a/drivers/md/dm-snap.c +++ b/drivers/md/dm-snap.c | |||
| @@ -326,8 +326,8 @@ static int init_origin_hash(void) | |||
| 326 | { | 326 | { |
| 327 | int i; | 327 | int i; |
| 328 | 328 | ||
| 329 | _origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head), | 329 | _origins = kmalloc_array(ORIGIN_HASH_SIZE, sizeof(struct list_head), |
| 330 | GFP_KERNEL); | 330 | GFP_KERNEL); |
| 331 | if (!_origins) { | 331 | if (!_origins) { |
| 332 | DMERR("unable to allocate memory for _origins"); | 332 | DMERR("unable to allocate memory for _origins"); |
| 333 | return -ENOMEM; | 333 | return -ENOMEM; |
| @@ -335,8 +335,9 @@ static int init_origin_hash(void) | |||
| 335 | for (i = 0; i < ORIGIN_HASH_SIZE; i++) | 335 | for (i = 0; i < ORIGIN_HASH_SIZE; i++) |
| 336 | INIT_LIST_HEAD(_origins + i); | 336 | INIT_LIST_HEAD(_origins + i); |
| 337 | 337 | ||
| 338 | _dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head), | 338 | _dm_origins = kmalloc_array(ORIGIN_HASH_SIZE, |
| 339 | GFP_KERNEL); | 339 | sizeof(struct list_head), |
| 340 | GFP_KERNEL); | ||
| 340 | if (!_dm_origins) { | 341 | if (!_dm_origins) { |
| 341 | DMERR("unable to allocate memory for _dm_origins"); | 342 | DMERR("unable to allocate memory for _dm_origins"); |
| 342 | kfree(_origins); | 343 | kfree(_origins); |
diff --git a/drivers/md/dm-stats.c b/drivers/md/dm-stats.c index 56059fb56e2d..21de30b4e2a1 100644 --- a/drivers/md/dm-stats.c +++ b/drivers/md/dm-stats.c | |||
| @@ -915,7 +915,9 @@ static int parse_histogram(const char *h, unsigned *n_histogram_entries, | |||
| 915 | if (*q == ',') | 915 | if (*q == ',') |
| 916 | (*n_histogram_entries)++; | 916 | (*n_histogram_entries)++; |
| 917 | 917 | ||
| 918 | *histogram_boundaries = kmalloc(*n_histogram_entries * sizeof(unsigned long long), GFP_KERNEL); | 918 | *histogram_boundaries = kmalloc_array(*n_histogram_entries, |
| 919 | sizeof(unsigned long long), | ||
| 920 | GFP_KERNEL); | ||
| 919 | if (!*histogram_boundaries) | 921 | if (!*histogram_boundaries) |
| 920 | return -ENOMEM; | 922 | return -ENOMEM; |
| 921 | 923 | ||
diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c index 7924a6a33ddc..fae35caf3672 100644 --- a/drivers/md/dm-switch.c +++ b/drivers/md/dm-switch.c | |||
| @@ -114,7 +114,8 @@ static int alloc_region_table(struct dm_target *ti, unsigned nr_paths) | |||
| 114 | return -EINVAL; | 114 | return -EINVAL; |
| 115 | } | 115 | } |
| 116 | 116 | ||
| 117 | sctx->region_table = vmalloc(nr_slots * sizeof(region_table_slot_t)); | 117 | sctx->region_table = vmalloc(array_size(nr_slots, |
| 118 | sizeof(region_table_slot_t))); | ||
| 118 | if (!sctx->region_table) { | 119 | if (!sctx->region_table) { |
| 119 | ti->error = "Cannot allocate region table"; | 120 | ti->error = "Cannot allocate region table"; |
| 120 | return -ENOMEM; | 121 | return -ENOMEM; |
diff --git a/drivers/md/dm-table.c b/drivers/md/dm-table.c index caa51dd351b6..938766794c2e 100644 --- a/drivers/md/dm-table.c +++ b/drivers/md/dm-table.c | |||
| @@ -561,7 +561,7 @@ static char **realloc_argv(unsigned *size, char **old_argv) | |||
| 561 | new_size = 8; | 561 | new_size = 8; |
| 562 | gfp = GFP_NOIO; | 562 | gfp = GFP_NOIO; |
| 563 | } | 563 | } |
| 564 | argv = kmalloc(new_size * sizeof(*argv), gfp); | 564 | argv = kmalloc_array(new_size, sizeof(*argv), gfp); |
| 565 | if (argv) { | 565 | if (argv) { |
| 566 | memcpy(argv, old_argv, *size * sizeof(*argv)); | 566 | memcpy(argv, old_argv, *size * sizeof(*argv)); |
| 567 | *size = new_size; | 567 | *size = new_size; |
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c index 6cf9c9364103..7945238df1c0 100644 --- a/drivers/md/dm-thin.c +++ b/drivers/md/dm-thin.c | |||
| @@ -2940,7 +2940,9 @@ static struct pool *pool_create(struct mapped_device *pool_md, | |||
| 2940 | goto bad_mapping_pool; | 2940 | goto bad_mapping_pool; |
| 2941 | } | 2941 | } |
| 2942 | 2942 | ||
| 2943 | pool->cell_sort_array = vmalloc(sizeof(*pool->cell_sort_array) * CELL_SORT_ARRAY_SIZE); | 2943 | pool->cell_sort_array = |
| 2944 | vmalloc(array_size(CELL_SORT_ARRAY_SIZE, | ||
| 2945 | sizeof(*pool->cell_sort_array))); | ||
| 2944 | if (!pool->cell_sort_array) { | 2946 | if (!pool->cell_sort_array) { |
| 2945 | *error = "Error allocating cell sort array"; | 2947 | *error = "Error allocating cell sort array"; |
| 2946 | err_p = ERR_PTR(-ENOMEM); | 2948 | err_p = ERR_PTR(-ENOMEM); |
diff --git a/drivers/md/dm-verity-target.c b/drivers/md/dm-verity-target.c index fc893f636a98..12decdbd722d 100644 --- a/drivers/md/dm-verity-target.c +++ b/drivers/md/dm-verity-target.c | |||
| @@ -797,8 +797,9 @@ static int verity_alloc_most_once(struct dm_verity *v) | |||
| 797 | return -E2BIG; | 797 | return -E2BIG; |
| 798 | } | 798 | } |
| 799 | 799 | ||
| 800 | v->validated_blocks = kvzalloc(BITS_TO_LONGS(v->data_blocks) * | 800 | v->validated_blocks = kvcalloc(BITS_TO_LONGS(v->data_blocks), |
| 801 | sizeof(unsigned long), GFP_KERNEL); | 801 | sizeof(unsigned long), |
| 802 | GFP_KERNEL); | ||
| 802 | if (!v->validated_blocks) { | 803 | if (!v->validated_blocks) { |
| 803 | ti->error = "failed to allocate bitset for check_at_most_once"; | 804 | ti->error = "failed to allocate bitset for check_at_most_once"; |
| 804 | return -ENOMEM; | 805 | return -ENOMEM; |
diff --git a/drivers/md/md-bitmap.c b/drivers/md/md-bitmap.c index 239c7bb3929b..f983c3fdf204 100644 --- a/drivers/md/md-bitmap.c +++ b/drivers/md/md-bitmap.c | |||
| @@ -789,8 +789,8 @@ static int bitmap_storage_alloc(struct bitmap_storage *store, | |||
| 789 | num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); | 789 | num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE); |
| 790 | offset = slot_number * num_pages; | 790 | offset = slot_number * num_pages; |
| 791 | 791 | ||
| 792 | store->filemap = kmalloc(sizeof(struct page *) | 792 | store->filemap = kmalloc_array(num_pages, sizeof(struct page *), |
| 793 | * num_pages, GFP_KERNEL); | 793 | GFP_KERNEL); |
| 794 | if (!store->filemap) | 794 | if (!store->filemap) |
| 795 | return -ENOMEM; | 795 | return -ENOMEM; |
| 796 | 796 | ||
| @@ -2117,7 +2117,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks, | |||
| 2117 | 2117 | ||
| 2118 | pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO); | 2118 | pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO); |
| 2119 | 2119 | ||
| 2120 | new_bp = kzalloc(pages * sizeof(*new_bp), GFP_KERNEL); | 2120 | new_bp = kcalloc(pages, sizeof(*new_bp), GFP_KERNEL); |
| 2121 | ret = -ENOMEM; | 2121 | ret = -ENOMEM; |
| 2122 | if (!new_bp) { | 2122 | if (!new_bp) { |
| 2123 | bitmap_file_unmap(&store); | 2123 | bitmap_file_unmap(&store); |
diff --git a/drivers/md/md-cluster.c b/drivers/md/md-cluster.c index 79bfbc840385..021cbf9ef1bf 100644 --- a/drivers/md/md-cluster.c +++ b/drivers/md/md-cluster.c | |||
| @@ -1380,9 +1380,9 @@ static int lock_all_bitmaps(struct mddev *mddev) | |||
| 1380 | char str[64]; | 1380 | char str[64]; |
| 1381 | struct md_cluster_info *cinfo = mddev->cluster_info; | 1381 | struct md_cluster_info *cinfo = mddev->cluster_info; |
| 1382 | 1382 | ||
| 1383 | cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) * | 1383 | cinfo->other_bitmap_lockres = |
| 1384 | sizeof(struct dlm_lock_resource *), | 1384 | kcalloc(mddev->bitmap_info.nodes - 1, |
| 1385 | GFP_KERNEL); | 1385 | sizeof(struct dlm_lock_resource *), GFP_KERNEL); |
| 1386 | if (!cinfo->other_bitmap_lockres) { | 1386 | if (!cinfo->other_bitmap_lockres) { |
| 1387 | pr_err("md: can't alloc mem for other bitmap locks\n"); | 1387 | pr_err("md: can't alloc mem for other bitmap locks\n"); |
| 1388 | return 0; | 1388 | return 0; |
diff --git a/drivers/md/md-multipath.c b/drivers/md/md-multipath.c index f71fcdb9b39c..881487de1e25 100644 --- a/drivers/md/md-multipath.c +++ b/drivers/md/md-multipath.c | |||
| @@ -399,7 +399,8 @@ static int multipath_run (struct mddev *mddev) | |||
| 399 | if (!conf) | 399 | if (!conf) |
| 400 | goto out; | 400 | goto out; |
| 401 | 401 | ||
| 402 | conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks, | 402 | conf->multipaths = kcalloc(mddev->raid_disks, |
| 403 | sizeof(struct multipath_info), | ||
| 403 | GFP_KERNEL); | 404 | GFP_KERNEL); |
| 404 | if (!conf->multipaths) | 405 | if (!conf->multipaths) |
| 405 | goto out_free_conf; | 406 | goto out_free_conf; |
diff --git a/drivers/md/raid0.c b/drivers/md/raid0.c index 65ae47a02218..ac1cffd2a09b 100644 --- a/drivers/md/raid0.c +++ b/drivers/md/raid0.c | |||
| @@ -159,12 +159,14 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) | |||
| 159 | } | 159 | } |
| 160 | 160 | ||
| 161 | err = -ENOMEM; | 161 | err = -ENOMEM; |
| 162 | conf->strip_zone = kzalloc(sizeof(struct strip_zone)* | 162 | conf->strip_zone = kcalloc(conf->nr_strip_zones, |
| 163 | conf->nr_strip_zones, GFP_KERNEL); | 163 | sizeof(struct strip_zone), |
| 164 | GFP_KERNEL); | ||
| 164 | if (!conf->strip_zone) | 165 | if (!conf->strip_zone) |
| 165 | goto abort; | 166 | goto abort; |
| 166 | conf->devlist = kzalloc(sizeof(struct md_rdev*)* | 167 | conf->devlist = kzalloc(array3_size(sizeof(struct md_rdev *), |
| 167 | conf->nr_strip_zones*mddev->raid_disks, | 168 | conf->nr_strip_zones, |
| 169 | mddev->raid_disks), | ||
| 168 | GFP_KERNEL); | 170 | GFP_KERNEL); |
| 169 | if (!conf->devlist) | 171 | if (!conf->devlist) |
| 170 | goto abort; | 172 | goto abort; |
diff --git a/drivers/md/raid1.c b/drivers/md/raid1.c index 0b344d087581..8e05c1092aef 100644 --- a/drivers/md/raid1.c +++ b/drivers/md/raid1.c | |||
| @@ -126,8 +126,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) | |||
| 126 | if (!r1_bio) | 126 | if (!r1_bio) |
| 127 | return NULL; | 127 | return NULL; |
| 128 | 128 | ||
| 129 | rps = kmalloc(sizeof(struct resync_pages) * pi->raid_disks, | 129 | rps = kmalloc_array(pi->raid_disks, sizeof(struct resync_pages), |
| 130 | gfp_flags); | 130 | gfp_flags); |
| 131 | if (!rps) | 131 | if (!rps) |
| 132 | goto out_free_r1bio; | 132 | goto out_free_r1bio; |
| 133 | 133 | ||
| @@ -2936,9 +2936,9 @@ static struct r1conf *setup_conf(struct mddev *mddev) | |||
| 2936 | if (!conf->barrier) | 2936 | if (!conf->barrier) |
| 2937 | goto abort; | 2937 | goto abort; |
| 2938 | 2938 | ||
| 2939 | conf->mirrors = kzalloc(sizeof(struct raid1_info) | 2939 | conf->mirrors = kzalloc(array3_size(sizeof(struct raid1_info), |
| 2940 | * mddev->raid_disks * 2, | 2940 | mddev->raid_disks, 2), |
| 2941 | GFP_KERNEL); | 2941 | GFP_KERNEL); |
| 2942 | if (!conf->mirrors) | 2942 | if (!conf->mirrors) |
| 2943 | goto abort; | 2943 | goto abort; |
| 2944 | 2944 | ||
| @@ -3241,7 +3241,8 @@ static int raid1_reshape(struct mddev *mddev) | |||
| 3241 | kfree(newpoolinfo); | 3241 | kfree(newpoolinfo); |
| 3242 | return ret; | 3242 | return ret; |
| 3243 | } | 3243 | } |
| 3244 | newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2, | 3244 | newmirrors = kzalloc(array3_size(sizeof(struct raid1_info), |
| 3245 | raid_disks, 2), | ||
| 3245 | GFP_KERNEL); | 3246 | GFP_KERNEL); |
| 3246 | if (!newmirrors) { | 3247 | if (!newmirrors) { |
| 3247 | kfree(newpoolinfo); | 3248 | kfree(newpoolinfo); |
diff --git a/drivers/md/raid10.c b/drivers/md/raid10.c index 1147ae59e3b6..478cf446827f 100644 --- a/drivers/md/raid10.c +++ b/drivers/md/raid10.c | |||
| @@ -175,7 +175,7 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data) | |||
| 175 | nalloc_rp = nalloc; | 175 | nalloc_rp = nalloc; |
| 176 | else | 176 | else |
| 177 | nalloc_rp = nalloc * 2; | 177 | nalloc_rp = nalloc * 2; |
| 178 | rps = kmalloc(sizeof(struct resync_pages) * nalloc_rp, gfp_flags); | 178 | rps = kmalloc_array(nalloc_rp, sizeof(struct resync_pages), gfp_flags); |
| 179 | if (!rps) | 179 | if (!rps) |
| 180 | goto out_free_r10bio; | 180 | goto out_free_r10bio; |
| 181 | 181 | ||
| @@ -3688,8 +3688,8 @@ static struct r10conf *setup_conf(struct mddev *mddev) | |||
| 3688 | goto out; | 3688 | goto out; |
| 3689 | 3689 | ||
| 3690 | /* FIXME calc properly */ | 3690 | /* FIXME calc properly */ |
| 3691 | conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks + | 3691 | conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks), |
| 3692 | max(0,-mddev->delta_disks)), | 3692 | sizeof(struct raid10_info), |
| 3693 | GFP_KERNEL); | 3693 | GFP_KERNEL); |
| 3694 | if (!conf->mirrors) | 3694 | if (!conf->mirrors) |
| 3695 | goto out; | 3695 | goto out; |
| @@ -4129,11 +4129,10 @@ static int raid10_check_reshape(struct mddev *mddev) | |||
| 4129 | conf->mirrors_new = NULL; | 4129 | conf->mirrors_new = NULL; |
| 4130 | if (mddev->delta_disks > 0) { | 4130 | if (mddev->delta_disks > 0) { |
| 4131 | /* allocate new 'mirrors' list */ | 4131 | /* allocate new 'mirrors' list */ |
| 4132 | conf->mirrors_new = kzalloc( | 4132 | conf->mirrors_new = |
| 4133 | sizeof(struct raid10_info) | 4133 | kcalloc(mddev->raid_disks + mddev->delta_disks, |
| 4134 | *(mddev->raid_disks + | 4134 | sizeof(struct raid10_info), |
| 4135 | mddev->delta_disks), | 4135 | GFP_KERNEL); |
| 4136 | GFP_KERNEL); | ||
| 4137 | if (!conf->mirrors_new) | 4136 | if (!conf->mirrors_new) |
| 4138 | return -ENOMEM; | 4137 | return -ENOMEM; |
| 4139 | } | 4138 | } |
diff --git a/drivers/md/raid5.c b/drivers/md/raid5.c index 73489446bbcb..2031506a0ecd 100644 --- a/drivers/md/raid5.c +++ b/drivers/md/raid5.c | |||
| @@ -2396,7 +2396,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) | |||
| 2396 | * is completely stalled, so now is a good time to resize | 2396 | * is completely stalled, so now is a good time to resize |
| 2397 | * conf->disks and the scribble region | 2397 | * conf->disks and the scribble region |
| 2398 | */ | 2398 | */ |
| 2399 | ndisks = kzalloc(newsize * sizeof(struct disk_info), GFP_NOIO); | 2399 | ndisks = kcalloc(newsize, sizeof(struct disk_info), GFP_NOIO); |
| 2400 | if (ndisks) { | 2400 | if (ndisks) { |
| 2401 | for (i = 0; i < conf->pool_size; i++) | 2401 | for (i = 0; i < conf->pool_size; i++) |
| 2402 | ndisks[i] = conf->disks[i]; | 2402 | ndisks[i] = conf->disks[i]; |
| @@ -6664,9 +6664,9 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt, | |||
| 6664 | } | 6664 | } |
| 6665 | *group_cnt = num_possible_nodes(); | 6665 | *group_cnt = num_possible_nodes(); |
| 6666 | size = sizeof(struct r5worker) * cnt; | 6666 | size = sizeof(struct r5worker) * cnt; |
| 6667 | workers = kzalloc(size * *group_cnt, GFP_NOIO); | 6667 | workers = kcalloc(size, *group_cnt, GFP_NOIO); |
| 6668 | *worker_groups = kzalloc(sizeof(struct r5worker_group) * | 6668 | *worker_groups = kcalloc(*group_cnt, sizeof(struct r5worker_group), |
| 6669 | *group_cnt, GFP_NOIO); | 6669 | GFP_NOIO); |
| 6670 | if (!*worker_groups || !workers) { | 6670 | if (!*worker_groups || !workers) { |
| 6671 | kfree(workers); | 6671 | kfree(workers); |
| 6672 | kfree(*worker_groups); | 6672 | kfree(*worker_groups); |
| @@ -6894,8 +6894,9 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
| 6894 | goto abort; | 6894 | goto abort; |
| 6895 | INIT_LIST_HEAD(&conf->free_list); | 6895 | INIT_LIST_HEAD(&conf->free_list); |
| 6896 | INIT_LIST_HEAD(&conf->pending_list); | 6896 | INIT_LIST_HEAD(&conf->pending_list); |
| 6897 | conf->pending_data = kzalloc(sizeof(struct r5pending_data) * | 6897 | conf->pending_data = kcalloc(PENDING_IO_MAX, |
| 6898 | PENDING_IO_MAX, GFP_KERNEL); | 6898 | sizeof(struct r5pending_data), |
| 6899 | GFP_KERNEL); | ||
| 6899 | if (!conf->pending_data) | 6900 | if (!conf->pending_data) |
| 6900 | goto abort; | 6901 | goto abort; |
| 6901 | for (i = 0; i < PENDING_IO_MAX; i++) | 6902 | for (i = 0; i < PENDING_IO_MAX; i++) |
| @@ -6944,7 +6945,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) | |||
| 6944 | conf->previous_raid_disks = mddev->raid_disks - mddev->delta_disks; | 6945 | conf->previous_raid_disks = mddev->raid_disks - mddev->delta_disks; |
| 6945 | max_disks = max(conf->raid_disks, conf->previous_raid_disks); | 6946 | max_disks = max(conf->raid_disks, conf->previous_raid_disks); |
| 6946 | 6947 | ||
| 6947 | conf->disks = kzalloc(max_disks * sizeof(struct disk_info), | 6948 | conf->disks = kcalloc(max_disks, sizeof(struct disk_info), |
| 6948 | GFP_KERNEL); | 6949 | GFP_KERNEL); |
| 6949 | 6950 | ||
| 6950 | if (!conf->disks) | 6951 | if (!conf->disks) |
diff --git a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c index 9b64f4f354bf..abd4c788dffd 100644 --- a/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +++ b/drivers/media/common/v4l2-tpg/v4l2-tpg-core.c | |||
| @@ -119,12 +119,14 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) | |||
| 119 | for (plane = 0; plane < TPG_MAX_PLANES; plane++) { | 119 | for (plane = 0; plane < TPG_MAX_PLANES; plane++) { |
| 120 | unsigned pixelsz = plane ? 2 : 4; | 120 | unsigned pixelsz = plane ? 2 : 4; |
| 121 | 121 | ||
| 122 | tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz); | 122 | tpg->lines[pat][plane] = |
| 123 | vzalloc(array3_size(max_w, 2, pixelsz)); | ||
| 123 | if (!tpg->lines[pat][plane]) | 124 | if (!tpg->lines[pat][plane]) |
| 124 | return -ENOMEM; | 125 | return -ENOMEM; |
| 125 | if (plane == 0) | 126 | if (plane == 0) |
| 126 | continue; | 127 | continue; |
| 127 | tpg->downsampled_lines[pat][plane] = vzalloc(max_w * 2 * pixelsz); | 128 | tpg->downsampled_lines[pat][plane] = |
| 129 | vzalloc(array3_size(max_w, 2, pixelsz)); | ||
| 128 | if (!tpg->downsampled_lines[pat][plane]) | 130 | if (!tpg->downsampled_lines[pat][plane]) |
| 129 | return -ENOMEM; | 131 | return -ENOMEM; |
| 130 | } | 132 | } |
| @@ -132,13 +134,16 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) | |||
| 132 | for (plane = 0; plane < TPG_MAX_PLANES; plane++) { | 134 | for (plane = 0; plane < TPG_MAX_PLANES; plane++) { |
| 133 | unsigned pixelsz = plane ? 2 : 4; | 135 | unsigned pixelsz = plane ? 2 : 4; |
| 134 | 136 | ||
| 135 | tpg->contrast_line[plane] = vzalloc(max_w * pixelsz); | 137 | tpg->contrast_line[plane] = |
| 138 | vzalloc(array_size(pixelsz, max_w)); | ||
| 136 | if (!tpg->contrast_line[plane]) | 139 | if (!tpg->contrast_line[plane]) |
| 137 | return -ENOMEM; | 140 | return -ENOMEM; |
| 138 | tpg->black_line[plane] = vzalloc(max_w * pixelsz); | 141 | tpg->black_line[plane] = |
| 142 | vzalloc(array_size(pixelsz, max_w)); | ||
| 139 | if (!tpg->black_line[plane]) | 143 | if (!tpg->black_line[plane]) |
| 140 | return -ENOMEM; | 144 | return -ENOMEM; |
| 141 | tpg->random_line[plane] = vzalloc(max_w * 2 * pixelsz); | 145 | tpg->random_line[plane] = |
| 146 | vzalloc(array3_size(max_w, 2, pixelsz)); | ||
| 142 | if (!tpg->random_line[plane]) | 147 | if (!tpg->random_line[plane]) |
| 143 | return -ENOMEM; | 148 | return -ENOMEM; |
| 144 | } | 149 | } |
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c index cb078d688c70..d548f98c7a67 100644 --- a/drivers/media/dvb-core/dmxdev.c +++ b/drivers/media/dvb-core/dmxdev.c | |||
| @@ -1417,7 +1417,8 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter) | |||
| 1417 | if (dmxdev->demux->open(dmxdev->demux) < 0) | 1417 | if (dmxdev->demux->open(dmxdev->demux) < 0) |
| 1418 | return -EUSERS; | 1418 | return -EUSERS; |
| 1419 | 1419 | ||
| 1420 | dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter)); | 1420 | dmxdev->filter = vmalloc(array_size(sizeof(struct dmxdev_filter), |
| 1421 | dmxdev->filternum)); | ||
| 1421 | if (!dmxdev->filter) | 1422 | if (!dmxdev->filter) |
| 1422 | return -ENOMEM; | 1423 | return -ENOMEM; |
| 1423 | 1424 | ||
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c index f45091246bdc..39a2c6ccf31d 100644 --- a/drivers/media/dvb-core/dvb_demux.c +++ b/drivers/media/dvb-core/dvb_demux.c | |||
| @@ -1247,12 +1247,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) | |||
| 1247 | 1247 | ||
| 1248 | dvbdemux->cnt_storage = NULL; | 1248 | dvbdemux->cnt_storage = NULL; |
| 1249 | dvbdemux->users = 0; | 1249 | dvbdemux->users = 0; |
| 1250 | dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); | 1250 | dvbdemux->filter = vmalloc(array_size(sizeof(struct dvb_demux_filter), |
| 1251 | dvbdemux->filternum)); | ||
| 1251 | 1252 | ||
| 1252 | if (!dvbdemux->filter) | 1253 | if (!dvbdemux->filter) |
| 1253 | return -ENOMEM; | 1254 | return -ENOMEM; |
| 1254 | 1255 | ||
| 1255 | dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); | 1256 | dvbdemux->feed = vmalloc(array_size(sizeof(struct dvb_demux_feed), |
| 1257 | dvbdemux->feednum)); | ||
| 1256 | if (!dvbdemux->feed) { | 1258 | if (!dvbdemux->feed) { |
| 1257 | vfree(dvbdemux->filter); | 1259 | vfree(dvbdemux->filter); |
| 1258 | dvbdemux->filter = NULL; | 1260 | dvbdemux->filter = NULL; |
diff --git a/drivers/media/dvb-frontends/dib7000p.c b/drivers/media/dvb-frontends/dib7000p.c index 902af482448e..5a8dbc0b25fb 100644 --- a/drivers/media/dvb-frontends/dib7000p.c +++ b/drivers/media/dvb-frontends/dib7000p.c | |||
| @@ -2018,10 +2018,10 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap) | |||
| 2018 | }; | 2018 | }; |
| 2019 | int ret = 0; | 2019 | int ret = 0; |
| 2020 | 2020 | ||
| 2021 | tx = kzalloc(2*sizeof(u8), GFP_KERNEL); | 2021 | tx = kzalloc(2, GFP_KERNEL); |
| 2022 | if (!tx) | 2022 | if (!tx) |
| 2023 | return -ENOMEM; | 2023 | return -ENOMEM; |
| 2024 | rx = kzalloc(2*sizeof(u8), GFP_KERNEL); | 2024 | rx = kzalloc(2, GFP_KERNEL); |
| 2025 | if (!rx) { | 2025 | if (!rx) { |
| 2026 | ret = -ENOMEM; | 2026 | ret = -ENOMEM; |
| 2027 | goto rx_memory_error; | 2027 | goto rx_memory_error; |
diff --git a/drivers/media/dvb-frontends/dib8000.c b/drivers/media/dvb-frontends/dib8000.c index 6f35173d2968..22eec8f65485 100644 --- a/drivers/media/dvb-frontends/dib8000.c +++ b/drivers/media/dvb-frontends/dib8000.c | |||
| @@ -4271,12 +4271,12 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, | |||
| 4271 | u8 new_addr = 0; | 4271 | u8 new_addr = 0; |
| 4272 | struct i2c_device client = {.adap = host }; | 4272 | struct i2c_device client = {.adap = host }; |
| 4273 | 4273 | ||
| 4274 | client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); | 4274 | client.i2c_write_buffer = kzalloc(4, GFP_KERNEL); |
| 4275 | if (!client.i2c_write_buffer) { | 4275 | if (!client.i2c_write_buffer) { |
| 4276 | dprintk("%s: not enough memory\n", __func__); | 4276 | dprintk("%s: not enough memory\n", __func__); |
| 4277 | return -ENOMEM; | 4277 | return -ENOMEM; |
| 4278 | } | 4278 | } |
| 4279 | client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); | 4279 | client.i2c_read_buffer = kzalloc(4, GFP_KERNEL); |
| 4280 | if (!client.i2c_read_buffer) { | 4280 | if (!client.i2c_read_buffer) { |
| 4281 | dprintk("%s: not enough memory\n", __func__); | 4281 | dprintk("%s: not enough memory\n", __func__); |
| 4282 | ret = -ENOMEM; | 4282 | ret = -ENOMEM; |
diff --git a/drivers/media/dvb-frontends/dib9000.c b/drivers/media/dvb-frontends/dib9000.c index f9289f488de7..b8edb55696bb 100644 --- a/drivers/media/dvb-frontends/dib9000.c +++ b/drivers/media/dvb-frontends/dib9000.c | |||
| @@ -2381,12 +2381,12 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul | |||
| 2381 | u8 new_addr = 0; | 2381 | u8 new_addr = 0; |
| 2382 | struct i2c_device client = {.i2c_adap = i2c }; | 2382 | struct i2c_device client = {.i2c_adap = i2c }; |
| 2383 | 2383 | ||
| 2384 | client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); | 2384 | client.i2c_write_buffer = kzalloc(4, GFP_KERNEL); |
| 2385 | if (!client.i2c_write_buffer) { | 2385 | if (!client.i2c_write_buffer) { |
| 2386 | dprintk("%s: not enough memory\n", __func__); | 2386 | dprintk("%s: not enough memory\n", __func__); |
| 2387 | return -ENOMEM; | 2387 | return -ENOMEM; |
| 2388 | } | 2388 | } |
| 2389 | client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL); | 2389 | client.i2c_read_buffer = kzalloc(4, GFP_KERNEL); |
| 2390 | if (!client.i2c_read_buffer) { | 2390 | if (!client.i2c_read_buffer) { |
| 2391 | dprintk("%s: not enough memory\n", __func__); | 2391 | dprintk("%s: not enough memory\n", __func__); |
| 2392 | ret = -ENOMEM; | 2392 | ret = -ENOMEM; |
diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index ff46d2c96cea..5007c9659342 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c | |||
| @@ -373,7 +373,7 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw, | |||
| 373 | data += S5K5BAG_FW_TAG_LEN; | 373 | data += S5K5BAG_FW_TAG_LEN; |
| 374 | count -= S5K5BAG_FW_TAG_LEN; | 374 | count -= S5K5BAG_FW_TAG_LEN; |
| 375 | 375 | ||
| 376 | d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL); | 376 | d = devm_kcalloc(dev, count, sizeof(u16), GFP_KERNEL); |
| 377 | if (!d) | 377 | if (!d) |
| 378 | return -ENOMEM; | 378 | return -ENOMEM; |
| 379 | 379 | ||
diff --git a/drivers/media/pci/bt8xx/bttv-risc.c b/drivers/media/pci/bt8xx/bttv-risc.c index 6a6be0b49f70..74aff6877d9c 100644 --- a/drivers/media/pci/bt8xx/bttv-risc.c +++ b/drivers/media/pci/bt8xx/bttv-risc.c | |||
| @@ -256,7 +256,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, | |||
| 256 | u32 addr; | 256 | u32 addr; |
| 257 | 257 | ||
| 258 | /* skip list for window clipping */ | 258 | /* skip list for window clipping */ |
| 259 | if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL))) | 259 | skips = kmalloc_array(ov->nclips, sizeof(*skips),GFP_KERNEL); |
| 260 | if (NULL == skips) | ||
| 260 | return -ENOMEM; | 261 | return -ENOMEM; |
| 261 | 262 | ||
| 262 | /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions | 263 | /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions |
diff --git a/drivers/media/pci/cx23885/cx23885-alsa.c b/drivers/media/pci/cx23885/cx23885-alsa.c index 20b3cb17f97f..db1e8ff35474 100644 --- a/drivers/media/pci/cx23885/cx23885-alsa.c +++ b/drivers/media/pci/cx23885/cx23885-alsa.c | |||
| @@ -95,7 +95,7 @@ static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages) | |||
| 95 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | 95 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); |
| 96 | buf->nr_pages = nr_pages; | 96 | buf->nr_pages = nr_pages; |
| 97 | 97 | ||
| 98 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | 98 | buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages)); |
| 99 | if (NULL == buf->sglist) | 99 | if (NULL == buf->sglist) |
| 100 | goto vzalloc_err; | 100 | goto vzalloc_err; |
| 101 | 101 | ||
diff --git a/drivers/media/pci/cx25821/cx25821-alsa.c b/drivers/media/pci/cx25821/cx25821-alsa.c index a45bf0331eeb..ef6380651c10 100644 --- a/drivers/media/pci/cx25821/cx25821-alsa.c +++ b/drivers/media/pci/cx25821/cx25821-alsa.c | |||
| @@ -159,7 +159,7 @@ static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages) | |||
| 159 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | 159 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); |
| 160 | buf->nr_pages = nr_pages; | 160 | buf->nr_pages = nr_pages; |
| 161 | 161 | ||
| 162 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | 162 | buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages)); |
| 163 | if (NULL == buf->sglist) | 163 | if (NULL == buf->sglist) |
| 164 | goto vzalloc_err; | 164 | goto vzalloc_err; |
| 165 | 165 | ||
diff --git a/drivers/media/pci/cx88/cx88-alsa.c b/drivers/media/pci/cx88/cx88-alsa.c index 8a28fda703a2..e5c3387cd1e8 100644 --- a/drivers/media/pci/cx88/cx88-alsa.c +++ b/drivers/media/pci/cx88/cx88-alsa.c | |||
| @@ -298,7 +298,7 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) | |||
| 298 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); | 298 | memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT); |
| 299 | buf->nr_pages = nr_pages; | 299 | buf->nr_pages = nr_pages; |
| 300 | 300 | ||
| 301 | buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist)); | 301 | buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages)); |
| 302 | if (!buf->sglist) | 302 | if (!buf->sglist) |
| 303 | goto vzalloc_err; | 303 | goto vzalloc_err; |
| 304 | 304 | ||
diff --git a/drivers/media/pci/ivtv/ivtvfb.c b/drivers/media/pci/ivtv/ivtvfb.c index 8e62b8be6529..b19058e36853 100644 --- a/drivers/media/pci/ivtv/ivtvfb.c +++ b/drivers/media/pci/ivtv/ivtvfb.c | |||
| @@ -1077,7 +1077,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) | |||
| 1077 | 1077 | ||
| 1078 | /* Allocate the pseudo palette */ | 1078 | /* Allocate the pseudo palette */ |
| 1079 | oi->ivtvfb_info.pseudo_palette = | 1079 | oi->ivtvfb_info.pseudo_palette = |
| 1080 | kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN); | 1080 | kmalloc_array(16, sizeof(u32), GFP_KERNEL|__GFP_NOWARN); |
| 1081 | 1081 | ||
| 1082 | if (!oi->ivtvfb_info.pseudo_palette) { | 1082 | if (!oi->ivtvfb_info.pseudo_palette) { |
| 1083 | IVTVFB_ERR("abort, unable to alloc pseudo palette\n"); | 1083 | IVTVFB_ERR("abort, unable to alloc pseudo palette\n"); |
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c index dedcdb573427..8001d3e9134e 100644 --- a/drivers/media/pci/meye/meye.c +++ b/drivers/media/pci/meye/meye.c | |||
| @@ -1625,7 +1625,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) | |||
| 1625 | ret = -ENOMEM; | 1625 | ret = -ENOMEM; |
| 1626 | meye.mchip_dev = pcidev; | 1626 | meye.mchip_dev = pcidev; |
| 1627 | 1627 | ||
| 1628 | meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); | 1628 | meye.grab_temp = vmalloc(array_size(PAGE_SIZE, MCHIP_NB_PAGES_MJPEG)); |
| 1629 | if (!meye.grab_temp) | 1629 | if (!meye.grab_temp) |
| 1630 | goto outvmalloc; | 1630 | goto outvmalloc; |
| 1631 | 1631 | ||
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c index 5708f69622cc..fda969a85684 100644 --- a/drivers/media/pci/pt1/pt1.c +++ b/drivers/media/pci/pt1/pt1.c | |||
| @@ -615,7 +615,7 @@ static int pt1_init_tables(struct pt1 *pt1) | |||
| 615 | if (!pt1_nr_tables) | 615 | if (!pt1_nr_tables) |
| 616 | return 0; | 616 | return 0; |
| 617 | 617 | ||
| 618 | tables = vmalloc(sizeof(struct pt1_table) * pt1_nr_tables); | 618 | tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table))); |
| 619 | if (tables == NULL) | 619 | if (tables == NULL) |
| 620 | return -ENOMEM; | 620 | return -ENOMEM; |
| 621 | 621 | ||
diff --git a/drivers/media/pci/saa7134/saa7134-alsa.c b/drivers/media/pci/saa7134/saa7134-alsa.c index 72311445d13d..b90cfde6e301 100644 --- a/drivers/media/pci/saa7134/saa7134-alsa.c +++ b/drivers/media/pci/saa7134/saa7134-alsa.c | |||
| @@ -279,7 +279,7 @@ static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages) | |||
| 279 | memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT); | 279 | memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT); |
| 280 | dma->nr_pages = nr_pages; | 280 | dma->nr_pages = nr_pages; |
| 281 | 281 | ||
| 282 | dma->sglist = vzalloc(dma->nr_pages * sizeof(*dma->sglist)); | 282 | dma->sglist = vzalloc(array_size(sizeof(*dma->sglist), dma->nr_pages)); |
| 283 | if (NULL == dma->sglist) | 283 | if (NULL == dma->sglist) |
| 284 | goto vzalloc_err; | 284 | goto vzalloc_err; |
| 285 | 285 | ||
diff --git a/drivers/media/pci/ttpci/av7110_ipack.c b/drivers/media/pci/ttpci/av7110_ipack.c index 5aff26574fe1..ec528fae7333 100644 --- a/drivers/media/pci/ttpci/av7110_ipack.c +++ b/drivers/media/pci/ttpci/av7110_ipack.c | |||
| @@ -24,7 +24,7 @@ void av7110_ipack_reset(struct ipack *p) | |||
| 24 | int av7110_ipack_init(struct ipack *p, int size, | 24 | int av7110_ipack_init(struct ipack *p, int size, |
| 25 | void (*func)(u8 *buf, int size, void *priv)) | 25 | void (*func)(u8 *buf, int size, void *priv)) |
| 26 | { | 26 | { |
| 27 | if (!(p->buf = vmalloc(size*sizeof(u8)))) { | 27 | if (!(p->buf = vmalloc(size))) { |
| 28 | printk(KERN_WARNING "Couldn't allocate memory for ipack\n"); | 28 | printk(KERN_WARNING "Couldn't allocate memory for ipack\n"); |
| 29 | return -ENOMEM; | 29 | return -ENOMEM; |
| 30 | } | 30 | } |
diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index 58ebc2220d0e..b05738a95e55 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c | |||
| @@ -2586,8 +2586,10 @@ static int vpfe_probe(struct platform_device *pdev) | |||
| 2586 | 2586 | ||
| 2587 | pm_runtime_put_sync(&pdev->dev); | 2587 | pm_runtime_put_sync(&pdev->dev); |
| 2588 | 2588 | ||
| 2589 | vpfe->sd = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_subdev *) * | 2589 | vpfe->sd = devm_kcalloc(&pdev->dev, |
| 2590 | ARRAY_SIZE(vpfe->cfg->asd), GFP_KERNEL); | 2590 | ARRAY_SIZE(vpfe->cfg->asd), |
| 2591 | sizeof(struct v4l2_subdev *), | ||
| 2592 | GFP_KERNEL); | ||
| 2591 | if (!vpfe->sd) { | 2593 | if (!vpfe->sd) { |
| 2592 | ret = -ENOMEM; | 2594 | ret = -ENOMEM; |
| 2593 | goto probe_out_v4l2_unregister; | 2595 | goto probe_out_v4l2_unregister; |
diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index 9364cdf62f54..a96f53ce8088 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c | |||
| @@ -1528,8 +1528,10 @@ vpif_capture_get_pdata(struct platform_device *pdev) | |||
| 1528 | if (!pdata) | 1528 | if (!pdata) |
| 1529 | return NULL; | 1529 | return NULL; |
| 1530 | pdata->subdev_info = | 1530 | pdata->subdev_info = |
| 1531 | devm_kzalloc(&pdev->dev, sizeof(*pdata->subdev_info) * | 1531 | devm_kcalloc(&pdev->dev, |
| 1532 | VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL); | 1532 | VPIF_CAPTURE_NUM_CHANNELS, |
| 1533 | sizeof(*pdata->subdev_info), | ||
| 1534 | GFP_KERNEL); | ||
| 1533 | 1535 | ||
| 1534 | if (!pdata->subdev_info) | 1536 | if (!pdata->subdev_info) |
| 1535 | return NULL; | 1537 | return NULL; |
| @@ -1546,9 +1548,9 @@ vpif_capture_get_pdata(struct platform_device *pdev) | |||
| 1546 | 1548 | ||
| 1547 | sdinfo = &pdata->subdev_info[i]; | 1549 | sdinfo = &pdata->subdev_info[i]; |
| 1548 | chan = &pdata->chan_config[i]; | 1550 | chan = &pdata->chan_config[i]; |
| 1549 | chan->inputs = devm_kzalloc(&pdev->dev, | 1551 | chan->inputs = devm_kcalloc(&pdev->dev, |
| 1550 | sizeof(*chan->inputs) * | ||
| 1551 | VPIF_CAPTURE_NUM_CHANNELS, | 1552 | VPIF_CAPTURE_NUM_CHANNELS, |
| 1553 | sizeof(*chan->inputs), | ||
| 1552 | GFP_KERNEL); | 1554 | GFP_KERNEL); |
| 1553 | if (!chan->inputs) | 1555 | if (!chan->inputs) |
| 1554 | return NULL; | 1556 | return NULL; |
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c index 64df82817de3..226f36ef7419 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c | |||
| @@ -845,7 +845,7 @@ int msm_csid_subdev_init(struct csid_device *csid, | |||
| 845 | while (res->clock[csid->nclocks]) | 845 | while (res->clock[csid->nclocks]) |
| 846 | csid->nclocks++; | 846 | csid->nclocks++; |
| 847 | 847 | ||
| 848 | csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock), | 848 | csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock), |
| 849 | GFP_KERNEL); | 849 | GFP_KERNEL); |
| 850 | if (!csid->clock) | 850 | if (!csid->clock) |
| 851 | return -ENOMEM; | 851 | return -ENOMEM; |
| @@ -868,8 +868,10 @@ int msm_csid_subdev_init(struct csid_device *csid, | |||
| 868 | continue; | 868 | continue; |
| 869 | } | 869 | } |
| 870 | 870 | ||
| 871 | clock->freq = devm_kzalloc(dev, clock->nfreqs * | 871 | clock->freq = devm_kcalloc(dev, |
| 872 | sizeof(*clock->freq), GFP_KERNEL); | 872 | clock->nfreqs, |
| 873 | sizeof(*clock->freq), | ||
| 874 | GFP_KERNEL); | ||
| 873 | if (!clock->freq) | 875 | if (!clock->freq) |
| 874 | return -ENOMEM; | 876 | return -ENOMEM; |
| 875 | 877 | ||
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c index 072c6cf053f6..7e61caba6a2d 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c | |||
| @@ -732,8 +732,9 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, | |||
| 732 | while (res->clock[csiphy->nclocks]) | 732 | while (res->clock[csiphy->nclocks]) |
| 733 | csiphy->nclocks++; | 733 | csiphy->nclocks++; |
| 734 | 734 | ||
| 735 | csiphy->clock = devm_kzalloc(dev, csiphy->nclocks * | 735 | csiphy->clock = devm_kcalloc(dev, |
| 736 | sizeof(*csiphy->clock), GFP_KERNEL); | 736 | csiphy->nclocks, sizeof(*csiphy->clock), |
| 737 | GFP_KERNEL); | ||
| 737 | if (!csiphy->clock) | 738 | if (!csiphy->clock) |
| 738 | return -ENOMEM; | 739 | return -ENOMEM; |
| 739 | 740 | ||
| @@ -755,8 +756,10 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, | |||
| 755 | continue; | 756 | continue; |
| 756 | } | 757 | } |
| 757 | 758 | ||
| 758 | clock->freq = devm_kzalloc(dev, clock->nfreqs * | 759 | clock->freq = devm_kcalloc(dev, |
| 759 | sizeof(*clock->freq), GFP_KERNEL); | 760 | clock->nfreqs, |
| 761 | sizeof(*clock->freq), | ||
| 762 | GFP_KERNEL); | ||
| 760 | if (!clock->freq) | 763 | if (!clock->freq) |
| 761 | return -ENOMEM; | 764 | return -ENOMEM; |
| 762 | 765 | ||
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-ispif.c b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c index 24da529397b5..9d1af9353c1d 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-ispif.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c | |||
| @@ -948,7 +948,8 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, | |||
| 948 | while (res->clock[ispif->nclocks]) | 948 | while (res->clock[ispif->nclocks]) |
| 949 | ispif->nclocks++; | 949 | ispif->nclocks++; |
| 950 | 950 | ||
| 951 | ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock), | 951 | ispif->clock = devm_kcalloc(dev, |
| 952 | ispif->nclocks, sizeof(*ispif->clock), | ||
| 952 | GFP_KERNEL); | 953 | GFP_KERNEL); |
| 953 | if (!ispif->clock) | 954 | if (!ispif->clock) |
| 954 | return -ENOMEM; | 955 | return -ENOMEM; |
| @@ -968,8 +969,10 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, | |||
| 968 | while (res->clock_for_reset[ispif->nclocks_for_reset]) | 969 | while (res->clock_for_reset[ispif->nclocks_for_reset]) |
| 969 | ispif->nclocks_for_reset++; | 970 | ispif->nclocks_for_reset++; |
| 970 | 971 | ||
| 971 | ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset * | 972 | ispif->clock_for_reset = devm_kcalloc(dev, |
| 972 | sizeof(*ispif->clock_for_reset), GFP_KERNEL); | 973 | ispif->nclocks_for_reset, |
| 974 | sizeof(*ispif->clock_for_reset), | ||
| 975 | GFP_KERNEL); | ||
| 973 | if (!ispif->clock_for_reset) | 976 | if (!ispif->clock_for_reset) |
| 974 | return -ENOMEM; | 977 | return -ENOMEM; |
| 975 | 978 | ||
diff --git a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c index 55232a912950..a6329a8a7c4a 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c | |||
| @@ -2794,7 +2794,7 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) | |||
| 2794 | while (res->clock[vfe->nclocks]) | 2794 | while (res->clock[vfe->nclocks]) |
| 2795 | vfe->nclocks++; | 2795 | vfe->nclocks++; |
| 2796 | 2796 | ||
| 2797 | vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock), | 2797 | vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock), |
| 2798 | GFP_KERNEL); | 2798 | GFP_KERNEL); |
| 2799 | if (!vfe->clock) | 2799 | if (!vfe->clock) |
| 2800 | return -ENOMEM; | 2800 | return -ENOMEM; |
| @@ -2817,8 +2817,10 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) | |||
| 2817 | continue; | 2817 | continue; |
| 2818 | } | 2818 | } |
| 2819 | 2819 | ||
| 2820 | clock->freq = devm_kzalloc(dev, clock->nfreqs * | 2820 | clock->freq = devm_kcalloc(dev, |
| 2821 | sizeof(*clock->freq), GFP_KERNEL); | 2821 | clock->nfreqs, |
| 2822 | sizeof(*clock->freq), | ||
| 2823 | GFP_KERNEL); | ||
| 2822 | if (!clock->freq) | 2824 | if (!clock->freq) |
| 2823 | return -ENOMEM; | 2825 | return -ENOMEM; |
| 2824 | 2826 | ||
diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c index 05f06c98aa64..23fda6207a23 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss.c +++ b/drivers/media/platform/qcom/camss-8x16/camss.c | |||
| @@ -271,7 +271,8 @@ static int camss_of_parse_endpoint_node(struct device *dev, | |||
| 271 | lncfg->clk.pol = mipi_csi2->lane_polarities[0]; | 271 | lncfg->clk.pol = mipi_csi2->lane_polarities[0]; |
| 272 | lncfg->num_data = mipi_csi2->num_data_lanes; | 272 | lncfg->num_data = mipi_csi2->num_data_lanes; |
| 273 | 273 | ||
| 274 | lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data), | 274 | lncfg->data = devm_kcalloc(dev, |
| 275 | lncfg->num_data, sizeof(*lncfg->data), | ||
| 275 | GFP_KERNEL); | 276 | GFP_KERNEL); |
| 276 | if (!lncfg->data) | 277 | if (!lncfg->data) |
| 277 | return -ENOMEM; | 278 | return -ENOMEM; |
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c index 69f0d8e80bd8..66d613629167 100644 --- a/drivers/media/platform/soc_camera/soc_camera.c +++ b/drivers/media/platform/soc_camera/soc_camera.c | |||
| @@ -481,7 +481,8 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) | |||
| 481 | return -ENXIO; | 481 | return -ENXIO; |
| 482 | 482 | ||
| 483 | icd->user_formats = | 483 | icd->user_formats = |
| 484 | vmalloc(fmts * sizeof(struct soc_camera_format_xlate)); | 484 | vmalloc(array_size(fmts, |
| 485 | sizeof(struct soc_camera_format_xlate))); | ||
| 485 | if (!icd->user_formats) | 486 | if (!icd->user_formats) |
| 486 | return -ENOMEM; | 487 | return -ENOMEM; |
| 487 | 488 | ||
diff --git a/drivers/media/platform/vivid/vivid-core.c b/drivers/media/platform/vivid/vivid-core.c index 82ec216f2ad8..31db363602e5 100644 --- a/drivers/media/platform/vivid/vivid-core.c +++ b/drivers/media/platform/vivid/vivid-core.c | |||
| @@ -844,10 +844,10 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) | |||
| 844 | tpg_init(&dev->tpg, 640, 360); | 844 | tpg_init(&dev->tpg, 640, 360); |
| 845 | if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH)) | 845 | if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH)) |
| 846 | goto free_dev; | 846 | goto free_dev; |
| 847 | dev->scaled_line = vzalloc(MAX_ZOOM * MAX_WIDTH); | 847 | dev->scaled_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM)); |
| 848 | if (!dev->scaled_line) | 848 | if (!dev->scaled_line) |
| 849 | goto free_dev; | 849 | goto free_dev; |
| 850 | dev->blended_line = vzalloc(MAX_ZOOM * MAX_WIDTH); | 850 | dev->blended_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM)); |
| 851 | if (!dev->blended_line) | 851 | if (!dev->blended_line) |
| 852 | goto free_dev; | 852 | goto free_dev; |
| 853 | 853 | ||
| @@ -859,8 +859,9 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) | |||
| 859 | /* create a string array containing the names of all the preset timings */ | 859 | /* create a string array containing the names of all the preset timings */ |
| 860 | while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width) | 860 | while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width) |
| 861 | dev->query_dv_timings_size++; | 861 | dev->query_dv_timings_size++; |
| 862 | dev->query_dv_timings_qmenu = kmalloc(dev->query_dv_timings_size * | 862 | dev->query_dv_timings_qmenu = kmalloc_array(dev->query_dv_timings_size, |
| 863 | (sizeof(void *) + 32), GFP_KERNEL); | 863 | (sizeof(void *) + 32), |
| 864 | GFP_KERNEL); | ||
| 864 | if (dev->query_dv_timings_qmenu == NULL) | 865 | if (dev->query_dv_timings_qmenu == NULL) |
| 865 | goto free_dev; | 866 | goto free_dev; |
| 866 | for (i = 0; i < dev->query_dv_timings_size; i++) { | 867 | for (i = 0; i < dev->query_dv_timings_size; i++) { |
diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index da276a85aa95..36a29e13109e 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c | |||
| @@ -630,7 +630,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, | |||
| 630 | entity->source_pad = num_pads - 1; | 630 | entity->source_pad = num_pads - 1; |
| 631 | 631 | ||
| 632 | /* Allocate and initialize pads. */ | 632 | /* Allocate and initialize pads. */ |
| 633 | entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads), | 633 | entity->pads = devm_kcalloc(vsp1->dev, |
| 634 | num_pads, sizeof(*entity->pads), | ||
| 634 | GFP_KERNEL); | 635 | GFP_KERNEL); |
| 635 | if (entity->pads == NULL) | 636 | if (entity->pads == NULL) |
| 636 | return -ENOMEM; | 637 | return -ENOMEM; |
diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index 6bb28cd49dae..6d95ec1e9a6b 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c | |||
| @@ -532,7 +532,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev) | |||
| 532 | 532 | ||
| 533 | /* Register the subdevices notifier. */ | 533 | /* Register the subdevices notifier. */ |
| 534 | num_subdevs = xdev->num_subdevs; | 534 | num_subdevs = xdev->num_subdevs; |
| 535 | subdevs = devm_kzalloc(xdev->dev, sizeof(*subdevs) * num_subdevs, | 535 | subdevs = devm_kcalloc(xdev->dev, num_subdevs, sizeof(*subdevs), |
| 536 | GFP_KERNEL); | 536 | GFP_KERNEL); |
| 537 | if (subdevs == NULL) { | 537 | if (subdevs == NULL) { |
| 538 | ret = -ENOMEM; | 538 | ret = -ENOMEM; |
diff --git a/drivers/media/usb/au0828/au0828-video.c b/drivers/media/usb/au0828/au0828-video.c index 964cd7bcdd2c..70e187971590 100644 --- a/drivers/media/usb/au0828/au0828-video.c +++ b/drivers/media/usb/au0828/au0828-video.c | |||
| @@ -217,14 +217,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, | |||
| 217 | dev->isoc_ctl.isoc_copy = isoc_copy; | 217 | dev->isoc_ctl.isoc_copy = isoc_copy; |
| 218 | dev->isoc_ctl.num_bufs = num_bufs; | 218 | dev->isoc_ctl.num_bufs = num_bufs; |
| 219 | 219 | ||
| 220 | dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | 220 | dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 221 | if (!dev->isoc_ctl.urb) { | 221 | if (!dev->isoc_ctl.urb) { |
| 222 | au0828_isocdbg("cannot alloc memory for usb buffers\n"); | 222 | au0828_isocdbg("cannot alloc memory for usb buffers\n"); |
| 223 | return -ENOMEM; | 223 | return -ENOMEM; |
| 224 | } | 224 | } |
| 225 | 225 | ||
| 226 | dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, | 226 | dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *), |
| 227 | GFP_KERNEL); | 227 | GFP_KERNEL); |
| 228 | if (!dev->isoc_ctl.transfer_buffer) { | 228 | if (!dev->isoc_ctl.transfer_buffer) { |
| 229 | au0828_isocdbg("cannot allocate memory for usb transfer\n"); | 229 | au0828_isocdbg("cannot allocate memory for usb transfer\n"); |
| 230 | kfree(dev->isoc_ctl.urb); | 230 | kfree(dev->isoc_ctl.urb); |
diff --git a/drivers/media/usb/cpia2/cpia2_usb.c b/drivers/media/usb/cpia2/cpia2_usb.c index b51fc372ca25..a771e0a52610 100644 --- a/drivers/media/usb/cpia2/cpia2_usb.c +++ b/drivers/media/usb/cpia2/cpia2_usb.c | |||
| @@ -663,7 +663,8 @@ static int submit_urbs(struct camera_data *cam) | |||
| 663 | if (cam->sbuf[i].data) | 663 | if (cam->sbuf[i].data) |
| 664 | continue; | 664 | continue; |
| 665 | cam->sbuf[i].data = | 665 | cam->sbuf[i].data = |
| 666 | kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL); | 666 | kmalloc_array(FRAME_SIZE_PER_DESC, FRAMES_PER_DESC, |
| 667 | GFP_KERNEL); | ||
| 667 | if (!cam->sbuf[i].data) { | 668 | if (!cam->sbuf[i].data) { |
| 668 | while (--i >= 0) { | 669 | while (--i >= 0) { |
| 669 | kfree(cam->sbuf[i].data); | 670 | kfree(cam->sbuf[i].data); |
diff --git a/drivers/media/usb/cx231xx/cx231xx-audio.c b/drivers/media/usb/cx231xx/cx231xx-audio.c index d96236d786d1..c4a84fb930b6 100644 --- a/drivers/media/usb/cx231xx/cx231xx-audio.c +++ b/drivers/media/usb/cx231xx/cx231xx-audio.c | |||
| @@ -710,7 +710,7 @@ static int cx231xx_audio_init(struct cx231xx *dev) | |||
| 710 | dev_info(dev->dev, | 710 | dev_info(dev->dev, |
| 711 | "audio EndPoint Addr 0x%x, Alternate settings: %i\n", | 711 | "audio EndPoint Addr 0x%x, Alternate settings: %i\n", |
| 712 | adev->end_point_addr, adev->num_alt); | 712 | adev->end_point_addr, adev->num_alt); |
| 713 | adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL); | 713 | adev->alt_max_pkt_size = kmalloc_array(32, adev->num_alt, GFP_KERNEL); |
| 714 | if (!adev->alt_max_pkt_size) { | 714 | if (!adev->alt_max_pkt_size) { |
| 715 | err = -ENOMEM; | 715 | err = -ENOMEM; |
| 716 | goto err_free_card; | 716 | goto err_free_card; |
diff --git a/drivers/media/usb/cx231xx/cx231xx-core.c b/drivers/media/usb/cx231xx/cx231xx-core.c index 4f43668df15d..53d846dea3d2 100644 --- a/drivers/media/usb/cx231xx/cx231xx-core.c +++ b/drivers/media/usb/cx231xx/cx231xx-core.c | |||
| @@ -1034,7 +1034,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
| 1034 | dma_q->partial_buf[i] = 0; | 1034 | dma_q->partial_buf[i] = 0; |
| 1035 | 1035 | ||
| 1036 | dev->video_mode.isoc_ctl.urb = | 1036 | dev->video_mode.isoc_ctl.urb = |
| 1037 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1037 | kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 1038 | if (!dev->video_mode.isoc_ctl.urb) { | 1038 | if (!dev->video_mode.isoc_ctl.urb) { |
| 1039 | dev_err(dev->dev, | 1039 | dev_err(dev->dev, |
| 1040 | "cannot alloc memory for usb buffers\n"); | 1040 | "cannot alloc memory for usb buffers\n"); |
| @@ -1042,7 +1042,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, | |||
| 1042 | } | 1042 | } |
| 1043 | 1043 | ||
| 1044 | dev->video_mode.isoc_ctl.transfer_buffer = | 1044 | dev->video_mode.isoc_ctl.transfer_buffer = |
| 1045 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1045 | kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 1046 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { | 1046 | if (!dev->video_mode.isoc_ctl.transfer_buffer) { |
| 1047 | dev_err(dev->dev, | 1047 | dev_err(dev->dev, |
| 1048 | "cannot allocate memory for usbtransfer\n"); | 1048 | "cannot allocate memory for usbtransfer\n"); |
| @@ -1169,7 +1169,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
| 1169 | dma_q->partial_buf[i] = 0; | 1169 | dma_q->partial_buf[i] = 0; |
| 1170 | 1170 | ||
| 1171 | dev->video_mode.bulk_ctl.urb = | 1171 | dev->video_mode.bulk_ctl.urb = |
| 1172 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1172 | kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 1173 | if (!dev->video_mode.bulk_ctl.urb) { | 1173 | if (!dev->video_mode.bulk_ctl.urb) { |
| 1174 | dev_err(dev->dev, | 1174 | dev_err(dev->dev, |
| 1175 | "cannot alloc memory for usb buffers\n"); | 1175 | "cannot alloc memory for usb buffers\n"); |
| @@ -1177,7 +1177,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, | |||
| 1177 | } | 1177 | } |
| 1178 | 1178 | ||
| 1179 | dev->video_mode.bulk_ctl.transfer_buffer = | 1179 | dev->video_mode.bulk_ctl.transfer_buffer = |
| 1180 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 1180 | kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 1181 | if (!dev->video_mode.bulk_ctl.transfer_buffer) { | 1181 | if (!dev->video_mode.bulk_ctl.transfer_buffer) { |
| 1182 | dev_err(dev->dev, | 1182 | dev_err(dev->dev, |
| 1183 | "cannot allocate memory for usbtransfer\n"); | 1183 | "cannot allocate memory for usbtransfer\n"); |
diff --git a/drivers/media/usb/cx231xx/cx231xx-vbi.c b/drivers/media/usb/cx231xx/cx231xx-vbi.c index d3bfe8e23b1f..b621cf1aa96b 100644 --- a/drivers/media/usb/cx231xx/cx231xx-vbi.c +++ b/drivers/media/usb/cx231xx/cx231xx-vbi.c | |||
| @@ -415,7 +415,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
| 415 | for (i = 0; i < 8; i++) | 415 | for (i = 0; i < 8; i++) |
| 416 | dma_q->partial_buf[i] = 0; | 416 | dma_q->partial_buf[i] = 0; |
| 417 | 417 | ||
| 418 | dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs, | 418 | dev->vbi_mode.bulk_ctl.urb = kcalloc(num_bufs, sizeof(void *), |
| 419 | GFP_KERNEL); | 419 | GFP_KERNEL); |
| 420 | if (!dev->vbi_mode.bulk_ctl.urb) { | 420 | if (!dev->vbi_mode.bulk_ctl.urb) { |
| 421 | dev_err(dev->dev, | 421 | dev_err(dev->dev, |
| @@ -424,7 +424,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, | |||
| 424 | } | 424 | } |
| 425 | 425 | ||
| 426 | dev->vbi_mode.bulk_ctl.transfer_buffer = | 426 | dev->vbi_mode.bulk_ctl.transfer_buffer = |
| 427 | kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL); | 427 | kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 428 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer) { | 428 | if (!dev->vbi_mode.bulk_ctl.transfer_buffer) { |
| 429 | dev_err(dev->dev, | 429 | dev_err(dev->dev, |
| 430 | "cannot allocate memory for usbtransfer\n"); | 430 | "cannot allocate memory for usbtransfer\n"); |
diff --git a/drivers/media/usb/go7007/go7007-fw.c b/drivers/media/usb/go7007/go7007-fw.c index 87b4fc48ef09..24f5b615dc7a 100644 --- a/drivers/media/usb/go7007/go7007-fw.c +++ b/drivers/media/usb/go7007/go7007-fw.c | |||
| @@ -1579,7 +1579,7 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen) | |||
| 1579 | GO7007_FW_NAME); | 1579 | GO7007_FW_NAME); |
| 1580 | return -1; | 1580 | return -1; |
| 1581 | } | 1581 | } |
| 1582 | code = kzalloc(codespace * 2, GFP_KERNEL); | 1582 | code = kcalloc(codespace, 2, GFP_KERNEL); |
| 1583 | if (code == NULL) | 1583 | if (code == NULL) |
| 1584 | goto fw_failed; | 1584 | goto fw_failed; |
| 1585 | 1585 | ||
diff --git a/drivers/media/usb/go7007/go7007-usb.c b/drivers/media/usb/go7007/go7007-usb.c index ed9bcaf08d5e..19c6a0354ce0 100644 --- a/drivers/media/usb/go7007/go7007-usb.c +++ b/drivers/media/usb/go7007/go7007-usb.c | |||
| @@ -1143,7 +1143,8 @@ static int go7007_usb_probe(struct usb_interface *intf, | |||
| 1143 | usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL); | 1143 | usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL); |
| 1144 | if (usb->intr_urb == NULL) | 1144 | if (usb->intr_urb == NULL) |
| 1145 | goto allocfail; | 1145 | goto allocfail; |
| 1146 | usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL); | 1146 | usb->intr_urb->transfer_buffer = kmalloc_array(2, sizeof(u16), |
| 1147 | GFP_KERNEL); | ||
| 1147 | if (usb->intr_urb->transfer_buffer == NULL) | 1148 | if (usb->intr_urb->transfer_buffer == NULL) |
| 1148 | goto allocfail; | 1149 | goto allocfail; |
| 1149 | 1150 | ||
diff --git a/drivers/media/usb/gspca/t613.c b/drivers/media/usb/gspca/t613.c index 0ae557cd15ef..445782919446 100644 --- a/drivers/media/usb/gspca/t613.c +++ b/drivers/media/usb/gspca/t613.c | |||
| @@ -363,7 +363,7 @@ static void reg_w_ixbuf(struct gspca_dev *gspca_dev, | |||
| 363 | if (len * 2 <= USB_BUF_SZ) { | 363 | if (len * 2 <= USB_BUF_SZ) { |
| 364 | p = tmpbuf = gspca_dev->usb_buf; | 364 | p = tmpbuf = gspca_dev->usb_buf; |
| 365 | } else { | 365 | } else { |
| 366 | p = tmpbuf = kmalloc(len * 2, GFP_KERNEL); | 366 | p = tmpbuf = kmalloc_array(len, 2, GFP_KERNEL); |
| 367 | if (!tmpbuf) { | 367 | if (!tmpbuf) { |
| 368 | pr_err("Out of memory\n"); | 368 | pr_err("Out of memory\n"); |
| 369 | return; | 369 | return; |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c index e0353161ccd6..a8519da0020b 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-hdw.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-hdw.c | |||
| @@ -2413,7 +2413,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, | |||
| 2413 | 2413 | ||
| 2414 | hdw->control_cnt = CTRLDEF_COUNT; | 2414 | hdw->control_cnt = CTRLDEF_COUNT; |
| 2415 | hdw->control_cnt += MPEGDEF_COUNT; | 2415 | hdw->control_cnt += MPEGDEF_COUNT; |
| 2416 | hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt, | 2416 | hdw->controls = kcalloc(hdw->control_cnt, sizeof(struct pvr2_ctrl), |
| 2417 | GFP_KERNEL); | 2417 | GFP_KERNEL); |
| 2418 | if (!hdw->controls) goto fail; | 2418 | if (!hdw->controls) goto fail; |
| 2419 | hdw->hdw_desc = hdw_desc; | 2419 | hdw->hdw_desc = hdw_desc; |
diff --git a/drivers/media/usb/pvrusb2/pvrusb2-std.c b/drivers/media/usb/pvrusb2/pvrusb2-std.c index 21bb20dba82c..6b651f8b54df 100644 --- a/drivers/media/usb/pvrusb2/pvrusb2-std.c +++ b/drivers/media/usb/pvrusb2/pvrusb2-std.c | |||
| @@ -361,7 +361,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr, | |||
| 361 | std_cnt); | 361 | std_cnt); |
| 362 | if (!std_cnt) return NULL; // paranoia | 362 | if (!std_cnt) return NULL; // paranoia |
| 363 | 363 | ||
| 364 | stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt, | 364 | stddefs = kcalloc(std_cnt, sizeof(struct v4l2_standard), |
| 365 | GFP_KERNEL); | 365 | GFP_KERNEL); |
| 366 | if (!stddefs) | 366 | if (!stddefs) |
| 367 | return NULL; | 367 | return NULL; |
diff --git a/drivers/media/usb/stk1160/stk1160-core.c b/drivers/media/usb/stk1160/stk1160-core.c index 72bd893c9659..468f5ccf4ae6 100644 --- a/drivers/media/usb/stk1160/stk1160-core.c +++ b/drivers/media/usb/stk1160/stk1160-core.c | |||
| @@ -290,8 +290,9 @@ static int stk1160_probe(struct usb_interface *interface, | |||
| 290 | return -ENODEV; | 290 | return -ENODEV; |
| 291 | 291 | ||
| 292 | /* Alloc an array for all possible max_pkt_size */ | 292 | /* Alloc an array for all possible max_pkt_size */ |
| 293 | alt_max_pkt_size = kmalloc(sizeof(alt_max_pkt_size[0]) * | 293 | alt_max_pkt_size = kmalloc_array(interface->num_altsetting, |
| 294 | interface->num_altsetting, GFP_KERNEL); | 294 | sizeof(alt_max_pkt_size[0]), |
| 295 | GFP_KERNEL); | ||
| 295 | if (alt_max_pkt_size == NULL) | 296 | if (alt_max_pkt_size == NULL) |
| 296 | return -ENOMEM; | 297 | return -ENOMEM; |
| 297 | 298 | ||
diff --git a/drivers/media/usb/stk1160/stk1160-video.c b/drivers/media/usb/stk1160/stk1160-video.c index 423c03a0638d..2811f612820f 100644 --- a/drivers/media/usb/stk1160/stk1160-video.c +++ b/drivers/media/usb/stk1160/stk1160-video.c | |||
| @@ -439,14 +439,14 @@ int stk1160_alloc_isoc(struct stk1160 *dev) | |||
| 439 | 439 | ||
| 440 | dev->isoc_ctl.buf = NULL; | 440 | dev->isoc_ctl.buf = NULL; |
| 441 | dev->isoc_ctl.max_pkt_size = dev->max_pkt_size; | 441 | dev->isoc_ctl.max_pkt_size = dev->max_pkt_size; |
| 442 | dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | 442 | dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL); |
| 443 | if (!dev->isoc_ctl.urb) { | 443 | if (!dev->isoc_ctl.urb) { |
| 444 | stk1160_err("out of memory for urb array\n"); | 444 | stk1160_err("out of memory for urb array\n"); |
| 445 | return -ENOMEM; | 445 | return -ENOMEM; |
| 446 | } | 446 | } |
| 447 | 447 | ||
| 448 | dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs, | 448 | dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *), |
| 449 | GFP_KERNEL); | 449 | GFP_KERNEL); |
| 450 | if (!dev->isoc_ctl.transfer_buffer) { | 450 | if (!dev->isoc_ctl.transfer_buffer) { |
| 451 | stk1160_err("out of memory for usb transfers\n"); | 451 | stk1160_err("out of memory for usb transfers\n"); |
| 452 | kfree(dev->isoc_ctl.urb); | 452 | kfree(dev->isoc_ctl.urb); |
diff --git a/drivers/media/usb/stkwebcam/stk-webcam.c b/drivers/media/usb/stkwebcam/stk-webcam.c index 22389b56ec24..5accb5241072 100644 --- a/drivers/media/usb/stkwebcam/stk-webcam.c +++ b/drivers/media/usb/stkwebcam/stk-webcam.c | |||
| @@ -567,8 +567,9 @@ static int stk_prepare_sio_buffers(struct stk_camera *dev, unsigned n_sbufs) | |||
| 567 | if (dev->sio_bufs != NULL) | 567 | if (dev->sio_bufs != NULL) |
| 568 | pr_err("sio_bufs already allocated\n"); | 568 | pr_err("sio_bufs already allocated\n"); |
| 569 | else { | 569 | else { |
| 570 | dev->sio_bufs = kzalloc(n_sbufs * sizeof(struct stk_sio_buffer), | 570 | dev->sio_bufs = kcalloc(n_sbufs, |
| 571 | GFP_KERNEL); | 571 | sizeof(struct stk_sio_buffer), |
| 572 | GFP_KERNEL); | ||
| 572 | if (dev->sio_bufs == NULL) | 573 | if (dev->sio_bufs == NULL) |
| 573 | return -ENOMEM; | 574 | return -ENOMEM; |
| 574 | for (i = 0; i < n_sbufs; i++) { | 575 | for (i = 0; i < n_sbufs; i++) { |
diff --git a/drivers/media/usb/tm6000/tm6000-video.c b/drivers/media/usb/tm6000/tm6000-video.c index aa85fe31c835..96055de6e8ce 100644 --- a/drivers/media/usb/tm6000/tm6000-video.c +++ b/drivers/media/usb/tm6000/tm6000-video.c | |||
| @@ -463,11 +463,12 @@ static int tm6000_alloc_urb_buffers(struct tm6000_core *dev) | |||
| 463 | if (dev->urb_buffer) | 463 | if (dev->urb_buffer) |
| 464 | return 0; | 464 | return 0; |
| 465 | 465 | ||
| 466 | dev->urb_buffer = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | 466 | dev->urb_buffer = kmalloc_array(num_bufs, sizeof(void *), GFP_KERNEL); |
| 467 | if (!dev->urb_buffer) | 467 | if (!dev->urb_buffer) |
| 468 | return -ENOMEM; | 468 | return -ENOMEM; |
| 469 | 469 | ||
| 470 | dev->urb_dma = kmalloc(sizeof(dma_addr_t *)*num_bufs, GFP_KERNEL); | 470 | dev->urb_dma = kmalloc_array(num_bufs, sizeof(dma_addr_t *), |
| 471 | GFP_KERNEL); | ||
| 471 | if (!dev->urb_dma) | 472 | if (!dev->urb_dma) |
| 472 | return -ENOMEM; | 473 | return -ENOMEM; |
| 473 | 474 | ||
| @@ -583,12 +584,14 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) | |||
| 583 | 584 | ||
| 584 | dev->isoc_ctl.num_bufs = num_bufs; | 585 | dev->isoc_ctl.num_bufs = num_bufs; |
| 585 | 586 | ||
| 586 | dev->isoc_ctl.urb = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL); | 587 | dev->isoc_ctl.urb = kmalloc_array(num_bufs, sizeof(void *), |
| 588 | GFP_KERNEL); | ||
| 587 | if (!dev->isoc_ctl.urb) | 589 | if (!dev->isoc_ctl.urb) |
| 588 | return -ENOMEM; | 590 | return -ENOMEM; |
| 589 | 591 | ||
| 590 | dev->isoc_ctl.transfer_buffer = kmalloc(sizeof(void *)*num_bufs, | 592 | dev->isoc_ctl.transfer_buffer = kmalloc_array(num_bufs, |
| 591 | GFP_KERNEL); | 593 | sizeof(void *), |
| 594 | GFP_KERNEL); | ||
| 592 | if (!dev->isoc_ctl.transfer_buffer) { | 595 | if (!dev->isoc_ctl.transfer_buffer) { |
| 593 | kfree(dev->isoc_ctl.urb); | 596 | kfree(dev->isoc_ctl.urb); |
| 594 | return -ENOMEM; | 597 | return -ENOMEM; |
diff --git a/drivers/media/usb/usbtv/usbtv-video.c b/drivers/media/usb/usbtv/usbtv-video.c index ce79df643c7e..36a9a4017185 100644 --- a/drivers/media/usb/usbtv/usbtv-video.c +++ b/drivers/media/usb/usbtv/usbtv-video.c | |||
| @@ -507,7 +507,7 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv) | |||
| 507 | ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP); | 507 | ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP); |
| 508 | ip->interval = 1; | 508 | ip->interval = 1; |
| 509 | ip->transfer_flags = URB_ISO_ASAP; | 509 | ip->transfer_flags = URB_ISO_ASAP; |
| 510 | ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS, | 510 | ip->transfer_buffer = kcalloc(USBTV_ISOC_PACKETS, size, |
| 511 | GFP_KERNEL); | 511 | GFP_KERNEL); |
| 512 | if (!ip->transfer_buffer) { | 512 | if (!ip->transfer_buffer) { |
| 513 | usb_free_urb(ip); | 513 | usb_free_urb(ip); |
diff --git a/drivers/media/usb/usbvision/usbvision-video.c b/drivers/media/usb/usbvision/usbvision-video.c index 0f5954a1fea2..f29d1bef0293 100644 --- a/drivers/media/usb/usbvision/usbvision-video.c +++ b/drivers/media/usb/usbvision/usbvision-video.c | |||
| @@ -1492,7 +1492,8 @@ static int usbvision_probe(struct usb_interface *intf, | |||
| 1492 | 1492 | ||
| 1493 | usbvision->num_alt = uif->num_altsetting; | 1493 | usbvision->num_alt = uif->num_altsetting; |
| 1494 | PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); | 1494 | PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt); |
| 1495 | usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL); | 1495 | usbvision->alt_max_pkt_size = kmalloc_array(32, usbvision->num_alt, |
| 1496 | GFP_KERNEL); | ||
| 1496 | if (!usbvision->alt_max_pkt_size) { | 1497 | if (!usbvision->alt_max_pkt_size) { |
| 1497 | ret = -ENOMEM; | 1498 | ret = -ENOMEM; |
| 1498 | goto err_pkt; | 1499 | goto err_pkt; |
diff --git a/drivers/media/usb/uvc/uvc_video.c b/drivers/media/usb/uvc/uvc_video.c index b28c997a7ab0..a88b2e51a666 100644 --- a/drivers/media/usb/uvc/uvc_video.c +++ b/drivers/media/usb/uvc/uvc_video.c | |||
| @@ -513,8 +513,8 @@ static int uvc_video_clock_init(struct uvc_streaming *stream) | |||
| 513 | spin_lock_init(&clock->lock); | 513 | spin_lock_init(&clock->lock); |
| 514 | clock->size = 32; | 514 | clock->size = 32; |
| 515 | 515 | ||
| 516 | clock->samples = kmalloc(clock->size * sizeof(*clock->samples), | 516 | clock->samples = kmalloc_array(clock->size, sizeof(*clock->samples), |
| 517 | GFP_KERNEL); | 517 | GFP_KERNEL); |
| 518 | if (clock->samples == NULL) | 518 | if (clock->samples == NULL) |
| 519 | return -ENOMEM; | 519 | return -ENOMEM; |
| 520 | 520 | ||
diff --git a/drivers/media/v4l2-core/v4l2-event.c b/drivers/media/v4l2-core/v4l2-event.c index 968c2eb08b5a..127fe6eb91d9 100644 --- a/drivers/media/v4l2-core/v4l2-event.c +++ b/drivers/media/v4l2-core/v4l2-event.c | |||
| @@ -215,8 +215,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, | |||
| 215 | if (elems < 1) | 215 | if (elems < 1) |
| 216 | elems = 1; | 216 | elems = 1; |
| 217 | 217 | ||
| 218 | sev = kvzalloc(sizeof(*sev) + sizeof(struct v4l2_kevent) * elems, | 218 | sev = kvzalloc(struct_size(sev, events, elems), GFP_KERNEL); |
| 219 | GFP_KERNEL); | ||
| 220 | if (!sev) | 219 | if (!sev) |
| 221 | return -ENOMEM; | 220 | return -ENOMEM; |
| 222 | for (i = 0; i < elems; i++) | 221 | for (i = 0; i < elems; i++) |
diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 4ceef217de83..215b4804ada2 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c | |||
| @@ -412,9 +412,10 @@ static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash, | |||
| 412 | struct v4l2_ctrl_config *ctrl_cfg; | 412 | struct v4l2_ctrl_config *ctrl_cfg; |
| 413 | int i, ret, num_ctrls = 0; | 413 | int i, ret, num_ctrls = 0; |
| 414 | 414 | ||
| 415 | v4l2_flash->ctrls = devm_kzalloc(v4l2_flash->sd.dev, | 415 | v4l2_flash->ctrls = devm_kcalloc(v4l2_flash->sd.dev, |
| 416 | sizeof(*v4l2_flash->ctrls) * | 416 | STROBE_SOURCE + 1, |
| 417 | (STROBE_SOURCE + 1), GFP_KERNEL); | 417 | sizeof(*v4l2_flash->ctrls), |
| 418 | GFP_KERNEL); | ||
| 418 | if (!v4l2_flash->ctrls) | 419 | if (!v4l2_flash->ctrls) |
| 419 | return -ENOMEM; | 420 | return -ENOMEM; |
| 420 | 421 | ||
diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c index 2e5c346f9c30..08929c087e27 100644 --- a/drivers/media/v4l2-core/videobuf-dma-sg.c +++ b/drivers/media/v4l2-core/videobuf-dma-sg.c | |||
| @@ -69,7 +69,7 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt, | |||
| 69 | struct page *pg; | 69 | struct page *pg; |
| 70 | int i; | 70 | int i; |
| 71 | 71 | ||
| 72 | sglist = vzalloc(nr_pages * sizeof(*sglist)); | 72 | sglist = vzalloc(array_size(nr_pages, sizeof(*sglist))); |
| 73 | if (NULL == sglist) | 73 | if (NULL == sglist) |
| 74 | return NULL; | 74 | return NULL; |
| 75 | sg_init_table(sglist, nr_pages); | 75 | sg_init_table(sglist, nr_pages); |
| @@ -100,7 +100,7 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages, | |||
| 100 | 100 | ||
| 101 | if (NULL == pages[0]) | 101 | if (NULL == pages[0]) |
| 102 | return NULL; | 102 | return NULL; |
| 103 | sglist = vmalloc(nr_pages * sizeof(*sglist)); | 103 | sglist = vmalloc(array_size(nr_pages, sizeof(*sglist))); |
| 104 | if (NULL == sglist) | 104 | if (NULL == sglist) |
| 105 | return NULL; | 105 | return NULL; |
| 106 | sg_init_table(sglist, nr_pages); | 106 | sg_init_table(sglist, nr_pages); |
| @@ -175,7 +175,8 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, | |||
| 175 | dma->offset = data & ~PAGE_MASK; | 175 | dma->offset = data & ~PAGE_MASK; |
| 176 | dma->size = size; | 176 | dma->size = size; |
| 177 | dma->nr_pages = last-first+1; | 177 | dma->nr_pages = last-first+1; |
| 178 | dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL); | 178 | dma->pages = kmalloc_array(dma->nr_pages, sizeof(struct page *), |
| 179 | GFP_KERNEL); | ||
| 179 | if (NULL == dma->pages) | 180 | if (NULL == dma->pages) |
| 180 | return -ENOMEM; | 181 | return -ENOMEM; |
| 181 | 182 | ||
diff --git a/drivers/memory/of_memory.c b/drivers/memory/of_memory.c index 568f05ed961a..2f5ed7366eec 100644 --- a/drivers/memory/of_memory.c +++ b/drivers/memory/of_memory.c | |||
| @@ -126,8 +126,8 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr, | |||
| 126 | arr_sz++; | 126 | arr_sz++; |
| 127 | 127 | ||
| 128 | if (arr_sz) | 128 | if (arr_sz) |
| 129 | timings = devm_kzalloc(dev, sizeof(*timings) * arr_sz, | 129 | timings = devm_kcalloc(dev, arr_sz, sizeof(*timings), |
| 130 | GFP_KERNEL); | 130 | GFP_KERNEL); |
| 131 | 131 | ||
| 132 | if (!timings) | 132 | if (!timings) |
| 133 | goto default_timings; | 133 | goto default_timings; |
diff --git a/drivers/memstick/core/ms_block.c b/drivers/memstick/core/ms_block.c index a15181fa45f7..716fc8ed31d3 100644 --- a/drivers/memstick/core/ms_block.c +++ b/drivers/memstick/core/ms_block.c | |||
| @@ -1201,7 +1201,8 @@ static int msb_read_boot_blocks(struct msb_data *msb) | |||
| 1201 | dbg_verbose("Start of a scan for the boot blocks"); | 1201 | dbg_verbose("Start of a scan for the boot blocks"); |
| 1202 | 1202 | ||
| 1203 | if (!msb->boot_page) { | 1203 | if (!msb->boot_page) { |
| 1204 | page = kmalloc(sizeof(struct ms_boot_page)*2, GFP_KERNEL); | 1204 | page = kmalloc_array(2, sizeof(struct ms_boot_page), |
| 1205 | GFP_KERNEL); | ||
| 1205 | if (!page) | 1206 | if (!page) |
| 1206 | return -ENOMEM; | 1207 | return -ENOMEM; |
| 1207 | 1208 | ||
| @@ -1341,7 +1342,8 @@ static int msb_ftl_initialize(struct msb_data *msb) | |||
| 1341 | msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); | 1342 | msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); |
| 1342 | msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); | 1343 | msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL); |
| 1343 | msb->lba_to_pba_table = | 1344 | msb->lba_to_pba_table = |
| 1344 | kmalloc(msb->logical_block_count * sizeof(u16), GFP_KERNEL); | 1345 | kmalloc_array(msb->logical_block_count, sizeof(u16), |
| 1346 | GFP_KERNEL); | ||
| 1345 | 1347 | ||
| 1346 | if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table || | 1348 | if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table || |
| 1347 | !msb->erased_blocks_bitmap) { | 1349 | !msb->erased_blocks_bitmap) { |
diff --git a/drivers/message/fusion/mptlan.c b/drivers/message/fusion/mptlan.c index 4cbed4d06aa7..ebc00d47abf5 100644 --- a/drivers/message/fusion/mptlan.c +++ b/drivers/message/fusion/mptlan.c | |||
| @@ -394,7 +394,8 @@ mpt_lan_open(struct net_device *dev) | |||
| 394 | "a moment.\n"); | 394 | "a moment.\n"); |
| 395 | } | 395 | } |
| 396 | 396 | ||
| 397 | priv->mpt_txfidx = kmalloc(priv->tx_max_out * sizeof(int), GFP_KERNEL); | 397 | priv->mpt_txfidx = kmalloc_array(priv->tx_max_out, sizeof(int), |
| 398 | GFP_KERNEL); | ||
| 398 | if (priv->mpt_txfidx == NULL) | 399 | if (priv->mpt_txfidx == NULL) |
| 399 | goto out; | 400 | goto out; |
| 400 | priv->mpt_txfidx_tail = -1; | 401 | priv->mpt_txfidx_tail = -1; |
| @@ -408,8 +409,8 @@ mpt_lan_open(struct net_device *dev) | |||
| 408 | 409 | ||
| 409 | dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n")); | 410 | dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n")); |
| 410 | 411 | ||
| 411 | priv->mpt_rxfidx = kmalloc(priv->max_buckets_out * sizeof(int), | 412 | priv->mpt_rxfidx = kmalloc_array(priv->max_buckets_out, sizeof(int), |
| 412 | GFP_KERNEL); | 413 | GFP_KERNEL); |
| 413 | if (priv->mpt_rxfidx == NULL) | 414 | if (priv->mpt_rxfidx == NULL) |
| 414 | goto out_SendCtl; | 415 | goto out_SendCtl; |
| 415 | priv->mpt_rxfidx_tail = -1; | 416 | priv->mpt_rxfidx_tail = -1; |
diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 831a1ceb2ed2..8d652b2f9d14 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c | |||
| @@ -2659,18 +2659,18 @@ static int ab8500_debug_probe(struct platform_device *plf) | |||
| 2659 | ab8500 = dev_get_drvdata(plf->dev.parent); | 2659 | ab8500 = dev_get_drvdata(plf->dev.parent); |
| 2660 | num_irqs = ab8500->mask_size; | 2660 | num_irqs = ab8500->mask_size; |
| 2661 | 2661 | ||
| 2662 | irq_count = devm_kzalloc(&plf->dev, | 2662 | irq_count = devm_kcalloc(&plf->dev, |
| 2663 | sizeof(*irq_count)*num_irqs, GFP_KERNEL); | 2663 | num_irqs, sizeof(*irq_count), GFP_KERNEL); |
| 2664 | if (!irq_count) | 2664 | if (!irq_count) |
| 2665 | return -ENOMEM; | 2665 | return -ENOMEM; |
| 2666 | 2666 | ||
| 2667 | dev_attr = devm_kzalloc(&plf->dev, | 2667 | dev_attr = devm_kcalloc(&plf->dev, |
| 2668 | sizeof(*dev_attr)*num_irqs, GFP_KERNEL); | 2668 | num_irqs, sizeof(*dev_attr), GFP_KERNEL); |
| 2669 | if (!dev_attr) | 2669 | if (!dev_attr) |
| 2670 | return -ENOMEM; | 2670 | return -ENOMEM; |
| 2671 | 2671 | ||
| 2672 | event_name = devm_kzalloc(&plf->dev, | 2672 | event_name = devm_kcalloc(&plf->dev, |
| 2673 | sizeof(*event_name)*num_irqs, GFP_KERNEL); | 2673 | num_irqs, sizeof(*event_name), GFP_KERNEL); |
| 2674 | if (!event_name) | 2674 | if (!event_name) |
| 2675 | return -ENOMEM; | 2675 | return -ENOMEM; |
| 2676 | 2676 | ||
diff --git a/drivers/mfd/cros_ec_dev.c b/drivers/mfd/cros_ec_dev.c index 4199cdd4ff89..306e1fd109bd 100644 --- a/drivers/mfd/cros_ec_dev.c +++ b/drivers/mfd/cros_ec_dev.c | |||
| @@ -299,13 +299,14 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) | |||
| 299 | resp = (struct ec_response_motion_sense *)msg->data; | 299 | resp = (struct ec_response_motion_sense *)msg->data; |
| 300 | sensor_num = resp->dump.sensor_count; | 300 | sensor_num = resp->dump.sensor_count; |
| 301 | /* Allocate 1 extra sensors in FIFO are needed */ | 301 | /* Allocate 1 extra sensors in FIFO are needed */ |
| 302 | sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 1), | 302 | sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell), |
| 303 | GFP_KERNEL); | 303 | GFP_KERNEL); |
| 304 | if (sensor_cells == NULL) | 304 | if (sensor_cells == NULL) |
| 305 | goto error; | 305 | goto error; |
| 306 | 306 | ||
| 307 | sensor_platforms = kzalloc(sizeof(struct cros_ec_sensor_platform) * | 307 | sensor_platforms = kcalloc(sensor_num + 1, |
| 308 | (sensor_num + 1), GFP_KERNEL); | 308 | sizeof(struct cros_ec_sensor_platform), |
| 309 | GFP_KERNEL); | ||
| 309 | if (sensor_platforms == NULL) | 310 | if (sensor_platforms == NULL) |
| 310 | goto error_platforms; | 311 | goto error_platforms; |
| 311 | 312 | ||
diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 4bf8b7781c77..01572b5e79e8 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c | |||
| @@ -477,7 +477,9 @@ static int htcpld_setup_chips(struct platform_device *pdev) | |||
| 477 | 477 | ||
| 478 | /* Setup each chip's output GPIOs */ | 478 | /* Setup each chip's output GPIOs */ |
| 479 | htcpld->nchips = pdata->num_chip; | 479 | htcpld->nchips = pdata->num_chip; |
| 480 | htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips, | 480 | htcpld->chip = devm_kcalloc(dev, |
| 481 | htcpld->nchips, | ||
| 482 | sizeof(struct htcpld_chip), | ||
| 481 | GFP_KERNEL); | 483 | GFP_KERNEL); |
| 482 | if (!htcpld->chip) | 484 | if (!htcpld->chip) |
| 483 | return -ENOMEM; | 485 | return -ENOMEM; |
diff --git a/drivers/mfd/mfd-core.c b/drivers/mfd/mfd-core.c index c57e407020f1..94e3f32ce935 100644 --- a/drivers/mfd/mfd-core.c +++ b/drivers/mfd/mfd-core.c | |||
| @@ -158,7 +158,7 @@ static int mfd_add_device(struct device *parent, int id, | |||
| 158 | if (!pdev) | 158 | if (!pdev) |
| 159 | goto fail_alloc; | 159 | goto fail_alloc; |
| 160 | 160 | ||
| 161 | res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL); | 161 | res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL); |
| 162 | if (!res) | 162 | if (!res) |
| 163 | goto fail_device; | 163 | goto fail_device; |
| 164 | 164 | ||
diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c index d2cc1eabac05..5276911caaec 100644 --- a/drivers/mfd/motorola-cpcap.c +++ b/drivers/mfd/motorola-cpcap.c | |||
| @@ -173,9 +173,9 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap) | |||
| 173 | int ret; | 173 | int ret; |
| 174 | 174 | ||
| 175 | cpcap->irqs = devm_kzalloc(&cpcap->spi->dev, | 175 | cpcap->irqs = devm_kzalloc(&cpcap->spi->dev, |
| 176 | sizeof(*cpcap->irqs) * | 176 | array3_size(sizeof(*cpcap->irqs), |
| 177 | CPCAP_NR_IRQ_REG_BANKS * | 177 | CPCAP_NR_IRQ_REG_BANKS, |
| 178 | cpcap->regmap_conf->val_bits, | 178 | cpcap->regmap_conf->val_bits), |
| 179 | GFP_KERNEL); | 179 | GFP_KERNEL); |
| 180 | if (!cpcap->irqs) | 180 | if (!cpcap->irqs) |
| 181 | return -ENOMEM; | 181 | return -ENOMEM; |
diff --git a/drivers/mfd/sprd-sc27xx-spi.c b/drivers/mfd/sprd-sc27xx-spi.c index 3460ef07623c..69df27769c21 100644 --- a/drivers/mfd/sprd-sc27xx-spi.c +++ b/drivers/mfd/sprd-sc27xx-spi.c | |||
| @@ -199,8 +199,9 @@ static int sprd_pmic_probe(struct spi_device *spi) | |||
| 199 | ddata->irq_chip.num_irqs = pdata->num_irqs; | 199 | ddata->irq_chip.num_irqs = pdata->num_irqs; |
| 200 | ddata->irq_chip.mask_invert = true; | 200 | ddata->irq_chip.mask_invert = true; |
| 201 | 201 | ||
| 202 | ddata->irqs = devm_kzalloc(&spi->dev, sizeof(struct regmap_irq) * | 202 | ddata->irqs = devm_kcalloc(&spi->dev, |
| 203 | pdata->num_irqs, GFP_KERNEL); | 203 | pdata->num_irqs, sizeof(struct regmap_irq), |
| 204 | GFP_KERNEL); | ||
| 204 | if (!ddata->irqs) | 205 | if (!ddata->irqs) |
| 205 | return -ENOMEM; | 206 | return -ENOMEM; |
| 206 | 207 | ||
diff --git a/drivers/mfd/timberdale.c b/drivers/mfd/timberdale.c index 7c13d2e7061c..05ecf828b2ab 100644 --- a/drivers/mfd/timberdale.c +++ b/drivers/mfd/timberdale.c | |||
| @@ -707,8 +707,8 @@ static int timb_probe(struct pci_dev *dev, | |||
| 707 | goto err_config; | 707 | goto err_config; |
| 708 | } | 708 | } |
| 709 | 709 | ||
| 710 | msix_entries = kzalloc(TIMBERDALE_NR_IRQS * sizeof(*msix_entries), | 710 | msix_entries = kcalloc(TIMBERDALE_NR_IRQS, sizeof(*msix_entries), |
| 711 | GFP_KERNEL); | 711 | GFP_KERNEL); |
| 712 | if (!msix_entries) | 712 | if (!msix_entries) |
| 713 | goto err_config; | 713 | goto err_config; |
| 714 | 714 | ||
diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index c649344fd7f2..4be3d239da9e 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c | |||
| @@ -1139,8 +1139,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) | |||
| 1139 | } | 1139 | } |
| 1140 | 1140 | ||
| 1141 | num_slaves = twl_get_num_slaves(); | 1141 | num_slaves = twl_get_num_slaves(); |
| 1142 | twl_priv->twl_modules = devm_kzalloc(&client->dev, | 1142 | twl_priv->twl_modules = devm_kcalloc(&client->dev, |
| 1143 | sizeof(struct twl_client) * num_slaves, | 1143 | num_slaves, |
| 1144 | sizeof(struct twl_client), | ||
| 1144 | GFP_KERNEL); | 1145 | GFP_KERNEL); |
| 1145 | if (!twl_priv->twl_modules) { | 1146 | if (!twl_priv->twl_modules) { |
| 1146 | status = -ENOMEM; | 1147 | status = -ENOMEM; |
diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 953d0790ffd5..5d5888ee2966 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c | |||
| @@ -368,9 +368,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) | |||
| 368 | goto err; | 368 | goto err; |
| 369 | } | 369 | } |
| 370 | 370 | ||
| 371 | wm8994->supplies = devm_kzalloc(wm8994->dev, | 371 | wm8994->supplies = devm_kcalloc(wm8994->dev, |
| 372 | sizeof(struct regulator_bulk_data) * | 372 | wm8994->num_supplies, |
| 373 | wm8994->num_supplies, GFP_KERNEL); | 373 | sizeof(struct regulator_bulk_data), |
| 374 | GFP_KERNEL); | ||
| 374 | if (!wm8994->supplies) { | 375 | if (!wm8994->supplies) { |
| 375 | ret = -ENOMEM; | 376 | ret = -ENOMEM; |
| 376 | goto err; | 377 | goto err; |
diff --git a/drivers/misc/altera-stapl/altera.c b/drivers/misc/altera-stapl/altera.c index f53e217e963f..ef83a9078646 100644 --- a/drivers/misc/altera-stapl/altera.c +++ b/drivers/misc/altera-stapl/altera.c | |||
| @@ -304,13 +304,13 @@ static int altera_execute(struct altera_state *astate, | |||
| 304 | if (sym_count <= 0) | 304 | if (sym_count <= 0) |
| 305 | goto exit_done; | 305 | goto exit_done; |
| 306 | 306 | ||
| 307 | vars = kzalloc(sym_count * sizeof(long), GFP_KERNEL); | 307 | vars = kcalloc(sym_count, sizeof(long), GFP_KERNEL); |
| 308 | 308 | ||
| 309 | if (vars == NULL) | 309 | if (vars == NULL) |
| 310 | status = -ENOMEM; | 310 | status = -ENOMEM; |
| 311 | 311 | ||
| 312 | if (status == 0) { | 312 | if (status == 0) { |
| 313 | var_size = kzalloc(sym_count * sizeof(s32), GFP_KERNEL); | 313 | var_size = kcalloc(sym_count, sizeof(s32), GFP_KERNEL); |
| 314 | 314 | ||
| 315 | if (var_size == NULL) | 315 | if (var_size == NULL) |
| 316 | status = -ENOMEM; | 316 | status = -ENOMEM; |
| @@ -1136,7 +1136,7 @@ exit_done: | |||
| 1136 | /* Allocate a writable buffer for this array */ | 1136 | /* Allocate a writable buffer for this array */ |
| 1137 | count = var_size[variable_id]; | 1137 | count = var_size[variable_id]; |
| 1138 | long_tmp = vars[variable_id]; | 1138 | long_tmp = vars[variable_id]; |
| 1139 | longptr_tmp = kzalloc(count * sizeof(long), | 1139 | longptr_tmp = kcalloc(count, sizeof(long), |
| 1140 | GFP_KERNEL); | 1140 | GFP_KERNEL); |
| 1141 | vars[variable_id] = (long)longptr_tmp; | 1141 | vars[variable_id] = (long)longptr_tmp; |
| 1142 | 1142 | ||
diff --git a/drivers/misc/cxl/guest.c b/drivers/misc/cxl/guest.c index f58b4b6c79f2..4644f16606a3 100644 --- a/drivers/misc/cxl/guest.c +++ b/drivers/misc/cxl/guest.c | |||
| @@ -89,7 +89,7 @@ static ssize_t guest_collect_vpd(struct cxl *adapter, struct cxl_afu *afu, | |||
| 89 | mod = 0; | 89 | mod = 0; |
| 90 | } | 90 | } |
| 91 | 91 | ||
| 92 | vpd_buf = kzalloc(entries * sizeof(unsigned long *), GFP_KERNEL); | 92 | vpd_buf = kcalloc(entries, sizeof(unsigned long *), GFP_KERNEL); |
| 93 | if (!vpd_buf) | 93 | if (!vpd_buf) |
| 94 | return -ENOMEM; | 94 | return -ENOMEM; |
| 95 | 95 | ||
diff --git a/drivers/misc/cxl/of.c b/drivers/misc/cxl/of.c index ec175ea5dfba..aff181cd0bf2 100644 --- a/drivers/misc/cxl/of.c +++ b/drivers/misc/cxl/of.c | |||
| @@ -302,7 +302,7 @@ static int read_adapter_irq_config(struct cxl *adapter, struct device_node *np) | |||
| 302 | if (nranges == 0 || (nranges * 2 * sizeof(int)) != len) | 302 | if (nranges == 0 || (nranges * 2 * sizeof(int)) != len) |
| 303 | return -EINVAL; | 303 | return -EINVAL; |
| 304 | 304 | ||
| 305 | adapter->guest->irq_avail = kzalloc(nranges * sizeof(struct irq_avail), | 305 | adapter->guest->irq_avail = kcalloc(nranges, sizeof(struct irq_avail), |
| 306 | GFP_KERNEL); | 306 | GFP_KERNEL); |
| 307 | if (adapter->guest->irq_avail == NULL) | 307 | if (adapter->guest->irq_avail == NULL) |
| 308 | return -ENOMEM; | 308 | return -ENOMEM; |
diff --git a/drivers/misc/eeprom/idt_89hpesx.c b/drivers/misc/eeprom/idt_89hpesx.c index 34a5a41578d7..59dc24bb70ec 100644 --- a/drivers/misc/eeprom/idt_89hpesx.c +++ b/drivers/misc/eeprom/idt_89hpesx.c | |||
| @@ -964,7 +964,7 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf, | |||
| 964 | if (colon_ch != NULL) { | 964 | if (colon_ch != NULL) { |
| 965 | csraddr_len = colon_ch - buf; | 965 | csraddr_len = colon_ch - buf; |
| 966 | csraddr_str = | 966 | csraddr_str = |
| 967 | kmalloc(sizeof(char)*(csraddr_len + 1), GFP_KERNEL); | 967 | kmalloc(csraddr_len + 1, GFP_KERNEL); |
| 968 | if (csraddr_str == NULL) { | 968 | if (csraddr_str == NULL) { |
| 969 | ret = -ENOMEM; | 969 | ret = -ENOMEM; |
| 970 | goto free_buf; | 970 | goto free_buf; |
diff --git a/drivers/misc/genwqe/card_ddcb.c b/drivers/misc/genwqe/card_ddcb.c index b7f8d35c17a9..656449cb4476 100644 --- a/drivers/misc/genwqe/card_ddcb.c +++ b/drivers/misc/genwqe/card_ddcb.c | |||
| @@ -1048,15 +1048,16 @@ static int setup_ddcb_queue(struct genwqe_dev *cd, struct ddcb_queue *queue) | |||
| 1048 | "[%s] **err: could not allocate DDCB **\n", __func__); | 1048 | "[%s] **err: could not allocate DDCB **\n", __func__); |
| 1049 | return -ENOMEM; | 1049 | return -ENOMEM; |
| 1050 | } | 1050 | } |
| 1051 | queue->ddcb_req = kzalloc(sizeof(struct ddcb_requ *) * | 1051 | queue->ddcb_req = kcalloc(queue->ddcb_max, sizeof(struct ddcb_requ *), |
| 1052 | queue->ddcb_max, GFP_KERNEL); | 1052 | GFP_KERNEL); |
| 1053 | if (!queue->ddcb_req) { | 1053 | if (!queue->ddcb_req) { |
| 1054 | rc = -ENOMEM; | 1054 | rc = -ENOMEM; |
| 1055 | goto free_ddcbs; | 1055 | goto free_ddcbs; |
| 1056 | } | 1056 | } |
| 1057 | 1057 | ||
| 1058 | queue->ddcb_waitqs = kzalloc(sizeof(wait_queue_head_t) * | 1058 | queue->ddcb_waitqs = kcalloc(queue->ddcb_max, |
| 1059 | queue->ddcb_max, GFP_KERNEL); | 1059 | sizeof(wait_queue_head_t), |
| 1060 | GFP_KERNEL); | ||
| 1060 | if (!queue->ddcb_waitqs) { | 1061 | if (!queue->ddcb_waitqs) { |
| 1061 | rc = -ENOMEM; | 1062 | rc = -ENOMEM; |
| 1062 | goto free_requs; | 1063 | goto free_requs; |
diff --git a/drivers/misc/sgi-xp/xpc_main.c b/drivers/misc/sgi-xp/xpc_main.c index 0c775d6fcf59..83fc748a91a7 100644 --- a/drivers/misc/sgi-xp/xpc_main.c +++ b/drivers/misc/sgi-xp/xpc_main.c | |||
| @@ -416,7 +416,8 @@ xpc_setup_ch_structures(struct xpc_partition *part) | |||
| 416 | * memory. | 416 | * memory. |
| 417 | */ | 417 | */ |
| 418 | DBUG_ON(part->channels != NULL); | 418 | DBUG_ON(part->channels != NULL); |
| 419 | part->channels = kzalloc(sizeof(struct xpc_channel) * XPC_MAX_NCHANNELS, | 419 | part->channels = kcalloc(XPC_MAX_NCHANNELS, |
| 420 | sizeof(struct xpc_channel), | ||
| 420 | GFP_KERNEL); | 421 | GFP_KERNEL); |
| 421 | if (part->channels == NULL) { | 422 | if (part->channels == NULL) { |
| 422 | dev_err(xpc_chan, "can't get memory for channels\n"); | 423 | dev_err(xpc_chan, "can't get memory for channels\n"); |
| @@ -905,8 +906,9 @@ xpc_setup_partitions(void) | |||
| 905 | short partid; | 906 | short partid; |
| 906 | struct xpc_partition *part; | 907 | struct xpc_partition *part; |
| 907 | 908 | ||
| 908 | xpc_partitions = kzalloc(sizeof(struct xpc_partition) * | 909 | xpc_partitions = kcalloc(xp_max_npartitions, |
| 909 | xp_max_npartitions, GFP_KERNEL); | 910 | sizeof(struct xpc_partition), |
| 911 | GFP_KERNEL); | ||
| 910 | if (xpc_partitions == NULL) { | 912 | if (xpc_partitions == NULL) { |
| 911 | dev_err(xpc_part, "can't get memory for partition structure\n"); | 913 | dev_err(xpc_part, "can't get memory for partition structure\n"); |
| 912 | return -ENOMEM; | 914 | return -ENOMEM; |
diff --git a/drivers/misc/sgi-xp/xpc_partition.c b/drivers/misc/sgi-xp/xpc_partition.c index 6956f7e7d439..7284413dabfd 100644 --- a/drivers/misc/sgi-xp/xpc_partition.c +++ b/drivers/misc/sgi-xp/xpc_partition.c | |||
| @@ -425,7 +425,7 @@ xpc_discovery(void) | |||
| 425 | if (remote_rp == NULL) | 425 | if (remote_rp == NULL) |
| 426 | return; | 426 | return; |
| 427 | 427 | ||
| 428 | discovered_nasids = kzalloc(sizeof(long) * xpc_nasid_mask_nlongs, | 428 | discovered_nasids = kcalloc(xpc_nasid_mask_nlongs, sizeof(long), |
| 429 | GFP_KERNEL); | 429 | GFP_KERNEL); |
| 430 | if (discovered_nasids == NULL) { | 430 | if (discovered_nasids == NULL) { |
| 431 | kfree(remote_rp_base); | 431 | kfree(remote_rp_base); |
diff --git a/drivers/misc/sgi-xp/xpnet.c b/drivers/misc/sgi-xp/xpnet.c index 216d5c756236..44d750d98bc8 100644 --- a/drivers/misc/sgi-xp/xpnet.c +++ b/drivers/misc/sgi-xp/xpnet.c | |||
| @@ -520,8 +520,9 @@ xpnet_init(void) | |||
| 520 | 520 | ||
| 521 | dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); | 521 | dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME); |
| 522 | 522 | ||
| 523 | xpnet_broadcast_partitions = kzalloc(BITS_TO_LONGS(xp_max_npartitions) * | 523 | xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions), |
| 524 | sizeof(long), GFP_KERNEL); | 524 | sizeof(long), |
| 525 | GFP_KERNEL); | ||
| 525 | if (xpnet_broadcast_partitions == NULL) | 526 | if (xpnet_broadcast_partitions == NULL) |
| 526 | return -ENOMEM; | 527 | return -ENOMEM; |
| 527 | 528 | ||
diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index fc0415771c00..c5dc6095686a 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c | |||
| @@ -185,7 +185,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) | |||
| 185 | * after the reserved blocks from the dt are processed. | 185 | * after the reserved blocks from the dt are processed. |
| 186 | */ | 186 | */ |
| 187 | nblocks = (np) ? of_get_available_child_count(np) + 1 : 1; | 187 | nblocks = (np) ? of_get_available_child_count(np) + 1 : 1; |
| 188 | rblocks = kzalloc((nblocks) * sizeof(*rblocks), GFP_KERNEL); | 188 | rblocks = kcalloc(nblocks, sizeof(*rblocks), GFP_KERNEL); |
| 189 | if (!rblocks) | 189 | if (!rblocks) |
| 190 | return -ENOMEM; | 190 | return -ENOMEM; |
| 191 | 191 | ||
| @@ -264,8 +264,8 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) | |||
| 264 | list_sort(NULL, &reserve_list, sram_reserve_cmp); | 264 | list_sort(NULL, &reserve_list, sram_reserve_cmp); |
| 265 | 265 | ||
| 266 | if (exports) { | 266 | if (exports) { |
| 267 | sram->partition = devm_kzalloc(sram->dev, | 267 | sram->partition = devm_kcalloc(sram->dev, |
| 268 | exports * sizeof(*sram->partition), | 268 | exports, sizeof(*sram->partition), |
| 269 | GFP_KERNEL); | 269 | GFP_KERNEL); |
| 270 | if (!sram->partition) { | 270 | if (!sram->partition) { |
| 271 | ret = -ENOMEM; | 271 | ret = -ENOMEM; |
diff --git a/drivers/misc/vmw_vmci/vmci_queue_pair.c b/drivers/misc/vmw_vmci/vmci_queue_pair.c index 0339538c182d..b4d7774cfe07 100644 --- a/drivers/misc/vmw_vmci/vmci_queue_pair.c +++ b/drivers/misc/vmw_vmci/vmci_queue_pair.c | |||
| @@ -449,12 +449,14 @@ static int qp_alloc_ppn_set(void *prod_q, | |||
| 449 | return VMCI_ERROR_ALREADY_EXISTS; | 449 | return VMCI_ERROR_ALREADY_EXISTS; |
| 450 | 450 | ||
| 451 | produce_ppns = | 451 | produce_ppns = |
| 452 | kmalloc(num_produce_pages * sizeof(*produce_ppns), GFP_KERNEL); | 452 | kmalloc_array(num_produce_pages, sizeof(*produce_ppns), |
| 453 | GFP_KERNEL); | ||
| 453 | if (!produce_ppns) | 454 | if (!produce_ppns) |
| 454 | return VMCI_ERROR_NO_MEM; | 455 | return VMCI_ERROR_NO_MEM; |
| 455 | 456 | ||
| 456 | consume_ppns = | 457 | consume_ppns = |
| 457 | kmalloc(num_consume_pages * sizeof(*consume_ppns), GFP_KERNEL); | 458 | kmalloc_array(num_consume_pages, sizeof(*consume_ppns), |
| 459 | GFP_KERNEL); | ||
| 458 | if (!consume_ppns) { | 460 | if (!consume_ppns) { |
| 459 | kfree(produce_ppns); | 461 | kfree(produce_ppns); |
| 460 | return VMCI_ERROR_NO_MEM; | 462 | return VMCI_ERROR_NO_MEM; |
diff --git a/drivers/mmc/host/sdhci-omap.c b/drivers/mmc/host/sdhci-omap.c index f3a7c8ece4be..88347ce78f23 100644 --- a/drivers/mmc/host/sdhci-omap.c +++ b/drivers/mmc/host/sdhci-omap.c | |||
| @@ -797,8 +797,10 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host | |||
| 797 | if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) | 797 | if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY)) |
| 798 | return 0; | 798 | return 0; |
| 799 | 799 | ||
| 800 | pinctrl_state = devm_kzalloc(dev, sizeof(*pinctrl_state) * | 800 | pinctrl_state = devm_kcalloc(dev, |
| 801 | (MMC_TIMING_MMC_HS200 + 1), GFP_KERNEL); | 801 | MMC_TIMING_MMC_HS200 + 1, |
| 802 | sizeof(*pinctrl_state), | ||
| 803 | GFP_KERNEL); | ||
| 802 | if (!pinctrl_state) | 804 | if (!pinctrl_state) |
| 803 | return -ENOMEM; | 805 | return -ENOMEM; |
| 804 | 806 | ||
diff --git a/drivers/mtd/ar7part.c b/drivers/mtd/ar7part.c index 90575deff0ae..fc15ec58230a 100644 --- a/drivers/mtd/ar7part.c +++ b/drivers/mtd/ar7part.c | |||
| @@ -55,7 +55,7 @@ static int create_mtd_partitions(struct mtd_info *master, | |||
| 55 | int retries = 10; | 55 | int retries = 10; |
| 56 | struct mtd_partition *ar7_parts; | 56 | struct mtd_partition *ar7_parts; |
| 57 | 57 | ||
| 58 | ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL); | 58 | ar7_parts = kcalloc(AR7_PARTS, sizeof(*ar7_parts), GFP_KERNEL); |
| 59 | if (!ar7_parts) | 59 | if (!ar7_parts) |
| 60 | return -ENOMEM; | 60 | return -ENOMEM; |
| 61 | ar7_parts[0].name = "loader"; | 61 | ar7_parts[0].name = "loader"; |
diff --git a/drivers/mtd/bcm47xxpart.c b/drivers/mtd/bcm47xxpart.c index 0f93d2239352..fc424b185b08 100644 --- a/drivers/mtd/bcm47xxpart.c +++ b/drivers/mtd/bcm47xxpart.c | |||
| @@ -110,7 +110,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, | |||
| 110 | blocksize = 0x1000; | 110 | blocksize = 0x1000; |
| 111 | 111 | ||
| 112 | /* Alloc */ | 112 | /* Alloc */ |
| 113 | parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS, | 113 | parts = kcalloc(BCM47XXPART_MAX_PARTS, sizeof(struct mtd_partition), |
| 114 | GFP_KERNEL); | 114 | GFP_KERNEL); |
| 115 | if (!parts) | 115 | if (!parts) |
| 116 | return -ENOMEM; | 116 | return -ENOMEM; |
diff --git a/drivers/mtd/chips/cfi_cmdset_0001.c b/drivers/mtd/chips/cfi_cmdset_0001.c index f5695be14499..6e8e7b1bb34b 100644 --- a/drivers/mtd/chips/cfi_cmdset_0001.c +++ b/drivers/mtd/chips/cfi_cmdset_0001.c | |||
| @@ -608,8 +608,9 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) | |||
| 608 | mtd->size = devsize * cfi->numchips; | 608 | mtd->size = devsize * cfi->numchips; |
| 609 | 609 | ||
| 610 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; | 610 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; |
| 611 | mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info) | 611 | mtd->eraseregions = kcalloc(mtd->numeraseregions, |
| 612 | * mtd->numeraseregions, GFP_KERNEL); | 612 | sizeof(struct mtd_erase_region_info), |
| 613 | GFP_KERNEL); | ||
| 613 | if (!mtd->eraseregions) | 614 | if (!mtd->eraseregions) |
| 614 | goto setup_err; | 615 | goto setup_err; |
| 615 | 616 | ||
| @@ -758,7 +759,9 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd, | |||
| 758 | newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL); | 759 | newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL); |
| 759 | if (!newcfi) | 760 | if (!newcfi) |
| 760 | return -ENOMEM; | 761 | return -ENOMEM; |
| 761 | shared = kmalloc(sizeof(struct flchip_shared) * cfi->numchips, GFP_KERNEL); | 762 | shared = kmalloc_array(cfi->numchips, |
| 763 | sizeof(struct flchip_shared), | ||
| 764 | GFP_KERNEL); | ||
| 762 | if (!shared) { | 765 | if (!shared) { |
| 763 | kfree(newcfi); | 766 | kfree(newcfi); |
| 764 | return -ENOMEM; | 767 | return -ENOMEM; |
diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 7c889eca9ab0..a0c655628d6d 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c | |||
| @@ -692,8 +692,9 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) | |||
| 692 | mtd->size = devsize * cfi->numchips; | 692 | mtd->size = devsize * cfi->numchips; |
| 693 | 693 | ||
| 694 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; | 694 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; |
| 695 | mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) | 695 | mtd->eraseregions = kmalloc_array(mtd->numeraseregions, |
| 696 | * mtd->numeraseregions, GFP_KERNEL); | 696 | sizeof(struct mtd_erase_region_info), |
| 697 | GFP_KERNEL); | ||
| 697 | if (!mtd->eraseregions) | 698 | if (!mtd->eraseregions) |
| 698 | goto setup_err; | 699 | goto setup_err; |
| 699 | 700 | ||
| @@ -2635,7 +2636,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, | |||
| 2635 | * first check the locking status of all sectors and save | 2636 | * first check the locking status of all sectors and save |
| 2636 | * it for future use. | 2637 | * it for future use. |
| 2637 | */ | 2638 | */ |
| 2638 | sect = kzalloc(MAX_SECTORS * sizeof(struct ppb_lock), GFP_KERNEL); | 2639 | sect = kcalloc(MAX_SECTORS, sizeof(struct ppb_lock), GFP_KERNEL); |
| 2639 | if (!sect) | 2640 | if (!sect) |
| 2640 | return -ENOMEM; | 2641 | return -ENOMEM; |
| 2641 | 2642 | ||
diff --git a/drivers/mtd/chips/cfi_cmdset_0020.c b/drivers/mtd/chips/cfi_cmdset_0020.c index 7b7658a05036..35aa72b720a6 100644 --- a/drivers/mtd/chips/cfi_cmdset_0020.c +++ b/drivers/mtd/chips/cfi_cmdset_0020.c | |||
| @@ -184,8 +184,9 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) | |||
| 184 | mtd->size = devsize * cfi->numchips; | 184 | mtd->size = devsize * cfi->numchips; |
| 185 | 185 | ||
| 186 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; | 186 | mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips; |
| 187 | mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info) | 187 | mtd->eraseregions = kmalloc_array(mtd->numeraseregions, |
| 188 | * mtd->numeraseregions, GFP_KERNEL); | 188 | sizeof(struct mtd_erase_region_info), |
| 189 | GFP_KERNEL); | ||
| 189 | if (!mtd->eraseregions) { | 190 | if (!mtd->eraseregions) { |
| 190 | kfree(cfi->cmdset_priv); | 191 | kfree(cfi->cmdset_priv); |
| 191 | kfree(mtd); | 192 | kfree(mtd); |
diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index 802d8f159e90..512bd4c2eec0 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c | |||
| @@ -1827,7 +1827,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) | |||
| 1827 | mtd->dev.parent = dev; | 1827 | mtd->dev.parent = dev; |
| 1828 | bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1, | 1828 | bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1, |
| 1829 | 8 * DOC_LAYOUT_PAGE_SIZE); | 1829 | 8 * DOC_LAYOUT_PAGE_SIZE); |
| 1830 | docg3->bbt = kzalloc(bbt_nbpages * DOC_LAYOUT_PAGE_SIZE, GFP_KERNEL); | 1830 | docg3->bbt = kcalloc(DOC_LAYOUT_PAGE_SIZE, bbt_nbpages, GFP_KERNEL); |
| 1831 | if (!docg3->bbt) | 1831 | if (!docg3->bbt) |
| 1832 | goto nomem3; | 1832 | goto nomem3; |
| 1833 | 1833 | ||
| @@ -1993,7 +1993,7 @@ static int __init docg3_probe(struct platform_device *pdev) | |||
| 1993 | base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE); | 1993 | base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE); |
| 1994 | 1994 | ||
| 1995 | ret = -ENOMEM; | 1995 | ret = -ENOMEM; |
| 1996 | cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS, | 1996 | cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade), |
| 1997 | GFP_KERNEL); | 1997 | GFP_KERNEL); |
| 1998 | if (!cascade) | 1998 | if (!cascade) |
| 1999 | return ret; | 1999 | return ret; |
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c index ef6ad2551d57..2578f27914ef 100644 --- a/drivers/mtd/ftl.c +++ b/drivers/mtd/ftl.c | |||
| @@ -201,15 +201,16 @@ static int build_maps(partition_t *part) | |||
| 201 | /* Set up erase unit maps */ | 201 | /* Set up erase unit maps */ |
| 202 | part->DataUnits = le16_to_cpu(part->header.NumEraseUnits) - | 202 | part->DataUnits = le16_to_cpu(part->header.NumEraseUnits) - |
| 203 | part->header.NumTransferUnits; | 203 | part->header.NumTransferUnits; |
| 204 | part->EUNInfo = kmalloc(part->DataUnits * sizeof(struct eun_info_t), | 204 | part->EUNInfo = kmalloc_array(part->DataUnits, sizeof(struct eun_info_t), |
| 205 | GFP_KERNEL); | 205 | GFP_KERNEL); |
| 206 | if (!part->EUNInfo) | 206 | if (!part->EUNInfo) |
| 207 | goto out; | 207 | goto out; |
| 208 | for (i = 0; i < part->DataUnits; i++) | 208 | for (i = 0; i < part->DataUnits; i++) |
| 209 | part->EUNInfo[i].Offset = 0xffffffff; | 209 | part->EUNInfo[i].Offset = 0xffffffff; |
| 210 | part->XferInfo = | 210 | part->XferInfo = |
| 211 | kmalloc(part->header.NumTransferUnits * sizeof(struct xfer_info_t), | 211 | kmalloc_array(part->header.NumTransferUnits, |
| 212 | GFP_KERNEL); | 212 | sizeof(struct xfer_info_t), |
| 213 | GFP_KERNEL); | ||
| 213 | if (!part->XferInfo) | 214 | if (!part->XferInfo) |
| 214 | goto out_EUNInfo; | 215 | goto out_EUNInfo; |
| 215 | 216 | ||
| @@ -262,15 +263,15 @@ static int build_maps(partition_t *part) | |||
| 262 | 263 | ||
| 263 | /* Set up virtual page map */ | 264 | /* Set up virtual page map */ |
| 264 | blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; | 265 | blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; |
| 265 | part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t)); | 266 | part->VirtualBlockMap = vmalloc(array_size(blocks, sizeof(uint32_t))); |
| 266 | if (!part->VirtualBlockMap) | 267 | if (!part->VirtualBlockMap) |
| 267 | goto out_XferInfo; | 268 | goto out_XferInfo; |
| 268 | 269 | ||
| 269 | memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t)); | 270 | memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t)); |
| 270 | part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize; | 271 | part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize; |
| 271 | 272 | ||
| 272 | part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(uint32_t), | 273 | part->bam_cache = kmalloc_array(part->BlocksPerUnit, sizeof(uint32_t), |
| 273 | GFP_KERNEL); | 274 | GFP_KERNEL); |
| 274 | if (!part->bam_cache) | 275 | if (!part->bam_cache) |
| 275 | goto out_VirtualBlockMap; | 276 | goto out_VirtualBlockMap; |
| 276 | 277 | ||
diff --git a/drivers/mtd/inftlmount.c b/drivers/mtd/inftlmount.c index 2d598412972d..10d977e9709d 100644 --- a/drivers/mtd/inftlmount.c +++ b/drivers/mtd/inftlmount.c | |||
| @@ -270,7 +270,8 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
| 270 | inftl->nb_blocks = ip->lastUnit + 1; | 270 | inftl->nb_blocks = ip->lastUnit + 1; |
| 271 | 271 | ||
| 272 | /* Memory alloc */ | 272 | /* Memory alloc */ |
| 273 | inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL); | 273 | inftl->PUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16), |
| 274 | GFP_KERNEL); | ||
| 274 | if (!inftl->PUtable) { | 275 | if (!inftl->PUtable) { |
| 275 | printk(KERN_WARNING "INFTL: allocation of PUtable " | 276 | printk(KERN_WARNING "INFTL: allocation of PUtable " |
| 276 | "failed (%zd bytes)\n", | 277 | "failed (%zd bytes)\n", |
| @@ -278,7 +279,8 @@ static int find_boot_record(struct INFTLrecord *inftl) | |||
| 278 | return -ENOMEM; | 279 | return -ENOMEM; |
| 279 | } | 280 | } |
| 280 | 281 | ||
| 281 | inftl->VUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL); | 282 | inftl->VUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16), |
| 283 | GFP_KERNEL); | ||
| 282 | if (!inftl->VUtable) { | 284 | if (!inftl->VUtable) { |
| 283 | kfree(inftl->PUtable); | 285 | kfree(inftl->PUtable); |
| 284 | printk(KERN_WARNING "INFTL: allocation of VUtable " | 286 | printk(KERN_WARNING "INFTL: allocation of VUtable " |
diff --git a/drivers/mtd/lpddr/lpddr_cmds.c b/drivers/mtd/lpddr/lpddr_cmds.c index 5c5ba3c7c79d..b13557fe52bd 100644 --- a/drivers/mtd/lpddr/lpddr_cmds.c +++ b/drivers/mtd/lpddr/lpddr_cmds.c | |||
| @@ -78,7 +78,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map) | |||
| 78 | mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift; | 78 | mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift; |
| 79 | mtd->writesize = 1 << lpddr->qinfo->BufSizeShift; | 79 | mtd->writesize = 1 << lpddr->qinfo->BufSizeShift; |
| 80 | 80 | ||
| 81 | shared = kmalloc(sizeof(struct flchip_shared) * lpddr->numchips, | 81 | shared = kmalloc_array(lpddr->numchips, sizeof(struct flchip_shared), |
| 82 | GFP_KERNEL); | 82 | GFP_KERNEL); |
| 83 | if (!shared) { | 83 | if (!shared) { |
| 84 | kfree(lpddr); | 84 | kfree(lpddr); |
diff --git a/drivers/mtd/maps/physmap_of_core.c b/drivers/mtd/maps/physmap_of_core.c index 527b1682381f..4129535b8e46 100644 --- a/drivers/mtd/maps/physmap_of_core.c +++ b/drivers/mtd/maps/physmap_of_core.c | |||
| @@ -124,7 +124,7 @@ static const char * const *of_get_probes(struct device_node *dp) | |||
| 124 | if (count < 0) | 124 | if (count < 0) |
| 125 | return part_probe_types_def; | 125 | return part_probe_types_def; |
| 126 | 126 | ||
| 127 | res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL); | 127 | res = kcalloc(count + 1, sizeof(*res), GFP_KERNEL); |
| 128 | if (!res) | 128 | if (!res) |
| 129 | return NULL; | 129 | return NULL; |
| 130 | 130 | ||
| @@ -197,7 +197,7 @@ static int of_flash_probe(struct platform_device *dev) | |||
| 197 | 197 | ||
| 198 | dev_set_drvdata(&dev->dev, info); | 198 | dev_set_drvdata(&dev->dev, info); |
| 199 | 199 | ||
| 200 | mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL); | 200 | mtd_list = kcalloc(count, sizeof(*mtd_list), GFP_KERNEL); |
| 201 | if (!mtd_list) | 201 | if (!mtd_list) |
| 202 | goto err_flash_remove; | 202 | goto err_flash_remove; |
| 203 | 203 | ||
diff --git a/drivers/mtd/maps/vmu-flash.c b/drivers/mtd/maps/vmu-flash.c index 6b223cfe92b7..c5d4b6589488 100644 --- a/drivers/mtd/maps/vmu-flash.c +++ b/drivers/mtd/maps/vmu-flash.c | |||
| @@ -629,15 +629,15 @@ static int vmu_connect(struct maple_device *mdev) | |||
| 629 | * Not sure there are actually any multi-partition devices in the | 629 | * Not sure there are actually any multi-partition devices in the |
| 630 | * real world, but the hardware supports them, so, so will we | 630 | * real world, but the hardware supports them, so, so will we |
| 631 | */ | 631 | */ |
| 632 | card->parts = kmalloc(sizeof(struct vmupart) * card->partitions, | 632 | card->parts = kmalloc_array(card->partitions, sizeof(struct vmupart), |
| 633 | GFP_KERNEL); | 633 | GFP_KERNEL); |
| 634 | if (!card->parts) { | 634 | if (!card->parts) { |
| 635 | error = -ENOMEM; | 635 | error = -ENOMEM; |
| 636 | goto fail_partitions; | 636 | goto fail_partitions; |
| 637 | } | 637 | } |
| 638 | 638 | ||
| 639 | card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions, | 639 | card->mtd = kmalloc_array(card->partitions, sizeof(struct mtd_info), |
| 640 | GFP_KERNEL); | 640 | GFP_KERNEL); |
| 641 | if (!card->mtd) { | 641 | if (!card->mtd) { |
| 642 | error = -ENOMEM; | 642 | error = -ENOMEM; |
| 643 | goto fail_mtd_info; | 643 | goto fail_mtd_info; |
diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index 6b86d1a73cf2..cbc5925e6440 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c | |||
| @@ -778,8 +778,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c | |||
| 778 | concat->mtd.erasesize = max_erasesize; | 778 | concat->mtd.erasesize = max_erasesize; |
| 779 | concat->mtd.numeraseregions = num_erase_region; | 779 | concat->mtd.numeraseregions = num_erase_region; |
| 780 | concat->mtd.eraseregions = erase_region_p = | 780 | concat->mtd.eraseregions = erase_region_p = |
| 781 | kmalloc(num_erase_region * | 781 | kmalloc_array(num_erase_region, |
| 782 | sizeof (struct mtd_erase_region_info), GFP_KERNEL); | 782 | sizeof(struct mtd_erase_region_info), |
| 783 | GFP_KERNEL); | ||
| 783 | if (!erase_region_p) { | 784 | if (!erase_region_p) { |
| 784 | kfree(concat); | 785 | kfree(concat); |
| 785 | printk | 786 | printk |
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 9f25111fd559..e078fc41aa61 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c | |||
| @@ -330,8 +330,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd) | |||
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | /* oops_page_used is a bit field */ | 332 | /* oops_page_used is a bit field */ |
| 333 | cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages, | 333 | cxt->oops_page_used = |
| 334 | BITS_PER_LONG) * sizeof(unsigned long)); | 334 | vmalloc(array_size(sizeof(unsigned long), |
| 335 | DIV_ROUND_UP(mtdoops_pages, | ||
| 336 | BITS_PER_LONG))); | ||
| 335 | if (!cxt->oops_page_used) { | 337 | if (!cxt->oops_page_used) { |
| 336 | printk(KERN_ERR "mtdoops: could not allocate page array\n"); | 338 | printk(KERN_ERR "mtdoops: could not allocate page array\n"); |
| 337 | return; | 339 | return; |
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c index 7161f8a17f62..d9dcb2d051b4 100644 --- a/drivers/mtd/mtdswap.c +++ b/drivers/mtd/mtdswap.c | |||
| @@ -1317,11 +1317,11 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, | |||
| 1317 | for (i = 0; i < MTDSWAP_TREE_CNT; i++) | 1317 | for (i = 0; i < MTDSWAP_TREE_CNT; i++) |
| 1318 | d->trees[i].root = RB_ROOT; | 1318 | d->trees[i].root = RB_ROOT; |
| 1319 | 1319 | ||
| 1320 | d->page_data = vmalloc(sizeof(int)*pages); | 1320 | d->page_data = vmalloc(array_size(pages, sizeof(int))); |
| 1321 | if (!d->page_data) | 1321 | if (!d->page_data) |
| 1322 | goto page_data_fail; | 1322 | goto page_data_fail; |
| 1323 | 1323 | ||
| 1324 | d->revmap = vmalloc(sizeof(int)*blocks); | 1324 | d->revmap = vmalloc(array_size(blocks, sizeof(int))); |
| 1325 | if (!d->revmap) | 1325 | if (!d->revmap) |
| 1326 | goto revmap_fail; | 1326 | goto revmap_fail; |
| 1327 | 1327 | ||
| @@ -1340,7 +1340,7 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, | |||
| 1340 | if (!d->page_buf) | 1340 | if (!d->page_buf) |
| 1341 | goto page_buf_fail; | 1341 | goto page_buf_fail; |
| 1342 | 1342 | ||
| 1343 | d->oob_buf = kmalloc(2 * mtd->oobavail, GFP_KERNEL); | 1343 | d->oob_buf = kmalloc_array(2, mtd->oobavail, GFP_KERNEL); |
| 1344 | if (!d->oob_buf) | 1344 | if (!d->oob_buf) |
| 1345 | goto oob_buf_fail; | 1345 | goto oob_buf_fail; |
| 1346 | 1346 | ||
diff --git a/drivers/mtd/nand/onenand/onenand_base.c b/drivers/mtd/nand/onenand/onenand_base.c index b7105192cb12..4ca4b194e7d7 100644 --- a/drivers/mtd/nand/onenand/onenand_base.c +++ b/drivers/mtd/nand/onenand/onenand_base.c | |||
| @@ -3721,8 +3721,10 @@ static int onenand_probe(struct mtd_info *mtd) | |||
| 3721 | this->dies = ONENAND_IS_DDP(this) ? 2 : 1; | 3721 | this->dies = ONENAND_IS_DDP(this) ? 2 : 1; |
| 3722 | /* Maximum possible erase regions */ | 3722 | /* Maximum possible erase regions */ |
| 3723 | mtd->numeraseregions = this->dies << 1; | 3723 | mtd->numeraseregions = this->dies << 1; |
| 3724 | mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info) | 3724 | mtd->eraseregions = |
| 3725 | * (this->dies << 1), GFP_KERNEL); | 3725 | kcalloc(this->dies << 1, |
| 3726 | sizeof(struct mtd_erase_region_info), | ||
| 3727 | GFP_KERNEL); | ||
| 3726 | if (!mtd->eraseregions) | 3728 | if (!mtd->eraseregions) |
| 3727 | return -ENOMEM; | 3729 | return -ENOMEM; |
| 3728 | } | 3730 | } |
diff --git a/drivers/mtd/nand/raw/nand_bch.c b/drivers/mtd/nand/raw/nand_bch.c index 7f11b68f6db1..b7387ace567a 100644 --- a/drivers/mtd/nand/raw/nand_bch.c +++ b/drivers/mtd/nand/raw/nand_bch.c | |||
| @@ -186,7 +186,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) | |||
| 186 | } | 186 | } |
| 187 | 187 | ||
| 188 | nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL); | 188 | nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL); |
| 189 | nbc->errloc = kmalloc(t*sizeof(*nbc->errloc), GFP_KERNEL); | 189 | nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL); |
| 190 | if (!nbc->eccmask || !nbc->errloc) | 190 | if (!nbc->eccmask || !nbc->errloc) |
| 191 | goto fail; | 191 | goto fail; |
| 192 | /* | 192 | /* |
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c index e027c6f9d327..f8edacde49ab 100644 --- a/drivers/mtd/nand/raw/nandsim.c +++ b/drivers/mtd/nand/raw/nandsim.c | |||
| @@ -565,8 +565,9 @@ static int __init alloc_device(struct nandsim *ns) | |||
| 565 | err = -EINVAL; | 565 | err = -EINVAL; |
| 566 | goto err_close; | 566 | goto err_close; |
| 567 | } | 567 | } |
| 568 | ns->pages_written = vzalloc(BITS_TO_LONGS(ns->geom.pgnum) * | 568 | ns->pages_written = |
| 569 | sizeof(unsigned long)); | 569 | vzalloc(array_size(sizeof(unsigned long), |
| 570 | BITS_TO_LONGS(ns->geom.pgnum))); | ||
| 570 | if (!ns->pages_written) { | 571 | if (!ns->pages_written) { |
| 571 | NS_ERR("alloc_device: unable to allocate pages written array\n"); | 572 | NS_ERR("alloc_device: unable to allocate pages written array\n"); |
| 572 | err = -ENOMEM; | 573 | err = -ENOMEM; |
| @@ -582,7 +583,7 @@ static int __init alloc_device(struct nandsim *ns) | |||
| 582 | return 0; | 583 | return 0; |
| 583 | } | 584 | } |
| 584 | 585 | ||
| 585 | ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); | 586 | ns->pages = vmalloc(array_size(sizeof(union ns_mem), ns->geom.pgnum)); |
| 586 | if (!ns->pages) { | 587 | if (!ns->pages) { |
| 587 | NS_ERR("alloc_device: unable to allocate page array\n"); | 588 | NS_ERR("alloc_device: unable to allocate page array\n"); |
| 588 | return -ENOMEM; | 589 | return -ENOMEM; |
diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index b554fb6e609c..6a5519f0ff25 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c | |||
| @@ -2510,8 +2510,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) | |||
| 2510 | if (!nandc->regs) | 2510 | if (!nandc->regs) |
| 2511 | return -ENOMEM; | 2511 | return -ENOMEM; |
| 2512 | 2512 | ||
| 2513 | nandc->reg_read_buf = devm_kzalloc(nandc->dev, | 2513 | nandc->reg_read_buf = devm_kcalloc(nandc->dev, |
| 2514 | MAX_REG_RD * sizeof(*nandc->reg_read_buf), | 2514 | MAX_REG_RD, sizeof(*nandc->reg_read_buf), |
| 2515 | GFP_KERNEL); | 2515 | GFP_KERNEL); |
| 2516 | if (!nandc->reg_read_buf) | 2516 | if (!nandc->reg_read_buf) |
| 2517 | return -ENOMEM; | 2517 | return -ENOMEM; |
diff --git a/drivers/mtd/nand/raw/s3c2410.c b/drivers/mtd/nand/raw/s3c2410.c index 1bc0458063d8..19661c5d3220 100644 --- a/drivers/mtd/nand/raw/s3c2410.c +++ b/drivers/mtd/nand/raw/s3c2410.c | |||
| @@ -1038,7 +1038,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev) | |||
| 1038 | if (!pdata->nr_sets) | 1038 | if (!pdata->nr_sets) |
| 1039 | return 0; | 1039 | return 0; |
| 1040 | 1040 | ||
| 1041 | sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets, | 1041 | sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets), |
| 1042 | GFP_KERNEL); | 1042 | GFP_KERNEL); |
| 1043 | if (!sets) | 1043 | if (!sets) |
| 1044 | return -ENOMEM; | 1044 | return -ENOMEM; |
diff --git a/drivers/mtd/nftlmount.c b/drivers/mtd/nftlmount.c index 6281da3dadac..27184e3874db 100644 --- a/drivers/mtd/nftlmount.c +++ b/drivers/mtd/nftlmount.c | |||
| @@ -199,13 +199,16 @@ device is already correct. | |||
| 199 | nftl->lastEUN = nftl->nb_blocks - 1; | 199 | nftl->lastEUN = nftl->nb_blocks - 1; |
| 200 | 200 | ||
| 201 | /* memory alloc */ | 201 | /* memory alloc */ |
| 202 | nftl->EUNtable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL); | 202 | nftl->EUNtable = kmalloc_array(nftl->nb_blocks, sizeof(u16), |
| 203 | GFP_KERNEL); | ||
| 203 | if (!nftl->EUNtable) { | 204 | if (!nftl->EUNtable) { |
| 204 | printk(KERN_NOTICE "NFTL: allocation of EUNtable failed\n"); | 205 | printk(KERN_NOTICE "NFTL: allocation of EUNtable failed\n"); |
| 205 | return -ENOMEM; | 206 | return -ENOMEM; |
| 206 | } | 207 | } |
| 207 | 208 | ||
| 208 | nftl->ReplUnitTable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL); | 209 | nftl->ReplUnitTable = kmalloc_array(nftl->nb_blocks, |
| 210 | sizeof(u16), | ||
| 211 | GFP_KERNEL); | ||
| 209 | if (!nftl->ReplUnitTable) { | 212 | if (!nftl->ReplUnitTable) { |
| 210 | kfree(nftl->EUNtable); | 213 | kfree(nftl->EUNtable); |
| 211 | printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n"); | 214 | printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n"); |
diff --git a/drivers/mtd/ofpart.c b/drivers/mtd/ofpart.c index 615f8c173162..6b21a92d3622 100644 --- a/drivers/mtd/ofpart.c +++ b/drivers/mtd/ofpart.c | |||
| @@ -71,7 +71,7 @@ static int parse_fixed_partitions(struct mtd_info *master, | |||
| 71 | if (nr_parts == 0) | 71 | if (nr_parts == 0) |
| 72 | return 0; | 72 | return 0; |
| 73 | 73 | ||
| 74 | parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL); | 74 | parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL); |
| 75 | if (!parts) | 75 | if (!parts) |
| 76 | return -ENOMEM; | 76 | return -ENOMEM; |
| 77 | 77 | ||
| @@ -177,7 +177,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, | |||
| 177 | 177 | ||
| 178 | nr_parts = plen / sizeof(part[0]); | 178 | nr_parts = plen / sizeof(part[0]); |
| 179 | 179 | ||
| 180 | parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL); | 180 | parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL); |
| 181 | if (!parts) | 181 | if (!parts) |
| 182 | return -ENOMEM; | 182 | return -ENOMEM; |
| 183 | 183 | ||
diff --git a/drivers/mtd/parsers/parser_trx.c b/drivers/mtd/parsers/parser_trx.c index df360a75e1eb..17ac33599783 100644 --- a/drivers/mtd/parsers/parser_trx.c +++ b/drivers/mtd/parsers/parser_trx.c | |||
| @@ -62,7 +62,7 @@ static int parser_trx_parse(struct mtd_info *mtd, | |||
| 62 | uint8_t curr_part = 0, i = 0; | 62 | uint8_t curr_part = 0, i = 0; |
| 63 | int err; | 63 | int err; |
| 64 | 64 | ||
| 65 | parts = kzalloc(sizeof(struct mtd_partition) * TRX_PARSER_MAX_PARTS, | 65 | parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition), |
| 66 | GFP_KERNEL); | 66 | GFP_KERNEL); |
| 67 | if (!parts) | 67 | if (!parts) |
| 68 | return -ENOMEM; | 68 | return -ENOMEM; |
diff --git a/drivers/mtd/parsers/sharpslpart.c b/drivers/mtd/parsers/sharpslpart.c index 8893dc82a5c8..e5ea6127ab5a 100644 --- a/drivers/mtd/parsers/sharpslpart.c +++ b/drivers/mtd/parsers/sharpslpart.c | |||
| @@ -362,8 +362,9 @@ static int sharpsl_parse_mtd_partitions(struct mtd_info *master, | |||
| 362 | return err; | 362 | return err; |
| 363 | } | 363 | } |
| 364 | 364 | ||
| 365 | sharpsl_nand_parts = kzalloc(sizeof(*sharpsl_nand_parts) * | 365 | sharpsl_nand_parts = kcalloc(SHARPSL_NAND_PARTS, |
| 366 | SHARPSL_NAND_PARTS, GFP_KERNEL); | 366 | sizeof(*sharpsl_nand_parts), |
| 367 | GFP_KERNEL); | ||
| 367 | if (!sharpsl_nand_parts) | 368 | if (!sharpsl_nand_parts) |
| 368 | return -ENOMEM; | 369 | return -ENOMEM; |
| 369 | 370 | ||
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c index df27f24ce0fa..94720f2ca9a8 100644 --- a/drivers/mtd/rfd_ftl.c +++ b/drivers/mtd/rfd_ftl.c | |||
| @@ -189,7 +189,8 @@ static int scan_header(struct partition *part) | |||
| 189 | if (!part->blocks) | 189 | if (!part->blocks) |
| 190 | goto err; | 190 | goto err; |
| 191 | 191 | ||
| 192 | part->sector_map = vmalloc(part->sector_count * sizeof(u_long)); | 192 | part->sector_map = vmalloc(array_size(sizeof(u_long), |
| 193 | part->sector_count)); | ||
| 193 | if (!part->sector_map) { | 194 | if (!part->sector_map) { |
| 194 | printk(KERN_ERR PREFIX "'%s': unable to allocate memory for " | 195 | printk(KERN_ERR PREFIX "'%s': unable to allocate memory for " |
| 195 | "sector map", part->mbd.mtd->name); | 196 | "sector map", part->mbd.mtd->name); |
diff --git a/drivers/mtd/sm_ftl.c b/drivers/mtd/sm_ftl.c index 79636349df96..f3bd86e13603 100644 --- a/drivers/mtd/sm_ftl.c +++ b/drivers/mtd/sm_ftl.c | |||
| @@ -82,7 +82,7 @@ static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl) | |||
| 82 | 82 | ||
| 83 | 83 | ||
| 84 | /* Create array of pointers to the attributes */ | 84 | /* Create array of pointers to the attributes */ |
| 85 | attributes = kzalloc(sizeof(struct attribute *) * (NUM_ATTRIBUTES + 1), | 85 | attributes = kcalloc(NUM_ATTRIBUTES + 1, sizeof(struct attribute *), |
| 86 | GFP_KERNEL); | 86 | GFP_KERNEL); |
| 87 | if (!attributes) | 87 | if (!attributes) |
| 88 | goto error3; | 88 | goto error3; |
| @@ -750,7 +750,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) | |||
| 750 | dbg("initializing zone %d", zone_num); | 750 | dbg("initializing zone %d", zone_num); |
| 751 | 751 | ||
| 752 | /* Allocate memory for FTL table */ | 752 | /* Allocate memory for FTL table */ |
| 753 | zone->lba_to_phys_table = kmalloc(ftl->max_lba * 2, GFP_KERNEL); | 753 | zone->lba_to_phys_table = kmalloc_array(ftl->max_lba, 2, GFP_KERNEL); |
| 754 | 754 | ||
| 755 | if (!zone->lba_to_phys_table) | 755 | if (!zone->lba_to_phys_table) |
| 756 | return -ENOMEM; | 756 | return -ENOMEM; |
| @@ -1137,7 +1137,7 @@ static void sm_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 1137 | goto error2; | 1137 | goto error2; |
| 1138 | 1138 | ||
| 1139 | /* Allocate zone array, it will be initialized on demand */ | 1139 | /* Allocate zone array, it will be initialized on demand */ |
| 1140 | ftl->zones = kzalloc(sizeof(struct ftl_zone) * ftl->zone_count, | 1140 | ftl->zones = kcalloc(ftl->zone_count, sizeof(struct ftl_zone), |
| 1141 | GFP_KERNEL); | 1141 | GFP_KERNEL); |
| 1142 | if (!ftl->zones) | 1142 | if (!ftl->zones) |
| 1143 | goto error3; | 1143 | goto error3; |
diff --git a/drivers/mtd/ssfdc.c b/drivers/mtd/ssfdc.c index 95f0bf95f095..7a1e54546f4a 100644 --- a/drivers/mtd/ssfdc.c +++ b/drivers/mtd/ssfdc.c | |||
| @@ -332,8 +332,9 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) | |||
| 332 | (long)ssfdc->sectors; | 332 | (long)ssfdc->sectors; |
| 333 | 333 | ||
| 334 | /* Allocate logical block map */ | 334 | /* Allocate logical block map */ |
| 335 | ssfdc->logic_block_map = kmalloc(sizeof(ssfdc->logic_block_map[0]) * | 335 | ssfdc->logic_block_map = |
| 336 | ssfdc->map_len, GFP_KERNEL); | 336 | kmalloc_array(ssfdc->map_len, |
| 337 | sizeof(ssfdc->logic_block_map[0]), GFP_KERNEL); | ||
| 337 | if (!ssfdc->logic_block_map) | 338 | if (!ssfdc->logic_block_map) |
| 338 | goto out_err; | 339 | goto out_err; |
| 339 | memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) * | 340 | memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) * |
diff --git a/drivers/mtd/tests/pagetest.c b/drivers/mtd/tests/pagetest.c index bc303cac9f43..75687369bc20 100644 --- a/drivers/mtd/tests/pagetest.c +++ b/drivers/mtd/tests/pagetest.c | |||
| @@ -127,7 +127,7 @@ static int crosstest(void) | |||
| 127 | unsigned char *pp1, *pp2, *pp3, *pp4; | 127 | unsigned char *pp1, *pp2, *pp3, *pp4; |
| 128 | 128 | ||
| 129 | pr_info("crosstest\n"); | 129 | pr_info("crosstest\n"); |
| 130 | pp1 = kzalloc(pgsize * 4, GFP_KERNEL); | 130 | pp1 = kcalloc(pgsize, 4, GFP_KERNEL); |
| 131 | if (!pp1) | 131 | if (!pp1) |
| 132 | return -ENOMEM; | 132 | return -ENOMEM; |
| 133 | pp2 = pp1 + pgsize; | 133 | pp2 = pp1 + pgsize; |
diff --git a/drivers/mtd/tests/stresstest.c b/drivers/mtd/tests/stresstest.c index e509f8aa9a7e..0fe1217f94b9 100644 --- a/drivers/mtd/tests/stresstest.c +++ b/drivers/mtd/tests/stresstest.c | |||
| @@ -199,7 +199,7 @@ static int __init mtd_stresstest_init(void) | |||
| 199 | err = -ENOMEM; | 199 | err = -ENOMEM; |
| 200 | readbuf = vmalloc(bufsize); | 200 | readbuf = vmalloc(bufsize); |
| 201 | writebuf = vmalloc(bufsize); | 201 | writebuf = vmalloc(bufsize); |
| 202 | offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL); | 202 | offsets = kmalloc_array(ebcnt, sizeof(int), GFP_KERNEL); |
| 203 | if (!readbuf || !writebuf || !offsets) | 203 | if (!readbuf || !writebuf || !offsets) |
| 204 | goto out; | 204 | goto out; |
| 205 | for (i = 0; i < ebcnt; i++) | 205 | for (i = 0; i < ebcnt; i++) |
diff --git a/drivers/mtd/ubi/eba.c b/drivers/mtd/ubi/eba.c index edb1c8362faa..b98481b69314 100644 --- a/drivers/mtd/ubi/eba.c +++ b/drivers/mtd/ubi/eba.c | |||
| @@ -1536,11 +1536,11 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, | |||
| 1536 | 1536 | ||
| 1537 | num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT; | 1537 | num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT; |
| 1538 | 1538 | ||
| 1539 | scan_eba = kmalloc(sizeof(*scan_eba) * num_volumes, GFP_KERNEL); | 1539 | scan_eba = kmalloc_array(num_volumes, sizeof(*scan_eba), GFP_KERNEL); |
| 1540 | if (!scan_eba) | 1540 | if (!scan_eba) |
| 1541 | return -ENOMEM; | 1541 | return -ENOMEM; |
| 1542 | 1542 | ||
| 1543 | fm_eba = kmalloc(sizeof(*fm_eba) * num_volumes, GFP_KERNEL); | 1543 | fm_eba = kmalloc_array(num_volumes, sizeof(*fm_eba), GFP_KERNEL); |
| 1544 | if (!fm_eba) { | 1544 | if (!fm_eba) { |
| 1545 | kfree(scan_eba); | 1545 | kfree(scan_eba); |
| 1546 | return -ENOMEM; | 1546 | return -ENOMEM; |
| @@ -1551,15 +1551,17 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, | |||
| 1551 | if (!vol) | 1551 | if (!vol) |
| 1552 | continue; | 1552 | continue; |
| 1553 | 1553 | ||
| 1554 | scan_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**scan_eba), | 1554 | scan_eba[i] = kmalloc_array(vol->reserved_pebs, |
| 1555 | GFP_KERNEL); | 1555 | sizeof(**scan_eba), |
| 1556 | GFP_KERNEL); | ||
| 1556 | if (!scan_eba[i]) { | 1557 | if (!scan_eba[i]) { |
| 1557 | ret = -ENOMEM; | 1558 | ret = -ENOMEM; |
| 1558 | goto out_free; | 1559 | goto out_free; |
| 1559 | } | 1560 | } |
| 1560 | 1561 | ||
| 1561 | fm_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**fm_eba), | 1562 | fm_eba[i] = kmalloc_array(vol->reserved_pebs, |
| 1562 | GFP_KERNEL); | 1563 | sizeof(**fm_eba), |
| 1564 | GFP_KERNEL); | ||
| 1563 | if (!fm_eba[i]) { | 1565 | if (!fm_eba[i]) { |
| 1564 | ret = -ENOMEM; | 1566 | ret = -ENOMEM; |
| 1565 | goto out_free; | 1567 | goto out_free; |
diff --git a/drivers/mtd/ubi/wl.c b/drivers/mtd/ubi/wl.c index f66b3b22f328..6f2ac865ff05 100644 --- a/drivers/mtd/ubi/wl.c +++ b/drivers/mtd/ubi/wl.c | |||
| @@ -1592,7 +1592,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) | |||
| 1592 | sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); | 1592 | sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num); |
| 1593 | 1593 | ||
| 1594 | err = -ENOMEM; | 1594 | err = -ENOMEM; |
| 1595 | ubi->lookuptbl = kzalloc(ubi->peb_count * sizeof(void *), GFP_KERNEL); | 1595 | ubi->lookuptbl = kcalloc(ubi->peb_count, sizeof(void *), GFP_KERNEL); |
| 1596 | if (!ubi->lookuptbl) | 1596 | if (!ubi->lookuptbl) |
| 1597 | return err; | 1597 | return err; |
| 1598 | 1598 | ||
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index bd53a71f6b00..63e3844c5bec 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -2418,7 +2418,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev, | |||
| 2418 | struct list_head *iter; | 2418 | struct list_head *iter; |
| 2419 | 2419 | ||
| 2420 | if (start_dev == end_dev) { | 2420 | if (start_dev == end_dev) { |
| 2421 | tags = kzalloc(sizeof(*tags) * (level + 1), GFP_ATOMIC); | 2421 | tags = kcalloc(level + 1, sizeof(*tags), GFP_ATOMIC); |
| 2422 | if (!tags) | 2422 | if (!tags) |
| 2423 | return ERR_PTR(-ENOMEM); | 2423 | return ERR_PTR(-ENOMEM); |
| 2424 | tags[level].vlan_proto = VLAN_N_VID; | 2424 | tags[level].vlan_proto = VLAN_N_VID; |
diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 2d3046afa80d..7eec1d9f86a0 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c | |||
| @@ -1057,7 +1057,7 @@ static int grcan_open(struct net_device *dev) | |||
| 1057 | return err; | 1057 | return err; |
| 1058 | } | 1058 | } |
| 1059 | 1059 | ||
| 1060 | priv->echo_skb = kzalloc(dma->tx.size * sizeof(*priv->echo_skb), | 1060 | priv->echo_skb = kcalloc(dma->tx.size, sizeof(*priv->echo_skb), |
| 1061 | GFP_KERNEL); | 1061 | GFP_KERNEL); |
| 1062 | if (!priv->echo_skb) { | 1062 | if (!priv->echo_skb) { |
| 1063 | err = -ENOMEM; | 1063 | err = -ENOMEM; |
| @@ -1066,7 +1066,7 @@ static int grcan_open(struct net_device *dev) | |||
| 1066 | priv->can.echo_skb_max = dma->tx.size; | 1066 | priv->can.echo_skb_max = dma->tx.size; |
| 1067 | priv->can.echo_skb = priv->echo_skb; | 1067 | priv->can.echo_skb = priv->echo_skb; |
| 1068 | 1068 | ||
| 1069 | priv->txdlc = kzalloc(dma->tx.size * sizeof(*priv->txdlc), GFP_KERNEL); | 1069 | priv->txdlc = kcalloc(dma->tx.size, sizeof(*priv->txdlc), GFP_KERNEL); |
| 1070 | if (!priv->txdlc) { | 1070 | if (!priv->txdlc) { |
| 1071 | err = -ENOMEM; | 1071 | err = -ENOMEM; |
| 1072 | goto exit_free_echo_skb; | 1072 | goto exit_free_echo_skb; |
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 89d60d8e467c..aa97dbc797b6 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
| @@ -703,7 +703,7 @@ static int __init slcan_init(void) | |||
| 703 | pr_info("slcan: serial line CAN interface driver\n"); | 703 | pr_info("slcan: serial line CAN interface driver\n"); |
| 704 | pr_info("slcan: %d dynamic interface channels.\n", maxdev); | 704 | pr_info("slcan: %d dynamic interface channels.\n", maxdev); |
| 705 | 705 | ||
| 706 | slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL); | 706 | slcan_devs = kcalloc(maxdev, sizeof(struct net_device *), GFP_KERNEL); |
| 707 | if (!slcan_devs) | 707 | if (!slcan_devs) |
| 708 | return -ENOMEM; | 708 | return -ENOMEM; |
| 709 | 709 | ||
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 5e010b1592f7..d93c790bfbe8 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
| @@ -2044,14 +2044,14 @@ static int b53_switch_init(struct b53_device *dev) | |||
| 2044 | } | 2044 | } |
| 2045 | } | 2045 | } |
| 2046 | 2046 | ||
| 2047 | dev->ports = devm_kzalloc(dev->dev, | 2047 | dev->ports = devm_kcalloc(dev->dev, |
| 2048 | sizeof(struct b53_port) * dev->num_ports, | 2048 | dev->num_ports, sizeof(struct b53_port), |
| 2049 | GFP_KERNEL); | 2049 | GFP_KERNEL); |
| 2050 | if (!dev->ports) | 2050 | if (!dev->ports) |
| 2051 | return -ENOMEM; | 2051 | return -ENOMEM; |
| 2052 | 2052 | ||
| 2053 | dev->vlans = devm_kzalloc(dev->dev, | 2053 | dev->vlans = devm_kcalloc(dev->dev, |
| 2054 | sizeof(struct b53_vlan) * dev->num_vlans, | 2054 | dev->num_vlans, sizeof(struct b53_vlan), |
| 2055 | GFP_KERNEL); | 2055 | GFP_KERNEL); |
| 2056 | if (!dev->vlans) | 2056 | if (!dev->vlans) |
| 2057 | return -ENOMEM; | 2057 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c index 060cb18fa659..521607bc4393 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c | |||
| @@ -838,8 +838,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) | |||
| 838 | return; | 838 | return; |
| 839 | } | 839 | } |
| 840 | 840 | ||
| 841 | strings_buf = devm_kzalloc(&adapter->pdev->dev, | 841 | strings_buf = devm_kcalloc(&adapter->pdev->dev, |
| 842 | strings_num * ETH_GSTRING_LEN, | 842 | ETH_GSTRING_LEN, strings_num, |
| 843 | GFP_ATOMIC); | 843 | GFP_ATOMIC); |
| 844 | if (!strings_buf) { | 844 | if (!strings_buf) { |
| 845 | netif_err(adapter, drv, netdev, | 845 | netif_err(adapter, drv, netdev, |
| @@ -847,8 +847,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) | |||
| 847 | return; | 847 | return; |
| 848 | } | 848 | } |
| 849 | 849 | ||
| 850 | data_buf = devm_kzalloc(&adapter->pdev->dev, | 850 | data_buf = devm_kcalloc(&adapter->pdev->dev, |
| 851 | strings_num * sizeof(u64), | 851 | strings_num, sizeof(u64), |
| 852 | GFP_ATOMIC); | 852 | GFP_ATOMIC); |
| 853 | if (!data_buf) { | 853 | if (!data_buf) { |
| 854 | netif_err(adapter, drv, netdev, | 854 | netif_err(adapter, drv, netdev, |
diff --git a/drivers/net/ethernet/amd/lance.c b/drivers/net/ethernet/amd/lance.c index 12a6a93d221b..b56d84c7df46 100644 --- a/drivers/net/ethernet/amd/lance.c +++ b/drivers/net/ethernet/amd/lance.c | |||
| @@ -551,13 +551,13 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int | |||
| 551 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); | 551 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); |
| 552 | dev->ml_priv = lp; | 552 | dev->ml_priv = lp; |
| 553 | lp->name = chipname; | 553 | lp->name = chipname; |
| 554 | lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, | 554 | lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ, |
| 555 | GFP_DMA | GFP_KERNEL); | 555 | GFP_DMA | GFP_KERNEL); |
| 556 | if (!lp->rx_buffs) | 556 | if (!lp->rx_buffs) |
| 557 | goto out_lp; | 557 | goto out_lp; |
| 558 | if (lance_need_isa_bounce_buffers) { | 558 | if (lance_need_isa_bounce_buffers) { |
| 559 | lp->tx_bounce_buffs = kmalloc(PKT_BUF_SZ*TX_RING_SIZE, | 559 | lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ, |
| 560 | GFP_DMA | GFP_KERNEL); | 560 | GFP_DMA | GFP_KERNEL); |
| 561 | if (!lp->tx_bounce_buffs) | 561 | if (!lp->tx_bounce_buffs) |
| 562 | goto out_rx; | 562 | goto out_rx; |
| 563 | } else | 563 | } else |
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c b/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c index cfe86a20c899..28e9ae1a193b 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c | |||
| @@ -209,8 +209,8 @@ static int atl1c_get_eeprom(struct net_device *netdev, | |||
| 209 | first_dword = eeprom->offset >> 2; | 209 | first_dword = eeprom->offset >> 2; |
| 210 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 210 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 211 | 211 | ||
| 212 | eeprom_buff = kmalloc(sizeof(u32) * | 212 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 213 | (last_dword - first_dword + 1), GFP_KERNEL); | 213 | GFP_KERNEL); |
| 214 | if (eeprom_buff == NULL) | 214 | if (eeprom_buff == NULL) |
| 215 | return -ENOMEM; | 215 | return -ENOMEM; |
| 216 | 216 | ||
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c index cb489e7e8374..282ebdde4769 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c | |||
| @@ -236,8 +236,8 @@ static int atl1e_get_eeprom(struct net_device *netdev, | |||
| 236 | first_dword = eeprom->offset >> 2; | 236 | first_dword = eeprom->offset >> 2; |
| 237 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 237 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 238 | 238 | ||
| 239 | eeprom_buff = kmalloc(sizeof(u32) * | 239 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 240 | (last_dword - first_dword + 1), GFP_KERNEL); | 240 | GFP_KERNEL); |
| 241 | if (eeprom_buff == NULL) | 241 | if (eeprom_buff == NULL) |
| 242 | return -ENOMEM; | 242 | return -ENOMEM; |
| 243 | 243 | ||
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index db4bcc51023a..bb41becb6609 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c | |||
| @@ -1941,8 +1941,8 @@ static int atl2_get_eeprom(struct net_device *netdev, | |||
| 1941 | first_dword = eeprom->offset >> 2; | 1941 | first_dword = eeprom->offset >> 2; |
| 1942 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 1942 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 1943 | 1943 | ||
| 1944 | eeprom_buff = kmalloc(sizeof(u32) * (last_dword - first_dword + 1), | 1944 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 1945 | GFP_KERNEL); | 1945 | GFP_KERNEL); |
| 1946 | if (!eeprom_buff) | 1946 | if (!eeprom_buff) |
| 1947 | return -ENOMEM; | 1947 | return -ENOMEM; |
| 1948 | 1948 | ||
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 14a59e51db67..897302adc38e 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c | |||
| @@ -2150,7 +2150,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2150 | priv->tx_desc_alloc_size = size; | 2150 | priv->tx_desc_alloc_size = size; |
| 2151 | priv->tx_desc_cpu = p; | 2151 | priv->tx_desc_cpu = p; |
| 2152 | 2152 | ||
| 2153 | priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size, | 2153 | priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *), |
| 2154 | GFP_KERNEL); | 2154 | GFP_KERNEL); |
| 2155 | if (!priv->tx_skb) { | 2155 | if (!priv->tx_skb) { |
| 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
| @@ -2164,7 +2164,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2164 | spin_lock_init(&priv->tx_lock); | 2164 | spin_lock_init(&priv->tx_lock); |
| 2165 | 2165 | ||
| 2166 | /* init & fill rx ring with skbs */ | 2166 | /* init & fill rx ring with skbs */ |
| 2167 | priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size, | 2167 | priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *), |
| 2168 | GFP_KERNEL); | 2168 | GFP_KERNEL); |
| 2169 | if (!priv->rx_skb) { | 2169 | if (!priv->rx_skb) { |
| 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 3853296d78c1..122fdb80a789 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c | |||
| @@ -778,7 +778,7 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) | |||
| 778 | int j; | 778 | int j; |
| 779 | 779 | ||
| 780 | rxr->rx_buf_ring = | 780 | rxr->rx_buf_ring = |
| 781 | vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring); | 781 | vzalloc(array_size(SW_RXBD_RING_SIZE, bp->rx_max_ring)); |
| 782 | if (!rxr->rx_buf_ring) | 782 | if (!rxr->rx_buf_ring) |
| 783 | return -ENOMEM; | 783 | return -ENOMEM; |
| 784 | 784 | ||
| @@ -794,8 +794,9 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) | |||
| 794 | } | 794 | } |
| 795 | 795 | ||
| 796 | if (bp->rx_pg_ring_size) { | 796 | if (bp->rx_pg_ring_size) { |
| 797 | rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE * | 797 | rxr->rx_pg_ring = |
| 798 | bp->rx_max_pg_ring); | 798 | vzalloc(array_size(SW_RXPG_RING_SIZE, |
| 799 | bp->rx_max_pg_ring)); | ||
| 799 | if (!rxr->rx_pg_ring) | 800 | if (!rxr->rx_pg_ring) |
| 800 | return -ENOMEM; | 801 | return -ENOMEM; |
| 801 | 802 | ||
| @@ -2666,7 +2667,7 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp) | |||
| 2666 | u32 good_mbuf_cnt; | 2667 | u32 good_mbuf_cnt; |
| 2667 | u32 val; | 2668 | u32 val; |
| 2668 | 2669 | ||
| 2669 | good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL); | 2670 | good_mbuf = kmalloc_array(512, sizeof(u16), GFP_KERNEL); |
| 2670 | if (!good_mbuf) | 2671 | if (!good_mbuf) |
| 2671 | return -ENOMEM; | 2672 | return -ENOMEM; |
| 2672 | 2673 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index ffa7959f6b31..dc77bfded865 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | |||
| @@ -571,7 +571,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf, | |||
| 571 | else | 571 | else |
| 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); | 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); |
| 573 | if (mc_num) { | 573 | if (mc_num) { |
| 574 | mc = kzalloc(mc_num * sizeof(struct bnx2x_mcast_list_elem), | 574 | mc = kcalloc(mc_num, sizeof(struct bnx2x_mcast_list_elem), |
| 575 | GFP_KERNEL); | 575 | GFP_KERNEL); |
| 576 | if (!mc) { | 576 | if (!mc) { |
| 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); | 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); |
| @@ -1253,8 +1253,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1253 | num_vfs_param, iov->nr_virtfn); | 1253 | num_vfs_param, iov->nr_virtfn); |
| 1254 | 1254 | ||
| 1255 | /* allocate the vf array */ | 1255 | /* allocate the vf array */ |
| 1256 | bp->vfdb->vfs = kzalloc(sizeof(struct bnx2x_virtf) * | 1256 | bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp), |
| 1257 | BNX2X_NR_VIRTFN(bp), GFP_KERNEL); | 1257 | sizeof(struct bnx2x_virtf), |
| 1258 | GFP_KERNEL); | ||
| 1258 | if (!bp->vfdb->vfs) { | 1259 | if (!bp->vfdb->vfs) { |
| 1259 | BNX2X_ERR("failed to allocate vf array\n"); | 1260 | BNX2X_ERR("failed to allocate vf array\n"); |
| 1260 | err = -ENOMEM; | 1261 | err = -ENOMEM; |
| @@ -1278,9 +1279,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1278 | } | 1279 | } |
| 1279 | 1280 | ||
| 1280 | /* allocate the queue arrays for all VFs */ | 1281 | /* allocate the queue arrays for all VFs */ |
| 1281 | bp->vfdb->vfqs = kzalloc( | 1282 | bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES, |
| 1282 | BNX2X_MAX_NUM_VF_QUEUES * sizeof(struct bnx2x_vf_queue), | 1283 | sizeof(struct bnx2x_vf_queue), |
| 1283 | GFP_KERNEL); | 1284 | GFP_KERNEL); |
| 1284 | 1285 | ||
| 1285 | if (!bp->vfdb->vfqs) { | 1286 | if (!bp->vfdb->vfqs) { |
| 1286 | BNX2X_ERR("failed to allocate vf queue array\n"); | 1287 | BNX2X_ERR("failed to allocate vf queue array\n"); |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index 38f635cf8408..05d405905906 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | |||
| @@ -444,8 +444,8 @@ static int bnxt_vf_reps_create(struct bnxt *bp) | |||
| 444 | return -ENOMEM; | 444 | return -ENOMEM; |
| 445 | 445 | ||
| 446 | /* storage for cfa_code to vf-idx mapping */ | 446 | /* storage for cfa_code to vf-idx mapping */ |
| 447 | cfa_code_map = kmalloc(sizeof(*bp->cfa_code_map) * MAX_CFA_CODE, | 447 | cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map), |
| 448 | GFP_KERNEL); | 448 | GFP_KERNEL); |
| 449 | if (!cfa_code_map) { | 449 | if (!cfa_code_map) { |
| 450 | rc = -ENOMEM; | 450 | rc = -ENOMEM; |
| 451 | goto err; | 451 | goto err; |
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 8bc126a156e8..30273a7717e2 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c | |||
| @@ -660,7 +660,7 @@ static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id, | |||
| 660 | id_tbl->max = size; | 660 | id_tbl->max = size; |
| 661 | id_tbl->next = next; | 661 | id_tbl->next = next; |
| 662 | spin_lock_init(&id_tbl->lock); | 662 | spin_lock_init(&id_tbl->lock); |
| 663 | id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL); | 663 | id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL); |
| 664 | if (!id_tbl->table) | 664 | if (!id_tbl->table) |
| 665 | return -ENOMEM; | 665 | return -ENOMEM; |
| 666 | 666 | ||
| @@ -1255,13 +1255,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1255 | cp->fcoe_init_cid = 0x10; | 1255 | cp->fcoe_init_cid = 0x10; |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ, | 1258 | cp->iscsi_tbl = kcalloc(MAX_ISCSI_TBL_SZ, sizeof(struct cnic_iscsi), |
| 1259 | GFP_KERNEL); | 1259 | GFP_KERNEL); |
| 1260 | if (!cp->iscsi_tbl) | 1260 | if (!cp->iscsi_tbl) |
| 1261 | goto error; | 1261 | goto error; |
| 1262 | 1262 | ||
| 1263 | cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) * | 1263 | cp->ctx_tbl = kcalloc(cp->max_cid_space, sizeof(struct cnic_context), |
| 1264 | cp->max_cid_space, GFP_KERNEL); | 1264 | GFP_KERNEL); |
| 1265 | if (!cp->ctx_tbl) | 1265 | if (!cp->ctx_tbl) |
| 1266 | goto error; | 1266 | goto error; |
| 1267 | 1267 | ||
| @@ -4100,7 +4100,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) | |||
| 4100 | struct cnic_local *cp = dev->cnic_priv; | 4100 | struct cnic_local *cp = dev->cnic_priv; |
| 4101 | u32 port_id; | 4101 | u32 port_id; |
| 4102 | 4102 | ||
| 4103 | cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ, | 4103 | cp->csk_tbl = kcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock), |
| 4104 | GFP_KERNEL); | 4104 | GFP_KERNEL); |
| 4105 | if (!cp->csk_tbl) | 4105 | if (!cp->csk_tbl) |
| 4106 | return -ENOMEM; | 4106 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 9f59b1270a7c..3be87efdc93d 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -8631,8 +8631,9 @@ static int tg3_mem_tx_acquire(struct tg3 *tp) | |||
| 8631 | tnapi++; | 8631 | tnapi++; |
| 8632 | 8632 | ||
| 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { | 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { |
| 8634 | tnapi->tx_buffers = kzalloc(sizeof(struct tg3_tx_ring_info) * | 8634 | tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE, |
| 8635 | TG3_TX_RING_SIZE, GFP_KERNEL); | 8635 | sizeof(struct tg3_tx_ring_info), |
| 8636 | GFP_KERNEL); | ||
| 8636 | if (!tnapi->tx_buffers) | 8637 | if (!tnapi->tx_buffers) |
| 8637 | goto err_out; | 8638 | goto err_out; |
| 8638 | 8639 | ||
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 69cc3e0119d6..ea5f32ea308a 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c | |||
| @@ -3141,7 +3141,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad) | |||
| 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) | 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) |
| 3142 | goto mode_default; | 3142 | goto mode_default; |
| 3143 | 3143 | ||
| 3144 | mac_list = kzalloc(uc_count * ETH_ALEN, GFP_ATOMIC); | 3144 | mac_list = kcalloc(ETH_ALEN, uc_count, GFP_ATOMIC); |
| 3145 | if (mac_list == NULL) | 3145 | if (mac_list == NULL) |
| 3146 | goto mode_default; | 3146 | goto mode_default; |
| 3147 | 3147 | ||
| @@ -3182,7 +3182,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad) | |||
| 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) | 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) |
| 3183 | goto mode_allmulti; | 3183 | goto mode_allmulti; |
| 3184 | 3184 | ||
| 3185 | mac_list = kzalloc((mc_count + 1) * ETH_ALEN, GFP_ATOMIC); | 3185 | mac_list = kcalloc(mc_count + 1, ETH_ALEN, GFP_ATOMIC); |
| 3186 | 3186 | ||
| 3187 | if (mac_list == NULL) | 3187 | if (mac_list == NULL) |
| 3188 | goto mode_allmulti; | 3188 | goto mode_allmulti; |
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index 2bd7c638b178..2c63afff1382 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c | |||
| @@ -739,7 +739,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 739 | 739 | ||
| 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); | 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); |
| 741 | 741 | ||
| 742 | priv->rx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_RX_RING_SZ, | 742 | priv->rx_skbuff = kcalloc(DMA_RX_RING_SZ, sizeof(struct sk_buff *), |
| 743 | GFP_KERNEL); | 743 | GFP_KERNEL); |
| 744 | if (!priv->rx_skbuff) | 744 | if (!priv->rx_skbuff) |
| 745 | return -ENOMEM; | 745 | return -ENOMEM; |
| @@ -752,7 +752,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 752 | if (!priv->dma_rx) | 752 | if (!priv->dma_rx) |
| 753 | goto err_dma_rx; | 753 | goto err_dma_rx; |
| 754 | 754 | ||
| 755 | priv->tx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_TX_RING_SZ, | 755 | priv->tx_skbuff = kcalloc(DMA_TX_RING_SZ, sizeof(struct sk_buff *), |
| 756 | GFP_KERNEL); | 756 | GFP_KERNEL); |
| 757 | if (!priv->tx_skbuff) | 757 | if (!priv->tx_skbuff) |
| 758 | goto err_tx_skb; | 758 | goto err_tx_skb; |
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c index f044718cea52..a71dbb7ab6af 100644 --- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c +++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c | |||
| @@ -281,13 +281,12 @@ int octeon_init_droq(struct octeon_device *oct, | |||
| 281 | droq->max_count); | 281 | droq->max_count); |
| 282 | 282 | ||
| 283 | droq->recv_buf_list = (struct octeon_recv_buffer *) | 283 | droq->recv_buf_list = (struct octeon_recv_buffer *) |
| 284 | vzalloc_node(droq->max_count * | 284 | vzalloc_node(array_size(droq->max_count, OCT_DROQ_RECVBUF_SIZE), |
| 285 | OCT_DROQ_RECVBUF_SIZE, | 285 | numa_node); |
| 286 | numa_node); | ||
| 287 | if (!droq->recv_buf_list) | 286 | if (!droq->recv_buf_list) |
| 288 | droq->recv_buf_list = (struct octeon_recv_buffer *) | 287 | droq->recv_buf_list = (struct octeon_recv_buffer *) |
| 289 | vzalloc(droq->max_count * | 288 | vzalloc(array_size(droq->max_count, |
| 290 | OCT_DROQ_RECVBUF_SIZE); | 289 | OCT_DROQ_RECVBUF_SIZE)); |
| 291 | if (!droq->recv_buf_list) { | 290 | if (!droq->recv_buf_list) { |
| 292 | dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n"); | 291 | dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n"); |
| 293 | goto init_droq_fail; | 292 | goto init_droq_fail; |
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c index b1270355b0b1..1f2e75da28f8 100644 --- a/drivers/net/ethernet/cavium/liquidio/request_manager.c +++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c | |||
| @@ -98,8 +98,9 @@ int octeon_init_instr_queue(struct octeon_device *oct, | |||
| 98 | iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs), | 98 | iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs), |
| 99 | numa_node); | 99 | numa_node); |
| 100 | if (!iq->request_list) | 100 | if (!iq->request_list) |
| 101 | iq->request_list = vmalloc(sizeof(*iq->request_list) * | 101 | iq->request_list = |
| 102 | num_descs); | 102 | vmalloc(array_size(num_descs, |
| 103 | sizeof(*iq->request_list))); | ||
| 103 | if (!iq->request_list) { | 104 | if (!iq->request_list) { |
| 104 | lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); | 105 | lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); |
| 105 | dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", | 106 | dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index d42704d07484..187a249ff2d1 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -292,8 +292,8 @@ static int nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr, | |||
| 292 | rbdr->is_xdp = true; | 292 | rbdr->is_xdp = true; |
| 293 | } | 293 | } |
| 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); | 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); |
| 295 | rbdr->pgcache = kzalloc(sizeof(*rbdr->pgcache) * | 295 | rbdr->pgcache = kcalloc(rbdr->pgcnt, sizeof(*rbdr->pgcache), |
| 296 | rbdr->pgcnt, GFP_KERNEL); | 296 | GFP_KERNEL); |
| 297 | if (!rbdr->pgcache) | 297 | if (!rbdr->pgcache) |
| 298 | return -ENOMEM; | 298 | return -ENOMEM; |
| 299 | rbdr->pgidx = 0; | 299 | rbdr->pgidx = 0; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c b/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c index 290039026ece..5701272aa7f7 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +++ b/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c | |||
| @@ -304,7 +304,7 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start, | |||
| 304 | for (i = 0; i < ctbl->clipt_size; ++i) | 304 | for (i = 0; i < ctbl->clipt_size; ++i) |
| 305 | INIT_LIST_HEAD(&ctbl->hash_list[i]); | 305 | INIT_LIST_HEAD(&ctbl->hash_list[i]); |
| 306 | 306 | ||
| 307 | cl_list = kvzalloc(clipt_size*sizeof(struct clip_entry), GFP_KERNEL); | 307 | cl_list = kvcalloc(clipt_size, sizeof(struct clip_entry), GFP_KERNEL); |
| 308 | if (!cl_list) { | 308 | if (!cl_list) { |
| 309 | kvfree(ctbl); | 309 | kvfree(ctbl); |
| 310 | return NULL; | 310 | return NULL; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 251d5bdc972f..c301aaf79d64 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
| @@ -873,7 +873,7 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v) | |||
| 873 | u16 (*incr)[NCCTRL_WIN]; | 873 | u16 (*incr)[NCCTRL_WIN]; |
| 874 | struct adapter *adap = seq->private; | 874 | struct adapter *adap = seq->private; |
| 875 | 875 | ||
| 876 | incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL); | 876 | incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL); |
| 877 | if (!incr) | 877 | if (!incr) |
| 878 | return -ENOMEM; | 878 | return -ENOMEM; |
| 879 | 879 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 35cb3ae4f7b6..dd04a2f89ce6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
| @@ -713,7 +713,7 @@ int cxgb4_write_rss(const struct port_info *pi, const u16 *queues) | |||
| 713 | const struct sge_eth_rxq *rxq; | 713 | const struct sge_eth_rxq *rxq; |
| 714 | 714 | ||
| 715 | rxq = &adapter->sge.ethrxq[pi->first_qset]; | 715 | rxq = &adapter->sge.ethrxq[pi->first_qset]; |
| 716 | rss = kmalloc(pi->rss_size * sizeof(u16), GFP_KERNEL); | 716 | rss = kmalloc_array(pi->rss_size, sizeof(u16), GFP_KERNEL); |
| 717 | if (!rss) | 717 | if (!rss) |
| 718 | return -ENOMEM; | 718 | return -ENOMEM; |
| 719 | 719 | ||
| @@ -4972,8 +4972,8 @@ static int enable_msix(struct adapter *adap) | |||
| 4972 | max_ingq += (MAX_OFLD_QSETS * adap->num_uld); | 4972 | max_ingq += (MAX_OFLD_QSETS * adap->num_uld); |
| 4973 | if (is_offload(adap)) | 4973 | if (is_offload(adap)) |
| 4974 | max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld); | 4974 | max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld); |
| 4975 | entries = kmalloc(sizeof(*entries) * (max_ingq + 1), | 4975 | entries = kmalloc_array(max_ingq + 1, sizeof(*entries), |
| 4976 | GFP_KERNEL); | 4976 | GFP_KERNEL); |
| 4977 | if (!entries) | 4977 | if (!entries) |
| 4978 | return -ENOMEM; | 4978 | return -ENOMEM; |
| 4979 | 4979 | ||
| @@ -5646,8 +5646,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 5646 | adapter->params.offload = 0; | 5646 | adapter->params.offload = 0; |
| 5647 | } | 5647 | } |
| 5648 | 5648 | ||
| 5649 | adapter->mps_encap = kvzalloc(sizeof(struct mps_encap_entry) * | 5649 | adapter->mps_encap = kvcalloc(adapter->params.arch.mps_tcam_size, |
| 5650 | adapter->params.arch.mps_tcam_size, | 5650 | sizeof(struct mps_encap_entry), |
| 5651 | GFP_KERNEL); | 5651 | GFP_KERNEL); |
| 5652 | if (!adapter->mps_encap) | 5652 | if (!adapter->mps_encap) |
| 5653 | dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n"); | 5653 | dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n"); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c index ab174bcfbfb0..18eb2aedd4cb 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | |||
| @@ -457,7 +457,8 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap) | |||
| 457 | unsigned int bmap_size; | 457 | unsigned int bmap_size; |
| 458 | 458 | ||
| 459 | bmap_size = BITS_TO_LONGS(max_tids); | 459 | bmap_size = BITS_TO_LONGS(max_tids); |
| 460 | link->tid_map = kvzalloc(sizeof(unsigned long) * bmap_size, GFP_KERNEL); | 460 | link->tid_map = kvcalloc(bmap_size, sizeof(unsigned long), |
| 461 | GFP_KERNEL); | ||
| 461 | if (!link->tid_map) | 462 | if (!link->tid_map) |
| 462 | goto out_no_mem; | 463 | goto out_no_mem; |
| 463 | bitmap_zero(link->tid_map, max_tids); | 464 | bitmap_zero(link->tid_map, max_tids); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c index a95cde0fadf7..4bc211093c98 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | |||
| @@ -561,13 +561,13 @@ int t4_uld_mem_alloc(struct adapter *adap) | |||
| 561 | if (!adap->uld) | 561 | if (!adap->uld) |
| 562 | return -ENOMEM; | 562 | return -ENOMEM; |
| 563 | 563 | ||
| 564 | s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX * | 564 | s->uld_rxq_info = kcalloc(CXGB4_ULD_MAX, |
| 565 | sizeof(struct sge_uld_rxq_info *), | 565 | sizeof(struct sge_uld_rxq_info *), |
| 566 | GFP_KERNEL); | 566 | GFP_KERNEL); |
| 567 | if (!s->uld_rxq_info) | 567 | if (!s->uld_rxq_info) |
| 568 | goto err_uld; | 568 | goto err_uld; |
| 569 | 569 | ||
| 570 | s->uld_txq_info = kzalloc(CXGB4_TX_MAX * | 570 | s->uld_txq_info = kcalloc(CXGB4_TX_MAX, |
| 571 | sizeof(struct sge_uld_txq_info *), | 571 | sizeof(struct sge_uld_txq_info *), |
| 572 | GFP_KERNEL); | 572 | GFP_KERNEL); |
| 573 | if (!s->uld_txq_info) | 573 | if (!s->uld_txq_info) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 7a271feec5e7..395e2a0e8d7f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size, | |||
| 699 | if (!p) | 699 | if (!p) |
| 700 | return NULL; | 700 | return NULL; |
| 701 | if (sw_size) { | 701 | if (sw_size) { |
| 702 | s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node); | 702 | s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node); |
| 703 | 703 | ||
| 704 | if (!s) { | 704 | if (!s) { |
| 705 | dma_free_coherent(dev, len, p, *phys); | 705 | dma_free_coherent(dev, len, p, *phys); |
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index ff9eb45f67f8..6d7404f66f84 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c | |||
| @@ -910,8 +910,8 @@ static int geth_setup_freeq(struct gemini_ethernet *geth) | |||
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | /* Allocate a mapping to page look-up index */ | 912 | /* Allocate a mapping to page look-up index */ |
| 913 | geth->freeq_pages = kzalloc(pages * sizeof(*geth->freeq_pages), | 913 | geth->freeq_pages = kcalloc(pages, sizeof(*geth->freeq_pages), |
| 914 | GFP_KERNEL); | 914 | GFP_KERNEL); |
| 915 | if (!geth->freeq_pages) | 915 | if (!geth->freeq_pages) |
| 916 | goto err_freeq; | 916 | goto err_freeq; |
| 917 | geth->num_freeq_pages = pages; | 917 | geth->num_freeq_pages = pages; |
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 00a57273b753..60da0499ad66 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c | |||
| @@ -1141,7 +1141,8 @@ static int ethoc_probe(struct platform_device *pdev) | |||
| 1141 | dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", | 1141 | dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", |
| 1142 | priv->num_tx, priv->num_rx); | 1142 | priv->num_tx, priv->num_rx); |
| 1143 | 1143 | ||
| 1144 | priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL); | 1144 | priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *), |
| 1145 | GFP_KERNEL); | ||
| 1145 | if (!priv->vma) { | 1146 | if (!priv->vma) { |
| 1146 | ret = -ENOMEM; | 1147 | ret = -ENOMEM; |
| 1147 | goto free; | 1148 | goto free; |
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index fd43f98ddbe7..5f4e1ffa7b95 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | |||
| @@ -664,7 +664,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev, | |||
| 664 | struct dpaa_fq *dpaa_fq; | 664 | struct dpaa_fq *dpaa_fq; |
| 665 | int i; | 665 | int i; |
| 666 | 666 | ||
| 667 | dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count, | 667 | dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq), |
| 668 | GFP_KERNEL); | 668 | GFP_KERNEL); |
| 669 | if (!dpaa_fq) | 669 | if (!dpaa_fq) |
| 670 | return NULL; | 670 | return NULL; |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index a96b838cffce..42fca3208c0b 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c | |||
| @@ -2253,9 +2253,9 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth) | |||
| 2253 | /* Init Tx bds */ | 2253 | /* Init Tx bds */ |
| 2254 | for (j = 0; j < ug_info->numQueuesTx; j++) { | 2254 | for (j = 0; j < ug_info->numQueuesTx; j++) { |
| 2255 | /* Setup the skbuff rings */ | 2255 | /* Setup the skbuff rings */ |
| 2256 | ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * | 2256 | ugeth->tx_skbuff[j] = |
| 2257 | ugeth->ug_info->bdRingLenTx[j], | 2257 | kmalloc_array(ugeth->ug_info->bdRingLenTx[j], |
| 2258 | GFP_KERNEL); | 2258 | sizeof(struct sk_buff *), GFP_KERNEL); |
| 2259 | 2259 | ||
| 2260 | if (ugeth->tx_skbuff[j] == NULL) { | 2260 | if (ugeth->tx_skbuff[j] == NULL) { |
| 2261 | if (netif_msg_ifup(ugeth)) | 2261 | if (netif_msg_ifup(ugeth)) |
| @@ -2326,9 +2326,9 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth) | |||
| 2326 | /* Init Rx bds */ | 2326 | /* Init Rx bds */ |
| 2327 | for (j = 0; j < ug_info->numQueuesRx; j++) { | 2327 | for (j = 0; j < ug_info->numQueuesRx; j++) { |
| 2328 | /* Setup the skbuff rings */ | 2328 | /* Setup the skbuff rings */ |
| 2329 | ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * | 2329 | ugeth->rx_skbuff[j] = |
| 2330 | ugeth->ug_info->bdRingLenRx[j], | 2330 | kmalloc_array(ugeth->ug_info->bdRingLenRx[j], |
| 2331 | GFP_KERNEL); | 2331 | sizeof(struct sk_buff *), GFP_KERNEL); |
| 2332 | 2332 | ||
| 2333 | if (ugeth->rx_skbuff[j] == NULL) { | 2333 | if (ugeth->rx_skbuff[j] == NULL) { |
| 2334 | if (netif_msg_ifup(ugeth)) | 2334 | if (netif_msg_ifup(ugeth)) |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index 85e1d14514fc..0ce07f6eb1e6 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | |||
| @@ -1406,8 +1406,8 @@ static int hns_dsaf_init(struct dsaf_device *dsaf_dev) | |||
| 1406 | return ret; | 1406 | return ret; |
| 1407 | 1407 | ||
| 1408 | /* malloc mem for tcam mac key(vlan+mac) */ | 1408 | /* malloc mem for tcam mac key(vlan+mac) */ |
| 1409 | priv->soft_mac_tbl = vzalloc(sizeof(*priv->soft_mac_tbl) | 1409 | priv->soft_mac_tbl = vzalloc(array_size(DSAF_TCAM_SUM, |
| 1410 | * DSAF_TCAM_SUM); | 1410 | sizeof(*priv->soft_mac_tbl))); |
| 1411 | if (!priv->soft_mac_tbl) { | 1411 | if (!priv->soft_mac_tbl) { |
| 1412 | ret = -ENOMEM; | 1412 | ret = -ENOMEM; |
| 1413 | goto remove_hw; | 1413 | goto remove_hw; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 1ccb6443d2ed..ef9ef703d13a 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c | |||
| @@ -2197,7 +2197,8 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) | |||
| 2197 | return -EINVAL; | 2197 | return -EINVAL; |
| 2198 | } | 2198 | } |
| 2199 | 2199 | ||
| 2200 | priv->ring_data = kzalloc(h->q_num * sizeof(*priv->ring_data) * 2, | 2200 | priv->ring_data = kzalloc(array3_size(h->q_num, |
| 2201 | sizeof(*priv->ring_data), 2), | ||
| 2201 | GFP_KERNEL); | 2202 | GFP_KERNEL); |
| 2202 | if (!priv->ring_data) | 2203 | if (!priv->ring_data) |
| 2203 | return -ENOMEM; | 2204 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index f2b31d278bc9..25a73bb2e642 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
| @@ -2846,8 +2846,10 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) | |||
| 2846 | struct pci_dev *pdev = h->pdev; | 2846 | struct pci_dev *pdev = h->pdev; |
| 2847 | int i, ret; | 2847 | int i, ret; |
| 2848 | 2848 | ||
| 2849 | priv->ring_data = devm_kzalloc(&pdev->dev, h->kinfo.num_tqps * | 2849 | priv->ring_data = devm_kzalloc(&pdev->dev, |
| 2850 | sizeof(*priv->ring_data) * 2, | 2850 | array3_size(h->kinfo.num_tqps, |
| 2851 | sizeof(*priv->ring_data), | ||
| 2852 | 2), | ||
| 2851 | GFP_KERNEL); | 2853 | GFP_KERNEL); |
| 2852 | if (!priv->ring_data) | 2854 | if (!priv->ring_data) |
| 2853 | return -ENOMEM; | 2855 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c index 28a81ac97af5..4d09ea786b35 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c | |||
| @@ -753,11 +753,12 @@ static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_wq *wq, | |||
| 753 | 753 | ||
| 754 | spin_lock_init(&cmdq->cmdq_lock); | 754 | spin_lock_init(&cmdq->cmdq_lock); |
| 755 | 755 | ||
| 756 | cmdq->done = vzalloc(wq->q_depth * sizeof(*cmdq->done)); | 756 | cmdq->done = vzalloc(array_size(sizeof(*cmdq->done), wq->q_depth)); |
| 757 | if (!cmdq->done) | 757 | if (!cmdq->done) |
| 758 | return -ENOMEM; | 758 | return -ENOMEM; |
| 759 | 759 | ||
| 760 | cmdq->errcode = vzalloc(wq->q_depth * sizeof(*cmdq->errcode)); | 760 | cmdq->errcode = vzalloc(array_size(sizeof(*cmdq->errcode), |
| 761 | wq->q_depth)); | ||
| 761 | if (!cmdq->errcode) { | 762 | if (!cmdq->errcode) { |
| 762 | err = -ENOMEM; | 763 | err = -ENOMEM; |
| 763 | goto err_errcode; | 764 | goto err_errcode; |
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index c1b51edaaf62..525d8b89187b 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c | |||
| @@ -171,7 +171,7 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) | |||
| 171 | { | 171 | { |
| 172 | int i; | 172 | int i; |
| 173 | 173 | ||
| 174 | pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL); | 174 | pool->free_map = kmalloc_array(pool->size, sizeof(u16), GFP_KERNEL); |
| 175 | 175 | ||
| 176 | if (!pool->free_map) | 176 | if (!pool->free_map) |
| 177 | return -1; | 177 | return -1; |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index 5d365a986bb0..bdb3f8e65ed4 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c | |||
| @@ -435,8 +435,8 @@ static int e1000_get_eeprom(struct net_device *netdev, | |||
| 435 | first_word = eeprom->offset >> 1; | 435 | first_word = eeprom->offset >> 1; |
| 436 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 436 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 437 | 437 | ||
| 438 | eeprom_buff = kmalloc(sizeof(u16) * | 438 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 439 | (last_word - first_word + 1), GFP_KERNEL); | 439 | GFP_KERNEL); |
| 440 | if (!eeprom_buff) | 440 | if (!eeprom_buff) |
| 441 | return -ENOMEM; | 441 | return -ENOMEM; |
| 442 | 442 | ||
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index e084cb734eb1..02ebf208f48b 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c | |||
| @@ -509,8 +509,8 @@ static int e1000_get_eeprom(struct net_device *netdev, | |||
| 509 | first_word = eeprom->offset >> 1; | 509 | first_word = eeprom->offset >> 1; |
| 510 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 510 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 511 | 511 | ||
| 512 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 512 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 513 | GFP_KERNEL); | 513 | GFP_KERNEL); |
| 514 | if (!eeprom_buff) | 514 | if (!eeprom_buff) |
| 515 | return -ENOMEM; | 515 | return -ENOMEM; |
| 516 | 516 | ||
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index acf1e8b52b8e..3ba0c90e7055 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
| @@ -3312,7 +3312,7 @@ static int e1000e_write_mc_addr_list(struct net_device *netdev) | |||
| 3312 | return 0; | 3312 | return 0; |
| 3313 | } | 3313 | } |
| 3314 | 3314 | ||
| 3315 | mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC); | 3315 | mta_list = kcalloc(netdev_mc_count(netdev), ETH_ALEN, GFP_ATOMIC); |
| 3316 | if (!mta_list) | 3316 | if (!mta_list) |
| 3317 | return -ENOMEM; | 3317 | return -ENOMEM; |
| 3318 | 3318 | ||
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c index 7657daa27298..4895dd83dd08 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | |||
| @@ -558,7 +558,7 @@ static int fm10k_set_ringparam(struct net_device *netdev, | |||
| 558 | 558 | ||
| 559 | /* allocate temporary buffer to store rings in */ | 559 | /* allocate temporary buffer to store rings in */ |
| 560 | i = max_t(int, interface->num_tx_queues, interface->num_rx_queues); | 560 | i = max_t(int, interface->num_tx_queues, interface->num_rx_queues); |
| 561 | temp_ring = vmalloc(i * sizeof(struct fm10k_ring)); | 561 | temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring))); |
| 562 | 562 | ||
| 563 | if (!temp_ring) { | 563 | if (!temp_ring) { |
| 564 | err = -ENOMEM; | 564 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index 2d798499d35e..f92f7918112d 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c | |||
| @@ -736,8 +736,8 @@ static int igb_get_eeprom(struct net_device *netdev, | |||
| 736 | first_word = eeprom->offset >> 1; | 736 | first_word = eeprom->offset >> 1; |
| 737 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 737 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 738 | 738 | ||
| 739 | eeprom_buff = kmalloc(sizeof(u16) * | 739 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 740 | (last_word - first_word + 1), GFP_KERNEL); | 740 | GFP_KERNEL); |
| 741 | if (!eeprom_buff) | 741 | if (!eeprom_buff) |
| 742 | return -ENOMEM; | 742 | return -ENOMEM; |
| 743 | 743 | ||
| @@ -902,11 +902,11 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | if (adapter->num_tx_queues > adapter->num_rx_queues) | 904 | if (adapter->num_tx_queues > adapter->num_rx_queues) |
| 905 | temp_ring = vmalloc(adapter->num_tx_queues * | 905 | temp_ring = vmalloc(array_size(sizeof(struct igb_ring), |
| 906 | sizeof(struct igb_ring)); | 906 | adapter->num_tx_queues)); |
| 907 | else | 907 | else |
| 908 | temp_ring = vmalloc(adapter->num_rx_queues * | 908 | temp_ring = vmalloc(array_size(sizeof(struct igb_ring), |
| 909 | sizeof(struct igb_ring)); | 909 | adapter->num_rx_queues)); |
| 910 | 910 | ||
| 911 | if (!temp_ring) { | 911 | if (!temp_ring) { |
| 912 | err = -ENOMEM; | 912 | err = -ENOMEM; |
| @@ -3245,8 +3245,8 @@ static int igb_get_module_eeprom(struct net_device *netdev, | |||
| 3245 | first_word = ee->offset >> 1; | 3245 | first_word = ee->offset >> 1; |
| 3246 | last_word = (ee->offset + ee->len - 1) >> 1; | 3246 | last_word = (ee->offset + ee->len - 1) >> 1; |
| 3247 | 3247 | ||
| 3248 | dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 3248 | dataword = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 3249 | GFP_KERNEL); | 3249 | GFP_KERNEL); |
| 3250 | if (!dataword) | 3250 | if (!dataword) |
| 3251 | return -ENOMEM; | 3251 | return -ENOMEM; |
| 3252 | 3252 | ||
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index c33821d2afb3..f707709969ac 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
| @@ -3763,8 +3763,9 @@ static int igb_sw_init(struct igb_adapter *adapter) | |||
| 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ | 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ |
| 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; | 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; |
| 3765 | 3765 | ||
| 3766 | adapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) * | 3766 | adapter->mac_table = kcalloc(hw->mac.rar_entry_count, |
| 3767 | hw->mac.rar_entry_count, GFP_ATOMIC); | 3767 | sizeof(struct igb_mac_addr), |
| 3768 | GFP_ATOMIC); | ||
| 3768 | if (!adapter->mac_table) | 3769 | if (!adapter->mac_table) |
| 3769 | return -ENOMEM; | 3770 | return -ENOMEM; |
| 3770 | 3771 | ||
| @@ -4752,7 +4753,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev) | |||
| 4752 | return 0; | 4753 | return 0; |
| 4753 | } | 4754 | } |
| 4754 | 4755 | ||
| 4755 | mta_list = kzalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); | 4756 | mta_list = kcalloc(netdev_mc_count(netdev), 6, GFP_ATOMIC); |
| 4756 | if (!mta_list) | 4757 | if (!mta_list) |
| 4757 | return -ENOMEM; | 4758 | return -ENOMEM; |
| 4758 | 4759 | ||
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c index 43744bf0fc1c..c8c93ac436d4 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c | |||
| @@ -375,8 +375,9 @@ ixgb_get_eeprom(struct net_device *netdev, | |||
| 375 | first_word = eeprom->offset >> 1; | 375 | first_word = eeprom->offset >> 1; |
| 376 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 376 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 377 | 377 | ||
| 378 | eeprom_buff = kmalloc(sizeof(__le16) * | 378 | eeprom_buff = kmalloc_array(last_word - first_word + 1, |
| 379 | (last_word - first_word + 1), GFP_KERNEL); | 379 | sizeof(__le16), |
| 380 | GFP_KERNEL); | ||
| 380 | if (!eeprom_buff) | 381 | if (!eeprom_buff) |
| 381 | return -ENOMEM; | 382 | return -ENOMEM; |
| 382 | 383 | ||
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 62f2173bc20e..43664adf7a3c 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c | |||
| @@ -1093,8 +1093,9 @@ ixgb_set_multi(struct net_device *netdev) | |||
| 1093 | rctl |= IXGB_RCTL_MPE; | 1093 | rctl |= IXGB_RCTL_MPE; |
| 1094 | IXGB_WRITE_REG(hw, RCTL, rctl); | 1094 | IXGB_WRITE_REG(hw, RCTL, rctl); |
| 1095 | } else { | 1095 | } else { |
| 1096 | u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES * | 1096 | u8 *mta = kmalloc_array(ETH_ALEN, |
| 1097 | ETH_ALEN, GFP_ATOMIC); | 1097 | IXGB_MAX_NUM_MULTICAST_ADDRESSES, |
| 1098 | GFP_ATOMIC); | ||
| 1098 | u8 *addr; | 1099 | u8 *addr; |
| 1099 | if (!mta) | 1100 | if (!mta) |
| 1100 | goto alloc_failed; | 1101 | goto alloc_failed; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index bdd179c29ea4..bd1ba88ec1d5 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |||
| @@ -901,7 +901,7 @@ static int ixgbe_get_eeprom(struct net_device *netdev, | |||
| 901 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 901 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 902 | eeprom_len = last_word - first_word + 1; | 902 | eeprom_len = last_word - first_word + 1; |
| 903 | 903 | ||
| 904 | eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL); | 904 | eeprom_buff = kmalloc_array(eeprom_len, sizeof(u16), GFP_KERNEL); |
| 905 | if (!eeprom_buff) | 905 | if (!eeprom_buff) |
| 906 | return -ENOMEM; | 906 | return -ENOMEM; |
| 907 | 907 | ||
| @@ -1063,7 +1063,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
| 1063 | /* allocate temporary buffer to store rings in */ | 1063 | /* allocate temporary buffer to store rings in */ |
| 1064 | i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues, | 1064 | i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues, |
| 1065 | adapter->num_rx_queues); | 1065 | adapter->num_rx_queues); |
| 1066 | temp_ring = vmalloc(i * sizeof(struct ixgbe_ring)); | 1066 | temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring))); |
| 1067 | 1067 | ||
| 1068 | if (!temp_ring) { | 1068 | if (!temp_ring) { |
| 1069 | err = -ENOMEM; | 1069 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 4929f7265598..0b1ba3ae159c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
| @@ -6034,8 +6034,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter, | |||
| 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) | 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) |
| 6035 | adapter->jump_tables[i] = NULL; | 6035 | adapter->jump_tables[i] = NULL; |
| 6036 | 6036 | ||
| 6037 | adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) * | 6037 | adapter->mac_table = kcalloc(hw->mac.num_rar_entries, |
| 6038 | hw->mac.num_rar_entries, | 6038 | sizeof(struct ixgbe_mac_addr), |
| 6039 | GFP_ATOMIC); | 6039 | GFP_ATOMIC); |
| 6040 | if (!adapter->mac_table) | 6040 | if (!adapter->mac_table) |
| 6041 | return -ENOMEM; | 6041 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c index e7813d76527c..631c91046f39 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c | |||
| @@ -282,8 +282,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, | |||
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | if (new_tx_count != adapter->tx_ring_count) { | 284 | if (new_tx_count != adapter->tx_ring_count) { |
| 285 | tx_ring = vmalloc((adapter->num_tx_queues + | 285 | tx_ring = vmalloc(array_size(sizeof(*tx_ring), |
| 286 | adapter->num_xdp_queues) * sizeof(*tx_ring)); | 286 | adapter->num_tx_queues + |
| 287 | adapter->num_xdp_queues)); | ||
| 287 | if (!tx_ring) { | 288 | if (!tx_ring) { |
| 288 | err = -ENOMEM; | 289 | err = -ENOMEM; |
| 289 | goto clear_reset; | 290 | goto clear_reset; |
| @@ -327,7 +328,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, | |||
| 327 | } | 328 | } |
| 328 | 329 | ||
| 329 | if (new_rx_count != adapter->rx_ring_count) { | 330 | if (new_rx_count != adapter->rx_ring_count) { |
| 330 | rx_ring = vmalloc(adapter->num_rx_queues * sizeof(*rx_ring)); | 331 | rx_ring = vmalloc(array_size(sizeof(*rx_ring), |
| 332 | adapter->num_rx_queues)); | ||
| 331 | if (!rx_ring) { | 333 | if (!rx_ring) { |
| 332 | err = -ENOMEM; | 334 | err = -ENOMEM; |
| 333 | goto clear_reset; | 335 | goto clear_reset; |
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 8a165842fa85..06ff185eb188 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
| @@ -589,8 +589,9 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
| 589 | atomic_set(&txring->next_to_clean, 0); | 589 | atomic_set(&txring->next_to_clean, 0); |
| 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); | 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); |
| 591 | 591 | ||
| 592 | txring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 592 | txring->bufinf = kcalloc(jme->tx_ring_size, |
| 593 | jme->tx_ring_size, GFP_ATOMIC); | 593 | sizeof(struct jme_buffer_info), |
| 594 | GFP_ATOMIC); | ||
| 594 | if (unlikely(!(txring->bufinf))) | 595 | if (unlikely(!(txring->bufinf))) |
| 595 | goto err_free_txring; | 596 | goto err_free_txring; |
| 596 | 597 | ||
| @@ -838,8 +839,9 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
| 838 | rxring->next_to_use = 0; | 839 | rxring->next_to_use = 0; |
| 839 | atomic_set(&rxring->next_to_clean, 0); | 840 | atomic_set(&rxring->next_to_clean, 0); |
| 840 | 841 | ||
| 841 | rxring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 842 | rxring->bufinf = kcalloc(jme->rx_ring_size, |
| 842 | jme->rx_ring_size, GFP_ATOMIC); | 843 | sizeof(struct jme_buffer_info), |
| 844 | GFP_ATOMIC); | ||
| 843 | if (unlikely(!(rxring->bufinf))) | 845 | if (unlikely(!(rxring->bufinf))) |
| 844 | goto err_free_rxring; | 846 | goto err_free_rxring; |
| 845 | 847 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 6dabd983e7e0..4bdf25059542 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c | |||
| @@ -185,8 +185,8 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, | |||
| 185 | bitmap->avail = num - reserved_top - reserved_bot; | 185 | bitmap->avail = num - reserved_top - reserved_bot; |
| 186 | bitmap->effective_len = bitmap->avail; | 186 | bitmap->effective_len = bitmap->avail; |
| 187 | spin_lock_init(&bitmap->lock); | 187 | spin_lock_init(&bitmap->lock); |
| 188 | bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) * | 188 | bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long), |
| 189 | sizeof(long), GFP_KERNEL); | 189 | GFP_KERNEL); |
| 190 | if (!bitmap->table) | 190 | if (!bitmap->table) |
| 191 | return -ENOMEM; | 191 | return -ENOMEM; |
| 192 | 192 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 6a9086dc1e92..e65bc3c95630 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
| @@ -2377,20 +2377,23 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) | |||
| 2377 | struct mlx4_vf_admin_state *vf_admin; | 2377 | struct mlx4_vf_admin_state *vf_admin; |
| 2378 | 2378 | ||
| 2379 | priv->mfunc.master.slave_state = | 2379 | priv->mfunc.master.slave_state = |
| 2380 | kzalloc(dev->num_slaves * | 2380 | kcalloc(dev->num_slaves, |
| 2381 | sizeof(struct mlx4_slave_state), GFP_KERNEL); | 2381 | sizeof(struct mlx4_slave_state), |
| 2382 | GFP_KERNEL); | ||
| 2382 | if (!priv->mfunc.master.slave_state) | 2383 | if (!priv->mfunc.master.slave_state) |
| 2383 | goto err_comm; | 2384 | goto err_comm; |
| 2384 | 2385 | ||
| 2385 | priv->mfunc.master.vf_admin = | 2386 | priv->mfunc.master.vf_admin = |
| 2386 | kzalloc(dev->num_slaves * | 2387 | kcalloc(dev->num_slaves, |
| 2387 | sizeof(struct mlx4_vf_admin_state), GFP_KERNEL); | 2388 | sizeof(struct mlx4_vf_admin_state), |
| 2389 | GFP_KERNEL); | ||
| 2388 | if (!priv->mfunc.master.vf_admin) | 2390 | if (!priv->mfunc.master.vf_admin) |
| 2389 | goto err_comm_admin; | 2391 | goto err_comm_admin; |
| 2390 | 2392 | ||
| 2391 | priv->mfunc.master.vf_oper = | 2393 | priv->mfunc.master.vf_oper = |
| 2392 | kzalloc(dev->num_slaves * | 2394 | kcalloc(dev->num_slaves, |
| 2393 | sizeof(struct mlx4_vf_oper_state), GFP_KERNEL); | 2395 | sizeof(struct mlx4_vf_oper_state), |
| 2396 | GFP_KERNEL); | ||
| 2394 | if (!priv->mfunc.master.vf_oper) | 2397 | if (!priv->mfunc.master.vf_oper) |
| 2395 | goto err_comm_oper; | 2398 | goto err_comm_oper; |
| 2396 | 2399 | ||
| @@ -2636,9 +2639,9 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev) | |||
| 2636 | int i; | 2639 | int i; |
| 2637 | int err = 0; | 2640 | int err = 0; |
| 2638 | 2641 | ||
| 2639 | priv->cmd.context = kmalloc(priv->cmd.max_cmds * | 2642 | priv->cmd.context = kmalloc_array(priv->cmd.max_cmds, |
| 2640 | sizeof(struct mlx4_cmd_context), | 2643 | sizeof(struct mlx4_cmd_context), |
| 2641 | GFP_KERNEL); | 2644 | GFP_KERNEL); |
| 2642 | if (!priv->cmd.context) | 2645 | if (!priv->cmd.context) |
| 2643 | return -ENOMEM; | 2646 | return -ENOMEM; |
| 2644 | 2647 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 9670b33fc9b1..65eb06e017e4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
| @@ -2229,13 +2229,15 @@ static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, | |||
| 2229 | if (!dst->tx_ring_num[t]) | 2229 | if (!dst->tx_ring_num[t]) |
| 2230 | continue; | 2230 | continue; |
| 2231 | 2231 | ||
| 2232 | dst->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 2232 | dst->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 2233 | MAX_TX_RINGS, GFP_KERNEL); | 2233 | sizeof(struct mlx4_en_tx_ring *), |
| 2234 | GFP_KERNEL); | ||
| 2234 | if (!dst->tx_ring[t]) | 2235 | if (!dst->tx_ring[t]) |
| 2235 | goto err_free_tx; | 2236 | goto err_free_tx; |
| 2236 | 2237 | ||
| 2237 | dst->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 2238 | dst->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 2238 | MAX_TX_RINGS, GFP_KERNEL); | 2239 | sizeof(struct mlx4_en_cq *), |
| 2240 | GFP_KERNEL); | ||
| 2239 | if (!dst->tx_cq[t]) { | 2241 | if (!dst->tx_cq[t]) { |
| 2240 | kfree(dst->tx_ring[t]); | 2242 | kfree(dst->tx_ring[t]); |
| 2241 | goto err_free_tx; | 2243 | goto err_free_tx; |
| @@ -3320,14 +3322,16 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 3320 | if (!priv->tx_ring_num[t]) | 3322 | if (!priv->tx_ring_num[t]) |
| 3321 | continue; | 3323 | continue; |
| 3322 | 3324 | ||
| 3323 | priv->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 3325 | priv->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 3324 | MAX_TX_RINGS, GFP_KERNEL); | 3326 | sizeof(struct mlx4_en_tx_ring *), |
| 3327 | GFP_KERNEL); | ||
| 3325 | if (!priv->tx_ring[t]) { | 3328 | if (!priv->tx_ring[t]) { |
| 3326 | err = -ENOMEM; | 3329 | err = -ENOMEM; |
| 3327 | goto out; | 3330 | goto out; |
| 3328 | } | 3331 | } |
| 3329 | priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 3332 | priv->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 3330 | MAX_TX_RINGS, GFP_KERNEL); | 3333 | sizeof(struct mlx4_en_cq *), |
| 3334 | GFP_KERNEL); | ||
| 3331 | if (!priv->tx_cq[t]) { | 3335 | if (!priv->tx_cq[t]) { |
| 3332 | err = -ENOMEM; | 3336 | err = -ENOMEM; |
| 3333 | goto out; | 3337 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 6f57c052053e..1f3372c1802e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c | |||
| @@ -1211,8 +1211,9 @@ int mlx4_init_eq_table(struct mlx4_dev *dev) | |||
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | priv->eq_table.irq_names = | 1213 | priv->eq_table.irq_names = |
| 1214 | kmalloc(MLX4_IRQNAME_SIZE * (dev->caps.num_comp_vectors + 1), | 1214 | kmalloc_array(MLX4_IRQNAME_SIZE, |
| 1215 | GFP_KERNEL); | 1215 | (dev->caps.num_comp_vectors + 1), |
| 1216 | GFP_KERNEL); | ||
| 1216 | if (!priv->eq_table.irq_names) { | 1217 | if (!priv->eq_table.irq_names) { |
| 1217 | err = -ENOMEM; | 1218 | err = -ENOMEM; |
| 1218 | goto err_out_clr_int; | 1219 | goto err_out_clr_int; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c index 5342bd8a3d0b..7262c6310650 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.c +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c | |||
| @@ -408,7 +408,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, | |||
| 408 | return -EINVAL; | 408 | return -EINVAL; |
| 409 | num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; | 409 | num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; |
| 410 | 410 | ||
| 411 | table->icm = kvzalloc(num_icm * sizeof(*table->icm), GFP_KERNEL); | 411 | table->icm = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL); |
| 412 | if (!table->icm) | 412 | if (!table->icm) |
| 413 | return -ENOMEM; | 413 | return -ENOMEM; |
| 414 | table->virt = virt; | 414 | table->virt = virt; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 0a30d81aab3b..872014702fc1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
| @@ -2982,7 +2982,8 @@ static int mlx4_init_steering(struct mlx4_dev *dev) | |||
| 2982 | int num_entries = dev->caps.num_ports; | 2982 | int num_entries = dev->caps.num_ports; |
| 2983 | int i, j; | 2983 | int i, j; |
| 2984 | 2984 | ||
| 2985 | priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL); | 2985 | priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer), |
| 2986 | GFP_KERNEL); | ||
| 2986 | if (!priv->steer) | 2987 | if (!priv->steer) |
| 2987 | return -ENOMEM; | 2988 | return -ENOMEM; |
| 2988 | 2989 | ||
| @@ -3103,7 +3104,7 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev, | |||
| 3103 | } | 3104 | } |
| 3104 | } | 3105 | } |
| 3105 | 3106 | ||
| 3106 | dev->dev_vfs = kzalloc(total_vfs * sizeof(*dev->dev_vfs), GFP_KERNEL); | 3107 | dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL); |
| 3107 | if (NULL == dev->dev_vfs) { | 3108 | if (NULL == dev->dev_vfs) { |
| 3108 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); | 3109 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); |
| 3109 | goto disable_sriov; | 3110 | goto disable_sriov; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 29e50f787349..7b1b5ac986d0 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
| @@ -487,7 +487,7 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); | 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); |
| 488 | 488 | ||
| 489 | priv->mfunc.master.res_tracker.slave_list = | 489 | priv->mfunc.master.res_tracker.slave_list = |
| 490 | kzalloc(dev->num_slaves * sizeof(struct slave_list), | 490 | kcalloc(dev->num_slaves, sizeof(struct slave_list), |
| 491 | GFP_KERNEL); | 491 | GFP_KERNEL); |
| 492 | if (!priv->mfunc.master.res_tracker.slave_list) | 492 | if (!priv->mfunc.master.res_tracker.slave_list) |
| 493 | return -ENOMEM; | 493 | return -ENOMEM; |
| @@ -507,19 +507,21 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 507 | for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) { | 507 | for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) { |
| 508 | struct resource_allocator *res_alloc = | 508 | struct resource_allocator *res_alloc = |
| 509 | &priv->mfunc.master.res_tracker.res_alloc[i]; | 509 | &priv->mfunc.master.res_tracker.res_alloc[i]; |
| 510 | res_alloc->quota = kmalloc((dev->persist->num_vfs + 1) * | 510 | res_alloc->quota = kmalloc_array(dev->persist->num_vfs + 1, |
| 511 | sizeof(int), GFP_KERNEL); | 511 | sizeof(int), |
| 512 | res_alloc->guaranteed = kmalloc((dev->persist->num_vfs + 1) * | 512 | GFP_KERNEL); |
| 513 | sizeof(int), GFP_KERNEL); | 513 | res_alloc->guaranteed = kmalloc_array(dev->persist->num_vfs + 1, |
| 514 | sizeof(int), | ||
| 515 | GFP_KERNEL); | ||
| 514 | if (i == RES_MAC || i == RES_VLAN) | 516 | if (i == RES_MAC || i == RES_VLAN) |
| 515 | res_alloc->allocated = kzalloc(MLX4_MAX_PORTS * | 517 | res_alloc->allocated = |
| 516 | (dev->persist->num_vfs | 518 | kcalloc(MLX4_MAX_PORTS * |
| 517 | + 1) * | 519 | (dev->persist->num_vfs + 1), |
| 518 | sizeof(int), GFP_KERNEL); | 520 | sizeof(int), GFP_KERNEL); |
| 519 | else | 521 | else |
| 520 | res_alloc->allocated = kzalloc((dev->persist-> | 522 | res_alloc->allocated = |
| 521 | num_vfs + 1) * | 523 | kcalloc(dev->persist->num_vfs + 1, |
| 522 | sizeof(int), GFP_KERNEL); | 524 | sizeof(int), GFP_KERNEL); |
| 523 | /* Reduce the sink counter */ | 525 | /* Reduce the sink counter */ |
| 524 | if (i == RES_COUNTER) | 526 | if (i == RES_COUNTER) |
| 525 | res_alloc->res_free = dev->caps.max_counters - 1; | 527 | res_alloc->res_free = dev->caps.max_counters - 1; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 89c96a0f708e..56c1b6f5593e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c | |||
| @@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, | |||
| 352 | { | 352 | { |
| 353 | int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); | 353 | int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); |
| 354 | 354 | ||
| 355 | rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info), | 355 | rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info), |
| 356 | GFP_KERNEL, cpu_to_node(c->cpu)); | 356 | GFP_KERNEL, cpu_to_node(c->cpu)); |
| 357 | if (!rq->mpwqe.info) | 357 | if (!rq->mpwqe.info) |
| 358 | return -ENOMEM; | 358 | return -ENOMEM; |
| @@ -448,7 +448,7 @@ static int mlx5e_init_di_list(struct mlx5e_rq *rq, | |||
| 448 | { | 448 | { |
| 449 | int len = wq_sz << rq->wqe.info.log_num_frags; | 449 | int len = wq_sz << rq->wqe.info.log_num_frags; |
| 450 | 450 | ||
| 451 | rq->wqe.di = kvzalloc_node(len * sizeof(*rq->wqe.di), | 451 | rq->wqe.di = kvzalloc_node(array_size(len, sizeof(*rq->wqe.di)), |
| 452 | GFP_KERNEL, cpu_to_node(cpu)); | 452 | GFP_KERNEL, cpu_to_node(cpu)); |
| 453 | if (!rq->wqe.di) | 453 | if (!rq->wqe.di) |
| 454 | return -ENOMEM; | 454 | return -ENOMEM; |
| @@ -563,8 +563,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, | |||
| 563 | 563 | ||
| 564 | rq->wqe.info = rqp->frags_info; | 564 | rq->wqe.info = rqp->frags_info; |
| 565 | rq->wqe.frags = | 565 | rq->wqe.frags = |
| 566 | kvzalloc_node((wq_sz << rq->wqe.info.log_num_frags) * | 566 | kvzalloc_node(array_size(sizeof(*rq->wqe.frags), |
| 567 | sizeof(*rq->wqe.frags), | 567 | (wq_sz << rq->wqe.info.log_num_frags)), |
| 568 | GFP_KERNEL, cpu_to_node(c->cpu)); | 568 | GFP_KERNEL, cpu_to_node(c->cpu)); |
| 569 | if (!rq->wqe.frags) { | 569 | if (!rq->wqe.frags) { |
| 570 | err = -ENOMEM; | 570 | err = -ENOMEM; |
| @@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa) | |||
| 972 | { | 972 | { |
| 973 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 973 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 974 | 974 | ||
| 975 | sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz, | 975 | sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di), |
| 976 | GFP_KERNEL, numa); | 976 | GFP_KERNEL, numa); |
| 977 | if (!sq->db.di) { | 977 | if (!sq->db.di) { |
| 978 | mlx5e_free_xdpsq_db(sq); | 978 | mlx5e_free_xdpsq_db(sq); |
| @@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa) | |||
| 1031 | { | 1031 | { |
| 1032 | u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 1032 | u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 1033 | 1033 | ||
| 1034 | sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz, | 1034 | sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe), |
| 1035 | GFP_KERNEL, numa); | 1035 | GFP_KERNEL, numa); |
| 1036 | if (!sq->db.ico_wqe) | 1036 | if (!sq->db.ico_wqe) |
| 1037 | return -ENOMEM; | 1037 | return -ENOMEM; |
| @@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa) | |||
| 1086 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 1086 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 1087 | int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; | 1087 | int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; |
| 1088 | 1088 | ||
| 1089 | sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo), | 1089 | sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo), |
| 1090 | GFP_KERNEL, numa); | 1090 | GFP_KERNEL, numa); |
| 1091 | sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info), | 1091 | sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info), |
| 1092 | GFP_KERNEL, numa); | 1092 | GFP_KERNEL, numa); |
| 1093 | if (!sq->db.dma_fifo || !sq->db.wqe_info) { | 1093 | if (!sq->db.dma_fifo || !sq->db.wqe_info) { |
| 1094 | mlx5e_free_txqsq_db(sq); | 1094 | mlx5e_free_txqsq_db(sq); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c index 4138a770ed57..8ca1d1949d93 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c | |||
| @@ -549,15 +549,17 @@ static int mlx5_fpga_conn_create_qp(struct mlx5_fpga_conn *conn, | |||
| 549 | if (err) | 549 | if (err) |
| 550 | goto out; | 550 | goto out; |
| 551 | 551 | ||
| 552 | conn->qp.rq.bufs = kvzalloc(sizeof(conn->qp.rq.bufs[0]) * | 552 | conn->qp.rq.bufs = kvcalloc(conn->qp.rq.size, |
| 553 | conn->qp.rq.size, GFP_KERNEL); | 553 | sizeof(conn->qp.rq.bufs[0]), |
| 554 | GFP_KERNEL); | ||
| 554 | if (!conn->qp.rq.bufs) { | 555 | if (!conn->qp.rq.bufs) { |
| 555 | err = -ENOMEM; | 556 | err = -ENOMEM; |
| 556 | goto err_wq; | 557 | goto err_wq; |
| 557 | } | 558 | } |
| 558 | 559 | ||
| 559 | conn->qp.sq.bufs = kvzalloc(sizeof(conn->qp.sq.bufs[0]) * | 560 | conn->qp.sq.bufs = kvcalloc(conn->qp.sq.size, |
| 560 | conn->qp.sq.size, GFP_KERNEL); | 561 | sizeof(conn->qp.sq.bufs[0]), |
| 562 | GFP_KERNEL); | ||
| 561 | if (!conn->qp.sq.bufs) { | 563 | if (!conn->qp.sq.bufs) { |
| 562 | err = -ENOMEM; | 564 | err = -ENOMEM; |
| 563 | goto err_rq_bufs; | 565 | goto err_rq_bufs; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index a0433b48e833..5645a4facad2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | |||
| @@ -381,7 +381,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters, | |||
| 381 | 381 | ||
| 382 | count = mlx5_fpga_ipsec_counters_count(mdev); | 382 | count = mlx5_fpga_ipsec_counters_count(mdev); |
| 383 | 383 | ||
| 384 | data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL); | 384 | data = kzalloc(array3_size(sizeof(*data), count, 2), GFP_KERNEL); |
| 385 | if (!data) { | 385 | if (!data) { |
| 386 | ret = -ENOMEM; | 386 | ret = -ENOMEM; |
| 387 | goto out; | 387 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 857035583ccd..1e062e6b2587 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | |||
| @@ -394,8 +394,9 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock) | |||
| 394 | int i; | 394 | int i; |
| 395 | 395 | ||
| 396 | clock->ptp_info.pin_config = | 396 | clock->ptp_info.pin_config = |
| 397 | kzalloc(sizeof(*clock->ptp_info.pin_config) * | 397 | kcalloc(clock->ptp_info.n_pins, |
| 398 | clock->ptp_info.n_pins, GFP_KERNEL); | 398 | sizeof(*clock->ptp_info.pin_config), |
| 399 | GFP_KERNEL); | ||
| 399 | if (!clock->ptp_info.pin_config) | 400 | if (!clock->ptp_info.pin_config) |
| 400 | return -ENOMEM; | 401 | return -ENOMEM; |
| 401 | clock->ptp_info.enable = mlx5_ptp_enable; | 402 | clock->ptp_info.enable = mlx5_ptp_enable; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c index 91262b0573e3..cad603c35271 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | |||
| @@ -740,7 +740,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port) | |||
| 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; | 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; |
| 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; | 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; |
| 742 | 742 | ||
| 743 | mlxsw_sp_qdisc = kzalloc(sizeof(*mlxsw_sp_qdisc) * IEEE_8021QAZ_MAX_TCS, | 743 | mlxsw_sp_qdisc = kcalloc(IEEE_8021QAZ_MAX_TCS, |
| 744 | sizeof(*mlxsw_sp_qdisc), | ||
| 744 | GFP_KERNEL); | 745 | GFP_KERNEL); |
| 745 | if (!mlxsw_sp_qdisc) | 746 | if (!mlxsw_sp_qdisc) |
| 746 | goto err_tclass_qdiscs_init; | 747 | goto err_tclass_qdiscs_init; |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 52207508744c..b72d1bd11296 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c | |||
| @@ -4372,7 +4372,7 @@ static void ksz_update_timer(struct ksz_timer_info *info) | |||
| 4372 | */ | 4372 | */ |
| 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) | 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) |
| 4374 | { | 4374 | { |
| 4375 | desc_info->ring = kzalloc(sizeof(struct ksz_desc) * desc_info->alloc, | 4375 | desc_info->ring = kcalloc(desc_info->alloc, sizeof(struct ksz_desc), |
| 4376 | GFP_KERNEL); | 4376 | GFP_KERNEL); |
| 4377 | if (!desc_info->ring) | 4377 | if (!desc_info->ring) |
| 4378 | return 1; | 4378 | return 1; |
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 2e4effa9fe45..b34055ac476f 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c | |||
| @@ -507,15 +507,15 @@ static int moxart_mac_probe(struct platform_device *pdev) | |||
| 507 | goto init_fail; | 507 | goto init_fail; |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM, | 510 | priv->tx_buf_base = kmalloc_array(priv->tx_buf_size, TX_DESC_NUM, |
| 511 | GFP_ATOMIC); | 511 | GFP_ATOMIC); |
| 512 | if (!priv->tx_buf_base) { | 512 | if (!priv->tx_buf_base) { |
| 513 | ret = -ENOMEM; | 513 | ret = -ENOMEM; |
| 514 | goto init_fail; | 514 | goto init_fail; |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM, | 517 | priv->rx_buf_base = kmalloc_array(priv->rx_buf_size, RX_DESC_NUM, |
| 518 | GFP_ATOMIC); | 518 | GFP_ATOMIC); |
| 519 | if (!priv->rx_buf_base) { | 519 | if (!priv->rx_buf_base) { |
| 520 | ret = -ENOMEM; | 520 | ret = -ENOMEM; |
| 521 | goto init_fail; | 521 | goto init_fail; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c index c60da9e8bf14..358ed6118881 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c | |||
| @@ -2220,22 +2220,22 @@ __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph, | |||
| 2220 | channel->length = length; | 2220 | channel->length = length; |
| 2221 | channel->vp_id = vp_id; | 2221 | channel->vp_id = vp_id; |
| 2222 | 2222 | ||
| 2223 | channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2223 | channel->work_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2224 | if (channel->work_arr == NULL) | 2224 | if (channel->work_arr == NULL) |
| 2225 | goto exit1; | 2225 | goto exit1; |
| 2226 | 2226 | ||
| 2227 | channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2227 | channel->free_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2228 | if (channel->free_arr == NULL) | 2228 | if (channel->free_arr == NULL) |
| 2229 | goto exit1; | 2229 | goto exit1; |
| 2230 | channel->free_ptr = length; | 2230 | channel->free_ptr = length; |
| 2231 | 2231 | ||
| 2232 | channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2232 | channel->reserve_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2233 | if (channel->reserve_arr == NULL) | 2233 | if (channel->reserve_arr == NULL) |
| 2234 | goto exit1; | 2234 | goto exit1; |
| 2235 | channel->reserve_ptr = length; | 2235 | channel->reserve_ptr = length; |
| 2236 | channel->reserve_top = 0; | 2236 | channel->reserve_top = 0; |
| 2237 | 2237 | ||
| 2238 | channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2238 | channel->orig_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2239 | if (channel->orig_arr == NULL) | 2239 | if (channel->orig_arr == NULL) |
| 2240 | goto exit1; | 2240 | goto exit1; |
| 2241 | 2241 | ||
| @@ -2565,7 +2565,7 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate, | |||
| 2565 | * allocate new memblock and its private part at once. | 2565 | * allocate new memblock and its private part at once. |
| 2566 | * This helps to minimize memory usage a lot. */ | 2566 | * This helps to minimize memory usage a lot. */ |
| 2567 | mempool->memblocks_priv_arr[i] = | 2567 | mempool->memblocks_priv_arr[i] = |
| 2568 | vzalloc(mempool->items_priv_size * n_items); | 2568 | vzalloc(array_size(mempool->items_priv_size, n_items)); |
| 2569 | if (mempool->memblocks_priv_arr[i] == NULL) { | 2569 | if (mempool->memblocks_priv_arr[i] == NULL) { |
| 2570 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2570 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| 2571 | goto exit; | 2571 | goto exit; |
| @@ -2665,7 +2665,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2665 | 2665 | ||
| 2666 | /* allocate array of memblocks */ | 2666 | /* allocate array of memblocks */ |
| 2667 | mempool->memblocks_arr = | 2667 | mempool->memblocks_arr = |
| 2668 | vzalloc(sizeof(void *) * mempool->memblocks_max); | 2668 | vzalloc(array_size(sizeof(void *), mempool->memblocks_max)); |
| 2669 | if (mempool->memblocks_arr == NULL) { | 2669 | if (mempool->memblocks_arr == NULL) { |
| 2670 | __vxge_hw_mempool_destroy(mempool); | 2670 | __vxge_hw_mempool_destroy(mempool); |
| 2671 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2671 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2675,7 +2675,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2675 | 2675 | ||
| 2676 | /* allocate array of private parts of items per memblocks */ | 2676 | /* allocate array of private parts of items per memblocks */ |
| 2677 | mempool->memblocks_priv_arr = | 2677 | mempool->memblocks_priv_arr = |
| 2678 | vzalloc(sizeof(void *) * mempool->memblocks_max); | 2678 | vzalloc(array_size(sizeof(void *), mempool->memblocks_max)); |
| 2679 | if (mempool->memblocks_priv_arr == NULL) { | 2679 | if (mempool->memblocks_priv_arr == NULL) { |
| 2680 | __vxge_hw_mempool_destroy(mempool); | 2680 | __vxge_hw_mempool_destroy(mempool); |
| 2681 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2681 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2685,8 +2685,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2685 | 2685 | ||
| 2686 | /* allocate array of memblocks DMA objects */ | 2686 | /* allocate array of memblocks DMA objects */ |
| 2687 | mempool->memblocks_dma_arr = | 2687 | mempool->memblocks_dma_arr = |
| 2688 | vzalloc(sizeof(struct vxge_hw_mempool_dma) * | 2688 | vzalloc(array_size(sizeof(struct vxge_hw_mempool_dma), |
| 2689 | mempool->memblocks_max); | 2689 | mempool->memblocks_max)); |
| 2690 | if (mempool->memblocks_dma_arr == NULL) { | 2690 | if (mempool->memblocks_dma_arr == NULL) { |
| 2691 | __vxge_hw_mempool_destroy(mempool); | 2691 | __vxge_hw_mempool_destroy(mempool); |
| 2692 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2692 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2695,7 +2695,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2695 | } | 2695 | } |
| 2696 | 2696 | ||
| 2697 | /* allocate hash array of items */ | 2697 | /* allocate hash array of items */ |
| 2698 | mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max); | 2698 | mempool->items_arr = vzalloc(array_size(sizeof(void *), |
| 2699 | mempool->items_max)); | ||
| 2699 | if (mempool->items_arr == NULL) { | 2700 | if (mempool->items_arr == NULL) { |
| 2700 | __vxge_hw_mempool_destroy(mempool); | 2701 | __vxge_hw_mempool_destroy(mempool); |
| 2701 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2702 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index a8918bb7c802..5ae3fa82909f 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c | |||
| @@ -3429,8 +3429,8 @@ static int vxge_device_register(struct __vxge_hw_device *hldev, | |||
| 3429 | vxge_initialize_ethtool_ops(ndev); | 3429 | vxge_initialize_ethtool_ops(ndev); |
| 3430 | 3430 | ||
| 3431 | /* Allocate memory for vpath */ | 3431 | /* Allocate memory for vpath */ |
| 3432 | vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) * | 3432 | vdev->vpaths = kcalloc(no_of_vpath, sizeof(struct vxge_vpath), |
| 3433 | no_of_vpath, GFP_KERNEL); | 3433 | GFP_KERNEL); |
| 3434 | if (!vdev->vpaths) { | 3434 | if (!vdev->vpaths) { |
| 3435 | vxge_debug_init(VXGE_ERR, | 3435 | vxge_debug_init(VXGE_ERR, |
| 3436 | "%s: vpath memory allocation failed", | 3436 | "%s: vpath memory allocation failed", |
diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c index 1561c2724c26..b84a6c2d387b 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/main.c +++ b/drivers/net/ethernet/netronome/nfp/abm/main.c | |||
| @@ -590,7 +590,7 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id) | |||
| 590 | alink->id = id; | 590 | alink->id = id; |
| 591 | alink->parent = TC_H_ROOT; | 591 | alink->parent = TC_H_ROOT; |
| 592 | alink->total_queues = alink->vnic->max_rx_rings; | 592 | alink->total_queues = alink->vnic->max_rx_rings; |
| 593 | alink->qdiscs = kvzalloc(sizeof(*alink->qdiscs) * alink->total_queues, | 593 | alink->qdiscs = kvcalloc(alink->total_queues, sizeof(*alink->qdiscs), |
| 594 | GFP_KERNEL); | 594 | GFP_KERNEL); |
| 595 | if (!alink->qdiscs) { | 595 | if (!alink->qdiscs) { |
| 596 | err = -ENOMEM; | 596 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 21668aa435e8..93fb809f50d1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c | |||
| @@ -417,7 +417,8 @@ int nfp_flower_metadata_init(struct nfp_app *app) | |||
| 417 | 417 | ||
| 418 | /* Init ring buffer and unallocated stats_ids. */ | 418 | /* Init ring buffer and unallocated stats_ids. */ |
| 419 | priv->stats_ids.free_list.buf = | 419 | priv->stats_ids.free_list.buf = |
| 420 | vmalloc(NFP_FL_STATS_ENTRY_RS * NFP_FL_STATS_ELEM_RS); | 420 | vmalloc(array_size(NFP_FL_STATS_ELEM_RS, |
| 421 | NFP_FL_STATS_ENTRY_RS)); | ||
| 421 | if (!priv->stats_ids.free_list.buf) | 422 | if (!priv->stats_ids.free_list.buf) |
| 422 | goto err_free_last_used; | 423 | goto err_free_last_used; |
| 423 | 424 | ||
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c index b092894dd128..09f674ec0f9e 100644 --- a/drivers/net/ethernet/ni/nixge.c +++ b/drivers/net/ethernet/ni/nixge.c | |||
| @@ -247,9 +247,8 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev) | |||
| 247 | if (!priv->tx_bd_v) | 247 | if (!priv->tx_bd_v) |
| 248 | goto out; | 248 | goto out; |
| 249 | 249 | ||
| 250 | priv->tx_skb = devm_kzalloc(ndev->dev.parent, | 250 | priv->tx_skb = devm_kcalloc(ndev->dev.parent, |
| 251 | sizeof(*priv->tx_skb) * | 251 | TX_BD_NUM, sizeof(*priv->tx_skb), |
| 252 | TX_BD_NUM, | ||
| 253 | GFP_KERNEL); | 252 | GFP_KERNEL); |
| 254 | if (!priv->tx_skb) | 253 | if (!priv->tx_skb) |
| 255 | goto out; | 254 | goto out; |
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 66c665d0b926..7cbd0174459c 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c | |||
| @@ -4630,8 +4630,10 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri | |||
| 4630 | ring->tx_pending), | 4630 | ring->tx_pending), |
| 4631 | &ring_addr, GFP_ATOMIC); | 4631 | &ring_addr, GFP_ATOMIC); |
| 4632 | } | 4632 | } |
| 4633 | rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL); | 4633 | rx_skbuff = kmalloc_array(ring->rx_pending, sizeof(struct nv_skb_map), |
| 4634 | tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL); | 4634 | GFP_KERNEL); |
| 4635 | tx_skbuff = kmalloc_array(ring->tx_pending, sizeof(struct nv_skb_map), | ||
| 4636 | GFP_KERNEL); | ||
| 4635 | if (!rxtx_ring || !rx_skbuff || !tx_skbuff) { | 4637 | if (!rxtx_ring || !rx_skbuff || !tx_skbuff) { |
| 4636 | /* fall back to old rings */ | 4638 | /* fall back to old rings */ |
| 4637 | if (!nv_optimized(np)) { | 4639 | if (!nv_optimized(np)) { |
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 7cd494611a74..34a1581eda95 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | |||
| @@ -2178,7 +2178,7 @@ static void pch_gbe_set_multi(struct net_device *netdev) | |||
| 2178 | 2178 | ||
| 2179 | if (mc_count >= PCH_GBE_MAR_ENTRIES) | 2179 | if (mc_count >= PCH_GBE_MAR_ENTRIES) |
| 2180 | return; | 2180 | return; |
| 2181 | mta_list = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC); | 2181 | mta_list = kmalloc_array(ETH_ALEN, mc_count, GFP_ATOMIC); |
| 2182 | if (!mta_list) | 2182 | if (!mta_list) |
| 2183 | return; | 2183 | return; |
| 2184 | 2184 | ||
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 07a2eb3781b1..8a31a02c9f47 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c | |||
| @@ -390,8 +390,9 @@ static int pasemi_mac_setup_rx_resources(const struct net_device *dev) | |||
| 390 | spin_lock_init(&ring->lock); | 390 | spin_lock_init(&ring->lock); |
| 391 | 391 | ||
| 392 | ring->size = RX_RING_SIZE; | 392 | ring->size = RX_RING_SIZE; |
| 393 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 393 | ring->ring_info = kcalloc(RX_RING_SIZE, |
| 394 | RX_RING_SIZE, GFP_KERNEL); | 394 | sizeof(struct pasemi_mac_buffer), |
| 395 | GFP_KERNEL); | ||
| 395 | 396 | ||
| 396 | if (!ring->ring_info) | 397 | if (!ring->ring_info) |
| 397 | goto out_ring_info; | 398 | goto out_ring_info; |
| @@ -473,8 +474,9 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev) | |||
| 473 | spin_lock_init(&ring->lock); | 474 | spin_lock_init(&ring->lock); |
| 474 | 475 | ||
| 475 | ring->size = TX_RING_SIZE; | 476 | ring->size = TX_RING_SIZE; |
| 476 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 477 | ring->ring_info = kcalloc(TX_RING_SIZE, |
| 477 | TX_RING_SIZE, GFP_KERNEL); | 478 | sizeof(struct pasemi_mac_buffer), |
| 479 | GFP_KERNEL); | ||
| 478 | if (!ring->ring_info) | 480 | if (!ring->ring_info) |
| 479 | goto out_ring_info; | 481 | goto out_ring_info; |
| 480 | 482 | ||
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c index b9ec460dd996..a14e48489029 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_debug.c +++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c | |||
| @@ -6617,7 +6617,8 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6617 | 6617 | ||
| 6618 | /* Read no. of modules and allocate memory for their pointers */ | 6618 | /* Read no. of modules and allocate memory for their pointers */ |
| 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); | 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); |
| 6620 | meta->modules = kzalloc(meta->modules_num * sizeof(char *), GFP_KERNEL); | 6620 | meta->modules = kcalloc(meta->modules_num, sizeof(char *), |
| 6621 | GFP_KERNEL); | ||
| 6621 | if (!meta->modules) | 6622 | if (!meta->modules) |
| 6622 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; | 6623 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; |
| 6623 | 6624 | ||
| @@ -6645,7 +6646,7 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6645 | 6646 | ||
| 6646 | /* Read number of formats and allocate memory for all formats */ | 6647 | /* Read number of formats and allocate memory for all formats */ |
| 6647 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); | 6648 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); |
| 6648 | meta->formats = kzalloc(meta->formats_num * | 6649 | meta->formats = kcalloc(meta->formats_num, |
| 6649 | sizeof(struct mcp_trace_format), | 6650 | sizeof(struct mcp_trace_format), |
| 6650 | GFP_KERNEL); | 6651 | GFP_KERNEL); |
| 6651 | if (!meta->formats) | 6652 | if (!meta->formats) |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index b285edc8d6a1..329781cda77f 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c | |||
| @@ -814,26 +814,26 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn) | |||
| 814 | if (rc) | 814 | if (rc) |
| 815 | goto alloc_err; | 815 | goto alloc_err; |
| 816 | 816 | ||
| 817 | qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) * | 817 | qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn), |
| 818 | qed_init_qm_get_num_pqs(p_hwfn), | 818 | sizeof(*qm_info->qm_pq_params), |
| 819 | GFP_KERNEL); | 819 | GFP_KERNEL); |
| 820 | if (!qm_info->qm_pq_params) | 820 | if (!qm_info->qm_pq_params) |
| 821 | goto alloc_err; | 821 | goto alloc_err; |
| 822 | 822 | ||
| 823 | qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) * | 823 | qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 824 | qed_init_qm_get_num_vports(p_hwfn), | 824 | sizeof(*qm_info->qm_vport_params), |
| 825 | GFP_KERNEL); | 825 | GFP_KERNEL); |
| 826 | if (!qm_info->qm_vport_params) | 826 | if (!qm_info->qm_vport_params) |
| 827 | goto alloc_err; | 827 | goto alloc_err; |
| 828 | 828 | ||
| 829 | qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) * | 829 | qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine, |
| 830 | p_hwfn->cdev->num_ports_in_engine, | 830 | sizeof(*qm_info->qm_port_params), |
| 831 | GFP_KERNEL); | 831 | GFP_KERNEL); |
| 832 | if (!qm_info->qm_port_params) | 832 | if (!qm_info->qm_port_params) |
| 833 | goto alloc_err; | 833 | goto alloc_err; |
| 834 | 834 | ||
| 835 | qm_info->wfq_data = kzalloc(sizeof(*qm_info->wfq_data) * | 835 | qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 836 | qed_init_qm_get_num_vports(p_hwfn), | 836 | sizeof(*qm_info->wfq_data), |
| 837 | GFP_KERNEL); | 837 | GFP_KERNEL); |
| 838 | if (!qm_info->wfq_data) | 838 | if (!qm_info->wfq_data) |
| 839 | goto alloc_err; | 839 | goto alloc_err; |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c index 3bb76da6baa2..d9ab5add27a8 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c | |||
| @@ -149,12 +149,12 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) | |||
| 149 | if (IS_VF(p_hwfn->cdev)) | 149 | if (IS_VF(p_hwfn->cdev)) |
| 150 | return 0; | 150 | return 0; |
| 151 | 151 | ||
| 152 | rt_data->b_valid = kzalloc(sizeof(bool) * RUNTIME_ARRAY_SIZE, | 152 | rt_data->b_valid = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(bool), |
| 153 | GFP_KERNEL); | 153 | GFP_KERNEL); |
| 154 | if (!rt_data->b_valid) | 154 | if (!rt_data->b_valid) |
| 155 | return -ENOMEM; | 155 | return -ENOMEM; |
| 156 | 156 | ||
| 157 | rt_data->init_val = kzalloc(sizeof(u32) * RUNTIME_ARRAY_SIZE, | 157 | rt_data->init_val = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(u32), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!rt_data->init_val) { | 159 | if (!rt_data->init_val) { |
| 160 | kfree(rt_data->b_valid); | 160 | kfree(rt_data->b_valid); |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c index 1f6ac848109d..99973e10b179 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_l2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c | |||
| @@ -98,7 +98,7 @@ int qed_l2_alloc(struct qed_hwfn *p_hwfn) | |||
| 98 | p_l2_info->queues = max_t(u8, rx, tx); | 98 | p_l2_info->queues = max_t(u8, rx, tx); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | pp_qids = kzalloc(sizeof(unsigned long *) * p_l2_info->queues, | 101 | pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *), |
| 102 | GFP_KERNEL); | 102 | GFP_KERNEL); |
| 103 | if (!pp_qids) | 103 | if (!pp_qids) |
| 104 | return -ENOMEM; | 104 | return -ENOMEM; |
| @@ -2435,7 +2435,7 @@ static int qed_update_vport(struct qed_dev *cdev, | |||
| 2435 | if (!cdev) | 2435 | if (!cdev) |
| 2436 | return -ENODEV; | 2436 | return -ENODEV; |
| 2437 | 2437 | ||
| 2438 | rss = vzalloc(sizeof(*rss) * cdev->num_hwfns); | 2438 | rss = vzalloc(array_size(sizeof(*rss), cdev->num_hwfns)); |
| 2439 | if (!rss) | 2439 | if (!rss) |
| 2440 | return -ENOMEM; | 2440 | return -ENOMEM; |
| 2441 | 2441 | ||
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c index 6f9927d1a501..4e0b443c9519 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c | |||
| @@ -2578,9 +2578,9 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn) | |||
| 2578 | goto err0; | 2578 | goto err0; |
| 2579 | } | 2579 | } |
| 2580 | 2580 | ||
| 2581 | nvm_info->image_att = kmalloc(nvm_info->num_images * | 2581 | nvm_info->image_att = kmalloc_array(nvm_info->num_images, |
| 2582 | sizeof(struct bist_nvm_image_att), | 2582 | sizeof(struct bist_nvm_image_att), |
| 2583 | GFP_KERNEL); | 2583 | GFP_KERNEL); |
| 2584 | if (!nvm_info->image_att) { | 2584 | if (!nvm_info->image_att) { |
| 2585 | rc = -ENOMEM; | 2585 | rc = -ENOMEM; |
| 2586 | goto err0; | 2586 | goto err0; |
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index e9e088d9c815..b823bfe2ea4d 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c | |||
| @@ -342,8 +342,9 @@ int qede_alloc_arfs(struct qede_dev *edev) | |||
| 342 | for (i = 0; i <= QEDE_RFS_FLW_MASK; i++) | 342 | for (i = 0; i <= QEDE_RFS_FLW_MASK; i++) |
| 343 | INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i)); | 343 | INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i)); |
| 344 | 344 | ||
| 345 | edev->arfs->arfs_fltr_bmap = vzalloc(BITS_TO_LONGS(QEDE_RFS_MAX_FLTR) * | 345 | edev->arfs->arfs_fltr_bmap = |
| 346 | sizeof(long)); | 346 | vzalloc(array_size(sizeof(long), |
| 347 | BITS_TO_LONGS(QEDE_RFS_MAX_FLTR))); | ||
| 347 | if (!edev->arfs->arfs_fltr_bmap) { | 348 | if (!edev->arfs->arfs_fltr_bmap) { |
| 348 | vfree(edev->arfs); | 349 | vfree(edev->arfs); |
| 349 | edev->arfs = NULL; | 350 | edev->arfs = NULL; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c index 97c146e7698a..569d54ededec 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | |||
| @@ -386,8 +386,9 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter) | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | /* setup interrupt mapping table for fw */ | 388 | /* setup interrupt mapping table for fw */ |
| 389 | ahw->intr_tbl = vzalloc(num_msix * | 389 | ahw->intr_tbl = |
| 390 | sizeof(struct qlcnic_intrpt_config)); | 390 | vzalloc(array_size(num_msix, |
| 391 | sizeof(struct qlcnic_intrpt_config))); | ||
| 391 | if (!ahw->intr_tbl) | 392 | if (!ahw->intr_tbl) |
| 392 | return -ENOMEM; | 393 | return -ENOMEM; |
| 393 | 394 | ||
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 1b5f7d57b6f8..2d38d1ac2aae 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
| @@ -916,8 +916,9 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type) | |||
| 916 | if (qlcnic_check_multi_tx(adapter) && | 916 | if (qlcnic_check_multi_tx(adapter) && |
| 917 | !ahw->diag_test && | 917 | !ahw->diag_test && |
| 918 | (adapter->flags & QLCNIC_MSIX_ENABLED)) { | 918 | (adapter->flags & QLCNIC_MSIX_ENABLED)) { |
| 919 | ahw->intr_tbl = vzalloc(ahw->num_msix * | 919 | ahw->intr_tbl = |
| 920 | sizeof(struct qlcnic_intrpt_config)); | 920 | vzalloc(array_size(sizeof(struct qlcnic_intrpt_config), |
| 921 | ahw->num_msix)); | ||
| 921 | if (!ahw->intr_tbl) | 922 | if (!ahw->intr_tbl) |
| 922 | return -ENOMEM; | 923 | return -ENOMEM; |
| 923 | 924 | ||
| @@ -1025,15 +1026,17 @@ int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | |||
| 1025 | 1026 | ||
| 1026 | act_pci_func = ahw->total_nic_func; | 1027 | act_pci_func = ahw->total_nic_func; |
| 1027 | 1028 | ||
| 1028 | adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * | 1029 | adapter->npars = kcalloc(act_pci_func, |
| 1029 | act_pci_func, GFP_KERNEL); | 1030 | sizeof(struct qlcnic_npar_info), |
| 1031 | GFP_KERNEL); | ||
| 1030 | if (!adapter->npars) { | 1032 | if (!adapter->npars) { |
| 1031 | ret = -ENOMEM; | 1033 | ret = -ENOMEM; |
| 1032 | goto err_pci_info; | 1034 | goto err_pci_info; |
| 1033 | } | 1035 | } |
| 1034 | 1036 | ||
| 1035 | adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * | 1037 | adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS, |
| 1036 | QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); | 1038 | sizeof(struct qlcnic_eswitch), |
| 1039 | GFP_KERNEL); | ||
| 1037 | if (!adapter->eswitch) { | 1040 | if (!adapter->eswitch) { |
| 1038 | ret = -ENOMEM; | 1041 | ret = -ENOMEM; |
| 1039 | goto err_npars; | 1042 | goto err_npars; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c index c58180f40844..0c744b9c6e0a 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | |||
| @@ -157,8 +157,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs) | |||
| 157 | adapter->ahw->sriov = sriov; | 157 | adapter->ahw->sriov = sriov; |
| 158 | sriov->num_vfs = num_vfs; | 158 | sriov->num_vfs = num_vfs; |
| 159 | bc = &sriov->bc; | 159 | bc = &sriov->bc; |
| 160 | sriov->vf_info = kzalloc(sizeof(struct qlcnic_vf_info) * | 160 | sriov->vf_info = kcalloc(num_vfs, sizeof(struct qlcnic_vf_info), |
| 161 | num_vfs, GFP_KERNEL); | 161 | GFP_KERNEL); |
| 162 | if (!sriov->vf_info) { | 162 | if (!sriov->vf_info) { |
| 163 | err = -ENOMEM; | 163 | err = -ENOMEM; |
| 164 | goto qlcnic_free_sriov; | 164 | goto qlcnic_free_sriov; |
| @@ -450,7 +450,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter, | |||
| 450 | return 0; | 450 | return 0; |
| 451 | 451 | ||
| 452 | num_vlans = sriov->num_allowed_vlans; | 452 | num_vlans = sriov->num_allowed_vlans; |
| 453 | sriov->allowed_vlans = kzalloc(sizeof(u16) * num_vlans, GFP_KERNEL); | 453 | sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL); |
| 454 | if (!sriov->allowed_vlans) | 454 | if (!sriov->allowed_vlans) |
| 455 | return -ENOMEM; | 455 | return -ENOMEM; |
| 456 | 456 | ||
| @@ -706,7 +706,7 @@ static inline int qlcnic_sriov_alloc_bc_trans(struct qlcnic_bc_trans **trans) | |||
| 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, | 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, |
| 707 | u32 size) | 707 | u32 size) |
| 708 | { | 708 | { |
| 709 | *hdr = kzalloc(sizeof(struct qlcnic_bc_hdr) * size, GFP_ATOMIC); | 709 | *hdr = kcalloc(size, sizeof(struct qlcnic_bc_hdr), GFP_ATOMIC); |
| 710 | if (!*hdr) | 710 | if (!*hdr) |
| 711 | return -ENOMEM; | 711 | return -ENOMEM; |
| 712 | 712 | ||
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index 70de062b72a1..353f1c129af1 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c | |||
| @@ -2810,7 +2810,8 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev, | |||
| 2810 | goto pci_alloc_err; | 2810 | goto pci_alloc_err; |
| 2811 | 2811 | ||
| 2812 | tx_ring->q = | 2812 | tx_ring->q = |
| 2813 | kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL); | 2813 | kmalloc_array(tx_ring->wq_len, sizeof(struct tx_ring_desc), |
| 2814 | GFP_KERNEL); | ||
| 2814 | if (tx_ring->q == NULL) | 2815 | if (tx_ring->q == NULL) |
| 2815 | goto err; | 2816 | goto err; |
| 2816 | 2817 | ||
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index d90a7b1f4088..23f0785c0573 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
| @@ -4984,7 +4984,8 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) | |||
| 4984 | net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; | 4984 | net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; |
| 4985 | } | 4985 | } |
| 4986 | 4986 | ||
| 4987 | table->entry = vzalloc(HUNT_FILTER_TBL_ROWS * sizeof(*table->entry)); | 4987 | table->entry = vzalloc(array_size(HUNT_FILTER_TBL_ROWS, |
| 4988 | sizeof(*table->entry))); | ||
| 4988 | if (!table->entry) { | 4989 | if (!table->entry) { |
| 4989 | rc = -ENOMEM; | 4990 | rc = -ENOMEM; |
| 4990 | goto fail; | 4991 | goto fail; |
diff --git a/drivers/net/ethernet/sfc/falcon/farch.c b/drivers/net/ethernet/sfc/falcon/farch.c index 494884f6af4a..411a2f419447 100644 --- a/drivers/net/ethernet/sfc/falcon/farch.c +++ b/drivers/net/ethernet/sfc/falcon/farch.c | |||
| @@ -2755,7 +2755,8 @@ int ef4_farch_filter_table_probe(struct ef4_nic *efx) | |||
| 2755 | GFP_KERNEL); | 2755 | GFP_KERNEL); |
| 2756 | if (!table->used_bitmap) | 2756 | if (!table->used_bitmap) |
| 2757 | goto fail; | 2757 | goto fail; |
| 2758 | table->spec = vzalloc(table->size * sizeof(*table->spec)); | 2758 | table->spec = vzalloc(array_size(sizeof(*table->spec), |
| 2759 | table->size)); | ||
| 2759 | if (!table->spec) | 2760 | if (!table->spec) |
| 2760 | goto fail; | 2761 | goto fail; |
| 2761 | } | 2762 | } |
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c index c72adf8b52ea..8edf20967c82 100644 --- a/drivers/net/ethernet/sfc/farch.c +++ b/drivers/net/ethernet/sfc/farch.c | |||
| @@ -2826,7 +2826,8 @@ int efx_farch_filter_table_probe(struct efx_nic *efx) | |||
| 2826 | GFP_KERNEL); | 2826 | GFP_KERNEL); |
| 2827 | if (!table->used_bitmap) | 2827 | if (!table->used_bitmap) |
| 2828 | goto fail; | 2828 | goto fail; |
| 2829 | table->spec = vzalloc(table->size * sizeof(*table->spec)); | 2829 | table->spec = vzalloc(array_size(sizeof(*table->spec), |
| 2830 | table->size)); | ||
| 2830 | if (!table->spec) | 2831 | if (!table->spec) |
| 2831 | goto fail; | 2832 | goto fail; |
| 2832 | } | 2833 | } |
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index ce8071fc90c4..e080d3e7c582 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c | |||
| @@ -973,7 +973,7 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) | |||
| 973 | goto err; | 973 | goto err; |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | dring->desc = kzalloc(DESC_NUM * sizeof(*dring->desc), GFP_KERNEL); | 976 | dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL); |
| 977 | if (!dring->desc) { | 977 | if (!dring->desc) { |
| 978 | ret = -ENOMEM; | 978 | ret = -ENOMEM; |
| 979 | goto err; | 979 | goto err; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 881c94b73e2f..2258cd8cc844 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | |||
| @@ -277,8 +277,8 @@ static int tc_init(struct stmmac_priv *priv) | |||
| 277 | 277 | ||
| 278 | /* Reserve one last filter which lets all pass */ | 278 | /* Reserve one last filter which lets all pass */ |
| 279 | priv->tc_entries_max = count; | 279 | priv->tc_entries_max = count; |
| 280 | priv->tc_entries = devm_kzalloc(priv->device, | 280 | priv->tc_entries = devm_kcalloc(priv->device, |
| 281 | sizeof(*priv->tc_entries) * count, GFP_KERNEL); | 281 | count, sizeof(*priv->tc_entries), GFP_KERNEL); |
| 282 | if (!priv->tc_entries) | 282 | if (!priv->tc_entries) |
| 283 | return -ENOMEM; | 283 | return -ENOMEM; |
| 284 | 284 | ||
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 534596ce00d3..358edab9e72e 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
| @@ -2740,8 +2740,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, | |||
| 2740 | } | 2740 | } |
| 2741 | data->active_slave = prop; | 2741 | data->active_slave = prop; |
| 2742 | 2742 | ||
| 2743 | data->slave_data = devm_kzalloc(&pdev->dev, data->slaves | 2743 | data->slave_data = devm_kcalloc(&pdev->dev, |
| 2744 | * sizeof(struct cpsw_slave_data), | 2744 | data->slaves, |
| 2745 | sizeof(struct cpsw_slave_data), | ||
| 2745 | GFP_KERNEL); | 2746 | GFP_KERNEL); |
| 2746 | if (!data->slave_data) | 2747 | if (!data->slave_data) |
| 2747 | return -ENOMEM; | 2748 | return -ENOMEM; |
| @@ -3045,8 +3046,8 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 3045 | 3046 | ||
| 3046 | memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); | 3047 | memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); |
| 3047 | 3048 | ||
| 3048 | cpsw->slaves = devm_kzalloc(&pdev->dev, | 3049 | cpsw->slaves = devm_kcalloc(&pdev->dev, |
| 3049 | sizeof(struct cpsw_slave) * data->slaves, | 3050 | data->slaves, sizeof(struct cpsw_slave), |
| 3050 | GFP_KERNEL); | 3051 | GFP_KERNEL); |
| 3051 | if (!cpsw->slaves) { | 3052 | if (!cpsw->slaves) { |
| 3052 | ret = -ENOMEM; | 3053 | ret = -ENOMEM; |
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 6e455a27a8de..72b98e27c992 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c | |||
| @@ -3285,8 +3285,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, | |||
| 3285 | gbe_dev->et_stats = xgbe10_et_stats; | 3285 | gbe_dev->et_stats = xgbe10_et_stats; |
| 3286 | gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); | 3286 | gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); |
| 3287 | 3287 | ||
| 3288 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3288 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3289 | gbe_dev->num_et_stats * sizeof(u64), | 3289 | gbe_dev->num_et_stats, sizeof(u64), |
| 3290 | GFP_KERNEL); | 3290 | GFP_KERNEL); |
| 3291 | if (!gbe_dev->hw_stats) { | 3291 | if (!gbe_dev->hw_stats) { |
| 3292 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3292 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3294,8 +3294,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, | |||
| 3294 | } | 3294 | } |
| 3295 | 3295 | ||
| 3296 | gbe_dev->hw_stats_prev = | 3296 | gbe_dev->hw_stats_prev = |
| 3297 | devm_kzalloc(gbe_dev->dev, | 3297 | devm_kcalloc(gbe_dev->dev, |
| 3298 | gbe_dev->num_et_stats * sizeof(u32), | 3298 | gbe_dev->num_et_stats, sizeof(u32), |
| 3299 | GFP_KERNEL); | 3299 | GFP_KERNEL); |
| 3300 | if (!gbe_dev->hw_stats_prev) { | 3300 | if (!gbe_dev->hw_stats_prev) { |
| 3301 | dev_err(gbe_dev->dev, | 3301 | dev_err(gbe_dev->dev, |
| @@ -3405,8 +3405,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, | |||
| 3405 | gbe_dev->et_stats = gbe13_et_stats; | 3405 | gbe_dev->et_stats = gbe13_et_stats; |
| 3406 | gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); | 3406 | gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); |
| 3407 | 3407 | ||
| 3408 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3408 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3409 | gbe_dev->num_et_stats * sizeof(u64), | 3409 | gbe_dev->num_et_stats, sizeof(u64), |
| 3410 | GFP_KERNEL); | 3410 | GFP_KERNEL); |
| 3411 | if (!gbe_dev->hw_stats) { | 3411 | if (!gbe_dev->hw_stats) { |
| 3412 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3412 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3414,8 +3414,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, | |||
| 3414 | } | 3414 | } |
| 3415 | 3415 | ||
| 3416 | gbe_dev->hw_stats_prev = | 3416 | gbe_dev->hw_stats_prev = |
| 3417 | devm_kzalloc(gbe_dev->dev, | 3417 | devm_kcalloc(gbe_dev->dev, |
| 3418 | gbe_dev->num_et_stats * sizeof(u32), | 3418 | gbe_dev->num_et_stats, sizeof(u32), |
| 3419 | GFP_KERNEL); | 3419 | GFP_KERNEL); |
| 3420 | if (!gbe_dev->hw_stats_prev) { | 3420 | if (!gbe_dev->hw_stats_prev) { |
| 3421 | dev_err(gbe_dev->dev, | 3421 | dev_err(gbe_dev->dev, |
| @@ -3477,8 +3477,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, | |||
| 3477 | gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + | 3477 | gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + |
| 3478 | GBENU_ET_STATS_PORT_SIZE; | 3478 | GBENU_ET_STATS_PORT_SIZE; |
| 3479 | 3479 | ||
| 3480 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3480 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3481 | gbe_dev->num_et_stats * sizeof(u64), | 3481 | gbe_dev->num_et_stats, sizeof(u64), |
| 3482 | GFP_KERNEL); | 3482 | GFP_KERNEL); |
| 3483 | if (!gbe_dev->hw_stats) { | 3483 | if (!gbe_dev->hw_stats) { |
| 3484 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3484 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3486,8 +3486,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, | |||
| 3486 | } | 3486 | } |
| 3487 | 3487 | ||
| 3488 | gbe_dev->hw_stats_prev = | 3488 | gbe_dev->hw_stats_prev = |
| 3489 | devm_kzalloc(gbe_dev->dev, | 3489 | devm_kcalloc(gbe_dev->dev, |
| 3490 | gbe_dev->num_et_stats * sizeof(u32), | 3490 | gbe_dev->num_et_stats, sizeof(u32), |
| 3491 | GFP_KERNEL); | 3491 | GFP_KERNEL); |
| 3492 | if (!gbe_dev->hw_stats_prev) { | 3492 | if (!gbe_dev->hw_stats_prev) { |
| 3493 | dev_err(gbe_dev->dev, | 3493 | dev_err(gbe_dev->dev, |
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c index eed18f88bdff..302079e22b06 100644 --- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c | |||
| @@ -2320,8 +2320,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card) | |||
| 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); | 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); |
| 2321 | 2321 | ||
| 2322 | /* allocate scan list */ | 2322 | /* allocate scan list */ |
| 2323 | wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) * | 2323 | wl->networks = kcalloc(GELIC_WL_BSS_MAX_ENT, |
| 2324 | GELIC_WL_BSS_MAX_ENT, GFP_KERNEL); | 2324 | sizeof(struct gelic_wl_scan_info), |
| 2325 | GFP_KERNEL); | ||
| 2325 | 2326 | ||
| 2326 | if (!wl->networks) | 2327 | if (!wl->networks) |
| 2327 | goto fail_bss; | 2328 | goto fail_bss; |
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index f38e32a7ec9c..ec629a730005 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c | |||
| @@ -742,11 +742,13 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) | |||
| 742 | { | 742 | { |
| 743 | int i; | 743 | int i; |
| 744 | 744 | ||
| 745 | gtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL); | 745 | gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
| 746 | GFP_KERNEL); | ||
| 746 | if (gtp->addr_hash == NULL) | 747 | if (gtp->addr_hash == NULL) |
| 747 | return -ENOMEM; | 748 | return -ENOMEM; |
| 748 | 749 | ||
| 749 | gtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL); | 750 | gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
| 751 | GFP_KERNEL); | ||
| 750 | if (gtp->tid_hash == NULL) | 752 | if (gtp->tid_hash == NULL) |
| 751 | goto err1; | 753 | goto err1; |
| 752 | 754 | ||
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c index f41116488079..029206e4da3b 100644 --- a/drivers/net/hippi/rrunner.c +++ b/drivers/net/hippi/rrunner.c | |||
| @@ -1583,7 +1583,7 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
| 1583 | return -EPERM; | 1583 | return -EPERM; |
| 1584 | } | 1584 | } |
| 1585 | 1585 | ||
| 1586 | image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); | 1586 | image = kmalloc_array(EEPROM_WORDS, sizeof(u32), GFP_KERNEL); |
| 1587 | if (!image) | 1587 | if (!image) |
| 1588 | return -ENOMEM; | 1588 | return -ENOMEM; |
| 1589 | 1589 | ||
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index a6c87793d899..79e9b103188b 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c | |||
| @@ -1097,8 +1097,9 @@ static struct dp83640_clock *dp83640_clock_get_bus(struct mii_bus *bus) | |||
| 1097 | if (!clock) | 1097 | if (!clock) |
| 1098 | goto out; | 1098 | goto out; |
| 1099 | 1099 | ||
| 1100 | clock->caps.pin_config = kzalloc(sizeof(struct ptp_pin_desc) * | 1100 | clock->caps.pin_config = kcalloc(DP83640_N_PINS, |
| 1101 | DP83640_N_PINS, GFP_KERNEL); | 1101 | sizeof(struct ptp_pin_desc), |
| 1102 | GFP_KERNEL); | ||
| 1102 | if (!clock->caps.pin_config) { | 1103 | if (!clock->caps.pin_config) { |
| 1103 | kfree(clock); | 1104 | kfree(clock); |
| 1104 | clock = NULL; | 1105 | clock = NULL; |
diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index 39ecad25b201..491efc1bf5c4 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c | |||
| @@ -128,9 +128,9 @@ int phy_led_triggers_register(struct phy_device *phy) | |||
| 128 | if (err) | 128 | if (err) |
| 129 | goto out_free_link; | 129 | goto out_free_link; |
| 130 | 130 | ||
| 131 | phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev, | 131 | phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, |
| 132 | sizeof(struct phy_led_trigger) * | 132 | phy->phy_num_led_triggers, |
| 133 | phy->phy_num_led_triggers, | 133 | sizeof(struct phy_led_trigger), |
| 134 | GFP_KERNEL); | 134 | GFP_KERNEL); |
| 135 | if (!phy->phy_led_triggers) { | 135 | if (!phy->phy_led_triggers) { |
| 136 | err = -ENOMEM; | 136 | err = -ENOMEM; |
diff --git a/drivers/net/ppp/bsd_comp.c b/drivers/net/ppp/bsd_comp.c index a9b759add187..61fedb23d3cf 100644 --- a/drivers/net/ppp/bsd_comp.c +++ b/drivers/net/ppp/bsd_comp.c | |||
| @@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
| 406 | * Allocate space for the dictionary. This may be more than one page in | 406 | * Allocate space for the dictionary. This may be more than one page in |
| 407 | * length. | 407 | * length. |
| 408 | */ | 408 | */ |
| 409 | db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); | 409 | db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict))); |
| 410 | if (!db->dict) | 410 | if (!db->dict) |
| 411 | { | 411 | { |
| 412 | bsd_free (db); | 412 | bsd_free (db); |
| @@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
| 425 | */ | 425 | */ |
| 426 | else | 426 | else |
| 427 | { | 427 | { |
| 428 | db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); | 428 | db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1))); |
| 429 | if (!db->lens) | 429 | if (!db->lens) |
| 430 | { | 430 | { |
| 431 | bsd_free (db); | 431 | bsd_free (db); |
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index 157b67c1bf8e..67ffe74747a1 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c | |||
| @@ -648,7 +648,7 @@ static int __init pptp_init_module(void) | |||
| 648 | int err = 0; | 648 | int err = 0; |
| 649 | pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); | 649 | pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); |
| 650 | 650 | ||
| 651 | callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *)); | 651 | callid_sock = vzalloc(array_size(sizeof(void *), (MAX_CALLID + 1))); |
| 652 | if (!callid_sock) | 652 | if (!callid_sock) |
| 653 | return -ENOMEM; | 653 | return -ENOMEM; |
| 654 | 654 | ||
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c index 8940417c30e5..b008266e91ea 100644 --- a/drivers/net/slip/slip.c +++ b/drivers/net/slip/slip.c | |||
| @@ -1307,7 +1307,7 @@ static int __init slip_init(void) | |||
| 1307 | printk(KERN_INFO "SLIP linefill/keepalive option.\n"); | 1307 | printk(KERN_INFO "SLIP linefill/keepalive option.\n"); |
| 1308 | #endif | 1308 | #endif |
| 1309 | 1309 | ||
| 1310 | slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, | 1310 | slip_devs = kcalloc(slip_maxdev, sizeof(struct net_device *), |
| 1311 | GFP_KERNEL); | 1311 | GFP_KERNEL); |
| 1312 | if (!slip_devs) | 1312 | if (!slip_devs) |
| 1313 | return -ENOMEM; | 1313 | return -ENOMEM; |
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 8863fa023500..b070959737ff 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
| @@ -280,7 +280,7 @@ static int __team_options_register(struct team *team, | |||
| 280 | struct team_option **dst_opts; | 280 | struct team_option **dst_opts; |
| 281 | int err; | 281 | int err; |
| 282 | 282 | ||
| 283 | dst_opts = kzalloc(sizeof(struct team_option *) * option_count, | 283 | dst_opts = kcalloc(option_count, sizeof(struct team_option *), |
| 284 | GFP_KERNEL); | 284 | GFP_KERNEL); |
| 285 | if (!dst_opts) | 285 | if (!dst_opts) |
| 286 | return -ENOMEM; | 286 | return -ENOMEM; |
| @@ -791,7 +791,8 @@ static int team_queue_override_init(struct team *team) | |||
| 791 | 791 | ||
| 792 | if (!queue_cnt) | 792 | if (!queue_cnt) |
| 793 | return 0; | 793 | return 0; |
| 794 | listarr = kmalloc(sizeof(struct list_head) * queue_cnt, GFP_KERNEL); | 794 | listarr = kmalloc_array(queue_cnt, sizeof(struct list_head), |
| 795 | GFP_KERNEL); | ||
| 795 | if (!listarr) | 796 | if (!listarr) |
| 796 | return -ENOMEM; | 797 | return -ENOMEM; |
| 797 | team->qom_lists = listarr; | 798 | team->qom_lists = listarr; |
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c index f4d7362eb325..e95dd12edec4 100644 --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c | |||
| @@ -640,8 +640,8 @@ int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 640 | first_word = eeprom->offset >> 1; | 640 | first_word = eeprom->offset >> 1; |
| 641 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 641 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 642 | 642 | ||
| 643 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 643 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 644 | GFP_KERNEL); | 644 | GFP_KERNEL); |
| 645 | if (!eeprom_buff) | 645 | if (!eeprom_buff) |
| 646 | return -ENOMEM; | 646 | return -ENOMEM; |
| 647 | 647 | ||
| @@ -680,8 +680,8 @@ int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 680 | first_word = eeprom->offset >> 1; | 680 | first_word = eeprom->offset >> 1; |
| 681 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 681 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 682 | 682 | ||
| 683 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 683 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 684 | GFP_KERNEL); | 684 | GFP_KERNEL); |
| 685 | if (!eeprom_buff) | 685 | if (!eeprom_buff) |
| 686 | return -ENOMEM; | 686 | return -ENOMEM; |
| 687 | 687 | ||
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index a6ef75907ae9..9e8ad372f419 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c | |||
| @@ -599,8 +599,8 @@ ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 599 | 599 | ||
| 600 | first_word = eeprom->offset >> 1; | 600 | first_word = eeprom->offset >> 1; |
| 601 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 601 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 602 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 602 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 603 | GFP_KERNEL); | 603 | GFP_KERNEL); |
| 604 | if (!eeprom_buff) | 604 | if (!eeprom_buff) |
| 605 | return -ENOMEM; | 605 | return -ENOMEM; |
| 606 | 606 | ||
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 309b88acd3d0..06b4d290784d 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
| @@ -1661,7 +1661,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 1661 | } | 1661 | } |
| 1662 | 1662 | ||
| 1663 | if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { | 1663 | if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { |
| 1664 | u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL); | 1664 | u32 *filter_mask = kcalloc(32, sizeof(u32), GFP_KERNEL); |
| 1665 | u32 command[2]; | 1665 | u32 command[2]; |
| 1666 | u32 offset[2]; | 1666 | u32 offset[2]; |
| 1667 | u32 crc[4]; | 1667 | u32 crc[4]; |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index d9eea8cfe6cb..770aa624147f 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
| @@ -1323,8 +1323,8 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb) | |||
| 1323 | return 0; | 1323 | return 0; |
| 1324 | 1324 | ||
| 1325 | /* reserve one for zero packet */ | 1325 | /* reserve one for zero packet */ |
| 1326 | urb->sg = kmalloc((num_sgs + 1) * sizeof(struct scatterlist), | 1326 | urb->sg = kmalloc_array(num_sgs + 1, sizeof(struct scatterlist), |
| 1327 | GFP_ATOMIC); | 1327 | GFP_ATOMIC); |
| 1328 | if (!urb->sg) | 1328 | if (!urb->sg) |
| 1329 | return -ENOMEM; | 1329 | return -ENOMEM; |
| 1330 | 1330 | ||
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1619ee3070b6..b6c9a2af3732 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -2552,17 +2552,17 @@ static int virtnet_find_vqs(struct virtnet_info *vi) | |||
| 2552 | virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ); | 2552 | virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ); |
| 2553 | 2553 | ||
| 2554 | /* Allocate space for find_vqs parameters */ | 2554 | /* Allocate space for find_vqs parameters */ |
| 2555 | vqs = kzalloc(total_vqs * sizeof(*vqs), GFP_KERNEL); | 2555 | vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL); |
| 2556 | if (!vqs) | 2556 | if (!vqs) |
| 2557 | goto err_vq; | 2557 | goto err_vq; |
| 2558 | callbacks = kmalloc(total_vqs * sizeof(*callbacks), GFP_KERNEL); | 2558 | callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL); |
| 2559 | if (!callbacks) | 2559 | if (!callbacks) |
| 2560 | goto err_callback; | 2560 | goto err_callback; |
| 2561 | names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL); | 2561 | names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL); |
| 2562 | if (!names) | 2562 | if (!names) |
| 2563 | goto err_names; | 2563 | goto err_names; |
| 2564 | if (!vi->big_packets || vi->mergeable_rx_bufs) { | 2564 | if (!vi->big_packets || vi->mergeable_rx_bufs) { |
| 2565 | ctx = kzalloc(total_vqs * sizeof(*ctx), GFP_KERNEL); | 2565 | ctx = kcalloc(total_vqs, sizeof(*ctx), GFP_KERNEL); |
| 2566 | if (!ctx) | 2566 | if (!ctx) |
| 2567 | goto err_ctx; | 2567 | goto err_ctx; |
| 2568 | } else { | 2568 | } else { |
| @@ -2626,10 +2626,10 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) | |||
| 2626 | vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL); | 2626 | vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL); |
| 2627 | if (!vi->ctrl) | 2627 | if (!vi->ctrl) |
| 2628 | goto err_ctrl; | 2628 | goto err_ctrl; |
| 2629 | vi->sq = kzalloc(sizeof(*vi->sq) * vi->max_queue_pairs, GFP_KERNEL); | 2629 | vi->sq = kcalloc(vi->max_queue_pairs, sizeof(*vi->sq), GFP_KERNEL); |
| 2630 | if (!vi->sq) | 2630 | if (!vi->sq) |
| 2631 | goto err_sq; | 2631 | goto err_sq; |
| 2632 | vi->rq = kzalloc(sizeof(*vi->rq) * vi->max_queue_pairs, GFP_KERNEL); | 2632 | vi->rq = kcalloc(vi->max_queue_pairs, sizeof(*vi->rq), GFP_KERNEL); |
| 2633 | if (!vi->rq) | 2633 | if (!vi->rq) |
| 2634 | goto err_rq; | 2634 | goto err_rq; |
| 2635 | 2635 | ||
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 4205dfd19da3..9b09c9d0d0fb 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c | |||
| @@ -198,12 +198,14 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) | |||
| 198 | goto free_tx_bd; | 198 | goto free_tx_bd; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | priv->rx_skbuff = kzalloc(priv->rx_ring_size * sizeof(*priv->rx_skbuff), | 201 | priv->rx_skbuff = kcalloc(priv->rx_ring_size, |
| 202 | sizeof(*priv->rx_skbuff), | ||
| 202 | GFP_KERNEL); | 203 | GFP_KERNEL); |
| 203 | if (!priv->rx_skbuff) | 204 | if (!priv->rx_skbuff) |
| 204 | goto free_ucc_pram; | 205 | goto free_ucc_pram; |
| 205 | 206 | ||
| 206 | priv->tx_skbuff = kzalloc(priv->tx_ring_size * sizeof(*priv->tx_skbuff), | 207 | priv->tx_skbuff = kcalloc(priv->tx_ring_size, |
| 208 | sizeof(*priv->tx_skbuff), | ||
| 207 | GFP_KERNEL); | 209 | GFP_KERNEL); |
| 208 | if (!priv->tx_skbuff) | 210 | if (!priv->tx_skbuff) |
| 209 | goto free_rx_skbuff; | 211 | goto free_rx_skbuff; |
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index bd23f6940488..c72d8af122a2 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
| @@ -582,7 +582,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt) | |||
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | htt->rx_ring.netbufs_ring = | 584 | htt->rx_ring.netbufs_ring = |
| 585 | kzalloc(htt->rx_ring.size * sizeof(struct sk_buff *), | 585 | kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *), |
| 586 | GFP_KERNEL); | 586 | GFP_KERNEL); |
| 587 | if (!htt->rx_ring.netbufs_ring) | 587 | if (!htt->rx_ring.netbufs_ring) |
| 588 | goto err_netbuf; | 588 | goto err_netbuf; |
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c index 2e34a1fc5ba6..8c49a26fc571 100644 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c | |||
| @@ -155,7 +155,7 @@ ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr, | |||
| 155 | const void **tb; | 155 | const void **tb; |
| 156 | int ret; | 156 | int ret; |
| 157 | 157 | ||
| 158 | tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp); | 158 | tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp); |
| 159 | if (!tb) | 159 | if (!tb) |
| 160 | return ERR_PTR(-ENOMEM); | 160 | return ERR_PTR(-ENOMEM); |
| 161 | 161 | ||
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index 3513bbec4639..e01faf641288 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c | |||
| @@ -931,7 +931,7 @@ static int open_file_eeprom(struct inode *inode, struct file *file) | |||
| 931 | 931 | ||
| 932 | /* Create buffer and read in eeprom */ | 932 | /* Create buffer and read in eeprom */ |
| 933 | 933 | ||
| 934 | buf = vmalloc(eesize * 2); | 934 | buf = vmalloc(array_size(eesize, 2)); |
| 935 | if (!buf) { | 935 | if (!buf) { |
| 936 | ret = -ENOMEM; | 936 | ret = -ENOMEM; |
| 937 | goto err; | 937 | goto err; |
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index 641b13a279e1..b1b8bc326830 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c | |||
| @@ -890,7 +890,8 @@ ath5k_hw_rfregs_init(struct ath5k_hw *ah, | |||
| 890 | * ah->ah_rf_banks based on ah->ah_rf_banks_size | 890 | * ah->ah_rf_banks based on ah->ah_rf_banks_size |
| 891 | * we set above */ | 891 | * we set above */ |
| 892 | if (ah->ah_rf_banks == NULL) { | 892 | if (ah->ah_rf_banks == NULL) { |
| 893 | ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size, | 893 | ah->ah_rf_banks = kmalloc_array(ah->ah_rf_banks_size, |
| 894 | sizeof(u32), | ||
| 894 | GFP_KERNEL); | 895 | GFP_KERNEL); |
| 895 | if (ah->ah_rf_banks == NULL) { | 896 | if (ah->ah_rf_banks == NULL) { |
| 896 | ATH5K_ERR(ah, "out of memory\n"); | 897 | ATH5K_ERR(ah, "out of memory\n"); |
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2ba8cf3f38af..0687697d5e2d 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c | |||
| @@ -1041,7 +1041,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, | |||
| 1041 | 1041 | ||
| 1042 | n_channels = request->n_channels; | 1042 | n_channels = request->n_channels; |
| 1043 | 1043 | ||
| 1044 | channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL); | 1044 | channels = kcalloc(n_channels, sizeof(u16), GFP_KERNEL); |
| 1045 | if (channels == NULL) { | 1045 | if (channels == NULL) { |
| 1046 | ath6kl_warn("failed to set scan channels, scan all channels"); | 1046 | ath6kl_warn("failed to set scan channels, scan all channels"); |
| 1047 | n_channels = 0; | 1047 | n_channels = 0; |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index 6343cc91953e..34e100940284 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c | |||
| @@ -925,7 +925,7 @@ int ar9003_paprd_create_curve(struct ath_hw *ah, | |||
| 925 | 925 | ||
| 926 | memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain])); | 926 | memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain])); |
| 927 | 927 | ||
| 928 | buf = kmalloc(2 * 48 * sizeof(u32), GFP_KERNEL); | 928 | buf = kmalloc_array(2 * 48, sizeof(u32), GFP_KERNEL); |
| 929 | if (!buf) | 929 | if (!buf) |
| 930 | return -ENOMEM; | 930 | return -ENOMEM; |
| 931 | 931 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 6b37036b2d36..e60bea4604e4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
| @@ -127,13 +127,13 @@ void ath9k_hw_read_array(struct ath_hw *ah, u32 array[][2], int size) | |||
| 127 | u32 *tmp_reg_list, *tmp_data; | 127 | u32 *tmp_reg_list, *tmp_data; |
| 128 | int i; | 128 | int i; |
| 129 | 129 | ||
| 130 | tmp_reg_list = kmalloc(size * sizeof(u32), GFP_KERNEL); | 130 | tmp_reg_list = kmalloc_array(size, sizeof(u32), GFP_KERNEL); |
| 131 | if (!tmp_reg_list) { | 131 | if (!tmp_reg_list) { |
| 132 | dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__); | 132 | dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__); |
| 133 | return; | 133 | return; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | tmp_data = kmalloc(size * sizeof(u32), GFP_KERNEL); | 136 | tmp_data = kmalloc_array(size, sizeof(u32), GFP_KERNEL); |
| 137 | if (!tmp_data) { | 137 | if (!tmp_data) { |
| 138 | dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__); | 138 | dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__); |
| 139 | goto error_tmp_data; | 139 | goto error_tmp_data; |
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 29e93c953d93..7f1bdea742b8 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c | |||
| @@ -1958,7 +1958,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar) | |||
| 1958 | if (!bands) | 1958 | if (!bands) |
| 1959 | return -EINVAL; | 1959 | return -EINVAL; |
| 1960 | 1960 | ||
| 1961 | ar->survey = kzalloc(sizeof(struct survey_info) * chans, GFP_KERNEL); | 1961 | ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL); |
| 1962 | if (!ar->survey) | 1962 | if (!ar->survey) |
| 1963 | return -ENOMEM; | 1963 | return -ENOMEM; |
| 1964 | ar->num_channels = chans; | 1964 | ar->num_channels = chans; |
| @@ -1988,8 +1988,9 @@ int carl9170_register(struct ar9170 *ar) | |||
| 1988 | if (WARN_ON(ar->mem_bitmap)) | 1988 | if (WARN_ON(ar->mem_bitmap)) |
| 1989 | return -EINVAL; | 1989 | return -EINVAL; |
| 1990 | 1990 | ||
| 1991 | ar->mem_bitmap = kzalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG) * | 1991 | ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG), |
| 1992 | sizeof(unsigned long), GFP_KERNEL); | 1992 | sizeof(unsigned long), |
| 1993 | GFP_KERNEL); | ||
| 1993 | 1994 | ||
| 1994 | if (!ar->mem_bitmap) | 1995 | if (!ar->mem_bitmap) |
| 1995 | return -ENOMEM; | 1996 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c index f2a2f41e3c96..44ab080d6518 100644 --- a/drivers/net/wireless/broadcom/b43/phy_n.c +++ b/drivers/net/wireless/broadcom/b43/phy_n.c | |||
| @@ -1518,7 +1518,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev, | |||
| 1518 | u16 i; | 1518 | u16 i; |
| 1519 | u32 *data; | 1519 | u32 *data; |
| 1520 | 1520 | ||
| 1521 | data = kzalloc(len * sizeof(u32), GFP_KERNEL); | 1521 | data = kcalloc(len, sizeof(u32), GFP_KERNEL); |
| 1522 | if (!data) { | 1522 | if (!data) { |
| 1523 | b43err(dev->wl, "allocation for samples loading failed\n"); | 1523 | b43err(dev->wl, "allocation for samples loading failed\n"); |
| 1524 | return -ENOMEM; | 1524 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c b/drivers/net/wireless/broadcom/b43legacy/main.c index f1e3dad57629..55f411925960 100644 --- a/drivers/net/wireless/broadcom/b43legacy/main.c +++ b/drivers/net/wireless/broadcom/b43legacy/main.c | |||
| @@ -3300,8 +3300,8 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev) | |||
| 3300 | 3300 | ||
| 3301 | if ((phy->type == B43legacy_PHYTYPE_B) || | 3301 | if ((phy->type == B43legacy_PHYTYPE_B) || |
| 3302 | (phy->type == B43legacy_PHYTYPE_G)) { | 3302 | (phy->type == B43legacy_PHYTYPE_G)) { |
| 3303 | phy->_lo_pairs = kzalloc(sizeof(struct b43legacy_lopair) | 3303 | phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT, |
| 3304 | * B43legacy_LO_COUNT, | 3304 | sizeof(struct b43legacy_lopair), |
| 3305 | GFP_KERNEL); | 3305 | GFP_KERNEL); |
| 3306 | if (!phy->_lo_pairs) | 3306 | if (!phy->_lo_pairs) |
| 3307 | return -ENOMEM; | 3307 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index 49d37ad96958..c40ba8855cd5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | |||
| @@ -1486,8 +1486,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) | |||
| 1486 | (struct brcmf_commonring **)if_msgbuf->commonrings; | 1486 | (struct brcmf_commonring **)if_msgbuf->commonrings; |
| 1487 | msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings; | 1487 | msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings; |
| 1488 | msgbuf->max_flowrings = if_msgbuf->max_flowrings; | 1488 | msgbuf->max_flowrings = if_msgbuf->max_flowrings; |
| 1489 | msgbuf->flowring_dma_handle = kzalloc(msgbuf->max_flowrings * | 1489 | msgbuf->flowring_dma_handle = |
| 1490 | sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL); | 1490 | kcalloc(msgbuf->max_flowrings, |
| 1491 | sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL); | ||
| 1491 | if (!msgbuf->flowring_dma_handle) | 1492 | if (!msgbuf->flowring_dma_handle) |
| 1492 | goto fail; | 1493 | goto fail; |
| 1493 | 1494 | ||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index 4b2149b48362..3e9c4f2f5dd1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | |||
| @@ -1058,7 +1058,7 @@ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel) | |||
| 1058 | channel_cnt = AF_PEER_SEARCH_CNT; | 1058 | channel_cnt = AF_PEER_SEARCH_CNT; |
| 1059 | else | 1059 | else |
| 1060 | channel_cnt = SOCIAL_CHAN_CNT; | 1060 | channel_cnt = SOCIAL_CHAN_CNT; |
| 1061 | default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list), | 1061 | default_chan_list = kcalloc(channel_cnt, sizeof(*default_chan_list), |
| 1062 | GFP_KERNEL); | 1062 | GFP_KERNEL); |
| 1063 | if (default_chan_list == NULL) { | 1063 | if (default_chan_list == NULL) { |
| 1064 | brcmf_err("channel list allocation failed\n"); | 1064 | brcmf_err("channel list allocation failed\n"); |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c index 0a14942b8216..7d4e8f589fdc 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | |||
| @@ -507,7 +507,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 507 | wlc->hw->wlc = wlc; | 507 | wlc->hw->wlc = wlc; |
| 508 | 508 | ||
| 509 | wlc->hw->bandstate[0] = | 509 | wlc->hw->bandstate[0] = |
| 510 | kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC); | 510 | kcalloc(MAXBANDS, sizeof(struct brcms_hw_band), GFP_ATOMIC); |
| 511 | if (wlc->hw->bandstate[0] == NULL) { | 511 | if (wlc->hw->bandstate[0] == NULL) { |
| 512 | *err = 1006; | 512 | *err = 1006; |
| 513 | goto fail; | 513 | goto fail; |
| @@ -521,7 +521,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | wlc->modulecb = | 523 | wlc->modulecb = |
| 524 | kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC); | 524 | kcalloc(BRCMS_MAXMODULES, sizeof(struct modulecb), |
| 525 | GFP_ATOMIC); | ||
| 525 | if (wlc->modulecb == NULL) { | 526 | if (wlc->modulecb == NULL) { |
| 526 | *err = 1009; | 527 | *err = 1009; |
| 527 | goto fail; | 528 | goto fail; |
| @@ -553,7 +554,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 553 | } | 554 | } |
| 554 | 555 | ||
| 555 | wlc->bandstate[0] = | 556 | wlc->bandstate[0] = |
| 556 | kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC); | 557 | kcalloc(MAXBANDS, sizeof(struct brcms_band), GFP_ATOMIC); |
| 557 | if (wlc->bandstate[0] == NULL) { | 558 | if (wlc->bandstate[0] == NULL) { |
| 558 | *err = 1025; | 559 | *err = 1025; |
| 559 | goto fail; | 560 | goto fail; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c index 9d830d27b229..9fb0d9fbd939 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | |||
| @@ -1387,7 +1387,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, | |||
| 1387 | s16 *ptr; | 1387 | s16 *ptr; |
| 1388 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; | 1388 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
| 1389 | 1389 | ||
| 1390 | ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); | 1390 | ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC); |
| 1391 | if (NULL == ptr) | 1391 | if (NULL == ptr) |
| 1392 | return false; | 1392 | return false; |
| 1393 | if (module == 2) { | 1393 | if (module == 2) { |
| @@ -2670,7 +2670,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, | |||
| 2670 | u16 *values_to_save; | 2670 | u16 *values_to_save; |
| 2671 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; | 2671 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
| 2672 | 2672 | ||
| 2673 | values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); | 2673 | values_to_save = kmalloc_array(20, sizeof(u16), GFP_ATOMIC); |
| 2674 | if (NULL == values_to_save) | 2674 | if (NULL == values_to_save) |
| 2675 | return; | 2675 | return; |
| 2676 | 2676 | ||
| @@ -3678,11 +3678,11 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, | |||
| 3678 | u16 *phy_c32; | 3678 | u16 *phy_c32; |
| 3679 | phy_c21 = 0; | 3679 | phy_c21 = 0; |
| 3680 | phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; | 3680 | phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; |
| 3681 | ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); | 3681 | ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC); |
| 3682 | if (NULL == ptr) | 3682 | if (NULL == ptr) |
| 3683 | return; | 3683 | return; |
| 3684 | 3684 | ||
| 3685 | phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); | 3685 | phy_c32 = kmalloc_array(20, sizeof(u16), GFP_ATOMIC); |
| 3686 | if (NULL == phy_c32) { | 3686 | if (NULL == phy_c32) { |
| 3687 | kfree(ptr); | 3687 | kfree(ptr); |
| 3688 | return; | 3688 | return; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c index 7e01981bc5c8..1a187557982e 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | |||
| @@ -23032,7 +23032,7 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, | |||
| 23032 | u16 t; | 23032 | u16 t; |
| 23033 | u32 *data_buf = NULL; | 23033 | u32 *data_buf = NULL; |
| 23034 | 23034 | ||
| 23035 | data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); | 23035 | data_buf = kmalloc_array(num_samps, sizeof(u32), GFP_ATOMIC); |
| 23036 | if (data_buf == NULL) | 23036 | if (data_buf == NULL) |
| 23037 | return; | 23037 | return; |
| 23038 | 23038 | ||
| @@ -23074,7 +23074,8 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, | |||
| 23074 | tbl_len = (phy_bw << 1); | 23074 | tbl_len = (phy_bw << 1); |
| 23075 | } | 23075 | } |
| 23076 | 23076 | ||
| 23077 | tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC); | 23077 | tone_buf = kmalloc_array(tbl_len, sizeof(struct cordic_iq), |
| 23078 | GFP_ATOMIC); | ||
| 23078 | if (tone_buf == NULL) | 23079 | if (tone_buf == NULL) |
| 23079 | return 0; | 23080 | return 0; |
| 23080 | 23081 | ||
diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index ce0fbf83285f..72046e182745 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c | |||
| @@ -7127,7 +7127,7 @@ static int airo_get_aplist(struct net_device *dev, | |||
| 7127 | int i; | 7127 | int i; |
| 7128 | int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; | 7128 | int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; |
| 7129 | 7129 | ||
| 7130 | qual = kmalloc(IW_MAX_AP * sizeof(*qual), GFP_KERNEL); | 7130 | qual = kmalloc_array(IW_MAX_AP, sizeof(*qual), GFP_KERNEL); |
| 7131 | if (!qual) | 7131 | if (!qual) |
| 7132 | return -ENOMEM; | 7132 | return -ENOMEM; |
| 7133 | 7133 | ||
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c index 7c4f550a1475..b8fd3cc90634 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c | |||
| @@ -3445,8 +3445,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) | |||
| 3445 | dma_addr_t p; | 3445 | dma_addr_t p; |
| 3446 | 3446 | ||
| 3447 | priv->msg_buffers = | 3447 | priv->msg_buffers = |
| 3448 | kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), | 3448 | kmalloc_array(IPW_COMMAND_POOL_SIZE, |
| 3449 | GFP_KERNEL); | 3449 | sizeof(struct ipw2100_tx_packet), |
| 3450 | GFP_KERNEL); | ||
| 3450 | if (!priv->msg_buffers) | 3451 | if (!priv->msg_buffers) |
| 3451 | return -ENOMEM; | 3452 | return -ENOMEM; |
| 3452 | 3453 | ||
| @@ -4587,9 +4588,9 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv) | |||
| 4587 | /* | 4588 | /* |
| 4588 | * allocate packets | 4589 | * allocate packets |
| 4589 | */ | 4590 | */ |
| 4590 | priv->rx_buffers = kmalloc(RX_QUEUE_LENGTH * | 4591 | priv->rx_buffers = kmalloc_array(RX_QUEUE_LENGTH, |
| 4591 | sizeof(struct ipw2100_rx_packet), | 4592 | sizeof(struct ipw2100_rx_packet), |
| 4592 | GFP_KERNEL); | 4593 | GFP_KERNEL); |
| 4593 | if (!priv->rx_buffers) { | 4594 | if (!priv->rx_buffers) { |
| 4594 | IPW_DEBUG_INFO("can't allocate rx packet buffer table\n"); | 4595 | IPW_DEBUG_INFO("can't allocate rx packet buffer table\n"); |
| 4595 | 4596 | ||
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c index f26beeb6c5ff..8a858f7e36f4 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c | |||
| @@ -3208,13 +3208,13 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) | |||
| 3208 | 3208 | ||
| 3209 | IPW_DEBUG_TRACE("<< :\n"); | 3209 | IPW_DEBUG_TRACE("<< :\n"); |
| 3210 | 3210 | ||
| 3211 | virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL, | 3211 | virts = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(void *), |
| 3212 | GFP_KERNEL); | 3212 | GFP_KERNEL); |
| 3213 | if (!virts) | 3213 | if (!virts) |
| 3214 | return -ENOMEM; | 3214 | return -ENOMEM; |
| 3215 | 3215 | ||
| 3216 | phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL, | 3216 | phys = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(dma_addr_t), |
| 3217 | GFP_KERNEL); | 3217 | GFP_KERNEL); |
| 3218 | if (!phys) { | 3218 | if (!phys) { |
| 3219 | kfree(virts); | 3219 | kfree(virts); |
| 3220 | return -ENOMEM; | 3220 | return -ENOMEM; |
| @@ -3782,7 +3782,7 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, | |||
| 3782 | { | 3782 | { |
| 3783 | struct pci_dev *dev = priv->pci_dev; | 3783 | struct pci_dev *dev = priv->pci_dev; |
| 3784 | 3784 | ||
| 3785 | q->txb = kmalloc(sizeof(q->txb[0]) * count, GFP_KERNEL); | 3785 | q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL); |
| 3786 | if (!q->txb) { | 3786 | if (!q->txb) { |
| 3787 | IPW_ERROR("vmalloc for auxiliary BD structures failed\n"); | 3787 | IPW_ERROR("vmalloc for auxiliary BD structures failed\n"); |
| 3788 | return -ENOMEM; | 3788 | return -ENOMEM; |
diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 063e19ced7c8..6514baf799fe 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c | |||
| @@ -922,7 +922,7 @@ il_init_channel_map(struct il_priv *il) | |||
| 922 | D_EEPROM("Parsing data for %d channels.\n", il->channel_count); | 922 | D_EEPROM("Parsing data for %d channels.\n", il->channel_count); |
| 923 | 923 | ||
| 924 | il->channel_info = | 924 | il->channel_info = |
| 925 | kzalloc(sizeof(struct il_channel_info) * il->channel_count, | 925 | kcalloc(il->channel_count, sizeof(struct il_channel_info), |
| 926 | GFP_KERNEL); | 926 | GFP_KERNEL); |
| 927 | if (!il->channel_info) { | 927 | if (!il->channel_info) { |
| 928 | IL_ERR("Could not allocate channel_info\n"); | 928 | IL_ERR("Could not allocate channel_info\n"); |
| @@ -3041,9 +3041,9 @@ il_tx_queue_init(struct il_priv *il, u32 txq_id) | |||
| 3041 | } | 3041 | } |
| 3042 | 3042 | ||
| 3043 | txq->meta = | 3043 | txq->meta = |
| 3044 | kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); | 3044 | kcalloc(actual_slots, sizeof(struct il_cmd_meta), GFP_KERNEL); |
| 3045 | txq->cmd = | 3045 | txq->cmd = |
| 3046 | kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); | 3046 | kcalloc(actual_slots, sizeof(struct il_device_cmd *), GFP_KERNEL); |
| 3047 | 3047 | ||
| 3048 | if (!txq->meta || !txq->cmd) | 3048 | if (!txq->meta || !txq->cmd) |
| 3049 | goto out_free_arrays; | 3049 | goto out_free_arrays; |
| @@ -3455,7 +3455,7 @@ il_init_geos(struct il_priv *il) | |||
| 3455 | } | 3455 | } |
| 3456 | 3456 | ||
| 3457 | channels = | 3457 | channels = |
| 3458 | kzalloc(sizeof(struct ieee80211_channel) * il->channel_count, | 3458 | kcalloc(il->channel_count, sizeof(struct ieee80211_channel), |
| 3459 | GFP_KERNEL); | 3459 | GFP_KERNEL); |
| 3460 | if (!channels) | 3460 | if (!channels) |
| 3461 | return -ENOMEM; | 3461 | return -ENOMEM; |
| @@ -4654,8 +4654,9 @@ il_alloc_txq_mem(struct il_priv *il) | |||
| 4654 | { | 4654 | { |
| 4655 | if (!il->txq) | 4655 | if (!il->txq) |
| 4656 | il->txq = | 4656 | il->txq = |
| 4657 | kzalloc(sizeof(struct il_tx_queue) * | 4657 | kcalloc(il->cfg->num_of_queues, |
| 4658 | il->cfg->num_of_queues, GFP_KERNEL); | 4658 | sizeof(struct il_tx_queue), |
| 4659 | GFP_KERNEL); | ||
| 4659 | if (!il->txq) { | 4660 | if (!il->txq) { |
| 4660 | IL_ERR("Not enough memory for txq\n"); | 4661 | IL_ERR("Not enough memory for txq\n"); |
| 4661 | return -ENOMEM; | 4662 | return -ENOMEM; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c index 4b3753d78d03..11ecdf63b732 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c | |||
| @@ -564,7 +564,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm, | |||
| 564 | else | 564 | else |
| 565 | blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN; | 565 | blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN; |
| 566 | 566 | ||
| 567 | blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL); | 567 | blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL); |
| 568 | if (!blacklist) | 568 | if (!blacklist) |
| 569 | return -ENOMEM; | 569 | return -ENOMEM; |
| 570 | 570 | ||
diff --git a/drivers/net/wireless/intersil/hostap/hostap_info.c b/drivers/net/wireless/intersil/hostap/hostap_info.c index de8a099a9386..da8c30f10d92 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_info.c +++ b/drivers/net/wireless/intersil/hostap/hostap_info.c | |||
| @@ -271,8 +271,9 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf, | |||
| 271 | left -= 4; | 271 | left -= 4; |
| 272 | 272 | ||
| 273 | new_count = left / sizeof(struct hfa384x_scan_result); | 273 | new_count = left / sizeof(struct hfa384x_scan_result); |
| 274 | results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), | 274 | results = kmalloc_array(new_count, |
| 275 | GFP_ATOMIC); | 275 | sizeof(struct hfa384x_hostscan_result), |
| 276 | GFP_ATOMIC); | ||
| 276 | if (results == NULL) | 277 | if (results == NULL) |
| 277 | return; | 278 | return; |
| 278 | 279 | ||
diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c index c1bc0a6ef300..1ca9731d9b14 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c | |||
| @@ -513,8 +513,8 @@ static int prism2_ioctl_giwaplist(struct net_device *dev, | |||
| 513 | return -EOPNOTSUPP; | 513 | return -EOPNOTSUPP; |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL); | 516 | addr = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL); |
| 517 | qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL); | 517 | qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL); |
| 518 | if (addr == NULL || qual == NULL) { | 518 | if (addr == NULL || qual == NULL) { |
| 519 | kfree(addr); | 519 | kfree(addr); |
| 520 | kfree(qual); | 520 | kfree(qual); |
diff --git a/drivers/net/wireless/intersil/p54/eeprom.c b/drivers/net/wireless/intersil/p54/eeprom.c index d4c73d39336f..de2ef95c386c 100644 --- a/drivers/net/wireless/intersil/p54/eeprom.c +++ b/drivers/net/wireless/intersil/p54/eeprom.c | |||
| @@ -161,8 +161,9 @@ static int p54_generate_band(struct ieee80211_hw *dev, | |||
| 161 | if (!tmp) | 161 | if (!tmp) |
| 162 | goto err_out; | 162 | goto err_out; |
| 163 | 163 | ||
| 164 | tmp->channels = kzalloc(sizeof(struct ieee80211_channel) * | 164 | tmp->channels = kcalloc(list->band_channel_num[band], |
| 165 | list->band_channel_num[band], GFP_KERNEL); | 165 | sizeof(struct ieee80211_channel), |
| 166 | GFP_KERNEL); | ||
| 166 | if (!tmp->channels) | 167 | if (!tmp->channels) |
| 167 | goto err_out; | 168 | goto err_out; |
| 168 | 169 | ||
| @@ -344,7 +345,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
| 344 | goto free; | 345 | goto free; |
| 345 | } | 346 | } |
| 346 | priv->chan_num = max_channel_num; | 347 | priv->chan_num = max_channel_num; |
| 347 | priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num, | 348 | priv->survey = kcalloc(max_channel_num, sizeof(struct survey_info), |
| 348 | GFP_KERNEL); | 349 | GFP_KERNEL); |
| 349 | if (!priv->survey) { | 350 | if (!priv->survey) { |
| 350 | ret = -ENOMEM; | 351 | ret = -ENOMEM; |
| @@ -352,8 +353,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
| 352 | } | 353 | } |
| 353 | 354 | ||
| 354 | list->max_entries = max_channel_num; | 355 | list->max_entries = max_channel_num; |
| 355 | list->channels = kzalloc(sizeof(struct p54_channel_entry) * | 356 | list->channels = kcalloc(max_channel_num, |
| 356 | max_channel_num, GFP_KERNEL); | 357 | sizeof(struct p54_channel_entry), |
| 358 | GFP_KERNEL); | ||
| 357 | if (!list->channels) { | 359 | if (!list->channels) { |
| 358 | ret = -ENOMEM; | 360 | ret = -ENOMEM; |
| 359 | goto free; | 361 | goto free; |
diff --git a/drivers/net/wireless/intersil/prism54/oid_mgt.c b/drivers/net/wireless/intersil/prism54/oid_mgt.c index 6528ed5b9b1d..6d57e1cbcc07 100644 --- a/drivers/net/wireless/intersil/prism54/oid_mgt.c +++ b/drivers/net/wireless/intersil/prism54/oid_mgt.c | |||
| @@ -244,7 +244,7 @@ mgt_init(islpci_private *priv) | |||
| 244 | /* Alloc the cache */ | 244 | /* Alloc the cache */ |
| 245 | for (i = 0; i < OID_NUM_LAST; i++) { | 245 | for (i = 0; i < OID_NUM_LAST; i++) { |
| 246 | if (isl_oid[i].flags & OID_FLAG_CACHED) { | 246 | if (isl_oid[i].flags & OID_FLAG_CACHED) { |
| 247 | priv->mib[i] = kzalloc(isl_oid[i].size * | 247 | priv->mib[i] = kcalloc(isl_oid[i].size, |
| 248 | (isl_oid[i].range + 1), | 248 | (isl_oid[i].range + 1), |
| 249 | GFP_KERNEL); | 249 | GFP_KERNEL); |
| 250 | if (!priv->mib[i]) | 250 | if (!priv->mib[i]) |
diff --git a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c index 1edcddaf7b4b..7ab44cd32a9d 100644 --- a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | |||
| @@ -399,8 +399,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, | |||
| 399 | 399 | ||
| 400 | new_node->win_size = win_size; | 400 | new_node->win_size = win_size; |
| 401 | 401 | ||
| 402 | new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size, | 402 | new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *), |
| 403 | GFP_KERNEL); | 403 | GFP_KERNEL); |
| 404 | if (!new_node->rx_reorder_ptr) { | 404 | if (!new_node->rx_reorder_ptr) { |
| 405 | kfree((u8 *) new_node); | 405 | kfree((u8 *) new_node); |
| 406 | mwifiex_dbg(priv->adapter, ERROR, | 406 | mwifiex_dbg(priv->adapter, ERROR, |
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index a67e2d66ac9d..4b5ae9098504 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c | |||
| @@ -4242,8 +4242,8 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter) | |||
| 4242 | * additional active scan request for hidden SSIDs on passive channels. | 4242 | * additional active scan request for hidden SSIDs on passive channels. |
| 4243 | */ | 4243 | */ |
| 4244 | adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); | 4244 | adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); |
| 4245 | adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) * | 4245 | adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats), |
| 4246 | adapter->num_in_chan_stats); | 4246 | adapter->num_in_chan_stats)); |
| 4247 | 4247 | ||
| 4248 | if (!adapter->chan_stats) | 4248 | if (!adapter->chan_stats) |
| 4249 | return -ENOMEM; | 4249 | return -ENOMEM; |
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 47d2dcc3f28f..dfdcbc4f141a 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c | |||
| @@ -2106,15 +2106,16 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) | |||
| 2106 | return -ENOMEM; | 2106 | return -ENOMEM; |
| 2107 | 2107 | ||
| 2108 | /* Allocate skb pointer buffers */ | 2108 | /* Allocate skb pointer buffers */ |
| 2109 | card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) * | 2109 | card->mpa_rx.skb_arr = kcalloc(card->mp_agg_pkt_limit, sizeof(void *), |
| 2110 | card->mp_agg_pkt_limit, GFP_KERNEL); | 2110 | GFP_KERNEL); |
| 2111 | if (!card->mpa_rx.skb_arr) { | 2111 | if (!card->mpa_rx.skb_arr) { |
| 2112 | kfree(card->mp_regs); | 2112 | kfree(card->mp_regs); |
| 2113 | return -ENOMEM; | 2113 | return -ENOMEM; |
| 2114 | } | 2114 | } |
| 2115 | 2115 | ||
| 2116 | card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) * | 2116 | card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit, |
| 2117 | card->mp_agg_pkt_limit, GFP_KERNEL); | 2117 | sizeof(*card->mpa_rx.len_arr), |
| 2118 | GFP_KERNEL); | ||
| 2118 | if (!card->mpa_rx.len_arr) { | 2119 | if (!card->mpa_rx.len_arr) { |
| 2119 | kfree(card->mp_regs); | 2120 | kfree(card->mp_regs); |
| 2120 | kfree(card->mpa_rx.skb_arr); | 2121 | kfree(card->mpa_rx.skb_arr); |
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index fcd079a96782..d62e34e7eadf 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c | |||
| @@ -181,7 +181,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, | |||
| 181 | if (!chanlist) | 181 | if (!chanlist) |
| 182 | return -ENOMEM; | 182 | return -ENOMEM; |
| 183 | 183 | ||
| 184 | msband->chan = devm_kzalloc(dev->dev, n_chan * sizeof(*msband->chan), | 184 | msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan), |
| 185 | GFP_KERNEL); | 185 | GFP_KERNEL); |
| 186 | if (!msband->chan) | 186 | if (!msband->chan) |
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 5eb143667539..c5d94a95e21a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c | |||
| @@ -1216,7 +1216,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, | |||
| 1216 | return -EINVAL; | 1216 | return -EINVAL; |
| 1217 | } | 1217 | } |
| 1218 | 1218 | ||
| 1219 | limits = kzalloc(sizeof(*limits) * rec->n_limits, | 1219 | limits = kcalloc(rec->n_limits, sizeof(*limits), |
| 1220 | GFP_KERNEL); | 1220 | GFP_KERNEL); |
| 1221 | if (!limits) | 1221 | if (!limits) |
| 1222 | return -ENOMEM; | 1222 | return -ENOMEM; |
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c index 0eee479583b8..acc399b5574e 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c | |||
| @@ -397,7 +397,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file, | |||
| 397 | if (*offset) | 397 | if (*offset) |
| 398 | return 0; | 398 | return 0; |
| 399 | 399 | ||
| 400 | data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL); | 400 | data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL); |
| 401 | if (!data) | 401 | if (!data) |
| 402 | return -ENOMEM; | 402 | return -ENOMEM; |
| 403 | 403 | ||
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c index fd13d4ef53b8..9729e51fce38 100644 --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c | |||
| @@ -258,8 +258,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) | |||
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | /* allocate memory for efuse_tbl and efuse_word */ | 260 | /* allocate memory for efuse_tbl and efuse_word */ |
| 261 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] * | 261 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE], |
| 262 | sizeof(u8), GFP_ATOMIC); | 262 | GFP_ATOMIC); |
| 263 | if (!efuse_tbl) | 263 | if (!efuse_tbl) |
| 264 | return; | 264 | return; |
| 265 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); | 265 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); |
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index ce3103bb8ebb..f9faffc498bc 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c | |||
| @@ -1048,7 +1048,7 @@ int rtl_usb_probe(struct usb_interface *intf, | |||
| 1048 | } | 1048 | } |
| 1049 | rtlpriv = hw->priv; | 1049 | rtlpriv = hw->priv; |
| 1050 | rtlpriv->hw = hw; | 1050 | rtlpriv->hw = hw; |
| 1051 | rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32), | 1051 | rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32), |
| 1052 | GFP_KERNEL); | 1052 | GFP_KERNEL); |
| 1053 | if (!rtlpriv->usb_data) | 1053 | if (!rtlpriv->usb_data) |
| 1054 | return -ENOMEM; | 1054 | return -ENOMEM; |
diff --git a/drivers/net/wireless/st/cw1200/queue.c b/drivers/net/wireless/st/cw1200/queue.c index 5153d2cfd991..7c31b63b8258 100644 --- a/drivers/net/wireless/st/cw1200/queue.c +++ b/drivers/net/wireless/st/cw1200/queue.c | |||
| @@ -154,7 +154,7 @@ int cw1200_queue_stats_init(struct cw1200_queue_stats *stats, | |||
| 154 | spin_lock_init(&stats->lock); | 154 | spin_lock_init(&stats->lock); |
| 155 | init_waitqueue_head(&stats->wait_link_id_empty); | 155 | init_waitqueue_head(&stats->wait_link_id_empty); |
| 156 | 156 | ||
| 157 | stats->link_map_cache = kzalloc(sizeof(int) * map_capacity, | 157 | stats->link_map_cache = kcalloc(map_capacity, sizeof(int), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!stats->link_map_cache) | 159 | if (!stats->link_map_cache) |
| 160 | return -ENOMEM; | 160 | return -ENOMEM; |
| @@ -181,13 +181,13 @@ int cw1200_queue_init(struct cw1200_queue *queue, | |||
| 181 | spin_lock_init(&queue->lock); | 181 | spin_lock_init(&queue->lock); |
| 182 | timer_setup(&queue->gc, cw1200_queue_gc, 0); | 182 | timer_setup(&queue->gc, cw1200_queue_gc, 0); |
| 183 | 183 | ||
| 184 | queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity, | 184 | queue->pool = kcalloc(capacity, sizeof(struct cw1200_queue_item), |
| 185 | GFP_KERNEL); | 185 | GFP_KERNEL); |
| 186 | if (!queue->pool) | 186 | if (!queue->pool) |
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
| 188 | 188 | ||
| 189 | queue->link_map_cache = kzalloc(sizeof(int) * stats->map_capacity, | 189 | queue->link_map_cache = kcalloc(stats->map_capacity, sizeof(int), |
| 190 | GFP_KERNEL); | 190 | GFP_KERNEL); |
| 191 | if (!queue->link_map_cache) { | 191 | if (!queue->link_map_cache) { |
| 192 | kfree(queue->pool); | 192 | kfree(queue->pool); |
| 193 | queue->pool = NULL; | 193 | queue->pool = NULL; |
diff --git a/drivers/net/wireless/st/cw1200/scan.c b/drivers/net/wireless/st/cw1200/scan.c index cc2ce60f4f09..67213f11acbd 100644 --- a/drivers/net/wireless/st/cw1200/scan.c +++ b/drivers/net/wireless/st/cw1200/scan.c | |||
| @@ -230,9 +230,9 @@ void cw1200_scan_work(struct work_struct *work) | |||
| 230 | scan.type = WSM_SCAN_TYPE_BACKGROUND; | 230 | scan.type = WSM_SCAN_TYPE_BACKGROUND; |
| 231 | scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND; | 231 | scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND; |
| 232 | } | 232 | } |
| 233 | scan.ch = kzalloc( | 233 | scan.ch = kcalloc(it - priv->scan.curr, |
| 234 | sizeof(struct wsm_scan_ch) * (it - priv->scan.curr), | 234 | sizeof(struct wsm_scan_ch), |
| 235 | GFP_KERNEL); | 235 | GFP_KERNEL); |
| 236 | if (!scan.ch) { | 236 | if (!scan.ch) { |
| 237 | priv->scan.status = -ENOMEM; | 237 | priv->scan.status = -ENOMEM; |
| 238 | goto fail; | 238 | goto fail; |
diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c index b01b44a5d16e..1f6d9f357e57 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c | |||
| @@ -732,7 +732,8 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, | |||
| 732 | 732 | ||
| 733 | /* Alloc memory for full beacon write at once. */ | 733 | /* Alloc memory for full beacon write at once. */ |
| 734 | num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len; | 734 | num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len; |
| 735 | ioreqs = kmalloc(num_cmds * sizeof(struct zd_ioreq32), GFP_KERNEL); | 735 | ioreqs = kmalloc_array(num_cmds, sizeof(struct zd_ioreq32), |
| 736 | GFP_KERNEL); | ||
| 736 | if (!ioreqs) { | 737 | if (!ioreqs) { |
| 737 | r = -ENOMEM; | 738 | r = -ENOMEM; |
| 738 | goto out_nofree; | 739 | goto out_nofree; |
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index e1aef253601e..cd51492ae6c2 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c | |||
| @@ -977,8 +977,8 @@ static void connect(struct backend_info *be) | |||
| 977 | } | 977 | } |
| 978 | 978 | ||
| 979 | /* Use the number of queues requested by the frontend */ | 979 | /* Use the number of queues requested by the frontend */ |
| 980 | be->vif->queues = vzalloc(requested_num_queues * | 980 | be->vif->queues = vzalloc(array_size(requested_num_queues, |
| 981 | sizeof(struct xenvif_queue)); | 981 | sizeof(struct xenvif_queue))); |
| 982 | if (!be->vif->queues) { | 982 | if (!be->vif->queues) { |
| 983 | xenbus_dev_fatal(dev, -ENOMEM, | 983 | xenbus_dev_fatal(dev, -ENOMEM, |
| 984 | "allocating queues"); | 984 | "allocating queues"); |
diff --git a/drivers/nfc/fdp/i2c.c b/drivers/nfc/fdp/i2c.c index c4da50e07bbc..d8d70dd830b0 100644 --- a/drivers/nfc/fdp/i2c.c +++ b/drivers/nfc/fdp/i2c.c | |||
| @@ -259,8 +259,8 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev, | |||
| 259 | /* Add 1 to the length to inclue the length byte itself */ | 259 | /* Add 1 to the length to inclue the length byte itself */ |
| 260 | len++; | 260 | len++; |
| 261 | 261 | ||
| 262 | *fw_vsc_cfg = devm_kmalloc(dev, | 262 | *fw_vsc_cfg = devm_kmalloc_array(dev, |
| 263 | len * sizeof(**fw_vsc_cfg), | 263 | len, sizeof(**fw_vsc_cfg), |
| 264 | GFP_KERNEL); | 264 | GFP_KERNEL); |
| 265 | 265 | ||
| 266 | r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME, | 266 | r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME, |
diff --git a/drivers/ntb/hw/amd/ntb_hw_amd.c b/drivers/ntb/hw/amd/ntb_hw_amd.c index 3cfa46876239..efb214fc545a 100644 --- a/drivers/ntb/hw/amd/ntb_hw_amd.c +++ b/drivers/ntb/hw/amd/ntb_hw_amd.c | |||
| @@ -592,12 +592,12 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev, | |||
| 592 | ndev->db_mask = ndev->db_valid_mask; | 592 | ndev->db_mask = ndev->db_valid_mask; |
| 593 | 593 | ||
| 594 | /* Try to set up msix irq */ | 594 | /* Try to set up msix irq */ |
| 595 | ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec), | 595 | ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec), |
| 596 | GFP_KERNEL, node); | 596 | GFP_KERNEL, node); |
| 597 | if (!ndev->vec) | 597 | if (!ndev->vec) |
| 598 | goto err_msix_vec_alloc; | 598 | goto err_msix_vec_alloc; |
| 599 | 599 | ||
| 600 | ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix), | 600 | ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix), |
| 601 | GFP_KERNEL, node); | 601 | GFP_KERNEL, node); |
| 602 | if (!ndev->msix) | 602 | if (!ndev->msix) |
| 603 | goto err_msix_alloc; | 603 | goto err_msix_alloc; |
diff --git a/drivers/ntb/hw/intel/ntb_hw_gen1.c b/drivers/ntb/hw/intel/ntb_hw_gen1.c index ffdee98e8ece..6aa573227279 100644 --- a/drivers/ntb/hw/intel/ntb_hw_gen1.c +++ b/drivers/ntb/hw/intel/ntb_hw_gen1.c | |||
| @@ -380,12 +380,12 @@ int ndev_init_isr(struct intel_ntb_dev *ndev, | |||
| 380 | 380 | ||
| 381 | /* Try to set up msix irq */ | 381 | /* Try to set up msix irq */ |
| 382 | 382 | ||
| 383 | ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec), | 383 | ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec), |
| 384 | GFP_KERNEL, node); | 384 | GFP_KERNEL, node); |
| 385 | if (!ndev->vec) | 385 | if (!ndev->vec) |
| 386 | goto err_msix_vec_alloc; | 386 | goto err_msix_vec_alloc; |
| 387 | 387 | ||
| 388 | ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix), | 388 | ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix), |
| 389 | GFP_KERNEL, node); | 389 | GFP_KERNEL, node); |
| 390 | if (!ndev->msix) | 390 | if (!ndev->msix) |
| 391 | goto err_msix_alloc; | 391 | goto err_msix_alloc; |
diff --git a/drivers/ntb/ntb_transport.c b/drivers/ntb/ntb_transport.c index 8145be34328b..939895966476 100644 --- a/drivers/ntb/ntb_transport.c +++ b/drivers/ntb/ntb_transport.c | |||
| @@ -1102,7 +1102,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) | |||
| 1102 | max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2; | 1102 | max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2; |
| 1103 | nt->mw_count = min(mw_count, max_mw_count_for_spads); | 1103 | nt->mw_count = min(mw_count, max_mw_count_for_spads); |
| 1104 | 1104 | ||
| 1105 | nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec), | 1105 | nt->mw_vec = kcalloc_node(mw_count, sizeof(*nt->mw_vec), |
| 1106 | GFP_KERNEL, node); | 1106 | GFP_KERNEL, node); |
| 1107 | if (!nt->mw_vec) { | 1107 | if (!nt->mw_vec) { |
| 1108 | rc = -ENOMEM; | 1108 | rc = -ENOMEM; |
| @@ -1143,7 +1143,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) | |||
| 1143 | nt->qp_bitmap = qp_bitmap; | 1143 | nt->qp_bitmap = qp_bitmap; |
| 1144 | nt->qp_bitmap_free = qp_bitmap; | 1144 | nt->qp_bitmap_free = qp_bitmap; |
| 1145 | 1145 | ||
| 1146 | nt->qp_vec = kzalloc_node(qp_count * sizeof(*nt->qp_vec), | 1146 | nt->qp_vec = kcalloc_node(qp_count, sizeof(*nt->qp_vec), |
| 1147 | GFP_KERNEL, node); | 1147 | GFP_KERNEL, node); |
| 1148 | if (!nt->qp_vec) { | 1148 | if (!nt->qp_vec) { |
| 1149 | rc = -ENOMEM; | 1149 | rc = -ENOMEM; |
diff --git a/drivers/nvmem/rockchip-efuse.c b/drivers/nvmem/rockchip-efuse.c index b3b0b648be62..146de9489339 100644 --- a/drivers/nvmem/rockchip-efuse.c +++ b/drivers/nvmem/rockchip-efuse.c | |||
| @@ -122,7 +122,8 @@ static int rockchip_rk3328_efuse_read(void *context, unsigned int offset, | |||
| 122 | addr_offset = offset % RK3399_NBYTES; | 122 | addr_offset = offset % RK3399_NBYTES; |
| 123 | addr_len = addr_end - addr_start; | 123 | addr_len = addr_end - addr_start; |
| 124 | 124 | ||
| 125 | buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL); | 125 | buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)), |
| 126 | GFP_KERNEL); | ||
| 126 | if (!buf) { | 127 | if (!buf) { |
| 127 | ret = -ENOMEM; | 128 | ret = -ENOMEM; |
| 128 | goto nomem; | 129 | goto nomem; |
| @@ -174,7 +175,8 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset, | |||
| 174 | addr_offset = offset % RK3399_NBYTES; | 175 | addr_offset = offset % RK3399_NBYTES; |
| 175 | addr_len = addr_end - addr_start; | 176 | addr_len = addr_end - addr_start; |
| 176 | 177 | ||
| 177 | buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL); | 178 | buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)), |
| 179 | GFP_KERNEL); | ||
| 178 | if (!buf) { | 180 | if (!buf) { |
| 179 | clk_disable_unprepare(efuse->clk); | 181 | clk_disable_unprepare(efuse->clk); |
| 180 | return -ENOMEM; | 182 | return -ENOMEM; |
diff --git a/drivers/nvmem/sunxi_sid.c b/drivers/nvmem/sunxi_sid.c index 26bb637afe92..d020f89248fd 100644 --- a/drivers/nvmem/sunxi_sid.c +++ b/drivers/nvmem/sunxi_sid.c | |||
| @@ -185,7 +185,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) | |||
| 185 | if (IS_ERR(nvmem)) | 185 | if (IS_ERR(nvmem)) |
| 186 | return PTR_ERR(nvmem); | 186 | return PTR_ERR(nvmem); |
| 187 | 187 | ||
| 188 | randomness = kzalloc(sizeof(u8) * (size), GFP_KERNEL); | 188 | randomness = kzalloc(size, GFP_KERNEL); |
| 189 | if (!randomness) { | 189 | if (!randomness) { |
| 190 | ret = -EINVAL; | 190 | ret = -EINVAL; |
| 191 | goto err_unreg_nvmem; | 191 | goto err_unreg_nvmem; |
diff --git a/drivers/of/platform.c b/drivers/of/platform.c index 59731a950c1f..6925d993e1f0 100644 --- a/drivers/of/platform.c +++ b/drivers/of/platform.c | |||
| @@ -129,7 +129,7 @@ struct platform_device *of_device_alloc(struct device_node *np, | |||
| 129 | 129 | ||
| 130 | /* Populate the resource table */ | 130 | /* Populate the resource table */ |
| 131 | if (num_irq || num_reg) { | 131 | if (num_irq || num_reg) { |
| 132 | res = kzalloc(sizeof(*res) * (num_irq + num_reg), GFP_KERNEL); | 132 | res = kcalloc(num_irq + num_reg, sizeof(*res), GFP_KERNEL); |
| 133 | if (!res) { | 133 | if (!res) { |
| 134 | platform_device_put(dev); | 134 | platform_device_put(dev); |
| 135 | return NULL; | 135 | return NULL; |
diff --git a/drivers/of/unittest.c b/drivers/of/unittest.c index ecee50d10d14..722537e14848 100644 --- a/drivers/of/unittest.c +++ b/drivers/of/unittest.c | |||
| @@ -156,7 +156,7 @@ static void __init of_unittest_dynamic(void) | |||
| 156 | } | 156 | } |
| 157 | 157 | ||
| 158 | /* Array of 4 properties for the purpose of testing */ | 158 | /* Array of 4 properties for the purpose of testing */ |
| 159 | prop = kzalloc(sizeof(*prop) * 4, GFP_KERNEL); | 159 | prop = kcalloc(4, sizeof(*prop), GFP_KERNEL); |
| 160 | if (!prop) { | 160 | if (!prop) { |
| 161 | unittest(0, "kzalloc() failed\n"); | 161 | unittest(0, "kzalloc() failed\n"); |
| 162 | return; | 162 | return; |
diff --git a/drivers/opp/ti-opp-supply.c b/drivers/opp/ti-opp-supply.c index 370eff3acd8a..9e5a9a3112c9 100644 --- a/drivers/opp/ti-opp-supply.c +++ b/drivers/opp/ti-opp-supply.c | |||
| @@ -122,8 +122,8 @@ static int _store_optimized_voltages(struct device *dev, | |||
| 122 | goto out; | 122 | goto out; |
| 123 | } | 123 | } |
| 124 | 124 | ||
| 125 | table = kzalloc(sizeof(*data->vdd_table) * | 125 | table = kcalloc(data->num_vdd_table, sizeof(*data->vdd_table), |
| 126 | data->num_vdd_table, GFP_KERNEL); | 126 | GFP_KERNEL); |
| 127 | if (!table) { | 127 | if (!table) { |
| 128 | ret = -ENOMEM; | 128 | ret = -ENOMEM; |
| 129 | goto out; | 129 | goto out; |
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c index 32888f2bd1a9..12ea4a4ad607 100644 --- a/drivers/oprofile/event_buffer.c +++ b/drivers/oprofile/event_buffer.c | |||
| @@ -91,7 +91,7 @@ int alloc_event_buffer(void) | |||
| 91 | return -EINVAL; | 91 | return -EINVAL; |
| 92 | 92 | ||
| 93 | buffer_pos = 0; | 93 | buffer_pos = 0; |
| 94 | event_buffer = vmalloc(sizeof(unsigned long) * buffer_size); | 94 | event_buffer = vmalloc(array_size(buffer_size, sizeof(unsigned long))); |
| 95 | if (!event_buffer) | 95 | if (!event_buffer) |
| 96 | return -ENOMEM; | 96 | return -ENOMEM; |
| 97 | 97 | ||
diff --git a/drivers/pci/controller/dwc/pci-dra7xx.c b/drivers/pci/controller/dwc/pci-dra7xx.c index cfaeef81d868..345aab56ce8b 100644 --- a/drivers/pci/controller/dwc/pci-dra7xx.c +++ b/drivers/pci/controller/dwc/pci-dra7xx.c | |||
| @@ -639,11 +639,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) | |||
| 639 | return phy_count; | 639 | return phy_count; |
| 640 | } | 640 | } |
| 641 | 641 | ||
| 642 | phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL); | 642 | phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL); |
| 643 | if (!phy) | 643 | if (!phy) |
| 644 | return -ENOMEM; | 644 | return -ENOMEM; |
| 645 | 645 | ||
| 646 | link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL); | 646 | link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL); |
| 647 | if (!link) | 647 | if (!link) |
| 648 | return -ENOMEM; | 648 | return -ENOMEM; |
| 649 | 649 | ||
diff --git a/drivers/pci/controller/dwc/pcie-designware-ep.c b/drivers/pci/controller/dwc/pcie-designware-ep.c index 1eec4415a77f..8650416f6f9e 100644 --- a/drivers/pci/controller/dwc/pcie-designware-ep.c +++ b/drivers/pci/controller/dwc/pcie-designware-ep.c | |||
| @@ -366,19 +366,21 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) | |||
| 366 | return -EINVAL; | 366 | return -EINVAL; |
| 367 | } | 367 | } |
| 368 | 368 | ||
| 369 | ep->ib_window_map = devm_kzalloc(dev, sizeof(long) * | 369 | ep->ib_window_map = devm_kcalloc(dev, |
| 370 | BITS_TO_LONGS(ep->num_ib_windows), | 370 | BITS_TO_LONGS(ep->num_ib_windows), |
| 371 | sizeof(long), | ||
| 371 | GFP_KERNEL); | 372 | GFP_KERNEL); |
| 372 | if (!ep->ib_window_map) | 373 | if (!ep->ib_window_map) |
| 373 | return -ENOMEM; | 374 | return -ENOMEM; |
| 374 | 375 | ||
| 375 | ep->ob_window_map = devm_kzalloc(dev, sizeof(long) * | 376 | ep->ob_window_map = devm_kcalloc(dev, |
| 376 | BITS_TO_LONGS(ep->num_ob_windows), | 377 | BITS_TO_LONGS(ep->num_ob_windows), |
| 378 | sizeof(long), | ||
| 377 | GFP_KERNEL); | 379 | GFP_KERNEL); |
| 378 | if (!ep->ob_window_map) | 380 | if (!ep->ob_window_map) |
| 379 | return -ENOMEM; | 381 | return -ENOMEM; |
| 380 | 382 | ||
| 381 | addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows, | 383 | addr = devm_kcalloc(dev, ep->num_ob_windows, sizeof(phys_addr_t), |
| 382 | GFP_KERNEL); | 384 | GFP_KERNEL); |
| 383 | if (!addr) | 385 | if (!addr) |
| 384 | return -ENOMEM; | 386 | return -ENOMEM; |
diff --git a/drivers/pci/controller/pcie-cadence-ep.c b/drivers/pci/controller/pcie-cadence-ep.c index 3d8283e450a9..e3fe4124e3af 100644 --- a/drivers/pci/controller/pcie-cadence-ep.c +++ b/drivers/pci/controller/pcie-cadence-ep.c | |||
| @@ -467,7 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev) | |||
| 467 | dev_err(dev, "missing \"cdns,max-outbound-regions\"\n"); | 467 | dev_err(dev, "missing \"cdns,max-outbound-regions\"\n"); |
| 468 | return ret; | 468 | return ret; |
| 469 | } | 469 | } |
| 470 | ep->ob_addr = devm_kzalloc(dev, ep->max_regions * sizeof(*ep->ob_addr), | 470 | ep->ob_addr = devm_kcalloc(dev, |
| 471 | ep->max_regions, sizeof(*ep->ob_addr), | ||
| 471 | GFP_KERNEL); | 472 | GFP_KERNEL); |
| 472 | if (!ep->ob_addr) | 473 | if (!ep->ob_addr) |
| 473 | return -ENOMEM; | 474 | return -ENOMEM; |
diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c index fc267a49a932..6beba8ed7b84 100644 --- a/drivers/pci/controller/pcie-rockchip-ep.c +++ b/drivers/pci/controller/pcie-rockchip-ep.c | |||
| @@ -593,7 +593,7 @@ static int rockchip_pcie_ep_probe(struct platform_device *pdev) | |||
| 593 | PCIE_CLIENT_CONFIG); | 593 | PCIE_CLIENT_CONFIG); |
| 594 | 594 | ||
| 595 | max_regions = ep->max_regions; | 595 | max_regions = ep->max_regions; |
| 596 | ep->ob_addr = devm_kzalloc(dev, max_regions * sizeof(*ep->ob_addr), | 596 | ep->ob_addr = devm_kcalloc(dev, max_regions, sizeof(*ep->ob_addr), |
| 597 | GFP_KERNEL); | 597 | GFP_KERNEL); |
| 598 | 598 | ||
| 599 | if (!ep->ob_addr) { | 599 | if (!ep->ob_addr) { |
diff --git a/drivers/pci/msi.c b/drivers/pci/msi.c index f45b74fcc059..4d88afdfc843 100644 --- a/drivers/pci/msi.c +++ b/drivers/pci/msi.c | |||
| @@ -474,7 +474,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev) | |||
| 474 | return 0; | 474 | return 0; |
| 475 | 475 | ||
| 476 | /* Dynamically create the MSI attributes for the PCI device */ | 476 | /* Dynamically create the MSI attributes for the PCI device */ |
| 477 | msi_attrs = kzalloc(sizeof(void *) * (num_msi + 1), GFP_KERNEL); | 477 | msi_attrs = kcalloc(num_msi + 1, sizeof(void *), GFP_KERNEL); |
| 478 | if (!msi_attrs) | 478 | if (!msi_attrs) |
| 479 | return -ENOMEM; | 479 | return -ENOMEM; |
| 480 | for_each_pci_msi_entry(entry, pdev) { | 480 | for_each_pci_msi_entry(entry, pdev) { |
| @@ -501,7 +501,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev) | |||
| 501 | msi_irq_group->name = "msi_irqs"; | 501 | msi_irq_group->name = "msi_irqs"; |
| 502 | msi_irq_group->attrs = msi_attrs; | 502 | msi_irq_group->attrs = msi_attrs; |
| 503 | 503 | ||
| 504 | msi_irq_groups = kzalloc(sizeof(void *) * 2, GFP_KERNEL); | 504 | msi_irq_groups = kcalloc(2, sizeof(void *), GFP_KERNEL); |
| 505 | if (!msi_irq_groups) | 505 | if (!msi_irq_groups) |
| 506 | goto error_irq_group; | 506 | goto error_irq_group; |
| 507 | msi_irq_groups[0] = msi_irq_group; | 507 | msi_irq_groups[0] = msi_irq_group; |
diff --git a/drivers/pci/pci-sysfs.c b/drivers/pci/pci-sysfs.c index 788a200fb2dc..0c4653c1d2ce 100644 --- a/drivers/pci/pci-sysfs.c +++ b/drivers/pci/pci-sysfs.c | |||
| @@ -1076,7 +1076,7 @@ void pci_create_legacy_files(struct pci_bus *b) | |||
| 1076 | { | 1076 | { |
| 1077 | int error; | 1077 | int error; |
| 1078 | 1078 | ||
| 1079 | b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2, | 1079 | b->legacy_io = kcalloc(2, sizeof(struct bin_attribute), |
| 1080 | GFP_ATOMIC); | 1080 | GFP_ATOMIC); |
| 1081 | if (!b->legacy_io) | 1081 | if (!b->legacy_io) |
| 1082 | goto kzalloc_err; | 1082 | goto kzalloc_err; |
diff --git a/drivers/pcmcia/cistpl.c b/drivers/pcmcia/cistpl.c index 102646fedb56..ac0672b8dfca 100644 --- a/drivers/pcmcia/cistpl.c +++ b/drivers/pcmcia/cistpl.c | |||
| @@ -1481,11 +1481,11 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, | |||
| 1481 | u_char *tuplebuffer; | 1481 | u_char *tuplebuffer; |
| 1482 | u_char *tempbuffer; | 1482 | u_char *tempbuffer; |
| 1483 | 1483 | ||
| 1484 | tuplebuffer = kmalloc(sizeof(u_char) * 256, GFP_KERNEL); | 1484 | tuplebuffer = kmalloc_array(256, sizeof(u_char), GFP_KERNEL); |
| 1485 | if (!tuplebuffer) | 1485 | if (!tuplebuffer) |
| 1486 | return -ENOMEM; | 1486 | return -ENOMEM; |
| 1487 | 1487 | ||
| 1488 | tempbuffer = kmalloc(sizeof(u_char) * 258, GFP_KERNEL); | 1488 | tempbuffer = kmalloc_array(258, sizeof(u_char), GFP_KERNEL); |
| 1489 | if (!tempbuffer) { | 1489 | if (!tempbuffer) { |
| 1490 | ret = -ENOMEM; | 1490 | ret = -ENOMEM; |
| 1491 | goto free_tuple; | 1491 | goto free_tuple; |
diff --git a/drivers/pcmcia/pd6729.c b/drivers/pcmcia/pd6729.c index 959ae3e65ef8..f0af9985ca09 100644 --- a/drivers/pcmcia/pd6729.c +++ b/drivers/pcmcia/pd6729.c | |||
| @@ -628,7 +628,7 @@ static int pd6729_pci_probe(struct pci_dev *dev, | |||
| 628 | char configbyte; | 628 | char configbyte; |
| 629 | struct pd6729_socket *socket; | 629 | struct pd6729_socket *socket; |
| 630 | 630 | ||
| 631 | socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS, | 631 | socket = kcalloc(MAX_SOCKETS, sizeof(struct pd6729_socket), |
| 632 | GFP_KERNEL); | 632 | GFP_KERNEL); |
| 633 | if (!socket) { | 633 | if (!socket) { |
| 634 | dev_warn(&dev->dev, "failed to kzalloc socket.\n"); | 634 | dev_warn(&dev->dev, "failed to kzalloc socket.\n"); |
diff --git a/drivers/pinctrl/bcm/pinctrl-bcm2835.c b/drivers/pinctrl/bcm/pinctrl-bcm2835.c index 136ccaf53df8..fa530913a2c8 100644 --- a/drivers/pinctrl/bcm/pinctrl-bcm2835.c +++ b/drivers/pinctrl/bcm/pinctrl-bcm2835.c | |||
| @@ -771,8 +771,8 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 771 | maps_per_pin++; | 771 | maps_per_pin++; |
| 772 | if (num_pulls) | 772 | if (num_pulls) |
| 773 | maps_per_pin++; | 773 | maps_per_pin++; |
| 774 | cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps), | 774 | cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps), |
| 775 | GFP_KERNEL); | 775 | GFP_KERNEL); |
| 776 | if (!maps) | 776 | if (!maps) |
| 777 | return -ENOMEM; | 777 | return -ENOMEM; |
| 778 | 778 | ||
diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c index a620a8e8fa78..d6d183e9db17 100644 --- a/drivers/pinctrl/berlin/berlin.c +++ b/drivers/pinctrl/berlin/berlin.c | |||
| @@ -216,8 +216,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) | |||
| 216 | } | 216 | } |
| 217 | 217 | ||
| 218 | /* we will reallocate later */ | 218 | /* we will reallocate later */ |
| 219 | pctrl->functions = devm_kzalloc(&pdev->dev, | 219 | pctrl->functions = devm_kcalloc(&pdev->dev, |
| 220 | max_functions * sizeof(*pctrl->functions), | 220 | max_functions, |
| 221 | sizeof(*pctrl->functions), | ||
| 221 | GFP_KERNEL); | 222 | GFP_KERNEL); |
| 222 | if (!pctrl->functions) | 223 | if (!pctrl->functions) |
| 223 | return -ENOMEM; | 224 | return -ENOMEM; |
| @@ -261,8 +262,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) | |||
| 261 | 262 | ||
| 262 | if (!function->groups) { | 263 | if (!function->groups) { |
| 263 | function->groups = | 264 | function->groups = |
| 264 | devm_kzalloc(&pdev->dev, | 265 | devm_kcalloc(&pdev->dev, |
| 265 | function->ngroups * sizeof(char *), | 266 | function->ngroups, |
| 267 | sizeof(char *), | ||
| 266 | GFP_KERNEL); | 268 | GFP_KERNEL); |
| 267 | 269 | ||
| 268 | if (!function->groups) | 270 | if (!function->groups) |
diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index e582a21cfe54..1c6bb15579e1 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c | |||
| @@ -81,7 +81,8 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 81 | map_num++; | 81 | map_num++; |
| 82 | } | 82 | } |
| 83 | 83 | ||
| 84 | new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL); | 84 | new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map), |
| 85 | GFP_KERNEL); | ||
| 85 | if (!new_map) | 86 | if (!new_map) |
| 86 | return -ENOMEM; | 87 | return -ENOMEM; |
| 87 | 88 | ||
| @@ -476,10 +477,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np, | |||
| 476 | config = imx_pinconf_parse_generic_config(np, ipctl); | 477 | config = imx_pinconf_parse_generic_config(np, ipctl); |
| 477 | 478 | ||
| 478 | grp->num_pins = size / pin_size; | 479 | grp->num_pins = size / pin_size; |
| 479 | grp->data = devm_kzalloc(ipctl->dev, grp->num_pins * | 480 | grp->data = devm_kcalloc(ipctl->dev, |
| 480 | sizeof(struct imx_pin), GFP_KERNEL); | 481 | grp->num_pins, sizeof(struct imx_pin), |
| 481 | grp->pins = devm_kzalloc(ipctl->dev, grp->num_pins * | 482 | GFP_KERNEL); |
| 482 | sizeof(unsigned int), GFP_KERNEL); | 483 | grp->pins = devm_kcalloc(ipctl->dev, |
| 484 | grp->num_pins, sizeof(unsigned int), | ||
| 485 | GFP_KERNEL); | ||
| 483 | if (!grp->pins || !grp->data) | 486 | if (!grp->pins || !grp->data) |
| 484 | return -ENOMEM; | 487 | return -ENOMEM; |
| 485 | 488 | ||
| @@ -697,8 +700,9 @@ int imx_pinctrl_probe(struct platform_device *pdev, | |||
| 697 | if (!ipctl) | 700 | if (!ipctl) |
| 698 | return -ENOMEM; | 701 | return -ENOMEM; |
| 699 | 702 | ||
| 700 | ipctl->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*ipctl->pin_regs) * | 703 | ipctl->pin_regs = devm_kmalloc_array(&pdev->dev, |
| 701 | info->npins, GFP_KERNEL); | 704 | info->npins, sizeof(*ipctl->pin_regs), |
| 705 | GFP_KERNEL); | ||
| 702 | if (!ipctl->pin_regs) | 706 | if (!ipctl->pin_regs) |
| 703 | return -ENOMEM; | 707 | return -ENOMEM; |
| 704 | 708 | ||
diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index 5af89de0ff02..c3bdd90b1422 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c | |||
| @@ -241,7 +241,8 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 241 | for (i = 0; i < grp->npins; i++) | 241 | for (i = 0; i < grp->npins; i++) |
| 242 | map_num++; | 242 | map_num++; |
| 243 | 243 | ||
| 244 | new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL); | 244 | new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map), |
| 245 | GFP_KERNEL); | ||
| 245 | if (!new_map) | 246 | if (!new_map) |
| 246 | return -ENOMEM; | 247 | return -ENOMEM; |
| 247 | 248 | ||
| @@ -482,10 +483,10 @@ static int imx1_pinctrl_parse_groups(struct device_node *np, | |||
| 482 | } | 483 | } |
| 483 | 484 | ||
| 484 | grp->npins = size / 12; | 485 | grp->npins = size / 12; |
| 485 | grp->pins = devm_kzalloc(info->dev, | 486 | grp->pins = devm_kcalloc(info->dev, |
| 486 | grp->npins * sizeof(struct imx1_pin), GFP_KERNEL); | 487 | grp->npins, sizeof(struct imx1_pin), GFP_KERNEL); |
| 487 | grp->pin_ids = devm_kzalloc(info->dev, | 488 | grp->pin_ids = devm_kcalloc(info->dev, |
| 488 | grp->npins * sizeof(unsigned int), GFP_KERNEL); | 489 | grp->npins, sizeof(unsigned int), GFP_KERNEL); |
| 489 | 490 | ||
| 490 | if (!grp->pins || !grp->pin_ids) | 491 | if (!grp->pins || !grp->pin_ids) |
| 491 | return -ENOMEM; | 492 | return -ENOMEM; |
| @@ -522,8 +523,8 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, | |||
| 522 | if (func->num_groups == 0) | 523 | if (func->num_groups == 0) |
| 523 | return -EINVAL; | 524 | return -EINVAL; |
| 524 | 525 | ||
| 525 | func->groups = devm_kzalloc(info->dev, | 526 | func->groups = devm_kcalloc(info->dev, |
| 526 | func->num_groups * sizeof(char *), GFP_KERNEL); | 527 | func->num_groups, sizeof(char *), GFP_KERNEL); |
| 527 | 528 | ||
| 528 | if (!func->groups) | 529 | if (!func->groups) |
| 529 | return -ENOMEM; | 530 | return -ENOMEM; |
| @@ -565,12 +566,12 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, | |||
| 565 | } | 566 | } |
| 566 | 567 | ||
| 567 | info->nfunctions = nfuncs; | 568 | info->nfunctions = nfuncs; |
| 568 | info->functions = devm_kzalloc(&pdev->dev, | 569 | info->functions = devm_kcalloc(&pdev->dev, |
| 569 | nfuncs * sizeof(struct imx1_pmx_func), GFP_KERNEL); | 570 | nfuncs, sizeof(struct imx1_pmx_func), GFP_KERNEL); |
| 570 | 571 | ||
| 571 | info->ngroups = ngroups; | 572 | info->ngroups = ngroups; |
| 572 | info->groups = devm_kzalloc(&pdev->dev, | 573 | info->groups = devm_kcalloc(&pdev->dev, |
| 573 | ngroups * sizeof(struct imx1_pin_group), GFP_KERNEL); | 574 | ngroups, sizeof(struct imx1_pin_group), GFP_KERNEL); |
| 574 | 575 | ||
| 575 | 576 | ||
| 576 | if (!info->functions || !info->groups) | 577 | if (!info->functions || !info->groups) |
diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index 594f3e5ce9a9..a612e46ca51c 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c | |||
| @@ -89,7 +89,7 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 89 | if (!purecfg && config) | 89 | if (!purecfg && config) |
| 90 | new_num = 2; | 90 | new_num = 2; |
| 91 | 91 | ||
| 92 | new_map = kzalloc(sizeof(*new_map) * new_num, GFP_KERNEL); | 92 | new_map = kcalloc(new_num, sizeof(*new_map), GFP_KERNEL); |
| 93 | if (!new_map) | 93 | if (!new_map) |
| 94 | return -ENOMEM; | 94 | return -ENOMEM; |
| 95 | 95 | ||
| @@ -370,12 +370,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev, | |||
| 370 | return -EINVAL; | 370 | return -EINVAL; |
| 371 | g->npins = length / sizeof(u32); | 371 | g->npins = length / sizeof(u32); |
| 372 | 372 | ||
| 373 | g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins), | 373 | g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins), |
| 374 | GFP_KERNEL); | 374 | GFP_KERNEL); |
| 375 | if (!g->pins) | 375 | if (!g->pins) |
| 376 | return -ENOMEM; | 376 | return -ENOMEM; |
| 377 | 377 | ||
| 378 | g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel), | 378 | g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel), |
| 379 | GFP_KERNEL); | 379 | GFP_KERNEL); |
| 380 | if (!g->muxsel) | 380 | if (!g->muxsel) |
| 381 | return -ENOMEM; | 381 | return -ENOMEM; |
| @@ -426,13 +426,16 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, | |||
| 426 | } | 426 | } |
| 427 | } | 427 | } |
| 428 | 428 | ||
| 429 | soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions * | 429 | soc->functions = devm_kcalloc(&pdev->dev, |
| 430 | sizeof(*soc->functions), GFP_KERNEL); | 430 | soc->nfunctions, |
| 431 | sizeof(*soc->functions), | ||
| 432 | GFP_KERNEL); | ||
| 431 | if (!soc->functions) | 433 | if (!soc->functions) |
| 432 | return -ENOMEM; | 434 | return -ENOMEM; |
| 433 | 435 | ||
| 434 | soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups * | 436 | soc->groups = devm_kcalloc(&pdev->dev, |
| 435 | sizeof(*soc->groups), GFP_KERNEL); | 437 | soc->ngroups, sizeof(*soc->groups), |
| 438 | GFP_KERNEL); | ||
| 436 | if (!soc->groups) | 439 | if (!soc->groups) |
| 437 | return -ENOMEM; | 440 | return -ENOMEM; |
| 438 | 441 | ||
| @@ -492,7 +495,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, | |||
| 492 | 495 | ||
| 493 | if (strcmp(fn, child->name)) { | 496 | if (strcmp(fn, child->name)) { |
| 494 | f = &soc->functions[idxf++]; | 497 | f = &soc->functions[idxf++]; |
| 495 | f->groups = devm_kzalloc(&pdev->dev, f->ngroups * | 498 | f->groups = devm_kcalloc(&pdev->dev, |
| 499 | f->ngroups, | ||
| 496 | sizeof(*f->groups), | 500 | sizeof(*f->groups), |
| 497 | GFP_KERNEL); | 501 | GFP_KERNEL); |
| 498 | if (!f->groups) | 502 | if (!f->groups) |
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 674ffdf8103c..53cf800688e9 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c | |||
| @@ -856,9 +856,10 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) | |||
| 856 | struct armada_37xx_pin_group *grp = &info->groups[n]; | 856 | struct armada_37xx_pin_group *grp = &info->groups[n]; |
| 857 | int i, j, f; | 857 | int i, j, f; |
| 858 | 858 | ||
| 859 | grp->pins = devm_kzalloc(info->dev, | 859 | grp->pins = devm_kcalloc(info->dev, |
| 860 | (grp->npins + grp->extra_npins) * | 860 | grp->npins + grp->extra_npins, |
| 861 | sizeof(*grp->pins), GFP_KERNEL); | 861 | sizeof(*grp->pins), |
| 862 | GFP_KERNEL); | ||
| 862 | if (!grp->pins) | 863 | if (!grp->pins) |
| 863 | return -ENOMEM; | 864 | return -ENOMEM; |
| 864 | 865 | ||
| @@ -908,7 +909,8 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) | |||
| 908 | const char **groups; | 909 | const char **groups; |
| 909 | int g; | 910 | int g; |
| 910 | 911 | ||
| 911 | funcs[n].groups = devm_kzalloc(info->dev, funcs[n].ngroups * | 912 | funcs[n].groups = devm_kcalloc(info->dev, |
| 913 | funcs[n].ngroups, | ||
| 912 | sizeof(*(funcs[n].groups)), | 914 | sizeof(*(funcs[n].groups)), |
| 913 | GFP_KERNEL); | 915 | GFP_KERNEL); |
| 914 | if (!funcs[n].groups) | 916 | if (!funcs[n].groups) |
| @@ -948,8 +950,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, | |||
| 948 | ctrldesc->pmxops = &armada_37xx_pmx_ops; | 950 | ctrldesc->pmxops = &armada_37xx_pmx_ops; |
| 949 | ctrldesc->confops = &armada_37xx_pinconf_ops; | 951 | ctrldesc->confops = &armada_37xx_pinconf_ops; |
| 950 | 952 | ||
| 951 | pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * | 953 | pindesc = devm_kcalloc(&pdev->dev, |
| 952 | pin_data->nr_pins, GFP_KERNEL); | 954 | pin_data->nr_pins, sizeof(*pindesc), |
| 955 | GFP_KERNEL); | ||
| 953 | if (!pindesc) | 956 | if (!pindesc) |
| 954 | return -ENOMEM; | 957 | return -ENOMEM; |
| 955 | 958 | ||
| @@ -968,8 +971,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, | |||
| 968 | * we allocate functions for number of pins and hope there are | 971 | * we allocate functions for number of pins and hope there are |
| 969 | * fewer unique functions than pins available | 972 | * fewer unique functions than pins available |
| 970 | */ | 973 | */ |
| 971 | info->funcs = devm_kzalloc(&pdev->dev, pin_data->nr_pins * | 974 | info->funcs = devm_kcalloc(&pdev->dev, |
| 972 | sizeof(struct armada_37xx_pmx_func), GFP_KERNEL); | 975 | pin_data->nr_pins, |
| 976 | sizeof(struct armada_37xx_pmx_func), | ||
| 977 | GFP_KERNEL); | ||
| 973 | if (!info->funcs) | 978 | if (!info->funcs) |
| 974 | return -ENOMEM; | 979 | return -ENOMEM; |
| 975 | 980 | ||
diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c index 5e828468e43d..43231fd065a1 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-xp.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-xp.c | |||
| @@ -630,8 +630,8 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) | |||
| 630 | 630 | ||
| 631 | nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG); | 631 | nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG); |
| 632 | 632 | ||
| 633 | mpp_saved_regs = devm_kmalloc(&pdev->dev, nregs * sizeof(u32), | 633 | mpp_saved_regs = devm_kmalloc_array(&pdev->dev, nregs, sizeof(u32), |
| 634 | GFP_KERNEL); | 634 | GFP_KERNEL); |
| 635 | if (!mpp_saved_regs) | 635 | if (!mpp_saved_regs) |
| 636 | return -ENOMEM; | 636 | return -ENOMEM; |
| 637 | 637 | ||
diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 9e05cfaf75f0..d7ec7119701b 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c | |||
| @@ -501,8 +501,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, | |||
| 501 | 501 | ||
| 502 | /* we allocate functions for number of pins and hope | 502 | /* we allocate functions for number of pins and hope |
| 503 | * there are fewer unique functions than pins available */ | 503 | * there are fewer unique functions than pins available */ |
| 504 | funcs = devm_kzalloc(&pdev->dev, funcsize * | 504 | funcs = devm_kcalloc(&pdev->dev, |
| 505 | sizeof(struct mvebu_pinctrl_function), GFP_KERNEL); | 505 | funcsize, sizeof(struct mvebu_pinctrl_function), |
| 506 | GFP_KERNEL); | ||
| 506 | if (!funcs) | 507 | if (!funcs) |
| 507 | return -ENOMEM; | 508 | return -ENOMEM; |
| 508 | 509 | ||
| @@ -549,8 +550,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, | |||
| 549 | 550 | ||
| 550 | /* allocate group name array if not done already */ | 551 | /* allocate group name array if not done already */ |
| 551 | if (!f->groups) { | 552 | if (!f->groups) { |
| 552 | f->groups = devm_kzalloc(&pdev->dev, | 553 | f->groups = devm_kcalloc(&pdev->dev, |
| 553 | f->num_groups * sizeof(char *), | 554 | f->num_groups, |
| 555 | sizeof(char *), | ||
| 554 | GFP_KERNEL); | 556 | GFP_KERNEL); |
| 555 | if (!f->groups) | 557 | if (!f->groups) |
| 556 | return -ENOMEM; | 558 | return -ENOMEM; |
| @@ -622,8 +624,10 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) | |||
| 622 | } | 624 | } |
| 623 | } | 625 | } |
| 624 | 626 | ||
| 625 | pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins * | 627 | pdesc = devm_kcalloc(&pdev->dev, |
| 626 | sizeof(struct pinctrl_pin_desc), GFP_KERNEL); | 628 | pctl->desc.npins, |
| 629 | sizeof(struct pinctrl_pin_desc), | ||
| 630 | GFP_KERNEL); | ||
| 627 | if (!pdesc) | 631 | if (!pdesc) |
| 628 | return -ENOMEM; | 632 | return -ENOMEM; |
| 629 | 633 | ||
diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index bafb3d40545e..67e4d9ffa6b1 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c | |||
| @@ -945,27 +945,30 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) | |||
| 945 | return PTR_ERR(atmel_pioctrl->clk); | 945 | return PTR_ERR(atmel_pioctrl->clk); |
| 946 | } | 946 | } |
| 947 | 947 | ||
| 948 | atmel_pioctrl->pins = devm_kzalloc(dev, sizeof(*atmel_pioctrl->pins) | 948 | atmel_pioctrl->pins = devm_kcalloc(dev, |
| 949 | * atmel_pioctrl->npins, GFP_KERNEL); | 949 | atmel_pioctrl->npins, |
| 950 | sizeof(*atmel_pioctrl->pins), | ||
| 951 | GFP_KERNEL); | ||
| 950 | if (!atmel_pioctrl->pins) | 952 | if (!atmel_pioctrl->pins) |
| 951 | return -ENOMEM; | 953 | return -ENOMEM; |
| 952 | 954 | ||
| 953 | pin_desc = devm_kzalloc(dev, sizeof(*pin_desc) | 955 | pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc), |
| 954 | * atmel_pioctrl->npins, GFP_KERNEL); | 956 | GFP_KERNEL); |
| 955 | if (!pin_desc) | 957 | if (!pin_desc) |
| 956 | return -ENOMEM; | 958 | return -ENOMEM; |
| 957 | atmel_pinctrl_desc.pins = pin_desc; | 959 | atmel_pinctrl_desc.pins = pin_desc; |
| 958 | atmel_pinctrl_desc.npins = atmel_pioctrl->npins; | 960 | atmel_pinctrl_desc.npins = atmel_pioctrl->npins; |
| 959 | 961 | ||
| 960 | /* One pin is one group since a pin can achieve all functions. */ | 962 | /* One pin is one group since a pin can achieve all functions. */ |
| 961 | group_names = devm_kzalloc(dev, sizeof(*group_names) | 963 | group_names = devm_kcalloc(dev, |
| 962 | * atmel_pioctrl->npins, GFP_KERNEL); | 964 | atmel_pioctrl->npins, sizeof(*group_names), |
| 965 | GFP_KERNEL); | ||
| 963 | if (!group_names) | 966 | if (!group_names) |
| 964 | return -ENOMEM; | 967 | return -ENOMEM; |
| 965 | atmel_pioctrl->group_names = group_names; | 968 | atmel_pioctrl->group_names = group_names; |
| 966 | 969 | ||
| 967 | atmel_pioctrl->groups = devm_kzalloc(&pdev->dev, | 970 | atmel_pioctrl->groups = devm_kcalloc(&pdev->dev, |
| 968 | sizeof(*atmel_pioctrl->groups) * atmel_pioctrl->npins, | 971 | atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups), |
| 969 | GFP_KERNEL); | 972 | GFP_KERNEL); |
| 970 | if (!atmel_pioctrl->groups) | 973 | if (!atmel_pioctrl->groups) |
| 971 | return -ENOMEM; | 974 | return -ENOMEM; |
| @@ -1001,20 +1004,24 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) | |||
| 1001 | atmel_pioctrl->gpio_chip->parent = dev; | 1004 | atmel_pioctrl->gpio_chip->parent = dev; |
| 1002 | atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names; | 1005 | atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names; |
| 1003 | 1006 | ||
| 1004 | atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev, | 1007 | atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev, |
| 1005 | sizeof(*atmel_pioctrl->pm_wakeup_sources) | 1008 | atmel_pioctrl->nbanks, |
| 1006 | * atmel_pioctrl->nbanks, GFP_KERNEL); | 1009 | sizeof(*atmel_pioctrl->pm_wakeup_sources), |
| 1010 | GFP_KERNEL); | ||
| 1007 | if (!atmel_pioctrl->pm_wakeup_sources) | 1011 | if (!atmel_pioctrl->pm_wakeup_sources) |
| 1008 | return -ENOMEM; | 1012 | return -ENOMEM; |
| 1009 | 1013 | ||
| 1010 | atmel_pioctrl->pm_suspend_backup = devm_kzalloc(dev, | 1014 | atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev, |
| 1011 | sizeof(*atmel_pioctrl->pm_suspend_backup) | 1015 | atmel_pioctrl->nbanks, |
| 1012 | * atmel_pioctrl->nbanks, GFP_KERNEL); | 1016 | sizeof(*atmel_pioctrl->pm_suspend_backup), |
| 1017 | GFP_KERNEL); | ||
| 1013 | if (!atmel_pioctrl->pm_suspend_backup) | 1018 | if (!atmel_pioctrl->pm_suspend_backup) |
| 1014 | return -ENOMEM; | 1019 | return -ENOMEM; |
| 1015 | 1020 | ||
| 1016 | atmel_pioctrl->irqs = devm_kzalloc(dev, sizeof(*atmel_pioctrl->irqs) | 1021 | atmel_pioctrl->irqs = devm_kcalloc(dev, |
| 1017 | * atmel_pioctrl->nbanks, GFP_KERNEL); | 1022 | atmel_pioctrl->nbanks, |
| 1023 | sizeof(*atmel_pioctrl->irqs), | ||
| 1024 | GFP_KERNEL); | ||
| 1018 | if (!atmel_pioctrl->irqs) | 1025 | if (!atmel_pioctrl->irqs) |
| 1019 | return -ENOMEM; | 1026 | return -ENOMEM; |
| 1020 | 1027 | ||
diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 297f1d161211..50f0ec42c637 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c | |||
| @@ -269,7 +269,8 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | map_num += grp->npins; | 271 | map_num += grp->npins; |
| 272 | new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL); | 272 | new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), |
| 273 | GFP_KERNEL); | ||
| 273 | if (!new_map) | 274 | if (!new_map) |
| 274 | return -ENOMEM; | 275 | return -ENOMEM; |
| 275 | 276 | ||
| @@ -1049,7 +1050,8 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info, | |||
| 1049 | } | 1050 | } |
| 1050 | info->nmux = size / gpio_banks; | 1051 | info->nmux = size / gpio_banks; |
| 1051 | 1052 | ||
| 1052 | info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL); | 1053 | info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32), |
| 1054 | GFP_KERNEL); | ||
| 1053 | if (!info->mux_mask) | 1055 | if (!info->mux_mask) |
| 1054 | return -ENOMEM; | 1056 | return -ENOMEM; |
| 1055 | 1057 | ||
| @@ -1087,10 +1089,12 @@ static int at91_pinctrl_parse_groups(struct device_node *np, | |||
| 1087 | } | 1089 | } |
| 1088 | 1090 | ||
| 1089 | grp->npins = size / 4; | 1091 | grp->npins = size / 4; |
| 1090 | pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin), | 1092 | pin = grp->pins_conf = devm_kcalloc(info->dev, |
| 1091 | GFP_KERNEL); | 1093 | grp->npins, |
| 1092 | grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int), | 1094 | sizeof(struct at91_pmx_pin), |
| 1093 | GFP_KERNEL); | 1095 | GFP_KERNEL); |
| 1096 | grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), | ||
| 1097 | GFP_KERNEL); | ||
| 1094 | if (!grp->pins_conf || !grp->pins) | 1098 | if (!grp->pins_conf || !grp->pins) |
| 1095 | return -ENOMEM; | 1099 | return -ENOMEM; |
| 1096 | 1100 | ||
| @@ -1129,8 +1133,8 @@ static int at91_pinctrl_parse_functions(struct device_node *np, | |||
| 1129 | dev_err(info->dev, "no groups defined\n"); | 1133 | dev_err(info->dev, "no groups defined\n"); |
| 1130 | return -EINVAL; | 1134 | return -EINVAL; |
| 1131 | } | 1135 | } |
| 1132 | func->groups = devm_kzalloc(info->dev, | 1136 | func->groups = devm_kcalloc(info->dev, |
| 1133 | func->ngroups * sizeof(char *), GFP_KERNEL); | 1137 | func->ngroups, sizeof(char *), GFP_KERNEL); |
| 1134 | if (!func->groups) | 1138 | if (!func->groups) |
| 1135 | return -ENOMEM; | 1139 | return -ENOMEM; |
| 1136 | 1140 | ||
| @@ -1192,12 +1196,16 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, | |||
| 1192 | 1196 | ||
| 1193 | dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); | 1197 | dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); |
| 1194 | dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); | 1198 | dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); |
| 1195 | info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func), | 1199 | info->functions = devm_kcalloc(&pdev->dev, |
| 1200 | info->nfunctions, | ||
| 1201 | sizeof(struct at91_pmx_func), | ||
| 1196 | GFP_KERNEL); | 1202 | GFP_KERNEL); |
| 1197 | if (!info->functions) | 1203 | if (!info->functions) |
| 1198 | return -ENOMEM; | 1204 | return -ENOMEM; |
| 1199 | 1205 | ||
| 1200 | info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group), | 1206 | info->groups = devm_kcalloc(&pdev->dev, |
| 1207 | info->ngroups, | ||
| 1208 | sizeof(struct at91_pin_group), | ||
| 1201 | GFP_KERNEL); | 1209 | GFP_KERNEL); |
| 1202 | if (!info->groups) | 1210 | if (!info->groups) |
| 1203 | return -ENOMEM; | 1211 | return -ENOMEM; |
| @@ -1256,7 +1264,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev) | |||
| 1256 | at91_pinctrl_desc.name = dev_name(&pdev->dev); | 1264 | at91_pinctrl_desc.name = dev_name(&pdev->dev); |
| 1257 | at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; | 1265 | at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; |
| 1258 | at91_pinctrl_desc.pins = pdesc = | 1266 | at91_pinctrl_desc.pins = pdesc = |
| 1259 | devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL); | 1267 | devm_kcalloc(&pdev->dev, |
| 1268 | at91_pinctrl_desc.npins, sizeof(*pdesc), | ||
| 1269 | GFP_KERNEL); | ||
| 1260 | 1270 | ||
| 1261 | if (!at91_pinctrl_desc.pins) | 1271 | if (!at91_pinctrl_desc.pins) |
| 1262 | return -ENOMEM; | 1272 | return -ENOMEM; |
| @@ -1763,7 +1773,7 @@ static int at91_gpio_probe(struct platform_device *pdev) | |||
| 1763 | chip->ngpio = ngpio; | 1773 | chip->ngpio = ngpio; |
| 1764 | } | 1774 | } |
| 1765 | 1775 | ||
| 1766 | names = devm_kzalloc(&pdev->dev, sizeof(char *) * chip->ngpio, | 1776 | names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *), |
| 1767 | GFP_KERNEL); | 1777 | GFP_KERNEL); |
| 1768 | 1778 | ||
| 1769 | if (!names) { | 1779 | if (!names) { |
diff --git a/drivers/pinctrl/pinctrl-axp209.c b/drivers/pinctrl/pinctrl-axp209.c index 1231bbbfa744..a52779f33ad4 100644 --- a/drivers/pinctrl/pinctrl-axp209.c +++ b/drivers/pinctrl/pinctrl-axp209.c | |||
| @@ -328,7 +328,8 @@ static void axp20x_funcs_groups_from_mask(struct device *dev, unsigned int mask, | |||
| 328 | 328 | ||
| 329 | func->ngroups = ngroups; | 329 | func->ngroups = ngroups; |
| 330 | if (func->ngroups > 0) { | 330 | if (func->ngroups > 0) { |
| 331 | func->groups = devm_kzalloc(dev, ngroups * sizeof(const char *), | 331 | func->groups = devm_kcalloc(dev, |
| 332 | ngroups, sizeof(const char *), | ||
| 332 | GFP_KERNEL); | 333 | GFP_KERNEL); |
| 333 | group = func->groups; | 334 | group = func->groups; |
| 334 | for_each_set_bit(bit, &mask_cpy, mask_len) { | 335 | for_each_set_bit(bit, &mask_cpy, mask_len) { |
| @@ -358,8 +359,8 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev) | |||
| 358 | /* Every pin supports GPIO_OUT and GPIO_IN functions */ | 359 | /* Every pin supports GPIO_OUT and GPIO_IN functions */ |
| 359 | for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) { | 360 | for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) { |
| 360 | pctl->funcs[i].ngroups = npins; | 361 | pctl->funcs[i].ngroups = npins; |
| 361 | pctl->funcs[i].groups = devm_kzalloc(&pdev->dev, | 362 | pctl->funcs[i].groups = devm_kcalloc(&pdev->dev, |
| 362 | npins * sizeof(char *), | 363 | npins, sizeof(char *), |
| 363 | GFP_KERNEL); | 364 | GFP_KERNEL); |
| 364 | for (pin = 0; pin < npins; pin++) | 365 | for (pin = 0; pin < npins; pin++) |
| 365 | pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; | 366 | pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name; |
diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index ce269ced4d49..5353b23f775c 100644 --- a/drivers/pinctrl/pinctrl-digicolor.c +++ b/drivers/pinctrl/pinctrl-digicolor.c | |||
| @@ -291,10 +291,11 @@ static int dc_pinctrl_probe(struct platform_device *pdev) | |||
| 291 | if (IS_ERR(pmap->regs)) | 291 | if (IS_ERR(pmap->regs)) |
| 292 | return PTR_ERR(pmap->regs); | 292 | return PTR_ERR(pmap->regs); |
| 293 | 293 | ||
| 294 | pins = devm_kzalloc(&pdev->dev, sizeof(*pins)*PINS_COUNT, GFP_KERNEL); | 294 | pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins), |
| 295 | GFP_KERNEL); | ||
| 295 | if (!pins) | 296 | if (!pins) |
| 296 | return -ENOMEM; | 297 | return -ENOMEM; |
| 297 | pin_names = devm_kzalloc(&pdev->dev, name_len * PINS_COUNT, | 298 | pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len, |
| 298 | GFP_KERNEL); | 299 | GFP_KERNEL); |
| 299 | if (!pin_names) | 300 | if (!pin_names) |
| 300 | return -ENOMEM; | 301 | return -ENOMEM; |
diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c index ac38a3f9f86b..a1d7156d0a43 100644 --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c | |||
| @@ -770,8 +770,8 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev) | |||
| 770 | pctl_desc->pmxops = &ingenic_pmxops; | 770 | pctl_desc->pmxops = &ingenic_pmxops; |
| 771 | pctl_desc->confops = &ingenic_confops; | 771 | pctl_desc->confops = &ingenic_confops; |
| 772 | pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP; | 772 | pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP; |
| 773 | pctl_desc->pins = jzpc->pdesc = devm_kzalloc(&pdev->dev, | 773 | pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev, |
| 774 | sizeof(*jzpc->pdesc) * pctl_desc->npins, GFP_KERNEL); | 774 | pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL); |
| 775 | if (!jzpc->pdesc) | 775 | if (!jzpc->pdesc) |
| 776 | return -ENOMEM; | 776 | return -ENOMEM; |
| 777 | 777 | ||
diff --git a/drivers/pinctrl/pinctrl-lantiq.c b/drivers/pinctrl/pinctrl-lantiq.c index 41dc39c7a7b1..81632af3a86a 100644 --- a/drivers/pinctrl/pinctrl-lantiq.c +++ b/drivers/pinctrl/pinctrl-lantiq.c | |||
| @@ -158,7 +158,8 @@ static int ltq_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 158 | 158 | ||
| 159 | for_each_child_of_node(np_config, np) | 159 | for_each_child_of_node(np_config, np) |
| 160 | max_maps += ltq_pinctrl_dt_subnode_size(np); | 160 | max_maps += ltq_pinctrl_dt_subnode_size(np); |
| 161 | *map = kzalloc(max_maps * sizeof(struct pinctrl_map) * 2, GFP_KERNEL); | 161 | *map = kzalloc(array3_size(max_maps, sizeof(struct pinctrl_map), 2), |
| 162 | GFP_KERNEL); | ||
| 162 | if (!*map) | 163 | if (!*map) |
| 163 | return -ENOMEM; | 164 | return -ENOMEM; |
| 164 | tmp = *map; | 165 | tmp = *map; |
diff --git a/drivers/pinctrl/pinctrl-lpc18xx.c b/drivers/pinctrl/pinctrl-lpc18xx.c index d090f37ca4a1..190f17e4bbda 100644 --- a/drivers/pinctrl/pinctrl-lpc18xx.c +++ b/drivers/pinctrl/pinctrl-lpc18xx.c | |||
| @@ -1308,8 +1308,9 @@ static int lpc18xx_create_group_func_map(struct device *dev, | |||
| 1308 | } | 1308 | } |
| 1309 | 1309 | ||
| 1310 | scu->func[func].ngroups = ngroups; | 1310 | scu->func[func].ngroups = ngroups; |
| 1311 | scu->func[func].groups = devm_kzalloc(dev, ngroups * | 1311 | scu->func[func].groups = devm_kcalloc(dev, |
| 1312 | sizeof(char *), GFP_KERNEL); | 1312 | ngroups, sizeof(char *), |
| 1313 | GFP_KERNEL); | ||
| 1313 | if (!scu->func[func].groups) | 1314 | if (!scu->func[func].groups) |
| 1314 | return -ENOMEM; | 1315 | return -ENOMEM; |
| 1315 | 1316 | ||
diff --git a/drivers/pinctrl/pinctrl-ocelot.c b/drivers/pinctrl/pinctrl-ocelot.c index b5b3547fdcb2..15bb1cb8729b 100644 --- a/drivers/pinctrl/pinctrl-ocelot.c +++ b/drivers/pinctrl/pinctrl-ocelot.c | |||
| @@ -330,7 +330,8 @@ static int ocelot_create_group_func_map(struct device *dev, | |||
| 330 | } | 330 | } |
| 331 | 331 | ||
| 332 | info->func[f].ngroups = npins; | 332 | info->func[f].ngroups = npins; |
| 333 | info->func[f].groups = devm_kzalloc(dev, npins * | 333 | info->func[f].groups = devm_kcalloc(dev, |
| 334 | npins, | ||
| 334 | sizeof(char *), | 335 | sizeof(char *), |
| 335 | GFP_KERNEL); | 336 | GFP_KERNEL); |
| 336 | if (!info->func[f].groups) | 337 | if (!info->func[f].groups) |
diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 1882713e68f9..f4a61429e06e 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c | |||
| @@ -507,7 +507,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 507 | } | 507 | } |
| 508 | 508 | ||
| 509 | map_num += grp->npins; | 509 | map_num += grp->npins; |
| 510 | new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, | 510 | new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), |
| 511 | GFP_KERNEL); | 511 | GFP_KERNEL); |
| 512 | if (!new_map) | 512 | if (!new_map) |
| 513 | return -ENOMEM; | 513 | return -ENOMEM; |
| @@ -2473,10 +2473,11 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, | |||
| 2473 | 2473 | ||
| 2474 | grp->npins = size / 4; | 2474 | grp->npins = size / 4; |
| 2475 | 2475 | ||
| 2476 | grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int), | 2476 | grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), |
| 2477 | GFP_KERNEL); | 2477 | GFP_KERNEL); |
| 2478 | grp->data = devm_kzalloc(info->dev, grp->npins * | 2478 | grp->data = devm_kcalloc(info->dev, |
| 2479 | sizeof(struct rockchip_pin_config), | 2479 | grp->npins, |
| 2480 | sizeof(struct rockchip_pin_config), | ||
| 2480 | GFP_KERNEL); | 2481 | GFP_KERNEL); |
| 2481 | if (!grp->pins || !grp->data) | 2482 | if (!grp->pins || !grp->data) |
| 2482 | return -ENOMEM; | 2483 | return -ENOMEM; |
| @@ -2528,8 +2529,8 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, | |||
| 2528 | if (func->ngroups <= 0) | 2529 | if (func->ngroups <= 0) |
| 2529 | return 0; | 2530 | return 0; |
| 2530 | 2531 | ||
| 2531 | func->groups = devm_kzalloc(info->dev, | 2532 | func->groups = devm_kcalloc(info->dev, |
| 2532 | func->ngroups * sizeof(char *), GFP_KERNEL); | 2533 | func->ngroups, sizeof(char *), GFP_KERNEL); |
| 2533 | if (!func->groups) | 2534 | if (!func->groups) |
| 2534 | return -ENOMEM; | 2535 | return -ENOMEM; |
| 2535 | 2536 | ||
| @@ -2560,13 +2561,15 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, | |||
| 2560 | dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); | 2561 | dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); |
| 2561 | dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); | 2562 | dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); |
| 2562 | 2563 | ||
| 2563 | info->functions = devm_kzalloc(dev, info->nfunctions * | 2564 | info->functions = devm_kcalloc(dev, |
| 2565 | info->nfunctions, | ||
| 2564 | sizeof(struct rockchip_pmx_func), | 2566 | sizeof(struct rockchip_pmx_func), |
| 2565 | GFP_KERNEL); | 2567 | GFP_KERNEL); |
| 2566 | if (!info->functions) | 2568 | if (!info->functions) |
| 2567 | return -EINVAL; | 2569 | return -EINVAL; |
| 2568 | 2570 | ||
| 2569 | info->groups = devm_kzalloc(dev, info->ngroups * | 2571 | info->groups = devm_kcalloc(dev, |
| 2572 | info->ngroups, | ||
| 2570 | sizeof(struct rockchip_pin_group), | 2573 | sizeof(struct rockchip_pin_group), |
| 2571 | GFP_KERNEL); | 2574 | GFP_KERNEL); |
| 2572 | if (!info->groups) | 2575 | if (!info->groups) |
| @@ -2604,8 +2607,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, | |||
| 2604 | ctrldesc->pmxops = &rockchip_pmx_ops; | 2607 | ctrldesc->pmxops = &rockchip_pmx_ops; |
| 2605 | ctrldesc->confops = &rockchip_pinconf_ops; | 2608 | ctrldesc->confops = &rockchip_pinconf_ops; |
| 2606 | 2609 | ||
| 2607 | pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * | 2610 | pindesc = devm_kcalloc(&pdev->dev, |
| 2608 | info->ctrl->nr_pins, GFP_KERNEL); | 2611 | info->ctrl->nr_pins, sizeof(*pindesc), |
| 2612 | GFP_KERNEL); | ||
| 2609 | if (!pindesc) | 2613 | if (!pindesc) |
| 2610 | return -ENOMEM; | 2614 | return -ENOMEM; |
| 2611 | 2615 | ||
diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index 9c3c00515aa0..b3153c095199 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c | |||
| @@ -712,8 +712,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) | |||
| 712 | } | 712 | } |
| 713 | 713 | ||
| 714 | dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins); | 714 | dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins); |
| 715 | pcs->pins.pa = devm_kzalloc(pcs->dev, | 715 | pcs->pins.pa = devm_kcalloc(pcs->dev, |
| 716 | sizeof(*pcs->pins.pa) * nr_pins, | 716 | nr_pins, sizeof(*pcs->pins.pa), |
| 717 | GFP_KERNEL); | 717 | GFP_KERNEL); |
| 718 | if (!pcs->pins.pa) | 718 | if (!pcs->pins.pa) |
| 719 | return -ENOMEM; | 719 | return -ENOMEM; |
| @@ -924,15 +924,15 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, | |||
| 924 | if (!nconfs) | 924 | if (!nconfs) |
| 925 | return 0; | 925 | return 0; |
| 926 | 926 | ||
| 927 | func->conf = devm_kzalloc(pcs->dev, | 927 | func->conf = devm_kcalloc(pcs->dev, |
| 928 | sizeof(struct pcs_conf_vals) * nconfs, | 928 | nconfs, sizeof(struct pcs_conf_vals), |
| 929 | GFP_KERNEL); | 929 | GFP_KERNEL); |
| 930 | if (!func->conf) | 930 | if (!func->conf) |
| 931 | return -ENOMEM; | 931 | return -ENOMEM; |
| 932 | func->nconfs = nconfs; | 932 | func->nconfs = nconfs; |
| 933 | conf = &(func->conf[0]); | 933 | conf = &(func->conf[0]); |
| 934 | m++; | 934 | m++; |
| 935 | settings = devm_kzalloc(pcs->dev, sizeof(unsigned long) * nconfs, | 935 | settings = devm_kcalloc(pcs->dev, nconfs, sizeof(unsigned long), |
| 936 | GFP_KERNEL); | 936 | GFP_KERNEL); |
| 937 | if (!settings) | 937 | if (!settings) |
| 938 | return -ENOMEM; | 938 | return -ENOMEM; |
| @@ -988,11 +988,11 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, | |||
| 988 | return -EINVAL; | 988 | return -EINVAL; |
| 989 | } | 989 | } |
| 990 | 990 | ||
| 991 | vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL); | 991 | vals = devm_kcalloc(pcs->dev, rows, sizeof(*vals), GFP_KERNEL); |
| 992 | if (!vals) | 992 | if (!vals) |
| 993 | return -ENOMEM; | 993 | return -ENOMEM; |
| 994 | 994 | ||
| 995 | pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows, GFP_KERNEL); | 995 | pins = devm_kcalloc(pcs->dev, rows, sizeof(*pins), GFP_KERNEL); |
| 996 | if (!pins) | 996 | if (!pins) |
| 997 | goto free_vals; | 997 | goto free_vals; |
| 998 | 998 | ||
| @@ -1089,13 +1089,15 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, | |||
| 1089 | 1089 | ||
| 1090 | npins_in_row = pcs->width / pcs->bits_per_pin; | 1090 | npins_in_row = pcs->width / pcs->bits_per_pin; |
| 1091 | 1091 | ||
| 1092 | vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row, | 1092 | vals = devm_kzalloc(pcs->dev, |
| 1093 | GFP_KERNEL); | 1093 | array3_size(rows, npins_in_row, sizeof(*vals)), |
| 1094 | GFP_KERNEL); | ||
| 1094 | if (!vals) | 1095 | if (!vals) |
| 1095 | return -ENOMEM; | 1096 | return -ENOMEM; |
| 1096 | 1097 | ||
| 1097 | pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows * npins_in_row, | 1098 | pins = devm_kzalloc(pcs->dev, |
| 1098 | GFP_KERNEL); | 1099 | array3_size(rows, npins_in_row, sizeof(*pins)), |
| 1100 | GFP_KERNEL); | ||
| 1099 | if (!pins) | 1101 | if (!pins) |
| 1100 | goto free_vals; | 1102 | goto free_vals; |
| 1101 | 1103 | ||
| @@ -1217,7 +1219,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 1217 | pcs = pinctrl_dev_get_drvdata(pctldev); | 1219 | pcs = pinctrl_dev_get_drvdata(pctldev); |
| 1218 | 1220 | ||
| 1219 | /* create 2 maps. One is for pinmux, and the other is for pinconf. */ | 1221 | /* create 2 maps. One is for pinmux, and the other is for pinconf. */ |
| 1220 | *map = devm_kzalloc(pcs->dev, sizeof(**map) * 2, GFP_KERNEL); | 1222 | *map = devm_kcalloc(pcs->dev, 2, sizeof(**map), GFP_KERNEL); |
| 1221 | if (!*map) | 1223 | if (!*map) |
| 1222 | return -ENOMEM; | 1224 | return -ENOMEM; |
| 1223 | 1225 | ||
diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index 2081c67667a8..0966bb0bf71f 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c | |||
| @@ -823,8 +823,8 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 823 | } | 823 | } |
| 824 | 824 | ||
| 825 | map_num = grp->npins + 1; | 825 | map_num = grp->npins + 1; |
| 826 | new_map = devm_kzalloc(pctldev->dev, | 826 | new_map = devm_kcalloc(pctldev->dev, |
| 827 | sizeof(*new_map) * map_num, GFP_KERNEL); | 827 | map_num, sizeof(*new_map), GFP_KERNEL); |
| 828 | if (!new_map) | 828 | if (!new_map) |
| 829 | return -ENOMEM; | 829 | return -ENOMEM; |
| 830 | 830 | ||
| @@ -1191,9 +1191,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np, | |||
| 1191 | 1191 | ||
| 1192 | grp->npins = npins; | 1192 | grp->npins = npins; |
| 1193 | grp->name = np->name; | 1193 | grp->name = np->name; |
| 1194 | grp->pins = devm_kzalloc(info->dev, npins * sizeof(u32), GFP_KERNEL); | 1194 | grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL); |
| 1195 | grp->pin_conf = devm_kzalloc(info->dev, | 1195 | grp->pin_conf = devm_kcalloc(info->dev, |
| 1196 | npins * sizeof(*conf), GFP_KERNEL); | 1196 | npins, sizeof(*conf), GFP_KERNEL); |
| 1197 | 1197 | ||
| 1198 | if (!grp->pins || !grp->pin_conf) | 1198 | if (!grp->pins || !grp->pin_conf) |
| 1199 | return -ENOMEM; | 1199 | return -ENOMEM; |
| @@ -1249,8 +1249,8 @@ static int st_pctl_parse_functions(struct device_node *np, | |||
| 1249 | dev_err(info->dev, "No groups defined\n"); | 1249 | dev_err(info->dev, "No groups defined\n"); |
| 1250 | return -EINVAL; | 1250 | return -EINVAL; |
| 1251 | } | 1251 | } |
| 1252 | func->groups = devm_kzalloc(info->dev, | 1252 | func->groups = devm_kcalloc(info->dev, |
| 1253 | func->ngroups * sizeof(char *), GFP_KERNEL); | 1253 | func->ngroups, sizeof(char *), GFP_KERNEL); |
| 1254 | if (!func->groups) | 1254 | if (!func->groups) |
| 1255 | return -ENOMEM; | 1255 | return -ENOMEM; |
| 1256 | 1256 | ||
| @@ -1573,14 +1573,15 @@ static int st_pctl_probe_dt(struct platform_device *pdev, | |||
| 1573 | dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions); | 1573 | dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions); |
| 1574 | dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups); | 1574 | dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups); |
| 1575 | 1575 | ||
| 1576 | info->functions = devm_kzalloc(&pdev->dev, | 1576 | info->functions = devm_kcalloc(&pdev->dev, |
| 1577 | info->nfunctions * sizeof(*info->functions), GFP_KERNEL); | 1577 | info->nfunctions, sizeof(*info->functions), GFP_KERNEL); |
| 1578 | 1578 | ||
| 1579 | info->groups = devm_kzalloc(&pdev->dev, | 1579 | info->groups = devm_kcalloc(&pdev->dev, |
| 1580 | info->ngroups * sizeof(*info->groups) , GFP_KERNEL); | 1580 | info->ngroups, sizeof(*info->groups), |
| 1581 | GFP_KERNEL); | ||
| 1581 | 1582 | ||
| 1582 | info->banks = devm_kzalloc(&pdev->dev, | 1583 | info->banks = devm_kcalloc(&pdev->dev, |
| 1583 | info->nbanks * sizeof(*info->banks), GFP_KERNEL); | 1584 | info->nbanks, sizeof(*info->banks), GFP_KERNEL); |
| 1584 | 1585 | ||
| 1585 | if (!info->functions || !info->groups || !info->banks) | 1586 | if (!info->functions || !info->groups || !info->banks) |
| 1586 | return -ENOMEM; | 1587 | return -ENOMEM; |
| @@ -1608,8 +1609,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, | |||
| 1608 | } | 1609 | } |
| 1609 | 1610 | ||
| 1610 | pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK; | 1611 | pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK; |
| 1611 | pdesc = devm_kzalloc(&pdev->dev, | 1612 | pdesc = devm_kcalloc(&pdev->dev, |
| 1612 | sizeof(*pdesc) * pctl_desc->npins, GFP_KERNEL); | 1613 | pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL); |
| 1613 | if (!pdesc) | 1614 | if (!pdesc) |
| 1614 | return -ENOMEM; | 1615 | return -ENOMEM; |
| 1615 | 1616 | ||
diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index cd0f402c1164..93f8bd04e7fe 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c | |||
| @@ -1727,8 +1727,8 @@ static int pinmux_xway_probe(struct platform_device *pdev) | |||
| 1727 | xway_chip.ngpio = xway_soc->pin_count; | 1727 | xway_chip.ngpio = xway_soc->pin_count; |
| 1728 | 1728 | ||
| 1729 | /* load our pad descriptors */ | 1729 | /* load our pad descriptors */ |
| 1730 | xway_info.pads = devm_kzalloc(&pdev->dev, | 1730 | xway_info.pads = devm_kcalloc(&pdev->dev, |
| 1731 | sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio, | 1731 | xway_chip.ngpio, sizeof(struct pinctrl_pin_desc), |
| 1732 | GFP_KERNEL); | 1732 | GFP_KERNEL); |
| 1733 | if (!xway_info.pads) | 1733 | if (!xway_info.pads) |
| 1734 | return -ENOMEM; | 1734 | return -ENOMEM; |
diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index 0a625a64ff5d..a263ddd94945 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c | |||
| @@ -491,8 +491,9 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) | |||
| 491 | continue; | 491 | continue; |
| 492 | } | 492 | } |
| 493 | 493 | ||
| 494 | weint_data = devm_kzalloc(dev, bank->nr_pins | 494 | weint_data = devm_kcalloc(dev, |
| 495 | * sizeof(*weint_data), GFP_KERNEL); | 495 | bank->nr_pins, sizeof(*weint_data), |
| 496 | GFP_KERNEL); | ||
| 496 | if (!weint_data) | 497 | if (!weint_data) |
| 497 | return -ENOMEM; | 498 | return -ENOMEM; |
| 498 | 499 | ||
diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 618945a0fd38..698c7d8c9a08 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c | |||
| @@ -674,7 +674,7 @@ static struct samsung_pin_group *samsung_pinctrl_create_groups( | |||
| 674 | const struct pinctrl_pin_desc *pdesc; | 674 | const struct pinctrl_pin_desc *pdesc; |
| 675 | int i; | 675 | int i; |
| 676 | 676 | ||
| 677 | groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups), | 677 | groups = devm_kcalloc(dev, ctrldesc->npins, sizeof(*groups), |
| 678 | GFP_KERNEL); | 678 | GFP_KERNEL); |
| 679 | if (!groups) | 679 | if (!groups) |
| 680 | return ERR_PTR(-EINVAL); | 680 | return ERR_PTR(-EINVAL); |
| @@ -711,7 +711,7 @@ static int samsung_pinctrl_create_function(struct device *dev, | |||
| 711 | 711 | ||
| 712 | func->name = func_np->full_name; | 712 | func->name = func_np->full_name; |
| 713 | 713 | ||
| 714 | func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL); | 714 | func->groups = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL); |
| 715 | if (!func->groups) | 715 | if (!func->groups) |
| 716 | return -ENOMEM; | 716 | return -ENOMEM; |
| 717 | 717 | ||
| @@ -768,7 +768,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions( | |||
| 768 | } | 768 | } |
| 769 | } | 769 | } |
| 770 | 770 | ||
| 771 | functions = devm_kzalloc(dev, func_cnt * sizeof(*functions), | 771 | functions = devm_kcalloc(dev, func_cnt, sizeof(*functions), |
| 772 | GFP_KERNEL); | 772 | GFP_KERNEL); |
| 773 | if (!functions) | 773 | if (!functions) |
| 774 | return ERR_PTR(-ENOMEM); | 774 | return ERR_PTR(-ENOMEM); |
| @@ -860,8 +860,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev, | |||
| 860 | ctrldesc->pmxops = &samsung_pinmux_ops; | 860 | ctrldesc->pmxops = &samsung_pinmux_ops; |
| 861 | ctrldesc->confops = &samsung_pinconf_ops; | 861 | ctrldesc->confops = &samsung_pinconf_ops; |
| 862 | 862 | ||
| 863 | pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * | 863 | pindesc = devm_kcalloc(&pdev->dev, |
| 864 | drvdata->nr_pins, GFP_KERNEL); | 864 | drvdata->nr_pins, sizeof(*pindesc), |
| 865 | GFP_KERNEL); | ||
| 865 | if (!pindesc) | 866 | if (!pindesc) |
| 866 | return -ENOMEM; | 867 | return -ENOMEM; |
| 867 | ctrldesc->pins = pindesc; | 868 | ctrldesc->pins = pindesc; |
| @@ -875,8 +876,10 @@ static int samsung_pinctrl_register(struct platform_device *pdev, | |||
| 875 | * allocate space for storing the dynamically generated names for all | 876 | * allocate space for storing the dynamically generated names for all |
| 876 | * the pins which belong to this pin-controller. | 877 | * the pins which belong to this pin-controller. |
| 877 | */ | 878 | */ |
| 878 | pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH * | 879 | pin_names = devm_kzalloc(&pdev->dev, |
| 879 | drvdata->nr_pins, GFP_KERNEL); | 880 | array3_size(sizeof(char), PIN_NAME_LENGTH, |
| 881 | drvdata->nr_pins), | ||
| 882 | GFP_KERNEL); | ||
| 880 | if (!pin_names) | 883 | if (!pin_names) |
| 881 | return -ENOMEM; | 884 | return -ENOMEM; |
| 882 | 885 | ||
diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index eb06981538b4..c671c3c4aca6 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c | |||
| @@ -57,7 +57,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, | |||
| 57 | return -EINVAL; | 57 | return -EINVAL; |
| 58 | 58 | ||
| 59 | /* Allocate memory windows and IRQs arrays. */ | 59 | /* Allocate memory windows and IRQs arrays. */ |
| 60 | windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows), | 60 | windows = devm_kcalloc(pfc->dev, num_windows, sizeof(*windows), |
| 61 | GFP_KERNEL); | 61 | GFP_KERNEL); |
| 62 | if (windows == NULL) | 62 | if (windows == NULL) |
| 63 | return -ENOMEM; | 63 | return -ENOMEM; |
| @@ -66,7 +66,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, | |||
| 66 | pfc->windows = windows; | 66 | pfc->windows = windows; |
| 67 | 67 | ||
| 68 | if (num_irqs) { | 68 | if (num_irqs) { |
| 69 | irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs), | 69 | irqs = devm_kcalloc(pfc->dev, num_irqs, sizeof(*irqs), |
| 70 | GFP_KERNEL); | 70 | GFP_KERNEL); |
| 71 | if (irqs == NULL) | 71 | if (irqs == NULL) |
| 72 | return -ENOMEM; | 72 | return -ENOMEM; |
| @@ -444,7 +444,7 @@ static int sh_pfc_init_ranges(struct sh_pfc *pfc) | |||
| 444 | } | 444 | } |
| 445 | 445 | ||
| 446 | pfc->nr_ranges = nr_ranges; | 446 | pfc->nr_ranges = nr_ranges; |
| 447 | pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges, | 447 | pfc->ranges = devm_kcalloc(pfc->dev, nr_ranges, sizeof(*pfc->ranges), |
| 448 | GFP_KERNEL); | 448 | GFP_KERNEL); |
| 449 | if (pfc->ranges == NULL) | 449 | if (pfc->ranges == NULL) |
| 450 | return -ENOMEM; | 450 | return -ENOMEM; |
diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index 946d9be50b62..6ffdc6beb203 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c | |||
| @@ -107,7 +107,7 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip) | |||
| 107 | for (i = 0; pfc->info->data_regs[i].reg_width; ++i) | 107 | for (i = 0; pfc->info->data_regs[i].reg_width; ++i) |
| 108 | ; | 108 | ; |
| 109 | 109 | ||
| 110 | chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs), | 110 | chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs), |
| 111 | GFP_KERNEL); | 111 | GFP_KERNEL); |
| 112 | if (chip->regs == NULL) | 112 | if (chip->regs == NULL) |
| 113 | return -ENOMEM; | 113 | return -ENOMEM; |
| @@ -224,8 +224,9 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip) | |||
| 224 | struct gpio_chip *gc = &chip->gpio_chip; | 224 | struct gpio_chip *gc = &chip->gpio_chip; |
| 225 | int ret; | 225 | int ret; |
| 226 | 226 | ||
| 227 | chip->pins = devm_kzalloc(pfc->dev, pfc->info->nr_pins * | 227 | chip->pins = devm_kcalloc(pfc->dev, |
| 228 | sizeof(*chip->pins), GFP_KERNEL); | 228 | pfc->info->nr_pins, sizeof(*chip->pins), |
| 229 | GFP_KERNEL); | ||
| 229 | if (chip->pins == NULL) | 230 | if (chip->pins == NULL) |
| 230 | return -ENOMEM; | 231 | return -ENOMEM; |
| 231 | 232 | ||
diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 70db21638901..654dc20e171b 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c | |||
| @@ -770,14 +770,14 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) | |||
| 770 | unsigned int i; | 770 | unsigned int i; |
| 771 | 771 | ||
| 772 | /* Allocate and initialize the pins and configs arrays. */ | 772 | /* Allocate and initialize the pins and configs arrays. */ |
| 773 | pmx->pins = devm_kzalloc(pfc->dev, | 773 | pmx->pins = devm_kcalloc(pfc->dev, |
| 774 | sizeof(*pmx->pins) * pfc->info->nr_pins, | 774 | pfc->info->nr_pins, sizeof(*pmx->pins), |
| 775 | GFP_KERNEL); | 775 | GFP_KERNEL); |
| 776 | if (unlikely(!pmx->pins)) | 776 | if (unlikely(!pmx->pins)) |
| 777 | return -ENOMEM; | 777 | return -ENOMEM; |
| 778 | 778 | ||
| 779 | pmx->configs = devm_kzalloc(pfc->dev, | 779 | pmx->configs = devm_kcalloc(pfc->dev, |
| 780 | sizeof(*pmx->configs) * pfc->info->nr_pins, | 780 | pfc->info->nr_pins, sizeof(*pmx->configs), |
| 781 | GFP_KERNEL); | 781 | GFP_KERNEL); |
| 782 | if (unlikely(!pmx->configs)) | 782 | if (unlikely(!pmx->configs)) |
| 783 | return -ENOMEM; | 783 | return -ENOMEM; |
diff --git a/drivers/pinctrl/sirf/pinctrl-sirf.c b/drivers/pinctrl/sirf/pinctrl-sirf.c index ca2347d0d579..505845c66dd0 100644 --- a/drivers/pinctrl/sirf/pinctrl-sirf.c +++ b/drivers/pinctrl/sirf/pinctrl-sirf.c | |||
| @@ -108,7 +108,7 @@ static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 108 | return -ENODEV; | 108 | return -ENODEV; |
| 109 | } | 109 | } |
| 110 | 110 | ||
| 111 | *map = kzalloc(sizeof(**map) * count, GFP_KERNEL); | 111 | *map = kcalloc(count, sizeof(**map), GFP_KERNEL); |
| 112 | if (!*map) | 112 | if (!*map) |
| 113 | return -ENOMEM; | 113 | return -ENOMEM; |
| 114 | 114 | ||
diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index d2123e396b29..9d906474f3e4 100644 --- a/drivers/pinctrl/spear/pinctrl-plgpio.c +++ b/drivers/pinctrl/spear/pinctrl-plgpio.c | |||
| @@ -538,9 +538,9 @@ static int plgpio_probe(struct platform_device *pdev) | |||
| 538 | dev_warn(&pdev->dev, "clk_get() failed, work without it\n"); | 538 | dev_warn(&pdev->dev, "clk_get() failed, work without it\n"); |
| 539 | 539 | ||
| 540 | #ifdef CONFIG_PM_SLEEP | 540 | #ifdef CONFIG_PM_SLEEP |
| 541 | plgpio->csave_regs = devm_kzalloc(&pdev->dev, | 541 | plgpio->csave_regs = devm_kcalloc(&pdev->dev, |
| 542 | sizeof(*plgpio->csave_regs) * | ||
| 543 | DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG), | 542 | DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG), |
| 543 | sizeof(*plgpio->csave_regs), | ||
| 544 | GFP_KERNEL); | 544 | GFP_KERNEL); |
| 545 | if (!plgpio->csave_regs) | 545 | if (!plgpio->csave_regs) |
| 546 | return -ENOMEM; | 546 | return -ENOMEM; |
diff --git a/drivers/pinctrl/spear/pinctrl-spear.c b/drivers/pinctrl/spear/pinctrl-spear.c index efe79d3f7659..c4f850345dc4 100644 --- a/drivers/pinctrl/spear/pinctrl-spear.c +++ b/drivers/pinctrl/spear/pinctrl-spear.c | |||
| @@ -172,7 +172,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 172 | return -ENODEV; | 172 | return -ENODEV; |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | *map = kzalloc(sizeof(**map) * count, GFP_KERNEL); | 175 | *map = kcalloc(count, sizeof(**map), GFP_KERNEL); |
| 176 | if (!*map) | 176 | if (!*map) |
| 177 | return -ENOMEM; | 177 | return -ENOMEM; |
| 178 | 178 | ||
diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c index ba1c2ca406e4..78c2f548b25f 100644 --- a/drivers/pinctrl/sprd/pinctrl-sprd.c +++ b/drivers/pinctrl/sprd/pinctrl-sprd.c | |||
| @@ -879,8 +879,9 @@ static int sprd_pinctrl_parse_groups(struct device_node *np, | |||
| 879 | 879 | ||
| 880 | grp->name = np->name; | 880 | grp->name = np->name; |
| 881 | grp->npins = ret; | 881 | grp->npins = ret; |
| 882 | grp->pins = devm_kzalloc(sprd_pctl->dev, grp->npins * | 882 | grp->pins = devm_kcalloc(sprd_pctl->dev, |
| 883 | sizeof(unsigned int), GFP_KERNEL); | 883 | grp->npins, sizeof(unsigned int), |
| 884 | GFP_KERNEL); | ||
| 884 | if (!grp->pins) | 885 | if (!grp->pins) |
| 885 | return -ENOMEM; | 886 | return -ENOMEM; |
| 886 | 887 | ||
| @@ -931,14 +932,15 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl) | |||
| 931 | if (!info->ngroups) | 932 | if (!info->ngroups) |
| 932 | return 0; | 933 | return 0; |
| 933 | 934 | ||
| 934 | info->groups = devm_kzalloc(sprd_pctl->dev, info->ngroups * | 935 | info->groups = devm_kcalloc(sprd_pctl->dev, |
| 936 | info->ngroups, | ||
| 935 | sizeof(struct sprd_pin_group), | 937 | sizeof(struct sprd_pin_group), |
| 936 | GFP_KERNEL); | 938 | GFP_KERNEL); |
| 937 | if (!info->groups) | 939 | if (!info->groups) |
| 938 | return -ENOMEM; | 940 | return -ENOMEM; |
| 939 | 941 | ||
| 940 | info->grp_names = devm_kzalloc(sprd_pctl->dev, | 942 | info->grp_names = devm_kcalloc(sprd_pctl->dev, |
| 941 | info->ngroups * sizeof(char *), | 943 | info->ngroups, sizeof(char *), |
| 942 | GFP_KERNEL); | 944 | GFP_KERNEL); |
| 943 | if (!info->grp_names) | 945 | if (!info->grp_names) |
| 944 | return -ENOMEM; | 946 | return -ENOMEM; |
| @@ -980,8 +982,8 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl, | |||
| 980 | int i; | 982 | int i; |
| 981 | 983 | ||
| 982 | info->npins = pins_cnt; | 984 | info->npins = pins_cnt; |
| 983 | info->pins = devm_kzalloc(sprd_pctl->dev, | 985 | info->pins = devm_kcalloc(sprd_pctl->dev, |
| 984 | info->npins * sizeof(struct sprd_pin), | 986 | info->npins, sizeof(struct sprd_pin), |
| 985 | GFP_KERNEL); | 987 | GFP_KERNEL); |
| 986 | if (!info->pins) | 988 | if (!info->pins) |
| 987 | return -ENOMEM; | 989 | return -ENOMEM; |
| @@ -1057,7 +1059,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev, | |||
| 1057 | return ret; | 1059 | return ret; |
| 1058 | } | 1060 | } |
| 1059 | 1061 | ||
| 1060 | pin_desc = devm_kzalloc(&pdev->dev, pinctrl_info->npins * | 1062 | pin_desc = devm_kcalloc(&pdev->dev, |
| 1063 | pinctrl_info->npins, | ||
| 1061 | sizeof(struct pinctrl_pin_desc), | 1064 | sizeof(struct pinctrl_pin_desc), |
| 1062 | GFP_KERNEL); | 1065 | GFP_KERNEL); |
| 1063 | if (!pin_desc) | 1066 | if (!pin_desc) |
diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 25e80a5370ca..4d9bf9b3e9f3 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c | |||
| @@ -277,7 +277,7 @@ static unsigned long *sunxi_pctrl_build_pin_config(struct device_node *node, | |||
| 277 | if (!configlen) | 277 | if (!configlen) |
| 278 | return NULL; | 278 | return NULL; |
| 279 | 279 | ||
| 280 | pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL); | 280 | pinconfig = kcalloc(configlen, sizeof(*pinconfig), GFP_KERNEL); |
| 281 | if (!pinconfig) | 281 | if (!pinconfig) |
| 282 | return ERR_PTR(-ENOMEM); | 282 | return ERR_PTR(-ENOMEM); |
| 283 | 283 | ||
| @@ -352,7 +352,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 352 | * any configuration. | 352 | * any configuration. |
| 353 | */ | 353 | */ |
| 354 | nmaps = npins * 2; | 354 | nmaps = npins * 2; |
| 355 | *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL); | 355 | *map = kmalloc_array(nmaps, sizeof(struct pinctrl_map), GFP_KERNEL); |
| 356 | if (!*map) | 356 | if (!*map) |
| 357 | return -ENOMEM; | 357 | return -ENOMEM; |
| 358 | 358 | ||
| @@ -1055,8 +1055,8 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) | |||
| 1055 | * this means that the number of pins is the maximum group | 1055 | * this means that the number of pins is the maximum group |
| 1056 | * number we will ever see. | 1056 | * number we will ever see. |
| 1057 | */ | 1057 | */ |
| 1058 | pctl->groups = devm_kzalloc(&pdev->dev, | 1058 | pctl->groups = devm_kcalloc(&pdev->dev, |
| 1059 | pctl->desc->npins * sizeof(*pctl->groups), | 1059 | pctl->desc->npins, sizeof(*pctl->groups), |
| 1060 | GFP_KERNEL); | 1060 | GFP_KERNEL); |
| 1061 | if (!pctl->groups) | 1061 | if (!pctl->groups) |
| 1062 | return -ENOMEM; | 1062 | return -ENOMEM; |
| @@ -1079,8 +1079,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) | |||
| 1079 | * We suppose that we won't have any more functions than pins, | 1079 | * We suppose that we won't have any more functions than pins, |
| 1080 | * we'll reallocate that later anyway | 1080 | * we'll reallocate that later anyway |
| 1081 | */ | 1081 | */ |
| 1082 | pctl->functions = devm_kzalloc(&pdev->dev, | 1082 | pctl->functions = devm_kcalloc(&pdev->dev, |
| 1083 | pctl->ngroups * sizeof(*pctl->functions), | 1083 | pctl->ngroups, |
| 1084 | sizeof(*pctl->functions), | ||
| 1084 | GFP_KERNEL); | 1085 | GFP_KERNEL); |
| 1085 | if (!pctl->functions) | 1086 | if (!pctl->functions) |
| 1086 | return -ENOMEM; | 1087 | return -ENOMEM; |
| @@ -1137,8 +1138,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) | |||
| 1137 | 1138 | ||
| 1138 | if (!func_item->groups) { | 1139 | if (!func_item->groups) { |
| 1139 | func_item->groups = | 1140 | func_item->groups = |
| 1140 | devm_kzalloc(&pdev->dev, | 1141 | devm_kcalloc(&pdev->dev, |
| 1141 | func_item->ngroups * sizeof(*func_item->groups), | 1142 | func_item->ngroups, |
| 1143 | sizeof(*func_item->groups), | ||
| 1142 | GFP_KERNEL); | 1144 | GFP_KERNEL); |
| 1143 | if (!func_item->groups) | 1145 | if (!func_item->groups) |
| 1144 | return -ENOMEM; | 1146 | return -ENOMEM; |
| @@ -1281,8 +1283,8 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, | |||
| 1281 | return ret; | 1283 | return ret; |
| 1282 | } | 1284 | } |
| 1283 | 1285 | ||
| 1284 | pins = devm_kzalloc(&pdev->dev, | 1286 | pins = devm_kcalloc(&pdev->dev, |
| 1285 | pctl->desc->npins * sizeof(*pins), | 1287 | pctl->desc->npins, sizeof(*pins), |
| 1286 | GFP_KERNEL); | 1288 | GFP_KERNEL); |
| 1287 | if (!pins) | 1289 | if (!pins) |
| 1288 | return -ENOMEM; | 1290 | return -ENOMEM; |
diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c index 49c7c1499bc3..f974eee29a19 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra.c | |||
| @@ -665,8 +665,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev, | |||
| 665 | * Each mux group will appear in 4 functions' list of groups. | 665 | * Each mux group will appear in 4 functions' list of groups. |
| 666 | * This over-allocates slightly, since not all groups are mux groups. | 666 | * This over-allocates slightly, since not all groups are mux groups. |
| 667 | */ | 667 | */ |
| 668 | pmx->group_pins = devm_kzalloc(&pdev->dev, | 668 | pmx->group_pins = devm_kcalloc(&pdev->dev, |
| 669 | soc_data->ngroups * 4 * sizeof(*pmx->group_pins), | 669 | soc_data->ngroups * 4, sizeof(*pmx->group_pins), |
| 670 | GFP_KERNEL); | 670 | GFP_KERNEL); |
| 671 | if (!pmx->group_pins) | 671 | if (!pmx->group_pins) |
| 672 | return -ENOMEM; | 672 | return -ENOMEM; |
| @@ -708,7 +708,7 @@ int tegra_pinctrl_probe(struct platform_device *pdev, | |||
| 708 | } | 708 | } |
| 709 | pmx->nbanks = i; | 709 | pmx->nbanks = i; |
| 710 | 710 | ||
| 711 | pmx->regs = devm_kzalloc(&pdev->dev, pmx->nbanks * sizeof(*pmx->regs), | 711 | pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs), |
| 712 | GFP_KERNEL); | 712 | GFP_KERNEL); |
| 713 | if (!pmx->regs) | 713 | if (!pmx->regs) |
| 714 | return -ENOMEM; | 714 | return -ENOMEM; |
diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index a8a6510183b6..8782c348ebe9 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c | |||
| @@ -510,11 +510,11 @@ static int ti_iodelay_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 510 | goto free_map; | 510 | goto free_map; |
| 511 | } | 511 | } |
| 512 | 512 | ||
| 513 | pins = devm_kzalloc(iod->dev, sizeof(*pins) * rows, GFP_KERNEL); | 513 | pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL); |
| 514 | if (!pins) | 514 | if (!pins) |
| 515 | goto free_group; | 515 | goto free_group; |
| 516 | 516 | ||
| 517 | cfg = devm_kzalloc(iod->dev, sizeof(*cfg) * rows, GFP_KERNEL); | 517 | cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL); |
| 518 | if (!cfg) { | 518 | if (!cfg) { |
| 519 | error = -ENOMEM; | 519 | error = -ENOMEM; |
| 520 | goto free_pins; | 520 | goto free_pins; |
| @@ -749,7 +749,7 @@ static int ti_iodelay_alloc_pins(struct device *dev, | |||
| 749 | nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register); | 749 | nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register); |
| 750 | dev_dbg(dev, "Allocating %i pins\n", nr_pins); | 750 | dev_dbg(dev, "Allocating %i pins\n", nr_pins); |
| 751 | 751 | ||
| 752 | iod->pa = devm_kzalloc(dev, sizeof(*iod->pa) * nr_pins, GFP_KERNEL); | 752 | iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL); |
| 753 | if (!iod->pa) | 753 | if (!iod->pa) |
| 754 | return -ENOMEM; | 754 | return -ENOMEM; |
| 755 | 755 | ||
diff --git a/drivers/pinctrl/vt8500/pinctrl-wmt.c b/drivers/pinctrl/vt8500/pinctrl-wmt.c index d73956bdc211..c08318a5a91b 100644 --- a/drivers/pinctrl/vt8500/pinctrl-wmt.c +++ b/drivers/pinctrl/vt8500/pinctrl-wmt.c | |||
| @@ -352,7 +352,7 @@ static int wmt_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, | |||
| 352 | if (num_pulls) | 352 | if (num_pulls) |
| 353 | maps_per_pin++; | 353 | maps_per_pin++; |
| 354 | 354 | ||
| 355 | cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps), | 355 | cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps), |
| 356 | GFP_KERNEL); | 356 | GFP_KERNEL); |
| 357 | if (!maps) | 357 | if (!maps) |
| 358 | return -ENOMEM; | 358 | return -ENOMEM; |
diff --git a/drivers/pinctrl/zte/pinctrl-zx.c b/drivers/pinctrl/zte/pinctrl-zx.c index ded366bb6564..caa44dd2880a 100644 --- a/drivers/pinctrl/zte/pinctrl-zx.c +++ b/drivers/pinctrl/zte/pinctrl-zx.c | |||
| @@ -277,7 +277,7 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) | |||
| 277 | 277 | ||
| 278 | /* Every single pin composes a group */ | 278 | /* Every single pin composes a group */ |
| 279 | ngroups = info->npins; | 279 | ngroups = info->npins; |
| 280 | groups = devm_kzalloc(&pdev->dev, ngroups * sizeof(*groups), | 280 | groups = devm_kcalloc(&pdev->dev, ngroups, sizeof(*groups), |
| 281 | GFP_KERNEL); | 281 | GFP_KERNEL); |
| 282 | if (!groups) | 282 | if (!groups) |
| 283 | return -ENOMEM; | 283 | return -ENOMEM; |
| @@ -362,8 +362,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) | |||
| 362 | 362 | ||
| 363 | func = functions + j; | 363 | func = functions + j; |
| 364 | if (!func->group_names) { | 364 | if (!func->group_names) { |
| 365 | func->group_names = devm_kzalloc(&pdev->dev, | 365 | func->group_names = devm_kcalloc(&pdev->dev, |
| 366 | func->num_group_names * | 366 | func->num_group_names, |
| 367 | sizeof(*func->group_names), | 367 | sizeof(*func->group_names), |
| 368 | GFP_KERNEL); | 368 | GFP_KERNEL); |
| 369 | if (!func->group_names) { | 369 | if (!func->group_names) { |
diff --git a/drivers/platform/mellanox/mlxreg-hotplug.c b/drivers/platform/mellanox/mlxreg-hotplug.c index ea9e7f4479ca..36a41ff506f0 100644 --- a/drivers/platform/mellanox/mlxreg-hotplug.c +++ b/drivers/platform/mellanox/mlxreg-hotplug.c | |||
| @@ -217,7 +217,8 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv) | |||
| 217 | } | 217 | } |
| 218 | } | 218 | } |
| 219 | 219 | ||
| 220 | priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs * | 220 | priv->group.attrs = devm_kcalloc(&priv->pdev->dev, |
| 221 | num_attrs, | ||
| 221 | sizeof(struct attribute *), | 222 | sizeof(struct attribute *), |
| 222 | GFP_KERNEL); | 223 | GFP_KERNEL); |
| 223 | if (!priv->group.attrs) | 224 | if (!priv->group.attrs) |
diff --git a/drivers/platform/x86/alienware-wmi.c b/drivers/platform/x86/alienware-wmi.c index 9d7dbd925065..d975462a4c57 100644 --- a/drivers/platform/x86/alienware-wmi.c +++ b/drivers/platform/x86/alienware-wmi.c | |||
| @@ -458,19 +458,19 @@ static int alienware_zone_init(struct platform_device *dev) | |||
| 458 | * - zone_data num_zones is for the distinct zones | 458 | * - zone_data num_zones is for the distinct zones |
| 459 | */ | 459 | */ |
| 460 | zone_dev_attrs = | 460 | zone_dev_attrs = |
| 461 | kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1), | 461 | kcalloc(quirks->num_zones + 1, sizeof(struct device_attribute), |
| 462 | GFP_KERNEL); | 462 | GFP_KERNEL); |
| 463 | if (!zone_dev_attrs) | 463 | if (!zone_dev_attrs) |
| 464 | return -ENOMEM; | 464 | return -ENOMEM; |
| 465 | 465 | ||
| 466 | zone_attrs = | 466 | zone_attrs = |
| 467 | kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2), | 467 | kcalloc(quirks->num_zones + 2, sizeof(struct attribute *), |
| 468 | GFP_KERNEL); | 468 | GFP_KERNEL); |
| 469 | if (!zone_attrs) | 469 | if (!zone_attrs) |
| 470 | return -ENOMEM; | 470 | return -ENOMEM; |
| 471 | 471 | ||
| 472 | zone_data = | 472 | zone_data = |
| 473 | kzalloc(sizeof(struct platform_zone) * (quirks->num_zones), | 473 | kcalloc(quirks->num_zones, sizeof(struct platform_zone), |
| 474 | GFP_KERNEL); | 474 | GFP_KERNEL); |
| 475 | if (!zone_data) | 475 | if (!zone_data) |
| 476 | return -ENOMEM; | 476 | return -ENOMEM; |
diff --git a/drivers/platform/x86/intel_ips.c b/drivers/platform/x86/intel_ips.c index a0c95853fd3f..014fc1634a3d 100644 --- a/drivers/platform/x86/intel_ips.c +++ b/drivers/platform/x86/intel_ips.c | |||
| @@ -964,12 +964,12 @@ static int ips_monitor(void *data) | |||
| 964 | u16 *mcp_samples, *ctv1_samples, *ctv2_samples, *mch_samples; | 964 | u16 *mcp_samples, *ctv1_samples, *ctv2_samples, *mch_samples; |
| 965 | u8 cur_seqno, last_seqno; | 965 | u8 cur_seqno, last_seqno; |
| 966 | 966 | ||
| 967 | mcp_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 967 | mcp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL); |
| 968 | ctv1_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 968 | ctv1_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL); |
| 969 | ctv2_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 969 | ctv2_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL); |
| 970 | mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 970 | mch_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL); |
| 971 | cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 971 | cpu_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL); |
| 972 | mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL); | 972 | mchp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL); |
| 973 | if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples || | 973 | if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples || |
| 974 | !cpu_samples || !mchp_samples) { | 974 | !cpu_samples || !mchp_samples) { |
| 975 | dev_err(ips->dev, | 975 | dev_err(ips->dev, |
diff --git a/drivers/platform/x86/panasonic-laptop.c b/drivers/platform/x86/panasonic-laptop.c index 5c39b3211709..8361ad75389a 100644 --- a/drivers/platform/x86/panasonic-laptop.c +++ b/drivers/platform/x86/panasonic-laptop.c | |||
| @@ -571,7 +571,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) | |||
| 571 | return -ENOMEM; | 571 | return -ENOMEM; |
| 572 | } | 572 | } |
| 573 | 573 | ||
| 574 | pcc->sinf = kzalloc(sizeof(u32) * (num_sifr + 1), GFP_KERNEL); | 574 | pcc->sinf = kcalloc(num_sifr + 1, sizeof(u32), GFP_KERNEL); |
| 575 | if (!pcc->sinf) { | 575 | if (!pcc->sinf) { |
| 576 | result = -ENOMEM; | 576 | result = -ENOMEM; |
| 577 | goto out_hotkey; | 577 | goto out_hotkey; |
diff --git a/drivers/platform/x86/thinkpad_acpi.c b/drivers/platform/x86/thinkpad_acpi.c index da1ca4856ea1..ab2d28867c52 100644 --- a/drivers/platform/x86/thinkpad_acpi.c +++ b/drivers/platform/x86/thinkpad_acpi.c | |||
| @@ -6006,7 +6006,7 @@ static int __init led_init(struct ibm_init_struct *iibm) | |||
| 6006 | if (led_supported == TPACPI_LED_NONE) | 6006 | if (led_supported == TPACPI_LED_NONE) |
| 6007 | return 1; | 6007 | return 1; |
| 6008 | 6008 | ||
| 6009 | tpacpi_leds = kzalloc(sizeof(*tpacpi_leds) * TPACPI_LED_NUMLEDS, | 6009 | tpacpi_leds = kcalloc(TPACPI_LED_NUMLEDS, sizeof(*tpacpi_leds), |
| 6010 | GFP_KERNEL); | 6010 | GFP_KERNEL); |
| 6011 | if (!tpacpi_leds) { | 6011 | if (!tpacpi_leds) { |
| 6012 | pr_err("Out of memory for LED data\n"); | 6012 | pr_err("Out of memory for LED data\n"); |
diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index 2a50b4654793..faa1a67cf3d2 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c | |||
| @@ -1380,7 +1380,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm) | |||
| 1380 | 1380 | ||
| 1381 | snprintf(buf, 10, "charger.%d", i); | 1381 | snprintf(buf, 10, "charger.%d", i); |
| 1382 | str = devm_kzalloc(cm->dev, | 1382 | str = devm_kzalloc(cm->dev, |
| 1383 | sizeof(char) * (strlen(buf) + 1), GFP_KERNEL); | 1383 | strlen(buf) + 1, GFP_KERNEL); |
| 1384 | if (!str) | 1384 | if (!str) |
| 1385 | return -ENOMEM; | 1385 | return -ENOMEM; |
| 1386 | 1386 | ||
| @@ -1522,8 +1522,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) | |||
| 1522 | of_property_read_u32(np, "cm-num-chargers", &num_chgs); | 1522 | of_property_read_u32(np, "cm-num-chargers", &num_chgs); |
| 1523 | if (num_chgs) { | 1523 | if (num_chgs) { |
| 1524 | /* Allocate empty bin at the tail of array */ | 1524 | /* Allocate empty bin at the tail of array */ |
| 1525 | desc->psy_charger_stat = devm_kzalloc(dev, sizeof(char *) | 1525 | desc->psy_charger_stat = devm_kcalloc(dev, |
| 1526 | * (num_chgs + 1), GFP_KERNEL); | 1526 | num_chgs + 1, |
| 1527 | sizeof(char *), | ||
| 1528 | GFP_KERNEL); | ||
| 1527 | if (desc->psy_charger_stat) { | 1529 | if (desc->psy_charger_stat) { |
| 1528 | int i; | 1530 | int i; |
| 1529 | for (i = 0; i < num_chgs; i++) | 1531 | for (i = 0; i < num_chgs; i++) |
| @@ -1555,8 +1557,9 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) | |||
| 1555 | struct charger_regulator *chg_regs; | 1557 | struct charger_regulator *chg_regs; |
| 1556 | struct device_node *child; | 1558 | struct device_node *child; |
| 1557 | 1559 | ||
| 1558 | chg_regs = devm_kzalloc(dev, sizeof(*chg_regs) | 1560 | chg_regs = devm_kcalloc(dev, |
| 1559 | * desc->num_charger_regulators, | 1561 | desc->num_charger_regulators, |
| 1562 | sizeof(*chg_regs), | ||
| 1560 | GFP_KERNEL); | 1563 | GFP_KERNEL); |
| 1561 | if (!chg_regs) | 1564 | if (!chg_regs) |
| 1562 | return ERR_PTR(-ENOMEM); | 1565 | return ERR_PTR(-ENOMEM); |
| @@ -1573,9 +1576,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) | |||
| 1573 | /* charger cables */ | 1576 | /* charger cables */ |
| 1574 | chg_regs->num_cables = of_get_child_count(child); | 1577 | chg_regs->num_cables = of_get_child_count(child); |
| 1575 | if (chg_regs->num_cables) { | 1578 | if (chg_regs->num_cables) { |
| 1576 | cables = devm_kzalloc(dev, sizeof(*cables) | 1579 | cables = devm_kcalloc(dev, |
| 1577 | * chg_regs->num_cables, | 1580 | chg_regs->num_cables, |
| 1578 | GFP_KERNEL); | 1581 | sizeof(*cables), |
| 1582 | GFP_KERNEL); | ||
| 1579 | if (!cables) { | 1583 | if (!cables) { |
| 1580 | of_node_put(child); | 1584 | of_node_put(child); |
| 1581 | return ERR_PTR(-ENOMEM); | 1585 | return ERR_PTR(-ENOMEM); |
| @@ -1725,10 +1729,11 @@ static int charger_manager_probe(struct platform_device *pdev) | |||
| 1725 | cm->charger_psy_desc.name = cm->psy_name_buf; | 1729 | cm->charger_psy_desc.name = cm->psy_name_buf; |
| 1726 | 1730 | ||
| 1727 | /* Allocate for psy properties because they may vary */ | 1731 | /* Allocate for psy properties because they may vary */ |
| 1728 | cm->charger_psy_desc.properties = devm_kzalloc(&pdev->dev, | 1732 | cm->charger_psy_desc.properties = |
| 1729 | sizeof(enum power_supply_property) | 1733 | devm_kcalloc(&pdev->dev, |
| 1730 | * (ARRAY_SIZE(default_charger_props) + | 1734 | ARRAY_SIZE(default_charger_props) + |
| 1731 | NUM_CHARGER_PSY_OPTIONAL), GFP_KERNEL); | 1735 | NUM_CHARGER_PSY_OPTIONAL, |
| 1736 | sizeof(enum power_supply_property), GFP_KERNEL); | ||
| 1732 | if (!cm->charger_psy_desc.properties) | 1737 | if (!cm->charger_psy_desc.properties) |
| 1733 | return -ENOMEM; | 1738 | return -ENOMEM; |
| 1734 | 1739 | ||
diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index f57ab0a27301..d21f478741c1 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c | |||
| @@ -263,8 +263,8 @@ static int power_supply_check_supplies(struct power_supply *psy) | |||
| 263 | if (!psy->supplied_from) | 263 | if (!psy->supplied_from) |
| 264 | return -ENOMEM; | 264 | return -ENOMEM; |
| 265 | 265 | ||
| 266 | *psy->supplied_from = devm_kzalloc(&psy->dev, | 266 | *psy->supplied_from = devm_kcalloc(&psy->dev, |
| 267 | sizeof(char *) * (cnt - 1), | 267 | cnt - 1, sizeof(char *), |
| 268 | GFP_KERNEL); | 268 | GFP_KERNEL); |
| 269 | if (!*psy->supplied_from) | 269 | if (!*psy->supplied_from) |
| 270 | return -ENOMEM; | 270 | return -ENOMEM; |
diff --git a/drivers/power/supply/wm97xx_battery.c b/drivers/power/supply/wm97xx_battery.c index bd4f66651513..6754e761778a 100644 --- a/drivers/power/supply/wm97xx_battery.c +++ b/drivers/power/supply/wm97xx_battery.c | |||
| @@ -201,7 +201,7 @@ static int wm97xx_bat_probe(struct platform_device *dev) | |||
| 201 | if (pdata->min_voltage >= 0) | 201 | if (pdata->min_voltage >= 0) |
| 202 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ | 202 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ |
| 203 | 203 | ||
| 204 | prop = kzalloc(props * sizeof(*prop), GFP_KERNEL); | 204 | prop = kcalloc(props, sizeof(*prop), GFP_KERNEL); |
| 205 | if (!prop) { | 205 | if (!prop) { |
| 206 | ret = -ENOMEM; | 206 | ret = -ENOMEM; |
| 207 | goto err3; | 207 | goto err3; |
diff --git a/drivers/power/supply/z2_battery.c b/drivers/power/supply/z2_battery.c index 8a43b49cfd35..bcc2d1a9b0a7 100644 --- a/drivers/power/supply/z2_battery.c +++ b/drivers/power/supply/z2_battery.c | |||
| @@ -146,7 +146,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props) | |||
| 146 | if (info->min_voltage >= 0) | 146 | if (info->min_voltage >= 0) |
| 147 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ | 147 | props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */ |
| 148 | 148 | ||
| 149 | prop = kzalloc(props * sizeof(*prop), GFP_KERNEL); | 149 | prop = kcalloc(props, sizeof(*prop), GFP_KERNEL); |
| 150 | if (!prop) | 150 | if (!prop) |
| 151 | return -ENOMEM; | 151 | return -ENOMEM; |
| 152 | 152 | ||
diff --git a/drivers/powercap/powercap_sys.c b/drivers/powercap/powercap_sys.c index 64b2b2501a79..9e2f274bd44f 100644 --- a/drivers/powercap/powercap_sys.c +++ b/drivers/powercap/powercap_sys.c | |||
| @@ -545,15 +545,16 @@ struct powercap_zone *powercap_register_zone( | |||
| 545 | dev_set_name(&power_zone->dev, "%s:%x", | 545 | dev_set_name(&power_zone->dev, "%s:%x", |
| 546 | dev_name(power_zone->dev.parent), | 546 | dev_name(power_zone->dev.parent), |
| 547 | power_zone->id); | 547 | power_zone->id); |
| 548 | power_zone->constraints = kzalloc(sizeof(*power_zone->constraints) * | 548 | power_zone->constraints = kcalloc(nr_constraints, |
| 549 | nr_constraints, GFP_KERNEL); | 549 | sizeof(*power_zone->constraints), |
| 550 | GFP_KERNEL); | ||
| 550 | if (!power_zone->constraints) | 551 | if (!power_zone->constraints) |
| 551 | goto err_const_alloc; | 552 | goto err_const_alloc; |
| 552 | 553 | ||
| 553 | nr_attrs = nr_constraints * POWERCAP_CONSTRAINTS_ATTRS + | 554 | nr_attrs = nr_constraints * POWERCAP_CONSTRAINTS_ATTRS + |
| 554 | POWERCAP_ZONE_MAX_ATTRS + 1; | 555 | POWERCAP_ZONE_MAX_ATTRS + 1; |
| 555 | power_zone->zone_dev_attrs = kzalloc(sizeof(void *) * | 556 | power_zone->zone_dev_attrs = kcalloc(nr_attrs, sizeof(void *), |
| 556 | nr_attrs, GFP_KERNEL); | 557 | GFP_KERNEL); |
| 557 | if (!power_zone->zone_dev_attrs) | 558 | if (!power_zone->zone_dev_attrs) |
| 558 | goto err_attr_alloc; | 559 | goto err_attr_alloc; |
| 559 | create_power_zone_common_attributes(power_zone); | 560 | create_power_zone_common_attributes(power_zone); |
diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c index 52584e9962ed..15b40a8bc4fb 100644 --- a/drivers/pwm/pwm-lp3943.c +++ b/drivers/pwm/pwm-lp3943.c | |||
| @@ -225,7 +225,7 @@ static int lp3943_pwm_parse_dt(struct device *dev, | |||
| 225 | if (num_outputs == 0) | 225 | if (num_outputs == 0) |
| 226 | continue; | 226 | continue; |
| 227 | 227 | ||
| 228 | output = devm_kzalloc(dev, sizeof(*output) * num_outputs, | 228 | output = devm_kcalloc(dev, num_outputs, sizeof(*output), |
| 229 | GFP_KERNEL); | 229 | GFP_KERNEL); |
| 230 | if (!output) | 230 | if (!output) |
| 231 | return -ENOMEM; | 231 | return -ENOMEM; |
diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c index 0434ab7b6497..a8cb8d2f2abb 100644 --- a/drivers/rapidio/devices/rio_mport_cdev.c +++ b/drivers/rapidio/devices/rio_mport_cdev.c | |||
| @@ -975,7 +975,7 @@ static int rio_mport_transfer_ioctl(struct file *filp, void __user *arg) | |||
| 975 | priv->md->properties.transfer_mode) == 0) | 975 | priv->md->properties.transfer_mode) == 0) |
| 976 | return -ENODEV; | 976 | return -ENODEV; |
| 977 | 977 | ||
| 978 | transfer = vmalloc(transaction.count * sizeof(*transfer)); | 978 | transfer = vmalloc(array_size(sizeof(*transfer), transaction.count)); |
| 979 | if (!transfer) | 979 | if (!transfer) |
| 980 | return -ENOMEM; | 980 | return -ENOMEM; |
| 981 | 981 | ||
diff --git a/drivers/rapidio/rio-scan.c b/drivers/rapidio/rio-scan.c index 161b927d9de1..fd7b517132ac 100644 --- a/drivers/rapidio/rio-scan.c +++ b/drivers/rapidio/rio-scan.c | |||
| @@ -425,9 +425,9 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, | |||
| 425 | rswitch = rdev->rswitch; | 425 | rswitch = rdev->rswitch; |
| 426 | rswitch->port_ok = 0; | 426 | rswitch->port_ok = 0; |
| 427 | spin_lock_init(&rswitch->lock); | 427 | spin_lock_init(&rswitch->lock); |
| 428 | rswitch->route_table = kzalloc(sizeof(u8)* | 428 | rswitch->route_table = |
| 429 | RIO_MAX_ROUTE_ENTRIES(port->sys_size), | 429 | kzalloc(RIO_MAX_ROUTE_ENTRIES(port->sys_size), |
| 430 | GFP_KERNEL); | 430 | GFP_KERNEL); |
| 431 | if (!rswitch->route_table) | 431 | if (!rswitch->route_table) |
| 432 | goto cleanup; | 432 | goto cleanup; |
| 433 | /* Initialize switch route table */ | 433 | /* Initialize switch route table */ |
diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 7652477e6a9d..21e20483bd91 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c | |||
| @@ -424,9 +424,10 @@ static int act8865_pdata_from_dt(struct device *dev, | |||
| 424 | if (matched <= 0) | 424 | if (matched <= 0) |
| 425 | return matched; | 425 | return matched; |
| 426 | 426 | ||
| 427 | pdata->regulators = devm_kzalloc(dev, | 427 | pdata->regulators = devm_kcalloc(dev, |
| 428 | sizeof(struct act8865_regulator_data) * | 428 | num_matches, |
| 429 | num_matches, GFP_KERNEL); | 429 | sizeof(struct act8865_regulator_data), |
| 430 | GFP_KERNEL); | ||
| 430 | if (!pdata->regulators) | 431 | if (!pdata->regulators) |
| 431 | return -ENOMEM; | 432 | return -ENOMEM; |
| 432 | 433 | ||
diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 874d415d6b4f..565a71343a8e 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c | |||
| @@ -239,8 +239,10 @@ static int as3711_regulator_probe(struct platform_device *pdev) | |||
| 239 | } | 239 | } |
| 240 | } | 240 | } |
| 241 | 241 | ||
| 242 | regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM * | 242 | regs = devm_kcalloc(&pdev->dev, |
| 243 | sizeof(struct as3711_regulator), GFP_KERNEL); | 243 | AS3711_REGULATOR_NUM, |
| 244 | sizeof(struct as3711_regulator), | ||
| 245 | GFP_KERNEL); | ||
| 244 | if (!regs) | 246 | if (!regs) |
| 245 | return -ENOMEM; | 247 | return -ENOMEM; |
| 246 | 248 | ||
diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index 9dd715407b39..92d6d7b10cf7 100644 --- a/drivers/regulator/bcm590xx-regulator.c +++ b/drivers/regulator/bcm590xx-regulator.c | |||
| @@ -383,8 +383,10 @@ static int bcm590xx_probe(struct platform_device *pdev) | |||
| 383 | 383 | ||
| 384 | platform_set_drvdata(pdev, pmu); | 384 | platform_set_drvdata(pdev, pmu); |
| 385 | 385 | ||
| 386 | pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS * | 386 | pmu->desc = devm_kcalloc(&pdev->dev, |
| 387 | sizeof(struct regulator_desc), GFP_KERNEL); | 387 | BCM590XX_NUM_REGS, |
| 388 | sizeof(struct regulator_desc), | ||
| 389 | GFP_KERNEL); | ||
| 388 | if (!pmu->desc) | 390 | if (!pmu->desc) |
| 389 | return -ENOMEM; | 391 | return -ENOMEM; |
| 390 | 392 | ||
diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 6a8f9cd69f52..2df26f36c687 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c | |||
| @@ -681,8 +681,8 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt( | |||
| 681 | if (!pdata) | 681 | if (!pdata) |
| 682 | return ERR_PTR(-ENOMEM); | 682 | return ERR_PTR(-ENOMEM); |
| 683 | 683 | ||
| 684 | pdata->regulator_data = devm_kzalloc(&pdev->dev, | 684 | pdata->regulator_data = devm_kcalloc(&pdev->dev, |
| 685 | num * sizeof(*pdata->regulator_data), | 685 | num, sizeof(*pdata->regulator_data), |
| 686 | GFP_KERNEL); | 686 | GFP_KERNEL); |
| 687 | if (!pdata->regulator_data) | 687 | if (!pdata->regulator_data) |
| 688 | return ERR_PTR(-ENOMEM); | 688 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index a86b8997bb54..b2f5ec4f658a 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c | |||
| @@ -172,8 +172,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, | |||
| 172 | 172 | ||
| 173 | if (ret > 0) { | 173 | if (ret > 0) { |
| 174 | config->nr_gpios = ret; | 174 | config->nr_gpios = ret; |
| 175 | config->gpios = devm_kzalloc(dev, | 175 | config->gpios = devm_kcalloc(dev, |
| 176 | sizeof(struct gpio) * config->nr_gpios, | 176 | config->nr_gpios, sizeof(struct gpio), |
| 177 | GFP_KERNEL); | 177 | GFP_KERNEL); |
| 178 | if (!config->gpios) | 178 | if (!config->gpios) |
| 179 | return ERR_PTR(-ENOMEM); | 179 | return ERR_PTR(-ENOMEM); |
| @@ -214,9 +214,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, | |||
| 214 | return ERR_PTR(-EINVAL); | 214 | return ERR_PTR(-EINVAL); |
| 215 | } | 215 | } |
| 216 | 216 | ||
| 217 | config->states = devm_kzalloc(dev, | 217 | config->states = devm_kcalloc(dev, |
| 218 | sizeof(struct gpio_regulator_state) | 218 | proplen / 2, |
| 219 | * (proplen / 2), | 219 | sizeof(struct gpio_regulator_state), |
| 220 | GFP_KERNEL); | 220 | GFP_KERNEL); |
| 221 | if (!config->states) | 221 | if (!config->states) |
| 222 | return ERR_PTR(-ENOMEM); | 222 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 66bbaa999433..cc52779b53f7 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c | |||
| @@ -194,8 +194,10 @@ static int of_get_max1586_platform_data(struct device *dev, | |||
| 194 | if (matched <= 0) | 194 | if (matched <= 0) |
| 195 | return matched; | 195 | return matched; |
| 196 | 196 | ||
| 197 | pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) * | 197 | pdata->subdevs = devm_kcalloc(dev, |
| 198 | matched, GFP_KERNEL); | 198 | matched, |
| 199 | sizeof(struct max1586_subdev_data), | ||
| 200 | GFP_KERNEL); | ||
| 199 | if (!pdata->subdevs) | 201 | if (!pdata->subdevs) |
| 200 | return -ENOMEM; | 202 | return -ENOMEM; |
| 201 | 203 | ||
diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index a6183425f27d..4cf6897a401f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c | |||
| @@ -351,8 +351,10 @@ static int max8660_pdata_from_dt(struct device *dev, | |||
| 351 | if (matched <= 0) | 351 | if (matched <= 0) |
| 352 | return matched; | 352 | return matched; |
| 353 | 353 | ||
| 354 | pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) * | 354 | pdata->subdevs = devm_kcalloc(dev, |
| 355 | matched, GFP_KERNEL); | 355 | matched, |
| 356 | sizeof(struct max8660_subdev_data), | ||
| 357 | GFP_KERNEL); | ||
| 356 | if (!pdata->subdevs) | 358 | if (!pdata->subdevs) |
| 357 | return -ENOMEM; | 359 | return -ENOMEM; |
| 358 | 360 | ||
diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c index 559b9ac45404..a8ea30ee18a6 100644 --- a/drivers/regulator/max8997-regulator.c +++ b/drivers/regulator/max8997-regulator.c | |||
| @@ -929,8 +929,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
| 929 | /* count the number of regulators to be supported in pmic */ | 929 | /* count the number of regulators to be supported in pmic */ |
| 930 | pdata->num_regulators = of_get_child_count(regulators_np); | 930 | pdata->num_regulators = of_get_child_count(regulators_np); |
| 931 | 931 | ||
| 932 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * | 932 | rdata = devm_kcalloc(&pdev->dev, |
| 933 | pdata->num_regulators, GFP_KERNEL); | 933 | pdata->num_regulators, sizeof(*rdata), |
| 934 | GFP_KERNEL); | ||
| 934 | if (!rdata) { | 935 | if (!rdata) { |
| 935 | of_node_put(regulators_np); | 936 | of_node_put(regulators_np); |
| 936 | return -ENOMEM; | 937 | return -ENOMEM; |
diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 6a2b61c012b5..6b9f262ebbb0 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c | |||
| @@ -670,8 +670,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, | |||
| 670 | /* count the number of regulators to be supported in pmic */ | 670 | /* count the number of regulators to be supported in pmic */ |
| 671 | pdata->num_regulators = of_get_child_count(regulators_np); | 671 | pdata->num_regulators = of_get_child_count(regulators_np); |
| 672 | 672 | ||
| 673 | rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * | 673 | rdata = devm_kcalloc(iodev->dev, |
| 674 | pdata->num_regulators, GFP_KERNEL); | 674 | pdata->num_regulators, sizeof(*rdata), |
| 675 | GFP_KERNEL); | ||
| 675 | if (!rdata) { | 676 | if (!rdata) { |
| 676 | of_node_put(regulators_np); | 677 | of_node_put(regulators_np); |
| 677 | return -ENOMEM; | 678 | return -ENOMEM; |
diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 41271aeea63e..da4fb9824757 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c | |||
| @@ -171,7 +171,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( | |||
| 171 | if (!parent) | 171 | if (!parent) |
| 172 | return NULL; | 172 | return NULL; |
| 173 | 173 | ||
| 174 | data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators, | 174 | data = devm_kcalloc(&pdev->dev, priv->num_regulators, sizeof(*data), |
| 175 | GFP_KERNEL); | 175 | GFP_KERNEL); |
| 176 | if (!data) { | 176 | if (!data) { |
| 177 | of_node_put(parent); | 177 | of_node_put(parent); |
diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index 8f782d22fdbe..92b41a6a4dc2 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c | |||
| @@ -173,8 +173,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) | |||
| 173 | if (count < 0) | 173 | if (count < 0) |
| 174 | return count; | 174 | return count; |
| 175 | 175 | ||
| 176 | drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data) | 176 | drvdata = devm_kcalloc(&pdev->dev, |
| 177 | * count, GFP_KERNEL); | 177 | count, sizeof(struct pbias_regulator_data), |
| 178 | GFP_KERNEL); | ||
| 178 | if (!drvdata) | 179 | if (!drvdata) |
| 179 | return -ENOMEM; | 180 | return -ENOMEM; |
| 180 | 181 | ||
diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index d0f1340168b1..2ec51af43673 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c | |||
| @@ -132,8 +132,10 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) | |||
| 132 | return -ENODEV; | 132 | return -ENODEV; |
| 133 | } | 133 | } |
| 134 | 134 | ||
| 135 | regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX * | 135 | regs = devm_kcalloc(&pdev->dev, |
| 136 | sizeof(struct rc5t583_regulator), GFP_KERNEL); | 136 | RC5T583_REGULATOR_MAX, |
| 137 | sizeof(struct rc5t583_regulator), | ||
| 138 | GFP_KERNEL); | ||
| 137 | if (!regs) | 139 | if (!regs) |
| 138 | return -ENOMEM; | 140 | return -ENOMEM; |
| 139 | 141 | ||
diff --git a/drivers/regulator/s2mps11.c b/drivers/regulator/s2mps11.c index 7726b874e539..d1207ec683db 100644 --- a/drivers/regulator/s2mps11.c +++ b/drivers/regulator/s2mps11.c | |||
| @@ -1139,8 +1139,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
| 1139 | return -EINVAL; | 1139 | return -EINVAL; |
| 1140 | } | 1140 | } |
| 1141 | 1141 | ||
| 1142 | s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev, | 1142 | s2mps11->ext_control_gpio = devm_kmalloc_array(&pdev->dev, |
| 1143 | sizeof(*s2mps11->ext_control_gpio) * rdev_num, | 1143 | rdev_num, sizeof(*s2mps11->ext_control_gpio), |
| 1144 | GFP_KERNEL); | 1144 | GFP_KERNEL); |
| 1145 | if (!s2mps11->ext_control_gpio) | 1145 | if (!s2mps11->ext_control_gpio) |
| 1146 | return -ENOMEM; | 1146 | return -ENOMEM; |
| @@ -1162,7 +1162,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) | |||
| 1162 | } | 1162 | } |
| 1163 | } | 1163 | } |
| 1164 | 1164 | ||
| 1165 | rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL); | 1165 | rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL); |
| 1166 | if (!rdata) | 1166 | if (!rdata) |
| 1167 | return -ENOMEM; | 1167 | return -ENOMEM; |
| 1168 | 1168 | ||
diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index b8443a360646..0cbc980753c2 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c | |||
| @@ -553,13 +553,15 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, | |||
| 553 | /* count the number of regulators to be supported in pmic */ | 553 | /* count the number of regulators to be supported in pmic */ |
| 554 | pdata->num_regulators = of_get_child_count(regulators_np); | 554 | pdata->num_regulators = of_get_child_count(regulators_np); |
| 555 | 555 | ||
| 556 | rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * | 556 | rdata = devm_kcalloc(&pdev->dev, |
| 557 | pdata->num_regulators, GFP_KERNEL); | 557 | pdata->num_regulators, sizeof(*rdata), |
| 558 | GFP_KERNEL); | ||
| 558 | if (!rdata) | 559 | if (!rdata) |
| 559 | return -ENOMEM; | 560 | return -ENOMEM; |
| 560 | 561 | ||
| 561 | rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) * | 562 | rmode = devm_kcalloc(&pdev->dev, |
| 562 | pdata->num_regulators, GFP_KERNEL); | 563 | pdata->num_regulators, sizeof(*rmode), |
| 564 | GFP_KERNEL); | ||
| 563 | if (!rmode) | 565 | if (!rmode) |
| 564 | return -ENOMEM; | 566 | return -ENOMEM; |
| 565 | 567 | ||
diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index d2f994298753..cced1ffb896c 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c | |||
| @@ -532,13 +532,13 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, | |||
| 532 | } | 532 | } |
| 533 | num_entries /= num_values; | 533 | num_entries /= num_values; |
| 534 | 534 | ||
| 535 | info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL); | 535 | info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL); |
| 536 | if (!info) | 536 | if (!info) |
| 537 | return -ENOMEM; | 537 | return -ENOMEM; |
| 538 | 538 | ||
| 539 | abb->info = info; | 539 | abb->info = info; |
| 540 | 540 | ||
| 541 | volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries, | 541 | volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int), |
| 542 | GFP_KERNEL); | 542 | GFP_KERNEL); |
| 543 | if (!volt_table) | 543 | if (!volt_table) |
| 544 | return -ENOMEM; | 544 | return -ENOMEM; |
diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 2d398fa3b720..edaef9e4dc74 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c | |||
| @@ -331,8 +331,9 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( | |||
| 331 | if (!tps65090_pdata) | 331 | if (!tps65090_pdata) |
| 332 | return ERR_PTR(-ENOMEM); | 332 | return ERR_PTR(-ENOMEM); |
| 333 | 333 | ||
| 334 | reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * | 334 | reg_pdata = devm_kcalloc(&pdev->dev, |
| 335 | sizeof(*reg_pdata), GFP_KERNEL); | 335 | TPS65090_REGULATOR_MAX, sizeof(*reg_pdata), |
| 336 | GFP_KERNEL); | ||
| 336 | if (!reg_pdata) | 337 | if (!reg_pdata) |
| 337 | return ERR_PTR(-ENOMEM); | 338 | return ERR_PTR(-ENOMEM); |
| 338 | 339 | ||
| @@ -429,8 +430,9 @@ static int tps65090_regulator_probe(struct platform_device *pdev) | |||
| 429 | return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL; | 430 | return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL; |
| 430 | } | 431 | } |
| 431 | 432 | ||
| 432 | pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic), | 433 | pmic = devm_kcalloc(&pdev->dev, |
| 433 | GFP_KERNEL); | 434 | TPS65090_REGULATOR_MAX, sizeof(*pmic), |
| 435 | GFP_KERNEL); | ||
| 434 | if (!pmic) | 436 | if (!pmic) |
| 435 | return -ENOMEM; | 437 | return -ENOMEM; |
| 436 | 438 | ||
diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 7b12e880d1ea..fc12badf3805 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c | |||
| @@ -229,8 +229,9 @@ static int tps65217_regulator_probe(struct platform_device *pdev) | |||
| 229 | unsigned int val; | 229 | unsigned int val; |
| 230 | 230 | ||
| 231 | /* Allocate memory for strobes */ | 231 | /* Allocate memory for strobes */ |
| 232 | tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) * | 232 | tps->strobes = devm_kcalloc(&pdev->dev, |
| 233 | TPS65217_NUM_REGULATOR, GFP_KERNEL); | 233 | TPS65217_NUM_REGULATOR, sizeof(u8), |
| 234 | GFP_KERNEL); | ||
| 234 | 235 | ||
| 235 | platform_set_drvdata(pdev, tps); | 236 | platform_set_drvdata(pdev, tps); |
| 236 | 237 | ||
diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index 1827185beacc..6209beee1018 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c | |||
| @@ -324,8 +324,9 @@ static int tps65218_regulator_probe(struct platform_device *pdev) | |||
| 324 | config.regmap = tps->regmap; | 324 | config.regmap = tps->regmap; |
| 325 | 325 | ||
| 326 | /* Allocate memory for strobes */ | 326 | /* Allocate memory for strobes */ |
| 327 | tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) * | 327 | tps->strobes = devm_kcalloc(&pdev->dev, |
| 328 | TPS65218_NUM_REGULATOR, GFP_KERNEL); | 328 | TPS65218_NUM_REGULATOR, sizeof(u8), |
| 329 | GFP_KERNEL); | ||
| 329 | if (!tps->strobes) | 330 | if (!tps->strobes) |
| 330 | return -ENOMEM; | 331 | return -ENOMEM; |
| 331 | 332 | ||
diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 81672a58fcc2..02ccdaa226a7 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c | |||
| @@ -1131,18 +1131,24 @@ static int tps65910_probe(struct platform_device *pdev) | |||
| 1131 | return -ENODEV; | 1131 | return -ENODEV; |
| 1132 | } | 1132 | } |
| 1133 | 1133 | ||
| 1134 | pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators * | 1134 | pmic->desc = devm_kcalloc(&pdev->dev, |
| 1135 | sizeof(struct regulator_desc), GFP_KERNEL); | 1135 | pmic->num_regulators, |
| 1136 | sizeof(struct regulator_desc), | ||
| 1137 | GFP_KERNEL); | ||
| 1136 | if (!pmic->desc) | 1138 | if (!pmic->desc) |
| 1137 | return -ENOMEM; | 1139 | return -ENOMEM; |
| 1138 | 1140 | ||
| 1139 | pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators * | 1141 | pmic->info = devm_kcalloc(&pdev->dev, |
| 1140 | sizeof(struct tps_info *), GFP_KERNEL); | 1142 | pmic->num_regulators, |
| 1143 | sizeof(struct tps_info *), | ||
| 1144 | GFP_KERNEL); | ||
| 1141 | if (!pmic->info) | 1145 | if (!pmic->info) |
| 1142 | return -ENOMEM; | 1146 | return -ENOMEM; |
| 1143 | 1147 | ||
| 1144 | pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators * | 1148 | pmic->rdev = devm_kcalloc(&pdev->dev, |
| 1145 | sizeof(struct regulator_dev *), GFP_KERNEL); | 1149 | pmic->num_regulators, |
| 1150 | sizeof(struct regulator_dev *), | ||
| 1151 | GFP_KERNEL); | ||
| 1146 | if (!pmic->rdev) | 1152 | if (!pmic->rdev) |
| 1147 | return -ENOMEM; | 1153 | return -ENOMEM; |
| 1148 | 1154 | ||
diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index d4cc60ad18ae..1001147404c3 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c | |||
| @@ -691,8 +691,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev) | |||
| 691 | return -EINVAL; | 691 | return -EINVAL; |
| 692 | } | 692 | } |
| 693 | 693 | ||
| 694 | pmic = devm_kzalloc(&pdev->dev, | 694 | pmic = devm_kcalloc(&pdev->dev, |
| 695 | TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL); | 695 | TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL); |
| 696 | if (!pmic) | 696 | if (!pmic) |
| 697 | return -ENOMEM; | 697 | return -ENOMEM; |
| 698 | 698 | ||
diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c index 99520b0a1329..a2635c21db7f 100644 --- a/drivers/reset/reset-ti-syscon.c +++ b/drivers/reset/reset-ti-syscon.c | |||
| @@ -189,7 +189,8 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) | |||
| 189 | } | 189 | } |
| 190 | 190 | ||
| 191 | nr_controls = (size / sizeof(*list)) / 7; | 191 | nr_controls = (size / sizeof(*list)) / 7; |
| 192 | controls = devm_kzalloc(dev, nr_controls * sizeof(*controls), GFP_KERNEL); | 192 | controls = devm_kcalloc(dev, nr_controls, sizeof(*controls), |
| 193 | GFP_KERNEL); | ||
| 193 | if (!controls) | 194 | if (!controls) |
| 194 | return -ENOMEM; | 195 | return -ENOMEM; |
| 195 | 196 | ||
diff --git a/drivers/s390/block/dasd_eer.c b/drivers/s390/block/dasd_eer.c index fb2c3599d95c..0af8c5295b65 100644 --- a/drivers/s390/block/dasd_eer.c +++ b/drivers/s390/block/dasd_eer.c | |||
| @@ -561,8 +561,8 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) | |||
| 561 | return -EINVAL; | 561 | return -EINVAL; |
| 562 | } | 562 | } |
| 563 | eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE; | 563 | eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE; |
| 564 | eerb->buffer = kmalloc(eerb->buffer_page_count * sizeof(char *), | 564 | eerb->buffer = kmalloc_array(eerb->buffer_page_count, sizeof(char *), |
| 565 | GFP_KERNEL); | 565 | GFP_KERNEL); |
| 566 | if (!eerb->buffer) { | 566 | if (!eerb->buffer) { |
| 567 | kfree(eerb); | 567 | kfree(eerb); |
| 568 | return -ENOMEM; | 568 | return -ENOMEM; |
diff --git a/drivers/s390/block/dcssblk.c b/drivers/s390/block/dcssblk.c index 29024492b8ed..ed607288e696 100644 --- a/drivers/s390/block/dcssblk.c +++ b/drivers/s390/block/dcssblk.c | |||
| @@ -238,9 +238,9 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info) | |||
| 238 | if (dev_info->num_of_segments <= 1) | 238 | if (dev_info->num_of_segments <= 1) |
| 239 | return 0; | 239 | return 0; |
| 240 | 240 | ||
| 241 | sort_list = kzalloc( | 241 | sort_list = kcalloc(dev_info->num_of_segments, |
| 242 | sizeof(struct segment_info) * dev_info->num_of_segments, | 242 | sizeof(struct segment_info), |
| 243 | GFP_KERNEL); | 243 | GFP_KERNEL); |
| 244 | if (sort_list == NULL) | 244 | if (sort_list == NULL) |
| 245 | return -ENOMEM; | 245 | return -ENOMEM; |
| 246 | i = 0; | 246 | i = 0; |
diff --git a/drivers/s390/char/keyboard.c b/drivers/s390/char/keyboard.c index db1fbf9b00b5..79eb60958015 100644 --- a/drivers/s390/char/keyboard.c +++ b/drivers/s390/char/keyboard.c | |||
| @@ -78,7 +78,7 @@ kbd_alloc(void) { | |||
| 78 | } | 78 | } |
| 79 | } | 79 | } |
| 80 | kbd->fn_handler = | 80 | kbd->fn_handler = |
| 81 | kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL); | 81 | kcalloc(NR_FN_HANDLER, sizeof(fn_handler_fn *), GFP_KERNEL); |
| 82 | if (!kbd->fn_handler) | 82 | if (!kbd->fn_handler) |
| 83 | goto out_func; | 83 | goto out_func; |
| 84 | kbd->accent_table = kmemdup(ebc_accent_table, | 84 | kbd->accent_table = kmemdup(ebc_accent_table, |
diff --git a/drivers/s390/char/sclp_sd.c b/drivers/s390/char/sclp_sd.c index 99f41db5123b..1e244f78f192 100644 --- a/drivers/s390/char/sclp_sd.c +++ b/drivers/s390/char/sclp_sd.c | |||
| @@ -300,7 +300,7 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di) | |||
| 300 | goto out_result; | 300 | goto out_result; |
| 301 | 301 | ||
| 302 | /* Allocate memory */ | 302 | /* Allocate memory */ |
| 303 | data = vzalloc((size_t) dsize * PAGE_SIZE); | 303 | data = vzalloc(array_size((size_t)dsize, PAGE_SIZE)); |
| 304 | if (!data) { | 304 | if (!data) { |
| 305 | rc = -ENOMEM; | 305 | rc = -ENOMEM; |
| 306 | goto out; | 306 | goto out; |
diff --git a/drivers/s390/char/tty3270.c b/drivers/s390/char/tty3270.c index 1c98023cffd4..5b8af2782282 100644 --- a/drivers/s390/char/tty3270.c +++ b/drivers/s390/char/tty3270.c | |||
| @@ -719,7 +719,8 @@ tty3270_alloc_view(void) | |||
| 719 | if (!tp) | 719 | if (!tp) |
| 720 | goto out_err; | 720 | goto out_err; |
| 721 | tp->freemem_pages = | 721 | tp->freemem_pages = |
| 722 | kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL); | 722 | kmalloc_array(TTY3270_STRING_PAGES, sizeof(void *), |
| 723 | GFP_KERNEL); | ||
| 723 | if (!tp->freemem_pages) | 724 | if (!tp->freemem_pages) |
| 724 | goto out_tp; | 725 | goto out_tp; |
| 725 | INIT_LIST_HEAD(&tp->freemem); | 726 | INIT_LIST_HEAD(&tp->freemem); |
diff --git a/drivers/s390/char/vmur.c b/drivers/s390/char/vmur.c index 52aa89424318..cbde65ab2170 100644 --- a/drivers/s390/char/vmur.c +++ b/drivers/s390/char/vmur.c | |||
| @@ -242,7 +242,7 @@ static struct ccw1 *alloc_chan_prog(const char __user *ubuf, int rec_count, | |||
| 242 | * That means we allocate room for CCWs to cover count/reclen | 242 | * That means we allocate room for CCWs to cover count/reclen |
| 243 | * records plus a NOP. | 243 | * records plus a NOP. |
| 244 | */ | 244 | */ |
| 245 | cpa = kzalloc((rec_count + 1) * sizeof(struct ccw1), | 245 | cpa = kcalloc(rec_count + 1, sizeof(struct ccw1), |
| 246 | GFP_KERNEL | GFP_DMA); | 246 | GFP_KERNEL | GFP_DMA); |
| 247 | if (!cpa) | 247 | if (!cpa) |
| 248 | return ERR_PTR(-ENOMEM); | 248 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/s390/char/zcore.c b/drivers/s390/char/zcore.c index 4369662cfff5..76d3c50bf078 100644 --- a/drivers/s390/char/zcore.c +++ b/drivers/s390/char/zcore.c | |||
| @@ -152,7 +152,7 @@ static int zcore_memmap_open(struct inode *inode, struct file *filp) | |||
| 152 | char *buf; | 152 | char *buf; |
| 153 | int i = 0; | 153 | int i = 0; |
| 154 | 154 | ||
| 155 | buf = kzalloc(memblock.memory.cnt * CHUNK_INFO_SIZE, GFP_KERNEL); | 155 | buf = kcalloc(memblock.memory.cnt, CHUNK_INFO_SIZE, GFP_KERNEL); |
| 156 | if (!buf) { | 156 | if (!buf) { |
| 157 | return -ENOMEM; | 157 | return -ENOMEM; |
| 158 | } | 158 | } |
diff --git a/drivers/s390/cio/qdio_setup.c b/drivers/s390/cio/qdio_setup.c index 4c14ce428e92..78f1be41b05e 100644 --- a/drivers/s390/cio/qdio_setup.c +++ b/drivers/s390/cio/qdio_setup.c | |||
| @@ -536,7 +536,7 @@ void qdio_print_subchannel_info(struct qdio_irq *irq_ptr, | |||
| 536 | 536 | ||
| 537 | int qdio_enable_async_operation(struct qdio_output_q *outq) | 537 | int qdio_enable_async_operation(struct qdio_output_q *outq) |
| 538 | { | 538 | { |
| 539 | outq->aobs = kzalloc(sizeof(struct qaob *) * QDIO_MAX_BUFFERS_PER_Q, | 539 | outq->aobs = kcalloc(QDIO_MAX_BUFFERS_PER_Q, sizeof(struct qaob *), |
| 540 | GFP_ATOMIC); | 540 | GFP_ATOMIC); |
| 541 | if (!outq->aobs) { | 541 | if (!outq->aobs) { |
| 542 | outq->use_cq = 0; | 542 | outq->use_cq = 0; |
diff --git a/drivers/s390/cio/qdio_thinint.c b/drivers/s390/cio/qdio_thinint.c index 0787b587e4b8..07dea602205b 100644 --- a/drivers/s390/cio/qdio_thinint.c +++ b/drivers/s390/cio/qdio_thinint.c | |||
| @@ -241,8 +241,9 @@ out: | |||
| 241 | /* allocate non-shared indicators and shared indicator */ | 241 | /* allocate non-shared indicators and shared indicator */ |
| 242 | int __init tiqdio_allocate_memory(void) | 242 | int __init tiqdio_allocate_memory(void) |
| 243 | { | 243 | { |
| 244 | q_indicators = kzalloc(sizeof(struct indicator_t) * TIQDIO_NR_INDICATORS, | 244 | q_indicators = kcalloc(TIQDIO_NR_INDICATORS, |
| 245 | GFP_KERNEL); | 245 | sizeof(struct indicator_t), |
| 246 | GFP_KERNEL); | ||
| 246 | if (!q_indicators) | 247 | if (!q_indicators) |
| 247 | return -ENOMEM; | 248 | return -ENOMEM; |
| 248 | return 0; | 249 | return 0; |
diff --git a/drivers/s390/crypto/pkey_api.c b/drivers/s390/crypto/pkey_api.c index ed80d00cdb6f..3929c8be8098 100644 --- a/drivers/s390/crypto/pkey_api.c +++ b/drivers/s390/crypto/pkey_api.c | |||
| @@ -121,7 +121,7 @@ static int alloc_and_prep_cprbmem(size_t paramblen, | |||
| 121 | * allocate consecutive memory for request CPRB, request param | 121 | * allocate consecutive memory for request CPRB, request param |
| 122 | * block, reply CPRB and reply param block | 122 | * block, reply CPRB and reply param block |
| 123 | */ | 123 | */ |
| 124 | cprbmem = kzalloc(2 * cprbplusparamblen, GFP_KERNEL); | 124 | cprbmem = kcalloc(2, cprbplusparamblen, GFP_KERNEL); |
| 125 | if (!cprbmem) | 125 | if (!cprbmem) |
| 126 | return -ENOMEM; | 126 | return -ENOMEM; |
| 127 | 127 | ||
| @@ -899,9 +899,9 @@ int pkey_findcard(const struct pkey_seckey *seckey, | |||
| 899 | return -EINVAL; | 899 | return -EINVAL; |
| 900 | 900 | ||
| 901 | /* fetch status of all crypto cards */ | 901 | /* fetch status of all crypto cards */ |
| 902 | device_status = kmalloc(MAX_ZDEV_ENTRIES_EXT | 902 | device_status = kmalloc_array(MAX_ZDEV_ENTRIES_EXT, |
| 903 | * sizeof(struct zcrypt_device_status_ext), | 903 | sizeof(struct zcrypt_device_status_ext), |
| 904 | GFP_KERNEL); | 904 | GFP_KERNEL); |
| 905 | if (!device_status) | 905 | if (!device_status) |
| 906 | return -ENOMEM; | 906 | return -ENOMEM; |
| 907 | zcrypt_device_status_mask_ext(device_status); | 907 | zcrypt_device_status_mask_ext(device_status); |
diff --git a/drivers/s390/net/ctcm_main.c b/drivers/s390/net/ctcm_main.c index 7ce98b70cad3..7617d21cb296 100644 --- a/drivers/s390/net/ctcm_main.c +++ b/drivers/s390/net/ctcm_main.c | |||
| @@ -1379,7 +1379,7 @@ static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type, | |||
| 1379 | } else | 1379 | } else |
| 1380 | ccw_num = 8; | 1380 | ccw_num = 8; |
| 1381 | 1381 | ||
| 1382 | ch->ccw = kzalloc(ccw_num * sizeof(struct ccw1), GFP_KERNEL | GFP_DMA); | 1382 | ch->ccw = kcalloc(ccw_num, sizeof(struct ccw1), GFP_KERNEL | GFP_DMA); |
| 1383 | if (ch->ccw == NULL) | 1383 | if (ch->ccw == NULL) |
| 1384 | goto nomem_return; | 1384 | goto nomem_return; |
| 1385 | 1385 | ||
diff --git a/drivers/s390/net/qeth_core_main.c b/drivers/s390/net/qeth_core_main.c index 9f28b6f2efc4..8e1474f1ffac 100644 --- a/drivers/s390/net/qeth_core_main.c +++ b/drivers/s390/net/qeth_core_main.c | |||
| @@ -374,9 +374,10 @@ static int qeth_alloc_cq(struct qeth_card *card) | |||
| 374 | } | 374 | } |
| 375 | card->qdio.no_in_queues = 2; | 375 | card->qdio.no_in_queues = 2; |
| 376 | card->qdio.out_bufstates = | 376 | card->qdio.out_bufstates = |
| 377 | kzalloc(card->qdio.no_out_queues * | 377 | kcalloc(card->qdio.no_out_queues * |
| 378 | QDIO_MAX_BUFFERS_PER_Q * | 378 | QDIO_MAX_BUFFERS_PER_Q, |
| 379 | sizeof(struct qdio_outbuf_state), GFP_KERNEL); | 379 | sizeof(struct qdio_outbuf_state), |
| 380 | GFP_KERNEL); | ||
| 380 | outbuf_states = card->qdio.out_bufstates; | 381 | outbuf_states = card->qdio.out_bufstates; |
| 381 | if (outbuf_states == NULL) { | 382 | if (outbuf_states == NULL) { |
| 382 | rc = -1; | 383 | rc = -1; |
| @@ -2538,8 +2539,9 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card) | |||
| 2538 | 2539 | ||
| 2539 | /* outbound */ | 2540 | /* outbound */ |
| 2540 | card->qdio.out_qs = | 2541 | card->qdio.out_qs = |
| 2541 | kzalloc(card->qdio.no_out_queues * | 2542 | kcalloc(card->qdio.no_out_queues, |
| 2542 | sizeof(struct qeth_qdio_out_q *), GFP_KERNEL); | 2543 | sizeof(struct qeth_qdio_out_q *), |
| 2544 | GFP_KERNEL); | ||
| 2543 | if (!card->qdio.out_qs) | 2545 | if (!card->qdio.out_qs) |
| 2544 | goto out_freepool; | 2546 | goto out_freepool; |
| 2545 | for (i = 0; i < card->qdio.no_out_queues; ++i) { | 2547 | for (i = 0; i < card->qdio.no_out_queues; ++i) { |
| @@ -4963,8 +4965,8 @@ static int qeth_qdio_establish(struct qeth_card *card) | |||
| 4963 | 4965 | ||
| 4964 | QETH_DBF_TEXT(SETUP, 2, "qdioest"); | 4966 | QETH_DBF_TEXT(SETUP, 2, "qdioest"); |
| 4965 | 4967 | ||
| 4966 | qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char), | 4968 | qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q, |
| 4967 | GFP_KERNEL); | 4969 | GFP_KERNEL); |
| 4968 | if (!qib_param_field) { | 4970 | if (!qib_param_field) { |
| 4969 | rc = -ENOMEM; | 4971 | rc = -ENOMEM; |
| 4970 | goto out_free_nothing; | 4972 | goto out_free_nothing; |
| @@ -4973,8 +4975,8 @@ static int qeth_qdio_establish(struct qeth_card *card) | |||
| 4973 | qeth_create_qib_param_field(card, qib_param_field); | 4975 | qeth_create_qib_param_field(card, qib_param_field); |
| 4974 | qeth_create_qib_param_field_blkt(card, qib_param_field); | 4976 | qeth_create_qib_param_field_blkt(card, qib_param_field); |
| 4975 | 4977 | ||
| 4976 | in_sbal_ptrs = kzalloc(card->qdio.no_in_queues * | 4978 | in_sbal_ptrs = kcalloc(card->qdio.no_in_queues * QDIO_MAX_BUFFERS_PER_Q, |
| 4977 | QDIO_MAX_BUFFERS_PER_Q * sizeof(void *), | 4979 | sizeof(void *), |
| 4978 | GFP_KERNEL); | 4980 | GFP_KERNEL); |
| 4979 | if (!in_sbal_ptrs) { | 4981 | if (!in_sbal_ptrs) { |
| 4980 | rc = -ENOMEM; | 4982 | rc = -ENOMEM; |
| @@ -4985,7 +4987,7 @@ static int qeth_qdio_establish(struct qeth_card *card) | |||
| 4985 | virt_to_phys(card->qdio.in_q->bufs[i].buffer); | 4987 | virt_to_phys(card->qdio.in_q->bufs[i].buffer); |
| 4986 | } | 4988 | } |
| 4987 | 4989 | ||
| 4988 | queue_start_poll = kzalloc(sizeof(void *) * card->qdio.no_in_queues, | 4990 | queue_start_poll = kcalloc(card->qdio.no_in_queues, sizeof(void *), |
| 4989 | GFP_KERNEL); | 4991 | GFP_KERNEL); |
| 4990 | if (!queue_start_poll) { | 4992 | if (!queue_start_poll) { |
| 4991 | rc = -ENOMEM; | 4993 | rc = -ENOMEM; |
| @@ -4997,8 +4999,9 @@ static int qeth_qdio_establish(struct qeth_card *card) | |||
| 4997 | qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll); | 4999 | qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll); |
| 4998 | 5000 | ||
| 4999 | out_sbal_ptrs = | 5001 | out_sbal_ptrs = |
| 5000 | kzalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q * | 5002 | kcalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q, |
| 5001 | sizeof(void *), GFP_KERNEL); | 5003 | sizeof(void *), |
| 5004 | GFP_KERNEL); | ||
| 5002 | if (!out_sbal_ptrs) { | 5005 | if (!out_sbal_ptrs) { |
| 5003 | rc = -ENOMEM; | 5006 | rc = -ENOMEM; |
| 5004 | goto out_free_queue_start_poll; | 5007 | goto out_free_queue_start_poll; |
diff --git a/drivers/scsi/BusLogic.c b/drivers/scsi/BusLogic.c index 35380a58d3f0..0d4ffe0ae306 100644 --- a/drivers/scsi/BusLogic.c +++ b/drivers/scsi/BusLogic.c | |||
| @@ -2366,7 +2366,7 @@ static int __init blogic_init(void) | |||
| 2366 | if (blogic_probe_options.noprobe) | 2366 | if (blogic_probe_options.noprobe) |
| 2367 | return -ENODEV; | 2367 | return -ENODEV; |
| 2368 | blogic_probeinfo_list = | 2368 | blogic_probeinfo_list = |
| 2369 | kzalloc(BLOGIC_MAX_ADAPTERS * sizeof(struct blogic_probeinfo), | 2369 | kcalloc(BLOGIC_MAX_ADAPTERS, sizeof(struct blogic_probeinfo), |
| 2370 | GFP_KERNEL); | 2370 | GFP_KERNEL); |
| 2371 | if (blogic_probeinfo_list == NULL) { | 2371 | if (blogic_probeinfo_list == NULL) { |
| 2372 | blogic_err("BusLogic: Unable to allocate Probe Info List\n", | 2372 | blogic_err("BusLogic: Unable to allocate Probe Info List\n", |
diff --git a/drivers/scsi/aacraid/aachba.c b/drivers/scsi/aacraid/aachba.c index e7961cbd2c55..a9831bd37a73 100644 --- a/drivers/scsi/aacraid/aachba.c +++ b/drivers/scsi/aacraid/aachba.c | |||
| @@ -4132,7 +4132,7 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int | |||
| 4132 | if (aac_convert_sgl == 0) | 4132 | if (aac_convert_sgl == 0) |
| 4133 | return 0; | 4133 | return 0; |
| 4134 | 4134 | ||
| 4135 | sge = kmalloc(nseg_new * sizeof(struct sge_ieee1212), GFP_ATOMIC); | 4135 | sge = kmalloc_array(nseg_new, sizeof(struct sge_ieee1212), GFP_ATOMIC); |
| 4136 | if (sge == NULL) | 4136 | if (sge == NULL) |
| 4137 | return -ENOMEM; | 4137 | return -ENOMEM; |
| 4138 | 4138 | ||
diff --git a/drivers/scsi/aacraid/linit.c b/drivers/scsi/aacraid/linit.c index f24fb942065d..04443577d48b 100644 --- a/drivers/scsi/aacraid/linit.c +++ b/drivers/scsi/aacraid/linit.c | |||
| @@ -1681,7 +1681,9 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 1681 | if (aac_reset_devices || reset_devices) | 1681 | if (aac_reset_devices || reset_devices) |
| 1682 | aac->init_reset = true; | 1682 | aac->init_reset = true; |
| 1683 | 1683 | ||
| 1684 | aac->fibs = kzalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL); | 1684 | aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB, |
| 1685 | sizeof(struct fib), | ||
| 1686 | GFP_KERNEL); | ||
| 1685 | if (!aac->fibs) | 1687 | if (!aac->fibs) |
| 1686 | goto out_free_host; | 1688 | goto out_free_host; |
| 1687 | spin_lock_init(&aac->fib_lock); | 1689 | spin_lock_init(&aac->fib_lock); |
diff --git a/drivers/scsi/aha1542.c b/drivers/scsi/aha1542.c index 124217927c4a..41add33e3f1f 100644 --- a/drivers/scsi/aha1542.c +++ b/drivers/scsi/aha1542.c | |||
| @@ -400,7 +400,8 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) | |||
| 400 | #endif | 400 | #endif |
| 401 | if (bufflen) { /* allocate memory before taking host_lock */ | 401 | if (bufflen) { /* allocate memory before taking host_lock */ |
| 402 | sg_count = scsi_sg_count(cmd); | 402 | sg_count = scsi_sg_count(cmd); |
| 403 | cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA); | 403 | cptr = kmalloc_array(sg_count, sizeof(*cptr), |
| 404 | GFP_KERNEL | GFP_DMA); | ||
| 404 | if (!cptr) | 405 | if (!cptr) |
| 405 | return SCSI_MLQUEUE_HOST_BUSY; | 406 | return SCSI_MLQUEUE_HOST_BUSY; |
| 406 | } else { | 407 | } else { |
diff --git a/drivers/scsi/aic7xxx/aic79xx_core.c b/drivers/scsi/aic7xxx/aic79xx_core.c index 034f4eebb160..67d292dcc607 100644 --- a/drivers/scsi/aic7xxx/aic79xx_core.c +++ b/drivers/scsi/aic7xxx/aic79xx_core.c | |||
| @@ -7063,7 +7063,8 @@ ahd_init(struct ahd_softc *ahd) | |||
| 7063 | AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); | 7063 | AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK); |
| 7064 | 7064 | ||
| 7065 | ahd->stack_size = ahd_probe_stack_size(ahd); | 7065 | ahd->stack_size = ahd_probe_stack_size(ahd); |
| 7066 | ahd->saved_stack = kmalloc(ahd->stack_size * sizeof(uint16_t), GFP_ATOMIC); | 7066 | ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t), |
| 7067 | GFP_ATOMIC); | ||
| 7067 | if (ahd->saved_stack == NULL) | 7068 | if (ahd->saved_stack == NULL) |
| 7068 | return (ENOMEM); | 7069 | return (ENOMEM); |
| 7069 | 7070 | ||
diff --git a/drivers/scsi/aic7xxx/aic7xxx_core.c b/drivers/scsi/aic7xxx/aic7xxx_core.c index e97eceacf522..915a34f141e4 100644 --- a/drivers/scsi/aic7xxx/aic7xxx_core.c +++ b/drivers/scsi/aic7xxx/aic7xxx_core.c | |||
| @@ -4779,8 +4779,8 @@ ahc_init_scbdata(struct ahc_softc *ahc) | |||
| 4779 | SLIST_INIT(&scb_data->sg_maps); | 4779 | SLIST_INIT(&scb_data->sg_maps); |
| 4780 | 4780 | ||
| 4781 | /* Allocate SCB resources */ | 4781 | /* Allocate SCB resources */ |
| 4782 | scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC, | 4782 | scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb), |
| 4783 | GFP_ATOMIC); | 4783 | GFP_ATOMIC); |
| 4784 | if (scb_data->scbarray == NULL) | 4784 | if (scb_data->scbarray == NULL) |
| 4785 | return (ENOMEM); | 4785 | return (ENOMEM); |
| 4786 | 4786 | ||
diff --git a/drivers/scsi/aic94xx/aic94xx_hwi.c b/drivers/scsi/aic94xx/aic94xx_hwi.c index 2dbc8330d7d3..3b8ad55e59de 100644 --- a/drivers/scsi/aic94xx/aic94xx_hwi.c +++ b/drivers/scsi/aic94xx/aic94xx_hwi.c | |||
| @@ -220,8 +220,9 @@ static int asd_init_scbs(struct asd_ha_struct *asd_ha) | |||
| 220 | 220 | ||
| 221 | /* allocate the index array and bitmap */ | 221 | /* allocate the index array and bitmap */ |
| 222 | asd_ha->seq.tc_index_bitmap_bits = asd_ha->hw_prof.max_scbs; | 222 | asd_ha->seq.tc_index_bitmap_bits = asd_ha->hw_prof.max_scbs; |
| 223 | asd_ha->seq.tc_index_array = kzalloc(asd_ha->seq.tc_index_bitmap_bits* | 223 | asd_ha->seq.tc_index_array = kcalloc(asd_ha->seq.tc_index_bitmap_bits, |
| 224 | sizeof(void *), GFP_KERNEL); | 224 | sizeof(void *), |
| 225 | GFP_KERNEL); | ||
| 225 | if (!asd_ha->seq.tc_index_array) | 226 | if (!asd_ha->seq.tc_index_array) |
| 226 | return -ENOMEM; | 227 | return -ENOMEM; |
| 227 | 228 | ||
| @@ -291,7 +292,8 @@ static int asd_alloc_edbs(struct asd_ha_struct *asd_ha, gfp_t gfp_flags) | |||
| 291 | struct asd_seq_data *seq = &asd_ha->seq; | 292 | struct asd_seq_data *seq = &asd_ha->seq; |
| 292 | int i; | 293 | int i; |
| 293 | 294 | ||
| 294 | seq->edb_arr = kmalloc(seq->num_edbs*sizeof(*seq->edb_arr), gfp_flags); | 295 | seq->edb_arr = kmalloc_array(seq->num_edbs, sizeof(*seq->edb_arr), |
| 296 | gfp_flags); | ||
| 295 | if (!seq->edb_arr) | 297 | if (!seq->edb_arr) |
| 296 | return -ENOMEM; | 298 | return -ENOMEM; |
| 297 | 299 | ||
| @@ -323,8 +325,8 @@ static int asd_alloc_escbs(struct asd_ha_struct *asd_ha, | |||
| 323 | struct asd_ascb *escb; | 325 | struct asd_ascb *escb; |
| 324 | int i, escbs; | 326 | int i, escbs; |
| 325 | 327 | ||
| 326 | seq->escb_arr = kmalloc(seq->num_escbs*sizeof(*seq->escb_arr), | 328 | seq->escb_arr = kmalloc_array(seq->num_escbs, sizeof(*seq->escb_arr), |
| 327 | gfp_flags); | 329 | gfp_flags); |
| 328 | if (!seq->escb_arr) | 330 | if (!seq->escb_arr) |
| 329 | return -ENOMEM; | 331 | return -ENOMEM; |
| 330 | 332 | ||
diff --git a/drivers/scsi/aic94xx/aic94xx_init.c b/drivers/scsi/aic94xx/aic94xx_init.c index 6c838865ac5a..80e5b283fd81 100644 --- a/drivers/scsi/aic94xx/aic94xx_init.c +++ b/drivers/scsi/aic94xx/aic94xx_init.c | |||
| @@ -350,7 +350,7 @@ static ssize_t asd_store_update_bios(struct device *dev, | |||
| 350 | int flash_command = FLASH_CMD_NONE; | 350 | int flash_command = FLASH_CMD_NONE; |
| 351 | int err = 0; | 351 | int err = 0; |
| 352 | 352 | ||
| 353 | cmd_ptr = kzalloc(count*2, GFP_KERNEL); | 353 | cmd_ptr = kcalloc(count, 2, GFP_KERNEL); |
| 354 | 354 | ||
| 355 | if (!cmd_ptr) { | 355 | if (!cmd_ptr) { |
| 356 | err = FAIL_OUT_MEMORY; | 356 | err = FAIL_OUT_MEMORY; |
diff --git a/drivers/scsi/arm/queue.c b/drivers/scsi/arm/queue.c index 3441ce3ebabf..996dfe903928 100644 --- a/drivers/scsi/arm/queue.c +++ b/drivers/scsi/arm/queue.c | |||
| @@ -70,7 +70,7 @@ int queue_initialise (Queue_t *queue) | |||
| 70 | * need to keep free lists or allocate this | 70 | * need to keep free lists or allocate this |
| 71 | * memory. | 71 | * memory. |
| 72 | */ | 72 | */ |
| 73 | queue->alloc = q = kmalloc(sizeof(QE_t) * nqueues, GFP_KERNEL); | 73 | queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL); |
| 74 | if (q) { | 74 | if (q) { |
| 75 | for (; nqueues; q++, nqueues--) { | 75 | for (; nqueues; q++, nqueues--) { |
| 76 | SET_MAGIC(q, QUEUE_MAGIC_FREE); | 76 | SET_MAGIC(q, QUEUE_MAGIC_FREE); |
diff --git a/drivers/scsi/be2iscsi/be_main.c b/drivers/scsi/be2iscsi/be_main.c index b3cfdd5f4d1c..818d185d63f0 100644 --- a/drivers/scsi/be2iscsi/be_main.c +++ b/drivers/scsi/be2iscsi/be_main.c | |||
| @@ -2467,8 +2467,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) | |||
| 2467 | 2467 | ||
| 2468 | /* Allocate memory for wrb_context */ | 2468 | /* Allocate memory for wrb_context */ |
| 2469 | phwi_ctrlr = phba->phwi_ctrlr; | 2469 | phwi_ctrlr = phba->phwi_ctrlr; |
| 2470 | phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) * | 2470 | phwi_ctrlr->wrb_context = kcalloc(phba->params.cxns_per_ctrl, |
| 2471 | phba->params.cxns_per_ctrl, | 2471 | sizeof(struct hwi_wrb_context), |
| 2472 | GFP_KERNEL); | 2472 | GFP_KERNEL); |
| 2473 | if (!phwi_ctrlr->wrb_context) { | 2473 | if (!phwi_ctrlr->wrb_context) { |
| 2474 | kfree(phba->phwi_ctrlr); | 2474 | kfree(phba->phwi_ctrlr); |
| @@ -2483,8 +2483,9 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) | |||
| 2483 | return -ENOMEM; | 2483 | return -ENOMEM; |
| 2484 | } | 2484 | } |
| 2485 | 2485 | ||
| 2486 | mem_arr_orig = kmalloc(sizeof(*mem_arr_orig) * BEISCSI_MAX_FRAGS_INIT, | 2486 | mem_arr_orig = kmalloc_array(BEISCSI_MAX_FRAGS_INIT, |
| 2487 | GFP_KERNEL); | 2487 | sizeof(*mem_arr_orig), |
| 2488 | GFP_KERNEL); | ||
| 2488 | if (!mem_arr_orig) { | 2489 | if (!mem_arr_orig) { |
| 2489 | kfree(phba->init_mem); | 2490 | kfree(phba->init_mem); |
| 2490 | kfree(phwi_ctrlr->wrb_context); | 2491 | kfree(phwi_ctrlr->wrb_context); |
| @@ -2533,8 +2534,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) | |||
| 2533 | } while (alloc_size); | 2534 | } while (alloc_size); |
| 2534 | mem_descr->num_elements = j; | 2535 | mem_descr->num_elements = j; |
| 2535 | mem_descr->size_in_bytes = phba->mem_req[i]; | 2536 | mem_descr->size_in_bytes = phba->mem_req[i]; |
| 2536 | mem_descr->mem_array = kmalloc(sizeof(*mem_arr) * j, | 2537 | mem_descr->mem_array = kmalloc_array(j, sizeof(*mem_arr), |
| 2537 | GFP_KERNEL); | 2538 | GFP_KERNEL); |
| 2538 | if (!mem_descr->mem_array) | 2539 | if (!mem_descr->mem_array) |
| 2539 | goto free_mem; | 2540 | goto free_mem; |
| 2540 | 2541 | ||
| @@ -2620,8 +2621,8 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | |||
| 2620 | 2621 | ||
| 2621 | /* Allocate memory for WRBQ */ | 2622 | /* Allocate memory for WRBQ */ |
| 2622 | phwi_ctxt = phwi_ctrlr->phwi_ctxt; | 2623 | phwi_ctxt = phwi_ctrlr->phwi_ctxt; |
| 2623 | phwi_ctxt->be_wrbq = kzalloc(sizeof(struct be_queue_info) * | 2624 | phwi_ctxt->be_wrbq = kcalloc(phba->params.cxns_per_ctrl, |
| 2624 | phba->params.cxns_per_ctrl, | 2625 | sizeof(struct be_queue_info), |
| 2625 | GFP_KERNEL); | 2626 | GFP_KERNEL); |
| 2626 | if (!phwi_ctxt->be_wrbq) { | 2627 | if (!phwi_ctxt->be_wrbq) { |
| 2627 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2628 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| @@ -2632,16 +2633,18 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) | |||
| 2632 | for (index = 0; index < phba->params.cxns_per_ctrl; index++) { | 2633 | for (index = 0; index < phba->params.cxns_per_ctrl; index++) { |
| 2633 | pwrb_context = &phwi_ctrlr->wrb_context[index]; | 2634 | pwrb_context = &phwi_ctrlr->wrb_context[index]; |
| 2634 | pwrb_context->pwrb_handle_base = | 2635 | pwrb_context->pwrb_handle_base = |
| 2635 | kzalloc(sizeof(struct wrb_handle *) * | 2636 | kcalloc(phba->params.wrbs_per_cxn, |
| 2636 | phba->params.wrbs_per_cxn, GFP_KERNEL); | 2637 | sizeof(struct wrb_handle *), |
| 2638 | GFP_KERNEL); | ||
| 2637 | if (!pwrb_context->pwrb_handle_base) { | 2639 | if (!pwrb_context->pwrb_handle_base) { |
| 2638 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2640 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 2639 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | 2641 | "BM_%d : Mem Alloc Failed. Failing to load\n"); |
| 2640 | goto init_wrb_hndl_failed; | 2642 | goto init_wrb_hndl_failed; |
| 2641 | } | 2643 | } |
| 2642 | pwrb_context->pwrb_handle_basestd = | 2644 | pwrb_context->pwrb_handle_basestd = |
| 2643 | kzalloc(sizeof(struct wrb_handle *) * | 2645 | kcalloc(phba->params.wrbs_per_cxn, |
| 2644 | phba->params.wrbs_per_cxn, GFP_KERNEL); | 2646 | sizeof(struct wrb_handle *), |
| 2647 | GFP_KERNEL); | ||
| 2645 | if (!pwrb_context->pwrb_handle_basestd) { | 2648 | if (!pwrb_context->pwrb_handle_basestd) { |
| 2646 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 2649 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 2647 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | 2650 | "BM_%d : Mem Alloc Failed. Failing to load\n"); |
| @@ -3353,8 +3356,9 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba, | |||
| 3353 | idx = 0; | 3356 | idx = 0; |
| 3354 | mem_descr = phba->init_mem; | 3357 | mem_descr = phba->init_mem; |
| 3355 | mem_descr += HWI_MEM_WRB; | 3358 | mem_descr += HWI_MEM_WRB; |
| 3356 | pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl, | 3359 | pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl, |
| 3357 | GFP_KERNEL); | 3360 | sizeof(*pwrb_arr), |
| 3361 | GFP_KERNEL); | ||
| 3358 | if (!pwrb_arr) { | 3362 | if (!pwrb_arr) { |
| 3359 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3363 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 3360 | "BM_%d : Memory alloc failed in create wrb ring.\n"); | 3364 | "BM_%d : Memory alloc failed in create wrb ring.\n"); |
| @@ -3894,18 +3898,18 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) | |||
| 3894 | mem_descr_sglh = phba->init_mem; | 3898 | mem_descr_sglh = phba->init_mem; |
| 3895 | mem_descr_sglh += HWI_MEM_SGLH; | 3899 | mem_descr_sglh += HWI_MEM_SGLH; |
| 3896 | if (1 == mem_descr_sglh->num_elements) { | 3900 | if (1 == mem_descr_sglh->num_elements) { |
| 3897 | phba->io_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * | 3901 | phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl, |
| 3898 | phba->params.ios_per_ctrl, | 3902 | sizeof(struct sgl_handle *), |
| 3899 | GFP_KERNEL); | 3903 | GFP_KERNEL); |
| 3900 | if (!phba->io_sgl_hndl_base) { | 3904 | if (!phba->io_sgl_hndl_base) { |
| 3901 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3905 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 3902 | "BM_%d : Mem Alloc Failed. Failing to load\n"); | 3906 | "BM_%d : Mem Alloc Failed. Failing to load\n"); |
| 3903 | return -ENOMEM; | 3907 | return -ENOMEM; |
| 3904 | } | 3908 | } |
| 3905 | phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) * | 3909 | phba->eh_sgl_hndl_base = |
| 3906 | (phba->params.icds_per_ctrl - | 3910 | kcalloc(phba->params.icds_per_ctrl - |
| 3907 | phba->params.ios_per_ctrl), | 3911 | phba->params.ios_per_ctrl, |
| 3908 | GFP_KERNEL); | 3912 | sizeof(struct sgl_handle *), GFP_KERNEL); |
| 3909 | if (!phba->eh_sgl_hndl_base) { | 3913 | if (!phba->eh_sgl_hndl_base) { |
| 3910 | kfree(phba->io_sgl_hndl_base); | 3914 | kfree(phba->io_sgl_hndl_base); |
| 3911 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 3915 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| @@ -4032,8 +4036,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) | |||
| 4032 | phba->cid_array_info[ulp_num] = ptr_cid_info; | 4036 | phba->cid_array_info[ulp_num] = ptr_cid_info; |
| 4033 | } | 4037 | } |
| 4034 | } | 4038 | } |
| 4035 | phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) * | 4039 | phba->ep_array = kcalloc(phba->params.cxns_per_ctrl, |
| 4036 | phba->params.cxns_per_ctrl, GFP_KERNEL); | 4040 | sizeof(struct iscsi_endpoint *), |
| 4041 | GFP_KERNEL); | ||
| 4037 | if (!phba->ep_array) { | 4042 | if (!phba->ep_array) { |
| 4038 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4043 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 4039 | "BM_%d : Failed to allocate memory in " | 4044 | "BM_%d : Failed to allocate memory in " |
| @@ -4043,8 +4048,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) | |||
| 4043 | goto free_memory; | 4048 | goto free_memory; |
| 4044 | } | 4049 | } |
| 4045 | 4050 | ||
| 4046 | phba->conn_table = kzalloc(sizeof(struct beiscsi_conn *) * | 4051 | phba->conn_table = kcalloc(phba->params.cxns_per_ctrl, |
| 4047 | phba->params.cxns_per_ctrl, GFP_KERNEL); | 4052 | sizeof(struct beiscsi_conn *), |
| 4053 | GFP_KERNEL); | ||
| 4048 | if (!phba->conn_table) { | 4054 | if (!phba->conn_table) { |
| 4049 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, | 4055 | beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT, |
| 4050 | "BM_%d : Failed to allocate memory in" | 4056 | "BM_%d : Failed to allocate memory in" |
diff --git a/drivers/scsi/bfa/bfad_attr.c b/drivers/scsi/bfa/bfad_attr.c index d4d276c757ea..26b0fa4e90b5 100644 --- a/drivers/scsi/bfa/bfad_attr.c +++ b/drivers/scsi/bfa/bfad_attr.c | |||
| @@ -927,7 +927,7 @@ bfad_im_num_of_discovered_ports_show(struct device *dev, | |||
| 927 | struct bfa_rport_qualifier_s *rports = NULL; | 927 | struct bfa_rport_qualifier_s *rports = NULL; |
| 928 | unsigned long flags; | 928 | unsigned long flags; |
| 929 | 929 | ||
| 930 | rports = kzalloc(sizeof(struct bfa_rport_qualifier_s) * nrports, | 930 | rports = kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s), |
| 931 | GFP_ATOMIC); | 931 | GFP_ATOMIC); |
| 932 | if (rports == NULL) | 932 | if (rports == NULL) |
| 933 | return snprintf(buf, PAGE_SIZE, "Failed\n"); | 933 | return snprintf(buf, PAGE_SIZE, "Failed\n"); |
diff --git a/drivers/scsi/bfa/bfad_bsg.c b/drivers/scsi/bfa/bfad_bsg.c index 7c884f881180..5d163ca1b366 100644 --- a/drivers/scsi/bfa/bfad_bsg.c +++ b/drivers/scsi/bfa/bfad_bsg.c | |||
| @@ -3252,8 +3252,9 @@ bfad_fcxp_map_sg(struct bfad_s *bfad, void *payload_kbuf, | |||
| 3252 | struct bfa_sge_s *sg_table; | 3252 | struct bfa_sge_s *sg_table; |
| 3253 | int sge_num = 1; | 3253 | int sge_num = 1; |
| 3254 | 3254 | ||
| 3255 | buf_base = kzalloc((sizeof(struct bfad_buf_info) + | 3255 | buf_base = kcalloc(sizeof(struct bfad_buf_info) + |
| 3256 | sizeof(struct bfa_sge_s)) * sge_num, GFP_KERNEL); | 3256 | sizeof(struct bfa_sge_s), |
| 3257 | sge_num, GFP_KERNEL); | ||
| 3257 | if (!buf_base) | 3258 | if (!buf_base) |
| 3258 | return NULL; | 3259 | return NULL; |
| 3259 | 3260 | ||
diff --git a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c index 65de1d0578a1..f00045813378 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_fcoe.c +++ b/drivers/scsi/bnx2fc/bnx2fc_fcoe.c | |||
| @@ -1397,7 +1397,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic) | |||
| 1397 | hba->next_conn_id = 0; | 1397 | hba->next_conn_id = 0; |
| 1398 | 1398 | ||
| 1399 | hba->tgt_ofld_list = | 1399 | hba->tgt_ofld_list = |
| 1400 | kzalloc(sizeof(struct bnx2fc_rport *) * BNX2FC_NUM_MAX_SESS, | 1400 | kcalloc(BNX2FC_NUM_MAX_SESS, sizeof(struct bnx2fc_rport *), |
| 1401 | GFP_KERNEL); | 1401 | GFP_KERNEL); |
| 1402 | if (!hba->tgt_ofld_list) { | 1402 | if (!hba->tgt_ofld_list) { |
| 1403 | printk(KERN_ERR PFX "Unable to allocate tgt offload list\n"); | 1403 | printk(KERN_ERR PFX "Unable to allocate tgt offload list\n"); |
diff --git a/drivers/scsi/bnx2fc/bnx2fc_io.c b/drivers/scsi/bnx2fc/bnx2fc_io.c index 5a645b8b9af1..350257c13a5b 100644 --- a/drivers/scsi/bnx2fc/bnx2fc_io.c +++ b/drivers/scsi/bnx2fc/bnx2fc_io.c | |||
| @@ -240,15 +240,15 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba) | |||
| 240 | return NULL; | 240 | return NULL; |
| 241 | } | 241 | } |
| 242 | 242 | ||
| 243 | cmgr->free_list = kzalloc(sizeof(*cmgr->free_list) * | 243 | cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list), |
| 244 | arr_sz, GFP_KERNEL); | 244 | GFP_KERNEL); |
| 245 | if (!cmgr->free_list) { | 245 | if (!cmgr->free_list) { |
| 246 | printk(KERN_ERR PFX "failed to alloc free_list\n"); | 246 | printk(KERN_ERR PFX "failed to alloc free_list\n"); |
| 247 | goto mem_err; | 247 | goto mem_err; |
| 248 | } | 248 | } |
| 249 | 249 | ||
| 250 | cmgr->free_list_lock = kzalloc(sizeof(*cmgr->free_list_lock) * | 250 | cmgr->free_list_lock = kcalloc(arr_sz, sizeof(*cmgr->free_list_lock), |
| 251 | arr_sz, GFP_KERNEL); | 251 | GFP_KERNEL); |
| 252 | if (!cmgr->free_list_lock) { | 252 | if (!cmgr->free_list_lock) { |
| 253 | printk(KERN_ERR PFX "failed to alloc free_list_lock\n"); | 253 | printk(KERN_ERR PFX "failed to alloc free_list_lock\n"); |
| 254 | kfree(cmgr->free_list); | 254 | kfree(cmgr->free_list); |
diff --git a/drivers/scsi/csiostor/csio_wr.c b/drivers/scsi/csiostor/csio_wr.c index c0a17789752f..faa357b62c61 100644 --- a/drivers/scsi/csiostor/csio_wr.c +++ b/drivers/scsi/csiostor/csio_wr.c | |||
| @@ -276,7 +276,7 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize, | |||
| 276 | q->un.iq.flq_idx = flq_idx; | 276 | q->un.iq.flq_idx = flq_idx; |
| 277 | 277 | ||
| 278 | flq = wrm->q_arr[q->un.iq.flq_idx]; | 278 | flq = wrm->q_arr[q->un.iq.flq_idx]; |
| 279 | flq->un.fl.bufs = kzalloc(flq->credits * | 279 | flq->un.fl.bufs = kcalloc(flq->credits, |
| 280 | sizeof(struct csio_dma_buf), | 280 | sizeof(struct csio_dma_buf), |
| 281 | GFP_KERNEL); | 281 | GFP_KERNEL); |
| 282 | if (!flq->un.fl.bufs) { | 282 | if (!flq->un.fl.bufs) { |
| @@ -1579,7 +1579,7 @@ csio_wrm_init(struct csio_wrm *wrm, struct csio_hw *hw) | |||
| 1579 | return -EINVAL; | 1579 | return -EINVAL; |
| 1580 | } | 1580 | } |
| 1581 | 1581 | ||
| 1582 | wrm->q_arr = kzalloc(sizeof(struct csio_q *) * wrm->num_q, GFP_KERNEL); | 1582 | wrm->q_arr = kcalloc(wrm->num_q, sizeof(struct csio_q *), GFP_KERNEL); |
| 1583 | if (!wrm->q_arr) | 1583 | if (!wrm->q_arr) |
| 1584 | goto err; | 1584 | goto err; |
| 1585 | 1585 | ||
diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c index 9db645dde35e..bbe77db8938d 100644 --- a/drivers/scsi/esas2r/esas2r_init.c +++ b/drivers/scsi/esas2r/esas2r_init.c | |||
| @@ -833,7 +833,7 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, | |||
| 833 | 833 | ||
| 834 | /* allocate requests for asynchronous events */ | 834 | /* allocate requests for asynchronous events */ |
| 835 | a->first_ae_req = | 835 | a->first_ae_req = |
| 836 | kzalloc(num_ae_requests * sizeof(struct esas2r_request), | 836 | kcalloc(num_ae_requests, sizeof(struct esas2r_request), |
| 837 | GFP_KERNEL); | 837 | GFP_KERNEL); |
| 838 | 838 | ||
| 839 | if (a->first_ae_req == NULL) { | 839 | if (a->first_ae_req == NULL) { |
| @@ -843,8 +843,8 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, | |||
| 843 | } | 843 | } |
| 844 | 844 | ||
| 845 | /* allocate the S/G list memory descriptors */ | 845 | /* allocate the S/G list memory descriptors */ |
| 846 | a->sg_list_mds = kzalloc( | 846 | a->sg_list_mds = kcalloc(num_sg_lists, sizeof(struct esas2r_mem_desc), |
| 847 | num_sg_lists * sizeof(struct esas2r_mem_desc), GFP_KERNEL); | 847 | GFP_KERNEL); |
| 848 | 848 | ||
| 849 | if (a->sg_list_mds == NULL) { | 849 | if (a->sg_list_mds == NULL) { |
| 850 | esas2r_log(ESAS2R_LOG_CRIT, | 850 | esas2r_log(ESAS2R_LOG_CRIT, |
| @@ -854,8 +854,9 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, | |||
| 854 | 854 | ||
| 855 | /* allocate the request table */ | 855 | /* allocate the request table */ |
| 856 | a->req_table = | 856 | a->req_table = |
| 857 | kzalloc((num_requests + num_ae_requests + | 857 | kcalloc(num_requests + num_ae_requests + 1, |
| 858 | 1) * sizeof(struct esas2r_request *), GFP_KERNEL); | 858 | sizeof(struct esas2r_request *), |
| 859 | GFP_KERNEL); | ||
| 859 | 860 | ||
| 860 | if (a->req_table == NULL) { | 861 | if (a->req_table == NULL) { |
| 861 | esas2r_log(ESAS2R_LOG_CRIT, | 862 | esas2r_log(ESAS2R_LOG_CRIT, |
diff --git a/drivers/scsi/fcoe/fcoe_ctlr.c b/drivers/scsi/fcoe/fcoe_ctlr.c index 097f37de6ce9..ea23c8dffc25 100644 --- a/drivers/scsi/fcoe/fcoe_ctlr.c +++ b/drivers/scsi/fcoe/fcoe_ctlr.c | |||
| @@ -1390,8 +1390,8 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, | |||
| 1390 | */ | 1390 | */ |
| 1391 | num_vlink_desc = rlen / sizeof(*vp); | 1391 | num_vlink_desc = rlen / sizeof(*vp); |
| 1392 | if (num_vlink_desc) | 1392 | if (num_vlink_desc) |
| 1393 | vlink_desc_arr = kmalloc(sizeof(vp) * num_vlink_desc, | 1393 | vlink_desc_arr = kmalloc_array(num_vlink_desc, sizeof(vp), |
| 1394 | GFP_ATOMIC); | 1394 | GFP_ATOMIC); |
| 1395 | if (!vlink_desc_arr) | 1395 | if (!vlink_desc_arr) |
| 1396 | return; | 1396 | return; |
| 1397 | num_vlink_desc = 0; | 1397 | num_vlink_desc = 0; |
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c index 6d3e1cb4fea6..139fffa3658a 100644 --- a/drivers/scsi/fnic/fnic_debugfs.c +++ b/drivers/scsi/fnic/fnic_debugfs.c | |||
| @@ -233,8 +233,8 @@ static int fnic_trace_debugfs_open(struct inode *inode, | |||
| 233 | return -ENOMEM; | 233 | return -ENOMEM; |
| 234 | 234 | ||
| 235 | if (*rdata_ptr == fc_trc_flag->fnic_trace) { | 235 | if (*rdata_ptr == fc_trc_flag->fnic_trace) { |
| 236 | fnic_dbg_prt->buffer = vmalloc(3 * | 236 | fnic_dbg_prt->buffer = vmalloc(array3_size(3, trace_max_pages, |
| 237 | (trace_max_pages * PAGE_SIZE)); | 237 | PAGE_SIZE)); |
| 238 | if (!fnic_dbg_prt->buffer) { | 238 | if (!fnic_dbg_prt->buffer) { |
| 239 | kfree(fnic_dbg_prt); | 239 | kfree(fnic_dbg_prt); |
| 240 | return -ENOMEM; | 240 | return -ENOMEM; |
| @@ -244,7 +244,8 @@ static int fnic_trace_debugfs_open(struct inode *inode, | |||
| 244 | fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt); | 244 | fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt); |
| 245 | } else { | 245 | } else { |
| 246 | fnic_dbg_prt->buffer = | 246 | fnic_dbg_prt->buffer = |
| 247 | vmalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); | 247 | vmalloc(array3_size(3, fnic_fc_trace_max_pages, |
| 248 | PAGE_SIZE)); | ||
| 248 | if (!fnic_dbg_prt->buffer) { | 249 | if (!fnic_dbg_prt->buffer) { |
| 249 | kfree(fnic_dbg_prt); | 250 | kfree(fnic_dbg_prt); |
| 250 | return -ENOMEM; | 251 | return -ENOMEM; |
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c index 98597b59c12a..8271785bdb93 100644 --- a/drivers/scsi/fnic/fnic_trace.c +++ b/drivers/scsi/fnic/fnic_trace.c | |||
| @@ -477,8 +477,9 @@ int fnic_trace_buf_init(void) | |||
| 477 | } | 477 | } |
| 478 | memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE)); | 478 | memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE)); |
| 479 | 479 | ||
| 480 | fnic_trace_entries.page_offset = vmalloc(fnic_max_trace_entries * | 480 | fnic_trace_entries.page_offset = |
| 481 | sizeof(unsigned long)); | 481 | vmalloc(array_size(fnic_max_trace_entries, |
| 482 | sizeof(unsigned long))); | ||
| 482 | if (!fnic_trace_entries.page_offset) { | 483 | if (!fnic_trace_entries.page_offset) { |
| 483 | printk(KERN_ERR PFX "Failed to allocate memory for" | 484 | printk(KERN_ERR PFX "Failed to allocate memory for" |
| 484 | " page_offset\n"); | 485 | " page_offset\n"); |
| @@ -555,8 +556,9 @@ int fnic_fc_trace_init(void) | |||
| 555 | 556 | ||
| 556 | fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/ | 557 | fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/ |
| 557 | FC_TRC_SIZE_BYTES; | 558 | FC_TRC_SIZE_BYTES; |
| 558 | fnic_fc_ctlr_trace_buf_p = (unsigned long)vmalloc( | 559 | fnic_fc_ctlr_trace_buf_p = |
| 559 | fnic_fc_trace_max_pages * PAGE_SIZE); | 560 | (unsigned long)vmalloc(array_size(PAGE_SIZE, |
| 561 | fnic_fc_trace_max_pages)); | ||
| 560 | if (!fnic_fc_ctlr_trace_buf_p) { | 562 | if (!fnic_fc_ctlr_trace_buf_p) { |
| 561 | pr_err("fnic: Failed to allocate memory for " | 563 | pr_err("fnic: Failed to allocate memory for " |
| 562 | "FC Control Trace Buf\n"); | 564 | "FC Control Trace Buf\n"); |
| @@ -568,8 +570,9 @@ int fnic_fc_trace_init(void) | |||
| 568 | fnic_fc_trace_max_pages * PAGE_SIZE); | 570 | fnic_fc_trace_max_pages * PAGE_SIZE); |
| 569 | 571 | ||
| 570 | /* Allocate memory for page offset */ | 572 | /* Allocate memory for page offset */ |
| 571 | fc_trace_entries.page_offset = vmalloc(fc_trace_max_entries * | 573 | fc_trace_entries.page_offset = |
| 572 | sizeof(unsigned long)); | 574 | vmalloc(array_size(fc_trace_max_entries, |
| 575 | sizeof(unsigned long))); | ||
| 573 | if (!fc_trace_entries.page_offset) { | 576 | if (!fc_trace_entries.page_offset) { |
| 574 | pr_err("fnic:Failed to allocate memory for page_offset\n"); | 577 | pr_err("fnic:Failed to allocate memory for page_offset\n"); |
| 575 | if (fnic_fc_ctlr_trace_buf_p) { | 578 | if (fnic_fc_ctlr_trace_buf_p) { |
diff --git a/drivers/scsi/hpsa.c b/drivers/scsi/hpsa.c index 3a9eca163db8..af0e628ff396 100644 --- a/drivers/scsi/hpsa.c +++ b/drivers/scsi/hpsa.c | |||
| @@ -1923,8 +1923,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, | |||
| 1923 | } | 1923 | } |
| 1924 | spin_unlock_irqrestore(&h->reset_lock, flags); | 1924 | spin_unlock_irqrestore(&h->reset_lock, flags); |
| 1925 | 1925 | ||
| 1926 | added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL); | 1926 | added = kcalloc(HPSA_MAX_DEVICES, sizeof(*added), GFP_KERNEL); |
| 1927 | removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL); | 1927 | removed = kcalloc(HPSA_MAX_DEVICES, sizeof(*removed), GFP_KERNEL); |
| 1928 | 1928 | ||
| 1929 | if (!added || !removed) { | 1929 | if (!added || !removed) { |
| 1930 | dev_warn(&h->pdev->dev, "out of memory in " | 1930 | dev_warn(&h->pdev->dev, "out of memory in " |
| @@ -2171,14 +2171,15 @@ static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) | |||
| 2171 | return 0; | 2171 | return 0; |
| 2172 | 2172 | ||
| 2173 | h->ioaccel2_cmd_sg_list = | 2173 | h->ioaccel2_cmd_sg_list = |
| 2174 | kzalloc(sizeof(*h->ioaccel2_cmd_sg_list) * h->nr_cmds, | 2174 | kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list), |
| 2175 | GFP_KERNEL); | 2175 | GFP_KERNEL); |
| 2176 | if (!h->ioaccel2_cmd_sg_list) | 2176 | if (!h->ioaccel2_cmd_sg_list) |
| 2177 | return -ENOMEM; | 2177 | return -ENOMEM; |
| 2178 | for (i = 0; i < h->nr_cmds; i++) { | 2178 | for (i = 0; i < h->nr_cmds; i++) { |
| 2179 | h->ioaccel2_cmd_sg_list[i] = | 2179 | h->ioaccel2_cmd_sg_list[i] = |
| 2180 | kmalloc(sizeof(*h->ioaccel2_cmd_sg_list[i]) * | 2180 | kmalloc_array(h->maxsgentries, |
| 2181 | h->maxsgentries, GFP_KERNEL); | 2181 | sizeof(*h->ioaccel2_cmd_sg_list[i]), |
| 2182 | GFP_KERNEL); | ||
| 2182 | if (!h->ioaccel2_cmd_sg_list[i]) | 2183 | if (!h->ioaccel2_cmd_sg_list[i]) |
| 2183 | goto clean; | 2184 | goto clean; |
| 2184 | } | 2185 | } |
| @@ -2210,14 +2211,15 @@ static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) | |||
| 2210 | if (h->chainsize <= 0) | 2211 | if (h->chainsize <= 0) |
| 2211 | return 0; | 2212 | return 0; |
| 2212 | 2213 | ||
| 2213 | h->cmd_sg_list = kzalloc(sizeof(*h->cmd_sg_list) * h->nr_cmds, | 2214 | h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list), |
| 2214 | GFP_KERNEL); | 2215 | GFP_KERNEL); |
| 2215 | if (!h->cmd_sg_list) | 2216 | if (!h->cmd_sg_list) |
| 2216 | return -ENOMEM; | 2217 | return -ENOMEM; |
| 2217 | 2218 | ||
| 2218 | for (i = 0; i < h->nr_cmds; i++) { | 2219 | for (i = 0; i < h->nr_cmds; i++) { |
| 2219 | h->cmd_sg_list[i] = kmalloc(sizeof(*h->cmd_sg_list[i]) * | 2220 | h->cmd_sg_list[i] = kmalloc_array(h->chainsize, |
| 2220 | h->chainsize, GFP_KERNEL); | 2221 | sizeof(*h->cmd_sg_list[i]), |
| 2222 | GFP_KERNEL); | ||
| 2221 | if (!h->cmd_sg_list[i]) | 2223 | if (!h->cmd_sg_list[i]) |
| 2222 | goto clean; | 2224 | goto clean; |
| 2223 | 2225 | ||
| @@ -4319,7 +4321,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) | |||
| 4319 | bool physical_device; | 4321 | bool physical_device; |
| 4320 | DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); | 4322 | DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS); |
| 4321 | 4323 | ||
| 4322 | currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL); | 4324 | currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL); |
| 4323 | physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL); | 4325 | physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL); |
| 4324 | logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL); | 4326 | logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL); |
| 4325 | tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); | 4327 | tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL); |
| @@ -6402,12 +6404,12 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) | |||
| 6402 | status = -EINVAL; | 6404 | status = -EINVAL; |
| 6403 | goto cleanup1; | 6405 | goto cleanup1; |
| 6404 | } | 6406 | } |
| 6405 | buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL); | 6407 | buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(char *), GFP_KERNEL); |
| 6406 | if (!buff) { | 6408 | if (!buff) { |
| 6407 | status = -ENOMEM; | 6409 | status = -ENOMEM; |
| 6408 | goto cleanup1; | 6410 | goto cleanup1; |
| 6409 | } | 6411 | } |
| 6410 | buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL); | 6412 | buff_size = kmalloc_array(SG_ENTRIES_IN_CMD, sizeof(int), GFP_KERNEL); |
| 6411 | if (!buff_size) { | 6413 | if (!buff_size) { |
| 6412 | status = -ENOMEM; | 6414 | status = -ENOMEM; |
| 6413 | goto cleanup1; | 6415 | goto cleanup1; |
| @@ -7151,7 +7153,7 @@ static int controller_reset_failed(struct CfgTable __iomem *cfgtable) | |||
| 7151 | char *driver_ver, *old_driver_ver; | 7153 | char *driver_ver, *old_driver_ver; |
| 7152 | int rc, size = sizeof(cfgtable->driver_version); | 7154 | int rc, size = sizeof(cfgtable->driver_version); |
| 7153 | 7155 | ||
| 7154 | old_driver_ver = kmalloc(2 * size, GFP_KERNEL); | 7156 | old_driver_ver = kmalloc_array(2, size, GFP_KERNEL); |
| 7155 | if (!old_driver_ver) | 7157 | if (!old_driver_ver) |
| 7156 | return -ENOMEM; | 7158 | return -ENOMEM; |
| 7157 | driver_ver = old_driver_ver + size; | 7159 | driver_ver = old_driver_ver + size; |
| @@ -7931,9 +7933,9 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h) | |||
| 7931 | 7933 | ||
| 7932 | static int hpsa_alloc_cmd_pool(struct ctlr_info *h) | 7934 | static int hpsa_alloc_cmd_pool(struct ctlr_info *h) |
| 7933 | { | 7935 | { |
| 7934 | h->cmd_pool_bits = kzalloc( | 7936 | h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG), |
| 7935 | DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) * | 7937 | sizeof(unsigned long), |
| 7936 | sizeof(unsigned long), GFP_KERNEL); | 7938 | GFP_KERNEL); |
| 7937 | h->cmd_pool = pci_alloc_consistent(h->pdev, | 7939 | h->cmd_pool = pci_alloc_consistent(h->pdev, |
| 7938 | h->nr_cmds * sizeof(*h->cmd_pool), | 7940 | h->nr_cmds * sizeof(*h->cmd_pool), |
| 7939 | &(h->cmd_pool_dhandle)); | 7941 | &(h->cmd_pool_dhandle)); |
| @@ -8507,7 +8509,7 @@ static struct ctlr_info *hpda_alloc_ctlr_info(void) | |||
| 8507 | if (!h) | 8509 | if (!h) |
| 8508 | return NULL; | 8510 | return NULL; |
| 8509 | 8511 | ||
| 8510 | h->reply_map = kzalloc(sizeof(*h->reply_map) * nr_cpu_ids, GFP_KERNEL); | 8512 | h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL); |
| 8511 | if (!h->reply_map) { | 8513 | if (!h->reply_map) { |
| 8512 | kfree(h); | 8514 | kfree(h); |
| 8513 | return NULL; | 8515 | return NULL; |
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c index 6615ad8754b8..0a9b8b387bd2 100644 --- a/drivers/scsi/ipr.c +++ b/drivers/scsi/ipr.c | |||
| @@ -4331,9 +4331,11 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg) | |||
| 4331 | } | 4331 | } |
| 4332 | 4332 | ||
| 4333 | if (ioa_cfg->sis64) | 4333 | if (ioa_cfg->sis64) |
| 4334 | ioa_data = vmalloc(IPR_FMT3_MAX_NUM_DUMP_PAGES * sizeof(__be32 *)); | 4334 | ioa_data = vmalloc(array_size(IPR_FMT3_MAX_NUM_DUMP_PAGES, |
| 4335 | sizeof(__be32 *))); | ||
| 4335 | else | 4336 | else |
| 4336 | ioa_data = vmalloc(IPR_FMT2_MAX_NUM_DUMP_PAGES * sizeof(__be32 *)); | 4337 | ioa_data = vmalloc(array_size(IPR_FMT2_MAX_NUM_DUMP_PAGES, |
| 4338 | sizeof(__be32 *))); | ||
| 4337 | 4339 | ||
| 4338 | if (!ioa_data) { | 4340 | if (!ioa_data) { |
| 4339 | ipr_err("Dump memory allocation failed\n"); | 4341 | ipr_err("Dump memory allocation failed\n"); |
| @@ -9713,8 +9715,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) | |||
| 9713 | int i, rc = -ENOMEM; | 9715 | int i, rc = -ENOMEM; |
| 9714 | 9716 | ||
| 9715 | ENTER; | 9717 | ENTER; |
| 9716 | ioa_cfg->res_entries = kzalloc(sizeof(struct ipr_resource_entry) * | 9718 | ioa_cfg->res_entries = kcalloc(ioa_cfg->max_devs_supported, |
| 9717 | ioa_cfg->max_devs_supported, GFP_KERNEL); | 9719 | sizeof(struct ipr_resource_entry), |
| 9720 | GFP_KERNEL); | ||
| 9718 | 9721 | ||
| 9719 | if (!ioa_cfg->res_entries) | 9722 | if (!ioa_cfg->res_entries) |
| 9720 | goto out; | 9723 | goto out; |
| @@ -9775,8 +9778,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) | |||
| 9775 | list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); | 9778 | list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q); |
| 9776 | } | 9779 | } |
| 9777 | 9780 | ||
| 9778 | ioa_cfg->trace = kzalloc(sizeof(struct ipr_trace_entry) * | 9781 | ioa_cfg->trace = kcalloc(IPR_NUM_TRACE_ENTRIES, |
| 9779 | IPR_NUM_TRACE_ENTRIES, GFP_KERNEL); | 9782 | sizeof(struct ipr_trace_entry), |
| 9783 | GFP_KERNEL); | ||
| 9780 | 9784 | ||
| 9781 | if (!ioa_cfg->trace) | 9785 | if (!ioa_cfg->trace) |
| 9782 | goto out_free_hostrcb_dma; | 9786 | goto out_free_hostrcb_dma; |
diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index 05cf4daf8788..08c7b1e25fe4 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c | |||
| @@ -232,14 +232,14 @@ static int isci_register_sas_ha(struct isci_host *isci_host) | |||
| 232 | struct asd_sas_phy **sas_phys; | 232 | struct asd_sas_phy **sas_phys; |
| 233 | struct asd_sas_port **sas_ports; | 233 | struct asd_sas_port **sas_ports; |
| 234 | 234 | ||
| 235 | sas_phys = devm_kzalloc(&isci_host->pdev->dev, | 235 | sas_phys = devm_kcalloc(&isci_host->pdev->dev, |
| 236 | SCI_MAX_PHYS * sizeof(void *), | 236 | SCI_MAX_PHYS, sizeof(void *), |
| 237 | GFP_KERNEL); | 237 | GFP_KERNEL); |
| 238 | if (!sas_phys) | 238 | if (!sas_phys) |
| 239 | return -ENOMEM; | 239 | return -ENOMEM; |
| 240 | 240 | ||
| 241 | sas_ports = devm_kzalloc(&isci_host->pdev->dev, | 241 | sas_ports = devm_kcalloc(&isci_host->pdev->dev, |
| 242 | SCI_MAX_PORTS * sizeof(void *), | 242 | SCI_MAX_PORTS, sizeof(void *), |
| 243 | GFP_KERNEL); | 243 | GFP_KERNEL); |
| 244 | if (!sas_ports) | 244 | if (!sas_ports) |
| 245 | return -ENOMEM; | 245 | return -ENOMEM; |
diff --git a/drivers/scsi/libiscsi.c b/drivers/scsi/libiscsi.c index 71bdc0b52cf9..d6093838f5f2 100644 --- a/drivers/scsi/libiscsi.c +++ b/drivers/scsi/libiscsi.c | |||
| @@ -2576,7 +2576,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size) | |||
| 2576 | * the array. */ | 2576 | * the array. */ |
| 2577 | if (items) | 2577 | if (items) |
| 2578 | num_arrays++; | 2578 | num_arrays++; |
| 2579 | q->pool = kvzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL); | 2579 | q->pool = kvcalloc(num_arrays * max, sizeof(void *), GFP_KERNEL); |
| 2580 | if (q->pool == NULL) | 2580 | if (q->pool == NULL) |
| 2581 | return -ENOMEM; | 2581 | return -ENOMEM; |
| 2582 | 2582 | ||
diff --git a/drivers/scsi/libsas/sas_expander.c b/drivers/scsi/libsas/sas_expander.c index 8b7114348def..fadc99cb60df 100644 --- a/drivers/scsi/libsas/sas_expander.c +++ b/drivers/scsi/libsas/sas_expander.c | |||
| @@ -443,7 +443,7 @@ static int sas_expander_discover(struct domain_device *dev) | |||
| 443 | struct expander_device *ex = &dev->ex_dev; | 443 | struct expander_device *ex = &dev->ex_dev; |
| 444 | int res = -ENOMEM; | 444 | int res = -ENOMEM; |
| 445 | 445 | ||
| 446 | ex->ex_phy = kzalloc(sizeof(*ex->ex_phy)*ex->num_phys, GFP_KERNEL); | 446 | ex->ex_phy = kcalloc(ex->num_phys, sizeof(*ex->ex_phy), GFP_KERNEL); |
| 447 | if (!ex->ex_phy) | 447 | if (!ex->ex_phy) |
| 448 | return -ENOMEM; | 448 | return -ENOMEM; |
| 449 | 449 | ||
diff --git a/drivers/scsi/lpfc/lpfc_init.c b/drivers/scsi/lpfc/lpfc_init.c index 7ae343b14630..52cae87da0d2 100644 --- a/drivers/scsi/lpfc/lpfc_init.c +++ b/drivers/scsi/lpfc/lpfc_init.c | |||
| @@ -5723,8 +5723,9 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba) | |||
| 5723 | } | 5723 | } |
| 5724 | 5724 | ||
| 5725 | if (!phba->sli.sli3_ring) | 5725 | if (!phba->sli.sli3_ring) |
| 5726 | phba->sli.sli3_ring = kzalloc(LPFC_SLI3_MAX_RING * | 5726 | phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING, |
| 5727 | sizeof(struct lpfc_sli_ring), GFP_KERNEL); | 5727 | sizeof(struct lpfc_sli_ring), |
| 5728 | GFP_KERNEL); | ||
| 5728 | if (!phba->sli.sli3_ring) | 5729 | if (!phba->sli.sli3_ring) |
| 5729 | return -ENOMEM; | 5730 | return -ENOMEM; |
| 5730 | 5731 | ||
| @@ -6233,7 +6234,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) | |||
| 6233 | 6234 | ||
| 6234 | /* Allocate eligible FCF bmask memory for FCF roundrobin failover */ | 6235 | /* Allocate eligible FCF bmask memory for FCF roundrobin failover */ |
| 6235 | longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; | 6236 | longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG; |
| 6236 | phba->fcf.fcf_rr_bmask = kzalloc(longs * sizeof(unsigned long), | 6237 | phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long), |
| 6237 | GFP_KERNEL); | 6238 | GFP_KERNEL); |
| 6238 | if (!phba->fcf.fcf_rr_bmask) { | 6239 | if (!phba->fcf.fcf_rr_bmask) { |
| 6239 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, | 6240 | lpfc_printf_log(phba, KERN_ERR, LOG_INIT, |
diff --git a/drivers/scsi/lpfc/lpfc_mem.c b/drivers/scsi/lpfc/lpfc_mem.c index 41361662ff08..0758edb9dfe2 100644 --- a/drivers/scsi/lpfc/lpfc_mem.c +++ b/drivers/scsi/lpfc/lpfc_mem.c | |||
| @@ -120,8 +120,9 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align) | |||
| 120 | if (!phba->lpfc_mbuf_pool) | 120 | if (!phba->lpfc_mbuf_pool) |
| 121 | goto fail_free_dma_buf_pool; | 121 | goto fail_free_dma_buf_pool; |
| 122 | 122 | ||
| 123 | pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) * | 123 | pool->elements = kmalloc_array(LPFC_MBUF_POOL_SIZE, |
| 124 | LPFC_MBUF_POOL_SIZE, GFP_KERNEL); | 124 | sizeof(struct lpfc_dmabuf), |
| 125 | GFP_KERNEL); | ||
| 125 | if (!pool->elements) | 126 | if (!pool->elements) |
| 126 | goto fail_free_lpfc_mbuf_pool; | 127 | goto fail_free_lpfc_mbuf_pool; |
| 127 | 128 | ||
diff --git a/drivers/scsi/lpfc/lpfc_sli.c b/drivers/scsi/lpfc/lpfc_sli.c index 4b70d53acb72..6f3c00a233ec 100644 --- a/drivers/scsi/lpfc/lpfc_sli.c +++ b/drivers/scsi/lpfc/lpfc_sli.c | |||
| @@ -1720,7 +1720,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) | |||
| 1720 | - LPFC_IOCBQ_LOOKUP_INCREMENT)) { | 1720 | - LPFC_IOCBQ_LOOKUP_INCREMENT)) { |
| 1721 | new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; | 1721 | new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT; |
| 1722 | spin_unlock_irq(&phba->hbalock); | 1722 | spin_unlock_irq(&phba->hbalock); |
| 1723 | new_arr = kzalloc(new_len * sizeof (struct lpfc_iocbq *), | 1723 | new_arr = kcalloc(new_len, sizeof(struct lpfc_iocbq *), |
| 1724 | GFP_KERNEL); | 1724 | GFP_KERNEL); |
| 1725 | if (new_arr) { | 1725 | if (new_arr) { |
| 1726 | spin_lock_irq(&phba->hbalock); | 1726 | spin_lock_irq(&phba->hbalock); |
| @@ -5142,16 +5142,17 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba) | |||
| 5142 | */ | 5142 | */ |
| 5143 | if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) { | 5143 | if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) { |
| 5144 | longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG; | 5144 | longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG; |
| 5145 | phba->vpi_bmask = kzalloc(longs * sizeof(unsigned long), | 5145 | phba->vpi_bmask = kcalloc(longs, |
| 5146 | sizeof(unsigned long), | ||
| 5146 | GFP_KERNEL); | 5147 | GFP_KERNEL); |
| 5147 | if (!phba->vpi_bmask) { | 5148 | if (!phba->vpi_bmask) { |
| 5148 | rc = -ENOMEM; | 5149 | rc = -ENOMEM; |
| 5149 | goto lpfc_sli_hba_setup_error; | 5150 | goto lpfc_sli_hba_setup_error; |
| 5150 | } | 5151 | } |
| 5151 | 5152 | ||
| 5152 | phba->vpi_ids = kzalloc( | 5153 | phba->vpi_ids = kcalloc(phba->max_vpi + 1, |
| 5153 | (phba->max_vpi+1) * sizeof(uint16_t), | 5154 | sizeof(uint16_t), |
| 5154 | GFP_KERNEL); | 5155 | GFP_KERNEL); |
| 5155 | if (!phba->vpi_ids) { | 5156 | if (!phba->vpi_ids) { |
| 5156 | kfree(phba->vpi_bmask); | 5157 | kfree(phba->vpi_bmask); |
| 5157 | rc = -ENOMEM; | 5158 | rc = -ENOMEM; |
| @@ -5836,14 +5837,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) | |||
| 5836 | length = sizeof(struct lpfc_rsrc_blks); | 5837 | length = sizeof(struct lpfc_rsrc_blks); |
| 5837 | switch (type) { | 5838 | switch (type) { |
| 5838 | case LPFC_RSC_TYPE_FCOE_RPI: | 5839 | case LPFC_RSC_TYPE_FCOE_RPI: |
| 5839 | phba->sli4_hba.rpi_bmask = kzalloc(longs * | 5840 | phba->sli4_hba.rpi_bmask = kcalloc(longs, |
| 5840 | sizeof(unsigned long), | 5841 | sizeof(unsigned long), |
| 5841 | GFP_KERNEL); | 5842 | GFP_KERNEL); |
| 5842 | if (unlikely(!phba->sli4_hba.rpi_bmask)) { | 5843 | if (unlikely(!phba->sli4_hba.rpi_bmask)) { |
| 5843 | rc = -ENOMEM; | 5844 | rc = -ENOMEM; |
| 5844 | goto err_exit; | 5845 | goto err_exit; |
| 5845 | } | 5846 | } |
| 5846 | phba->sli4_hba.rpi_ids = kzalloc(rsrc_id_cnt * | 5847 | phba->sli4_hba.rpi_ids = kcalloc(rsrc_id_cnt, |
| 5847 | sizeof(uint16_t), | 5848 | sizeof(uint16_t), |
| 5848 | GFP_KERNEL); | 5849 | GFP_KERNEL); |
| 5849 | if (unlikely(!phba->sli4_hba.rpi_ids)) { | 5850 | if (unlikely(!phba->sli4_hba.rpi_ids)) { |
| @@ -5865,15 +5866,13 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) | |||
| 5865 | ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; | 5866 | ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list; |
| 5866 | break; | 5867 | break; |
| 5867 | case LPFC_RSC_TYPE_FCOE_VPI: | 5868 | case LPFC_RSC_TYPE_FCOE_VPI: |
| 5868 | phba->vpi_bmask = kzalloc(longs * | 5869 | phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), |
| 5869 | sizeof(unsigned long), | ||
| 5870 | GFP_KERNEL); | 5870 | GFP_KERNEL); |
| 5871 | if (unlikely(!phba->vpi_bmask)) { | 5871 | if (unlikely(!phba->vpi_bmask)) { |
| 5872 | rc = -ENOMEM; | 5872 | rc = -ENOMEM; |
| 5873 | goto err_exit; | 5873 | goto err_exit; |
| 5874 | } | 5874 | } |
| 5875 | phba->vpi_ids = kzalloc(rsrc_id_cnt * | 5875 | phba->vpi_ids = kcalloc(rsrc_id_cnt, sizeof(uint16_t), |
| 5876 | sizeof(uint16_t), | ||
| 5877 | GFP_KERNEL); | 5876 | GFP_KERNEL); |
| 5878 | if (unlikely(!phba->vpi_ids)) { | 5877 | if (unlikely(!phba->vpi_ids)) { |
| 5879 | kfree(phba->vpi_bmask); | 5878 | kfree(phba->vpi_bmask); |
| @@ -5887,7 +5886,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) | |||
| 5887 | ext_blk_list = &phba->lpfc_vpi_blk_list; | 5886 | ext_blk_list = &phba->lpfc_vpi_blk_list; |
| 5888 | break; | 5887 | break; |
| 5889 | case LPFC_RSC_TYPE_FCOE_XRI: | 5888 | case LPFC_RSC_TYPE_FCOE_XRI: |
| 5890 | phba->sli4_hba.xri_bmask = kzalloc(longs * | 5889 | phba->sli4_hba.xri_bmask = kcalloc(longs, |
| 5891 | sizeof(unsigned long), | 5890 | sizeof(unsigned long), |
| 5892 | GFP_KERNEL); | 5891 | GFP_KERNEL); |
| 5893 | if (unlikely(!phba->sli4_hba.xri_bmask)) { | 5892 | if (unlikely(!phba->sli4_hba.xri_bmask)) { |
| @@ -5895,7 +5894,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) | |||
| 5895 | goto err_exit; | 5894 | goto err_exit; |
| 5896 | } | 5895 | } |
| 5897 | phba->sli4_hba.max_cfg_param.xri_used = 0; | 5896 | phba->sli4_hba.max_cfg_param.xri_used = 0; |
| 5898 | phba->sli4_hba.xri_ids = kzalloc(rsrc_id_cnt * | 5897 | phba->sli4_hba.xri_ids = kcalloc(rsrc_id_cnt, |
| 5899 | sizeof(uint16_t), | 5898 | sizeof(uint16_t), |
| 5900 | GFP_KERNEL); | 5899 | GFP_KERNEL); |
| 5901 | if (unlikely(!phba->sli4_hba.xri_ids)) { | 5900 | if (unlikely(!phba->sli4_hba.xri_ids)) { |
| @@ -5910,14 +5909,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) | |||
| 5910 | ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; | 5909 | ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list; |
| 5911 | break; | 5910 | break; |
| 5912 | case LPFC_RSC_TYPE_FCOE_VFI: | 5911 | case LPFC_RSC_TYPE_FCOE_VFI: |
| 5913 | phba->sli4_hba.vfi_bmask = kzalloc(longs * | 5912 | phba->sli4_hba.vfi_bmask = kcalloc(longs, |
| 5914 | sizeof(unsigned long), | 5913 | sizeof(unsigned long), |
| 5915 | GFP_KERNEL); | 5914 | GFP_KERNEL); |
| 5916 | if (unlikely(!phba->sli4_hba.vfi_bmask)) { | 5915 | if (unlikely(!phba->sli4_hba.vfi_bmask)) { |
| 5917 | rc = -ENOMEM; | 5916 | rc = -ENOMEM; |
| 5918 | goto err_exit; | 5917 | goto err_exit; |
| 5919 | } | 5918 | } |
| 5920 | phba->sli4_hba.vfi_ids = kzalloc(rsrc_id_cnt * | 5919 | phba->sli4_hba.vfi_ids = kcalloc(rsrc_id_cnt, |
| 5921 | sizeof(uint16_t), | 5920 | sizeof(uint16_t), |
| 5922 | GFP_KERNEL); | 5921 | GFP_KERNEL); |
| 5923 | if (unlikely(!phba->sli4_hba.vfi_ids)) { | 5922 | if (unlikely(!phba->sli4_hba.vfi_ids)) { |
| @@ -6250,15 +6249,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) | |||
| 6250 | } | 6249 | } |
| 6251 | base = phba->sli4_hba.max_cfg_param.rpi_base; | 6250 | base = phba->sli4_hba.max_cfg_param.rpi_base; |
| 6252 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; | 6251 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; |
| 6253 | phba->sli4_hba.rpi_bmask = kzalloc(longs * | 6252 | phba->sli4_hba.rpi_bmask = kcalloc(longs, |
| 6254 | sizeof(unsigned long), | 6253 | sizeof(unsigned long), |
| 6255 | GFP_KERNEL); | 6254 | GFP_KERNEL); |
| 6256 | if (unlikely(!phba->sli4_hba.rpi_bmask)) { | 6255 | if (unlikely(!phba->sli4_hba.rpi_bmask)) { |
| 6257 | rc = -ENOMEM; | 6256 | rc = -ENOMEM; |
| 6258 | goto err_exit; | 6257 | goto err_exit; |
| 6259 | } | 6258 | } |
| 6260 | phba->sli4_hba.rpi_ids = kzalloc(count * | 6259 | phba->sli4_hba.rpi_ids = kcalloc(count, sizeof(uint16_t), |
| 6261 | sizeof(uint16_t), | ||
| 6262 | GFP_KERNEL); | 6260 | GFP_KERNEL); |
| 6263 | if (unlikely(!phba->sli4_hba.rpi_ids)) { | 6261 | if (unlikely(!phba->sli4_hba.rpi_ids)) { |
| 6264 | rc = -ENOMEM; | 6262 | rc = -ENOMEM; |
| @@ -6279,15 +6277,13 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) | |||
| 6279 | } | 6277 | } |
| 6280 | base = phba->sli4_hba.max_cfg_param.vpi_base; | 6278 | base = phba->sli4_hba.max_cfg_param.vpi_base; |
| 6281 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; | 6279 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; |
| 6282 | phba->vpi_bmask = kzalloc(longs * | 6280 | phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long), |
| 6283 | sizeof(unsigned long), | ||
| 6284 | GFP_KERNEL); | 6281 | GFP_KERNEL); |
| 6285 | if (unlikely(!phba->vpi_bmask)) { | 6282 | if (unlikely(!phba->vpi_bmask)) { |
| 6286 | rc = -ENOMEM; | 6283 | rc = -ENOMEM; |
| 6287 | goto free_rpi_ids; | 6284 | goto free_rpi_ids; |
| 6288 | } | 6285 | } |
| 6289 | phba->vpi_ids = kzalloc(count * | 6286 | phba->vpi_ids = kcalloc(count, sizeof(uint16_t), |
| 6290 | sizeof(uint16_t), | ||
| 6291 | GFP_KERNEL); | 6287 | GFP_KERNEL); |
| 6292 | if (unlikely(!phba->vpi_ids)) { | 6288 | if (unlikely(!phba->vpi_ids)) { |
| 6293 | rc = -ENOMEM; | 6289 | rc = -ENOMEM; |
| @@ -6308,7 +6304,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) | |||
| 6308 | } | 6304 | } |
| 6309 | base = phba->sli4_hba.max_cfg_param.xri_base; | 6305 | base = phba->sli4_hba.max_cfg_param.xri_base; |
| 6310 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; | 6306 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; |
| 6311 | phba->sli4_hba.xri_bmask = kzalloc(longs * | 6307 | phba->sli4_hba.xri_bmask = kcalloc(longs, |
| 6312 | sizeof(unsigned long), | 6308 | sizeof(unsigned long), |
| 6313 | GFP_KERNEL); | 6309 | GFP_KERNEL); |
| 6314 | if (unlikely(!phba->sli4_hba.xri_bmask)) { | 6310 | if (unlikely(!phba->sli4_hba.xri_bmask)) { |
| @@ -6316,8 +6312,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) | |||
| 6316 | goto free_vpi_ids; | 6312 | goto free_vpi_ids; |
| 6317 | } | 6313 | } |
| 6318 | phba->sli4_hba.max_cfg_param.xri_used = 0; | 6314 | phba->sli4_hba.max_cfg_param.xri_used = 0; |
| 6319 | phba->sli4_hba.xri_ids = kzalloc(count * | 6315 | phba->sli4_hba.xri_ids = kcalloc(count, sizeof(uint16_t), |
| 6320 | sizeof(uint16_t), | ||
| 6321 | GFP_KERNEL); | 6316 | GFP_KERNEL); |
| 6322 | if (unlikely(!phba->sli4_hba.xri_ids)) { | 6317 | if (unlikely(!phba->sli4_hba.xri_ids)) { |
| 6323 | rc = -ENOMEM; | 6318 | rc = -ENOMEM; |
| @@ -6338,15 +6333,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) | |||
| 6338 | } | 6333 | } |
| 6339 | base = phba->sli4_hba.max_cfg_param.vfi_base; | 6334 | base = phba->sli4_hba.max_cfg_param.vfi_base; |
| 6340 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; | 6335 | longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG; |
| 6341 | phba->sli4_hba.vfi_bmask = kzalloc(longs * | 6336 | phba->sli4_hba.vfi_bmask = kcalloc(longs, |
| 6342 | sizeof(unsigned long), | 6337 | sizeof(unsigned long), |
| 6343 | GFP_KERNEL); | 6338 | GFP_KERNEL); |
| 6344 | if (unlikely(!phba->sli4_hba.vfi_bmask)) { | 6339 | if (unlikely(!phba->sli4_hba.vfi_bmask)) { |
| 6345 | rc = -ENOMEM; | 6340 | rc = -ENOMEM; |
| 6346 | goto free_xri_ids; | 6341 | goto free_xri_ids; |
| 6347 | } | 6342 | } |
| 6348 | phba->sli4_hba.vfi_ids = kzalloc(count * | 6343 | phba->sli4_hba.vfi_ids = kcalloc(count, sizeof(uint16_t), |
| 6349 | sizeof(uint16_t), | ||
| 6350 | GFP_KERNEL); | 6344 | GFP_KERNEL); |
| 6351 | if (unlikely(!phba->sli4_hba.vfi_ids)) { | 6345 | if (unlikely(!phba->sli4_hba.vfi_ids)) { |
| 6352 | rc = -ENOMEM; | 6346 | rc = -ENOMEM; |
diff --git a/drivers/scsi/lpfc/lpfc_vport.c b/drivers/scsi/lpfc/lpfc_vport.c index c9d33b1268cb..81bc12dedf41 100644 --- a/drivers/scsi/lpfc/lpfc_vport.c +++ b/drivers/scsi/lpfc/lpfc_vport.c | |||
| @@ -840,7 +840,7 @@ lpfc_create_vport_work_array(struct lpfc_hba *phba) | |||
| 840 | struct lpfc_vport *port_iterator; | 840 | struct lpfc_vport *port_iterator; |
| 841 | struct lpfc_vport **vports; | 841 | struct lpfc_vport **vports; |
| 842 | int index = 0; | 842 | int index = 0; |
| 843 | vports = kzalloc((phba->max_vports + 1) * sizeof(struct lpfc_vport *), | 843 | vports = kcalloc(phba->max_vports + 1, sizeof(struct lpfc_vport *), |
| 844 | GFP_KERNEL); | 844 | GFP_KERNEL); |
| 845 | if (vports == NULL) | 845 | if (vports == NULL) |
| 846 | return NULL; | 846 | return NULL; |
diff --git a/drivers/scsi/mac53c94.c b/drivers/scsi/mac53c94.c index 8c4d3003b68b..177701dfdfcb 100644 --- a/drivers/scsi/mac53c94.c +++ b/drivers/scsi/mac53c94.c | |||
| @@ -464,8 +464,9 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat | |||
| 464 | * +1 to allow for aligning. | 464 | * +1 to allow for aligning. |
| 465 | * XXX FIXME: Use DMA consistent routines | 465 | * XXX FIXME: Use DMA consistent routines |
| 466 | */ | 466 | */ |
| 467 | dma_cmd_space = kmalloc((host->sg_tablesize + 2) * | 467 | dma_cmd_space = kmalloc_array(host->sg_tablesize + 2, |
| 468 | sizeof(struct dbdma_cmd), GFP_KERNEL); | 468 | sizeof(struct dbdma_cmd), |
| 469 | GFP_KERNEL); | ||
| 469 | if (dma_cmd_space == 0) { | 470 | if (dma_cmd_space == 0) { |
| 470 | printk(KERN_ERR "mac53c94: couldn't allocate dma " | 471 | printk(KERN_ERR "mac53c94: couldn't allocate dma " |
| 471 | "command space for %pOF\n", node); | 472 | "command space for %pOF\n", node); |
diff --git a/drivers/scsi/megaraid.c b/drivers/scsi/megaraid.c index 3b3767e240d8..8e8cf1145d7f 100644 --- a/drivers/scsi/megaraid.c +++ b/drivers/scsi/megaraid.c | |||
| @@ -4292,7 +4292,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) | |||
| 4292 | goto out_host_put; | 4292 | goto out_host_put; |
| 4293 | } | 4293 | } |
| 4294 | 4294 | ||
| 4295 | adapter->scb_list = kmalloc(sizeof(scb_t) * MAX_COMMANDS, GFP_KERNEL); | 4295 | adapter->scb_list = kmalloc_array(MAX_COMMANDS, sizeof(scb_t), |
| 4296 | GFP_KERNEL); | ||
| 4296 | if (!adapter->scb_list) { | 4297 | if (!adapter->scb_list) { |
| 4297 | dev_warn(&pdev->dev, "out of RAM\n"); | 4298 | dev_warn(&pdev->dev, "out of RAM\n"); |
| 4298 | goto out_free_cmd_buffer; | 4299 | goto out_free_cmd_buffer; |
diff --git a/drivers/scsi/megaraid/megaraid_mm.c b/drivers/scsi/megaraid/megaraid_mm.c index bb802b0c12b8..8428247015db 100644 --- a/drivers/scsi/megaraid/megaraid_mm.c +++ b/drivers/scsi/megaraid/megaraid_mm.c | |||
| @@ -935,10 +935,12 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp) | |||
| 935 | * Allocate single blocks of memory for all required kiocs, | 935 | * Allocate single blocks of memory for all required kiocs, |
| 936 | * mailboxes and passthru structures. | 936 | * mailboxes and passthru structures. |
| 937 | */ | 937 | */ |
| 938 | adapter->kioc_list = kmalloc(sizeof(uioc_t) * lld_adp->max_kioc, | 938 | adapter->kioc_list = kmalloc_array(lld_adp->max_kioc, |
| 939 | GFP_KERNEL); | 939 | sizeof(uioc_t), |
| 940 | adapter->mbox_list = kmalloc(sizeof(mbox64_t) * lld_adp->max_kioc, | 940 | GFP_KERNEL); |
| 941 | GFP_KERNEL); | 941 | adapter->mbox_list = kmalloc_array(lld_adp->max_kioc, |
| 942 | sizeof(mbox64_t), | ||
| 943 | GFP_KERNEL); | ||
| 942 | adapter->pthru_dma_pool = dma_pool_create("megaraid mm pthru pool", | 944 | adapter->pthru_dma_pool = dma_pool_create("megaraid mm pthru pool", |
| 943 | &adapter->pdev->dev, | 945 | &adapter->pdev->dev, |
| 944 | sizeof(mraid_passthru_t), | 946 | sizeof(mraid_passthru_t), |
diff --git a/drivers/scsi/megaraid/megaraid_sas_base.c b/drivers/scsi/megaraid/megaraid_sas_base.c index c5d0c4bd71d2..71d97573a667 100644 --- a/drivers/scsi/megaraid/megaraid_sas_base.c +++ b/drivers/scsi/megaraid/megaraid_sas_base.c | |||
| @@ -5419,9 +5419,9 @@ static int megasas_init_fw(struct megasas_instance *instance) | |||
| 5419 | /* stream detection initialization */ | 5419 | /* stream detection initialization */ |
| 5420 | if (instance->adapter_type == VENTURA_SERIES) { | 5420 | if (instance->adapter_type == VENTURA_SERIES) { |
| 5421 | fusion->stream_detect_by_ld = | 5421 | fusion->stream_detect_by_ld = |
| 5422 | kzalloc(sizeof(struct LD_STREAM_DETECT *) | 5422 | kcalloc(MAX_LOGICAL_DRIVES_EXT, |
| 5423 | * MAX_LOGICAL_DRIVES_EXT, | 5423 | sizeof(struct LD_STREAM_DETECT *), |
| 5424 | GFP_KERNEL); | 5424 | GFP_KERNEL); |
| 5425 | if (!fusion->stream_detect_by_ld) { | 5425 | if (!fusion->stream_detect_by_ld) { |
| 5426 | dev_err(&instance->pdev->dev, | 5426 | dev_err(&instance->pdev->dev, |
| 5427 | "unable to allocate stream detection for pool of LDs\n"); | 5427 | "unable to allocate stream detection for pool of LDs\n"); |
| @@ -6139,7 +6139,7 @@ static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance) | |||
| 6139 | */ | 6139 | */ |
| 6140 | static int megasas_alloc_ctrl_mem(struct megasas_instance *instance) | 6140 | static int megasas_alloc_ctrl_mem(struct megasas_instance *instance) |
| 6141 | { | 6141 | { |
| 6142 | instance->reply_map = kzalloc(sizeof(unsigned int) * nr_cpu_ids, | 6142 | instance->reply_map = kcalloc(nr_cpu_ids, sizeof(unsigned int), |
| 6143 | GFP_KERNEL); | 6143 | GFP_KERNEL); |
| 6144 | if (!instance->reply_map) | 6144 | if (!instance->reply_map) |
| 6145 | return -ENOMEM; | 6145 | return -ENOMEM; |
diff --git a/drivers/scsi/megaraid/megaraid_sas_fusion.c b/drivers/scsi/megaraid/megaraid_sas_fusion.c index 98a7a090b75e..94c23ad51179 100644 --- a/drivers/scsi/megaraid/megaraid_sas_fusion.c +++ b/drivers/scsi/megaraid/megaraid_sas_fusion.c | |||
| @@ -487,7 +487,7 @@ megasas_alloc_cmdlist_fusion(struct megasas_instance *instance) | |||
| 487 | * commands. | 487 | * commands. |
| 488 | */ | 488 | */ |
| 489 | fusion->cmd_list = | 489 | fusion->cmd_list = |
| 490 | kzalloc(sizeof(struct megasas_cmd_fusion *) * max_mpt_cmd, | 490 | kcalloc(max_mpt_cmd, sizeof(struct megasas_cmd_fusion *), |
| 491 | GFP_KERNEL); | 491 | GFP_KERNEL); |
| 492 | if (!fusion->cmd_list) { | 492 | if (!fusion->cmd_list) { |
| 493 | dev_err(&instance->pdev->dev, | 493 | dev_err(&instance->pdev->dev, |
| @@ -4829,8 +4829,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) | |||
| 4829 | (PLD_SPAN_INFO)__get_free_pages(GFP_KERNEL | __GFP_ZERO, | 4829 | (PLD_SPAN_INFO)__get_free_pages(GFP_KERNEL | __GFP_ZERO, |
| 4830 | fusion->log_to_span_pages); | 4830 | fusion->log_to_span_pages); |
| 4831 | if (!fusion->log_to_span) { | 4831 | if (!fusion->log_to_span) { |
| 4832 | fusion->log_to_span = vzalloc(MAX_LOGICAL_DRIVES_EXT * | 4832 | fusion->log_to_span = |
| 4833 | sizeof(LD_SPAN_INFO)); | 4833 | vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT, |
| 4834 | sizeof(LD_SPAN_INFO))); | ||
| 4834 | if (!fusion->log_to_span) { | 4835 | if (!fusion->log_to_span) { |
| 4835 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", | 4836 | dev_err(&instance->pdev->dev, "Failed from %s %d\n", |
| 4836 | __func__, __LINE__); | 4837 | __func__, __LINE__); |
| @@ -4844,8 +4845,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) | |||
| 4844 | (struct LD_LOAD_BALANCE_INFO *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, | 4845 | (struct LD_LOAD_BALANCE_INFO *)__get_free_pages(GFP_KERNEL | __GFP_ZERO, |
| 4845 | fusion->load_balance_info_pages); | 4846 | fusion->load_balance_info_pages); |
| 4846 | if (!fusion->load_balance_info) { | 4847 | if (!fusion->load_balance_info) { |
| 4847 | fusion->load_balance_info = vzalloc(MAX_LOGICAL_DRIVES_EXT * | 4848 | fusion->load_balance_info = |
| 4848 | sizeof(struct LD_LOAD_BALANCE_INFO)); | 4849 | vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT, |
| 4850 | sizeof(struct LD_LOAD_BALANCE_INFO))); | ||
| 4849 | if (!fusion->load_balance_info) | 4851 | if (!fusion->load_balance_info) |
| 4850 | dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, " | 4852 | dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, " |
| 4851 | "continuing without Load Balance support\n"); | 4853 | "continuing without Load Balance support\n"); |
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c index 2bbe797f8c3d..7a1a1edde35d 100644 --- a/drivers/scsi/osst.c +++ b/drivers/scsi/osst.c | |||
| @@ -381,7 +381,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd, | |||
| 381 | struct scatterlist *sg, *sgl = (struct scatterlist *)buffer; | 381 | struct scatterlist *sg, *sgl = (struct scatterlist *)buffer; |
| 382 | int i; | 382 | int i; |
| 383 | 383 | ||
| 384 | pages = kzalloc(use_sg * sizeof(struct page *), GFP_KERNEL); | 384 | pages = kcalloc(use_sg, sizeof(struct page *), GFP_KERNEL); |
| 385 | if (!pages) | 385 | if (!pages) |
| 386 | goto free_req; | 386 | goto free_req; |
| 387 | 387 | ||
| @@ -1488,7 +1488,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst | |||
| 1488 | int dbg = debugging; | 1488 | int dbg = debugging; |
| 1489 | #endif | 1489 | #endif |
| 1490 | 1490 | ||
| 1491 | if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL) | 1491 | if ((buffer = vmalloc(array_size((nframes + 1), OS_DATA_SIZE))) == NULL) |
| 1492 | return (-EIO); | 1492 | return (-EIO); |
| 1493 | 1493 | ||
| 1494 | printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n", | 1494 | printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n", |
| @@ -5856,7 +5856,9 @@ static int osst_probe(struct device *dev) | |||
| 5856 | /* if this is the first attach, build the infrastructure */ | 5856 | /* if this is the first attach, build the infrastructure */ |
| 5857 | write_lock(&os_scsi_tapes_lock); | 5857 | write_lock(&os_scsi_tapes_lock); |
| 5858 | if (os_scsi_tapes == NULL) { | 5858 | if (os_scsi_tapes == NULL) { |
| 5859 | os_scsi_tapes = kmalloc(osst_max_dev * sizeof(struct osst_tape *), GFP_ATOMIC); | 5859 | os_scsi_tapes = kmalloc_array(osst_max_dev, |
| 5860 | sizeof(struct osst_tape *), | ||
| 5861 | GFP_ATOMIC); | ||
| 5860 | if (os_scsi_tapes == NULL) { | 5862 | if (os_scsi_tapes == NULL) { |
| 5861 | write_unlock(&os_scsi_tapes_lock); | 5863 | write_unlock(&os_scsi_tapes_lock); |
| 5862 | printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n"); | 5864 | printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n"); |
diff --git a/drivers/scsi/pm8001/pm8001_ctl.c b/drivers/scsi/pm8001/pm8001_ctl.c index 596f3ff965f5..d193961ea82f 100644 --- a/drivers/scsi/pm8001/pm8001_ctl.c +++ b/drivers/scsi/pm8001/pm8001_ctl.c | |||
| @@ -705,7 +705,7 @@ static ssize_t pm8001_store_update_fw(struct device *cdev, | |||
| 705 | return -EINPROGRESS; | 705 | return -EINPROGRESS; |
| 706 | pm8001_ha->fw_status = FLASH_IN_PROGRESS; | 706 | pm8001_ha->fw_status = FLASH_IN_PROGRESS; |
| 707 | 707 | ||
| 708 | cmd_ptr = kzalloc(count*2, GFP_KERNEL); | 708 | cmd_ptr = kcalloc(count, 2, GFP_KERNEL); |
| 709 | if (!cmd_ptr) { | 709 | if (!cmd_ptr) { |
| 710 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; | 710 | pm8001_ha->fw_status = FAIL_OUT_MEMORY; |
| 711 | return -ENOMEM; | 711 | return -ENOMEM; |
diff --git a/drivers/scsi/pmcraid.c b/drivers/scsi/pmcraid.c index 95530393872d..4e86994e10e8 100644 --- a/drivers/scsi/pmcraid.c +++ b/drivers/scsi/pmcraid.c | |||
| @@ -4873,8 +4873,9 @@ static int pmcraid_allocate_config_buffers(struct pmcraid_instance *pinstance) | |||
| 4873 | int i; | 4873 | int i; |
| 4874 | 4874 | ||
| 4875 | pinstance->res_entries = | 4875 | pinstance->res_entries = |
| 4876 | kzalloc(sizeof(struct pmcraid_resource_entry) * | 4876 | kcalloc(PMCRAID_MAX_RESOURCES, |
| 4877 | PMCRAID_MAX_RESOURCES, GFP_KERNEL); | 4877 | sizeof(struct pmcraid_resource_entry), |
| 4878 | GFP_KERNEL); | ||
| 4878 | 4879 | ||
| 4879 | if (NULL == pinstance->res_entries) { | 4880 | if (NULL == pinstance->res_entries) { |
| 4880 | pmcraid_err("failed to allocate memory for resource table\n"); | 4881 | pmcraid_err("failed to allocate memory for resource table\n"); |
diff --git a/drivers/scsi/qedi/qedi_main.c b/drivers/scsi/qedi/qedi_main.c index 32ee7f62fef9..cf274a79e77a 100644 --- a/drivers/scsi/qedi/qedi_main.c +++ b/drivers/scsi/qedi/qedi_main.c | |||
| @@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl, u16 size, | |||
| 524 | id_tbl->max = size; | 524 | id_tbl->max = size; |
| 525 | id_tbl->next = next; | 525 | id_tbl->next = next; |
| 526 | spin_lock_init(&id_tbl->lock); | 526 | spin_lock_init(&id_tbl->lock); |
| 527 | id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL); | 527 | id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL); |
| 528 | if (!id_tbl->table) | 528 | if (!id_tbl->table) |
| 529 | return -ENOMEM; | 529 | return -ENOMEM; |
| 530 | 530 | ||
diff --git a/drivers/scsi/qla2xxx/qla_init.c b/drivers/scsi/qla2xxx/qla_init.c index 1aa3720ea2ed..fbbb328c64d5 100644 --- a/drivers/scsi/qla2xxx/qla_init.c +++ b/drivers/scsi/qla2xxx/qla_init.c | |||
| @@ -3089,8 +3089,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) | |||
| 3089 | req->num_outstanding_cmds = ha->cur_fw_iocb_count; | 3089 | req->num_outstanding_cmds = ha->cur_fw_iocb_count; |
| 3090 | } | 3090 | } |
| 3091 | 3091 | ||
| 3092 | req->outstanding_cmds = kzalloc(sizeof(srb_t *) * | 3092 | req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, |
| 3093 | req->num_outstanding_cmds, GFP_KERNEL); | 3093 | sizeof(srb_t *), |
| 3094 | GFP_KERNEL); | ||
| 3094 | 3095 | ||
| 3095 | if (!req->outstanding_cmds) { | 3096 | if (!req->outstanding_cmds) { |
| 3096 | /* | 3097 | /* |
| @@ -3098,8 +3099,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) | |||
| 3098 | * initialization. | 3099 | * initialization. |
| 3099 | */ | 3100 | */ |
| 3100 | req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; | 3101 | req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS; |
| 3101 | req->outstanding_cmds = kzalloc(sizeof(srb_t *) * | 3102 | req->outstanding_cmds = kcalloc(req->num_outstanding_cmds, |
| 3102 | req->num_outstanding_cmds, GFP_KERNEL); | 3103 | sizeof(srb_t *), |
| 3104 | GFP_KERNEL); | ||
| 3103 | 3105 | ||
| 3104 | if (!req->outstanding_cmds) { | 3106 | if (!req->outstanding_cmds) { |
| 3105 | ql_log(ql_log_fatal, NULL, 0x0126, | 3107 | ql_log(ql_log_fatal, NULL, 0x0126, |
diff --git a/drivers/scsi/qla2xxx/qla_isr.c b/drivers/scsi/qla2xxx/qla_isr.c index a3dc83f9444d..d14d3911516d 100644 --- a/drivers/scsi/qla2xxx/qla_isr.c +++ b/drivers/scsi/qla2xxx/qla_isr.c | |||
| @@ -3434,8 +3434,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) | |||
| 3434 | "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs); | 3434 | "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs); |
| 3435 | } | 3435 | } |
| 3436 | } | 3436 | } |
| 3437 | ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) * | 3437 | ha->msix_entries = kcalloc(ha->msix_count, |
| 3438 | ha->msix_count, GFP_KERNEL); | 3438 | sizeof(struct qla_msix_entry), |
| 3439 | GFP_KERNEL); | ||
| 3439 | if (!ha->msix_entries) { | 3440 | if (!ha->msix_entries) { |
| 3440 | ql_log(ql_log_fatal, vha, 0x00c8, | 3441 | ql_log(ql_log_fatal, vha, 0x00c8, |
| 3441 | "Failed to allocate memory for ha->msix_entries.\n"); | 3442 | "Failed to allocate memory for ha->msix_entries.\n"); |
diff --git a/drivers/scsi/qla2xxx/qla_nx.c b/drivers/scsi/qla2xxx/qla_nx.c index 872d66dd79cd..de2bc78449e7 100644 --- a/drivers/scsi/qla2xxx/qla_nx.c +++ b/drivers/scsi/qla2xxx/qla_nx.c | |||
| @@ -1230,7 +1230,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) | |||
| 1230 | ql_log(ql_log_info, vha, 0x0072, | 1230 | ql_log(ql_log_info, vha, 0x0072, |
| 1231 | "%d CRB init values found in ROM.\n", n); | 1231 | "%d CRB init values found in ROM.\n", n); |
| 1232 | 1232 | ||
| 1233 | buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL); | 1233 | buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL); |
| 1234 | if (buf == NULL) { | 1234 | if (buf == NULL) { |
| 1235 | ql_log(ql_log_fatal, vha, 0x010c, | 1235 | ql_log(ql_log_fatal, vha, 0x010c, |
| 1236 | "Unable to allocate memory.\n"); | 1236 | "Unable to allocate memory.\n"); |
diff --git a/drivers/scsi/qla2xxx/qla_os.c b/drivers/scsi/qla2xxx/qla_os.c index 817c18a8e84d..e881fce7477a 100644 --- a/drivers/scsi/qla2xxx/qla_os.c +++ b/drivers/scsi/qla2xxx/qla_os.c | |||
| @@ -410,7 +410,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, | |||
| 410 | struct rsp_que *rsp) | 410 | struct rsp_que *rsp) |
| 411 | { | 411 | { |
| 412 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); | 412 | scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev); |
| 413 | ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues, | 413 | ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *), |
| 414 | GFP_KERNEL); | 414 | GFP_KERNEL); |
| 415 | if (!ha->req_q_map) { | 415 | if (!ha->req_q_map) { |
| 416 | ql_log(ql_log_fatal, vha, 0x003b, | 416 | ql_log(ql_log_fatal, vha, 0x003b, |
| @@ -418,7 +418,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, | |||
| 418 | goto fail_req_map; | 418 | goto fail_req_map; |
| 419 | } | 419 | } |
| 420 | 420 | ||
| 421 | ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues, | 421 | ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *), |
| 422 | GFP_KERNEL); | 422 | GFP_KERNEL); |
| 423 | if (!ha->rsp_q_map) { | 423 | if (!ha->rsp_q_map) { |
| 424 | ql_log(ql_log_fatal, vha, 0x003c, | 424 | ql_log(ql_log_fatal, vha, 0x003c, |
| @@ -4045,8 +4045,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, | |||
| 4045 | (*rsp)->ring); | 4045 | (*rsp)->ring); |
| 4046 | /* Allocate memory for NVRAM data for vports */ | 4046 | /* Allocate memory for NVRAM data for vports */ |
| 4047 | if (ha->nvram_npiv_size) { | 4047 | if (ha->nvram_npiv_size) { |
| 4048 | ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) * | 4048 | ha->npiv_info = kcalloc(ha->nvram_npiv_size, |
| 4049 | ha->nvram_npiv_size, GFP_KERNEL); | 4049 | sizeof(struct qla_npiv_entry), |
| 4050 | GFP_KERNEL); | ||
| 4050 | if (!ha->npiv_info) { | 4051 | if (!ha->npiv_info) { |
| 4051 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, | 4052 | ql_log_pci(ql_log_fatal, ha->pdev, 0x002d, |
| 4052 | "Failed to allocate memory for npiv_info.\n"); | 4053 | "Failed to allocate memory for npiv_info.\n"); |
| @@ -4080,8 +4081,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, | |||
| 4080 | INIT_LIST_HEAD(&ha->vp_list); | 4081 | INIT_LIST_HEAD(&ha->vp_list); |
| 4081 | 4082 | ||
| 4082 | /* Allocate memory for our loop_id bitmap */ | 4083 | /* Allocate memory for our loop_id bitmap */ |
| 4083 | ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long), | 4084 | ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE), |
| 4084 | GFP_KERNEL); | 4085 | sizeof(long), |
| 4086 | GFP_KERNEL); | ||
| 4085 | if (!ha->loop_id_map) | 4087 | if (!ha->loop_id_map) |
| 4086 | goto fail_loop_id_map; | 4088 | goto fail_loop_id_map; |
| 4087 | else { | 4089 | else { |
diff --git a/drivers/scsi/qla2xxx/qla_target.c b/drivers/scsi/qla2xxx/qla_target.c index b85c833099ff..0fea2e2326be 100644 --- a/drivers/scsi/qla2xxx/qla_target.c +++ b/drivers/scsi/qla2xxx/qla_target.c | |||
| @@ -6248,8 +6248,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha) | |||
| 6248 | return -ENOMEM; | 6248 | return -ENOMEM; |
| 6249 | } | 6249 | } |
| 6250 | 6250 | ||
| 6251 | tgt->qphints = kzalloc((ha->max_qpairs + 1) * | 6251 | tgt->qphints = kcalloc(ha->max_qpairs + 1, |
| 6252 | sizeof(struct qla_qpair_hint), GFP_KERNEL); | 6252 | sizeof(struct qla_qpair_hint), |
| 6253 | GFP_KERNEL); | ||
| 6253 | if (!tgt->qphints) { | 6254 | if (!tgt->qphints) { |
| 6254 | kfree(tgt); | 6255 | kfree(tgt); |
| 6255 | ql_log(ql_log_warn, base_vha, 0x0197, | 6256 | ql_log(ql_log_warn, base_vha, 0x0197, |
| @@ -7089,8 +7090,9 @@ qlt_mem_alloc(struct qla_hw_data *ha) | |||
| 7089 | if (!QLA_TGT_MODE_ENABLED()) | 7090 | if (!QLA_TGT_MODE_ENABLED()) |
| 7090 | return 0; | 7091 | return 0; |
| 7091 | 7092 | ||
| 7092 | ha->tgt.tgt_vp_map = kzalloc(sizeof(struct qla_tgt_vp_map) * | 7093 | ha->tgt.tgt_vp_map = kcalloc(MAX_MULTI_ID_FABRIC, |
| 7093 | MAX_MULTI_ID_FABRIC, GFP_KERNEL); | 7094 | sizeof(struct qla_tgt_vp_map), |
| 7095 | GFP_KERNEL); | ||
| 7094 | if (!ha->tgt.tgt_vp_map) | 7096 | if (!ha->tgt.tgt_vp_map) |
| 7095 | return -ENOMEM; | 7097 | return -ENOMEM; |
| 7096 | 7098 | ||
diff --git a/drivers/scsi/qla2xxx/tcm_qla2xxx.c b/drivers/scsi/qla2xxx/tcm_qla2xxx.c index 0c2e82af9c0a..7732e9336d43 100644 --- a/drivers/scsi/qla2xxx/tcm_qla2xxx.c +++ b/drivers/scsi/qla2xxx/tcm_qla2xxx.c | |||
| @@ -1661,7 +1661,9 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport) | |||
| 1661 | return rc; | 1661 | return rc; |
| 1662 | } | 1662 | } |
| 1663 | 1663 | ||
| 1664 | lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); | 1664 | lport->lport_loopid_map = |
| 1665 | vzalloc(array_size(65536, | ||
| 1666 | sizeof(struct tcm_qla2xxx_fc_loopid))); | ||
| 1665 | if (!lport->lport_loopid_map) { | 1667 | if (!lport->lport_loopid_map) { |
| 1666 | pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", | 1668 | pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n", |
| 1667 | sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); | 1669 | sizeof(struct tcm_qla2xxx_fc_loopid) * 65536); |
diff --git a/drivers/scsi/qla4xxx/ql4_nx.c b/drivers/scsi/qla4xxx/ql4_nx.c index 43f73583ef5c..d2b333d629be 100644 --- a/drivers/scsi/qla4xxx/ql4_nx.c +++ b/drivers/scsi/qla4xxx/ql4_nx.c | |||
| @@ -1077,7 +1077,7 @@ qla4_82xx_pinit_from_rom(struct scsi_qla_host *ha, int verbose) | |||
| 1077 | ql4_printk(KERN_INFO, ha, | 1077 | ql4_printk(KERN_INFO, ha, |
| 1078 | "%s: %d CRB init values found in ROM.\n", DRIVER_NAME, n); | 1078 | "%s: %d CRB init values found in ROM.\n", DRIVER_NAME, n); |
| 1079 | 1079 | ||
| 1080 | buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL); | 1080 | buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL); |
| 1081 | if (buf == NULL) { | 1081 | if (buf == NULL) { |
| 1082 | ql4_printk(KERN_WARNING, ha, | 1082 | ql4_printk(KERN_WARNING, ha, |
| 1083 | "%s: [ERROR] Unable to malloc memory.\n", DRIVER_NAME); | 1083 | "%s: [ERROR] Unable to malloc memory.\n", DRIVER_NAME); |
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c index 656c98e116a9..24d7496cd9e2 100644 --- a/drivers/scsi/scsi_debug.c +++ b/drivers/scsi/scsi_debug.c | |||
| @@ -3450,7 +3450,7 @@ static int resp_comp_write(struct scsi_cmnd *scp, | |||
| 3450 | return check_condition_result; | 3450 | return check_condition_result; |
| 3451 | } | 3451 | } |
| 3452 | dnum = 2 * num; | 3452 | dnum = 2 * num; |
| 3453 | arr = kzalloc(dnum * lb_size, GFP_ATOMIC); | 3453 | arr = kcalloc(lb_size, dnum, GFP_ATOMIC); |
| 3454 | if (NULL == arr) { | 3454 | if (NULL == arr) { |
| 3455 | mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, | 3455 | mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC, |
| 3456 | INSUFF_RES_ASCQ); | 3456 | INSUFF_RES_ASCQ); |
| @@ -5439,7 +5439,8 @@ static int __init scsi_debug_init(void) | |||
| 5439 | } | 5439 | } |
| 5440 | 5440 | ||
| 5441 | map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; | 5441 | map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; |
| 5442 | map_storep = vmalloc(BITS_TO_LONGS(map_size) * sizeof(long)); | 5442 | map_storep = vmalloc(array_size(sizeof(long), |
| 5443 | BITS_TO_LONGS(map_size))); | ||
| 5443 | 5444 | ||
| 5444 | pr_info("%lu provisioning blocks\n", map_size); | 5445 | pr_info("%lu provisioning blocks\n", map_size); |
| 5445 | 5446 | ||
diff --git a/drivers/scsi/sd_zbc.c b/drivers/scsi/sd_zbc.c index 323e3dc4bc59..76da8c3a6f09 100644 --- a/drivers/scsi/sd_zbc.c +++ b/drivers/scsi/sd_zbc.c | |||
| @@ -494,7 +494,7 @@ out_free: | |||
| 494 | static inline unsigned long * | 494 | static inline unsigned long * |
| 495 | sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node) | 495 | sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node) |
| 496 | { | 496 | { |
| 497 | return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long), | 497 | return kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(unsigned long), |
| 498 | GFP_KERNEL, numa_node); | 498 | GFP_KERNEL, numa_node); |
| 499 | } | 499 | } |
| 500 | 500 | ||
diff --git a/drivers/scsi/ses.c b/drivers/scsi/ses.c index 62f04c0511cf..0fc39224ce1e 100644 --- a/drivers/scsi/ses.c +++ b/drivers/scsi/ses.c | |||
| @@ -747,7 +747,7 @@ static int ses_intf_add(struct device *cdev, | |||
| 747 | buf = NULL; | 747 | buf = NULL; |
| 748 | } | 748 | } |
| 749 | page2_not_supported: | 749 | page2_not_supported: |
| 750 | scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL); | 750 | scomp = kcalloc(components, sizeof(struct ses_component), GFP_KERNEL); |
| 751 | if (!scomp) | 751 | if (!scomp) |
| 752 | goto err_free; | 752 | goto err_free; |
| 753 | 753 | ||
diff --git a/drivers/scsi/sg.c b/drivers/scsi/sg.c index 573763908562..53ae52dbff84 100644 --- a/drivers/scsi/sg.c +++ b/drivers/scsi/sg.c | |||
| @@ -1045,7 +1045,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) | |||
| 1045 | else { | 1045 | else { |
| 1046 | sg_req_info_t *rinfo; | 1046 | sg_req_info_t *rinfo; |
| 1047 | 1047 | ||
| 1048 | rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE, | 1048 | rinfo = kcalloc(SG_MAX_QUEUE, SZ_SG_REQ_INFO, |
| 1049 | GFP_KERNEL); | 1049 | GFP_KERNEL); |
| 1050 | if (!rinfo) | 1050 | if (!rinfo) |
| 1051 | return -ENOMEM; | 1051 | return -ENOMEM; |
diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index 592b6dbf8b35..b78d20b74ed8 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c | |||
| @@ -1820,8 +1820,9 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) | |||
| 1820 | 1820 | ||
| 1821 | num_new_devices = num_physicals + num_logicals; | 1821 | num_new_devices = num_physicals + num_logicals; |
| 1822 | 1822 | ||
| 1823 | new_device_list = kmalloc(sizeof(*new_device_list) * | 1823 | new_device_list = kmalloc_array(num_new_devices, |
| 1824 | num_new_devices, GFP_KERNEL); | 1824 | sizeof(*new_device_list), |
| 1825 | GFP_KERNEL); | ||
| 1825 | if (!new_device_list) { | 1826 | if (!new_device_list) { |
| 1826 | dev_warn(&ctrl_info->pci_dev->dev, "%s\n", out_of_memory_msg); | 1827 | dev_warn(&ctrl_info->pci_dev->dev, "%s\n", out_of_memory_msg); |
| 1827 | rc = -ENOMEM; | 1828 | rc = -ENOMEM; |
| @@ -4251,8 +4252,9 @@ static int pqi_alloc_io_resources(struct pqi_ctrl_info *ctrl_info) | |||
| 4251 | struct device *dev; | 4252 | struct device *dev; |
| 4252 | struct pqi_io_request *io_request; | 4253 | struct pqi_io_request *io_request; |
| 4253 | 4254 | ||
| 4254 | ctrl_info->io_request_pool = kzalloc(ctrl_info->max_io_slots * | 4255 | ctrl_info->io_request_pool = |
| 4255 | sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL); | 4256 | kcalloc(ctrl_info->max_io_slots, |
| 4257 | sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL); | ||
| 4256 | 4258 | ||
| 4257 | if (!ctrl_info->io_request_pool) { | 4259 | if (!ctrl_info->io_request_pool) { |
| 4258 | dev_err(&ctrl_info->pci_dev->dev, | 4260 | dev_err(&ctrl_info->pci_dev->dev, |
diff --git a/drivers/scsi/st.c b/drivers/scsi/st.c index c9e27e752c25..50c66ccc4b41 100644 --- a/drivers/scsi/st.c +++ b/drivers/scsi/st.c | |||
| @@ -3888,7 +3888,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) | |||
| 3888 | tb->dma = need_dma; | 3888 | tb->dma = need_dma; |
| 3889 | tb->buffer_size = 0; | 3889 | tb->buffer_size = 0; |
| 3890 | 3890 | ||
| 3891 | tb->reserved_pages = kzalloc(max_sg * sizeof(struct page *), | 3891 | tb->reserved_pages = kcalloc(max_sg, sizeof(struct page *), |
| 3892 | GFP_KERNEL); | 3892 | GFP_KERNEL); |
| 3893 | if (!tb->reserved_pages) { | 3893 | if (!tb->reserved_pages) { |
| 3894 | kfree(tb); | 3894 | kfree(tb); |
| @@ -4915,7 +4915,8 @@ static int sgl_map_user_pages(struct st_buffer *STbp, | |||
| 4915 | if (count == 0) | 4915 | if (count == 0) |
| 4916 | return 0; | 4916 | return 0; |
| 4917 | 4917 | ||
| 4918 | if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_KERNEL)) == NULL) | 4918 | pages = kmalloc_array(max_pages, sizeof(*pages), GFP_KERNEL); |
| 4919 | if (pages == NULL) | ||
| 4919 | return -ENOMEM; | 4920 | return -ENOMEM; |
| 4920 | 4921 | ||
| 4921 | /* Try to fault in all of the necessary pages */ | 4922 | /* Try to fault in all of the necessary pages */ |
diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index e82bde077296..895a9b5ac989 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c | |||
| @@ -86,8 +86,8 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) | |||
| 86 | goto out; | 86 | goto out; |
| 87 | } | 87 | } |
| 88 | 88 | ||
| 89 | clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq), | 89 | clkfreq = devm_kcalloc(dev, sz, sizeof(*clkfreq), |
| 90 | GFP_KERNEL); | 90 | GFP_KERNEL); |
| 91 | if (!clkfreq) { | 91 | if (!clkfreq) { |
| 92 | ret = -ENOMEM; | 92 | ret = -ENOMEM; |
| 93 | goto out; | 93 | goto out; |
diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index 3a811c5f70ba..397081d320b1 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c | |||
| @@ -3357,8 +3357,8 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba) | |||
| 3357 | } | 3357 | } |
| 3358 | 3358 | ||
| 3359 | /* Allocate memory for local reference block */ | 3359 | /* Allocate memory for local reference block */ |
| 3360 | hba->lrb = devm_kzalloc(hba->dev, | 3360 | hba->lrb = devm_kcalloc(hba->dev, |
| 3361 | hba->nutrs * sizeof(struct ufshcd_lrb), | 3361 | hba->nutrs, sizeof(struct ufshcd_lrb), |
| 3362 | GFP_KERNEL); | 3362 | GFP_KERNEL); |
| 3363 | if (!hba->lrb) { | 3363 | if (!hba->lrb) { |
| 3364 | dev_err(hba->dev, "LRB Memory allocation failed\n"); | 3364 | dev_err(hba->dev, "LRB Memory allocation failed\n"); |
diff --git a/drivers/scsi/virtio_scsi.c b/drivers/scsi/virtio_scsi.c index 45d04631888a..6dc8891ccb74 100644 --- a/drivers/scsi/virtio_scsi.c +++ b/drivers/scsi/virtio_scsi.c | |||
| @@ -794,9 +794,10 @@ static int virtscsi_init(struct virtio_device *vdev, | |||
| 794 | struct irq_affinity desc = { .pre_vectors = 2 }; | 794 | struct irq_affinity desc = { .pre_vectors = 2 }; |
| 795 | 795 | ||
| 796 | num_vqs = vscsi->num_queues + VIRTIO_SCSI_VQ_BASE; | 796 | num_vqs = vscsi->num_queues + VIRTIO_SCSI_VQ_BASE; |
| 797 | vqs = kmalloc(num_vqs * sizeof(struct virtqueue *), GFP_KERNEL); | 797 | vqs = kmalloc_array(num_vqs, sizeof(struct virtqueue *), GFP_KERNEL); |
| 798 | callbacks = kmalloc(num_vqs * sizeof(vq_callback_t *), GFP_KERNEL); | 798 | callbacks = kmalloc_array(num_vqs, sizeof(vq_callback_t *), |
| 799 | names = kmalloc(num_vqs * sizeof(char *), GFP_KERNEL); | 799 | GFP_KERNEL); |
| 800 | names = kmalloc_array(num_vqs, sizeof(char *), GFP_KERNEL); | ||
| 800 | 801 | ||
| 801 | if (!callbacks || !vqs || !names) { | 802 | if (!callbacks || !vqs || !names) { |
| 802 | err = -ENOMEM; | 803 | err = -ENOMEM; |
diff --git a/drivers/sh/clk/cpg.c b/drivers/sh/clk/cpg.c index 7442bc130055..eeb028b9cdb3 100644 --- a/drivers/sh/clk/cpg.c +++ b/drivers/sh/clk/cpg.c | |||
| @@ -249,7 +249,7 @@ static int __init sh_clk_div_register_ops(struct clk *clks, int nr, | |||
| 249 | int k; | 249 | int k; |
| 250 | 250 | ||
| 251 | freq_table_size *= (nr_divs + 1); | 251 | freq_table_size *= (nr_divs + 1); |
| 252 | freq_table = kzalloc(freq_table_size * nr, GFP_KERNEL); | 252 | freq_table = kcalloc(nr, freq_table_size, GFP_KERNEL); |
| 253 | if (!freq_table) { | 253 | if (!freq_table) { |
| 254 | pr_err("%s: unable to alloc memory\n", __func__); | 254 | pr_err("%s: unable to alloc memory\n", __func__); |
| 255 | return -ENOMEM; | 255 | return -ENOMEM; |
diff --git a/drivers/sh/intc/core.c b/drivers/sh/intc/core.c index 8e72bcbd3d6d..46f0f322d4d8 100644 --- a/drivers/sh/intc/core.c +++ b/drivers/sh/intc/core.c | |||
| @@ -203,7 +203,7 @@ int __init register_intc_controller(struct intc_desc *desc) | |||
| 203 | 203 | ||
| 204 | if (desc->num_resources) { | 204 | if (desc->num_resources) { |
| 205 | d->nr_windows = desc->num_resources; | 205 | d->nr_windows = desc->num_resources; |
| 206 | d->window = kzalloc(d->nr_windows * sizeof(*d->window), | 206 | d->window = kcalloc(d->nr_windows, sizeof(*d->window), |
| 207 | GFP_NOWAIT); | 207 | GFP_NOWAIT); |
| 208 | if (!d->window) | 208 | if (!d->window) |
| 209 | goto err1; | 209 | goto err1; |
| @@ -230,12 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc) | |||
| 230 | d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0; | 230 | d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0; |
| 231 | d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0; | 231 | d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0; |
| 232 | 232 | ||
| 233 | d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT); | 233 | d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT); |
| 234 | if (!d->reg) | 234 | if (!d->reg) |
| 235 | goto err2; | 235 | goto err2; |
| 236 | 236 | ||
| 237 | #ifdef CONFIG_SMP | 237 | #ifdef CONFIG_SMP |
| 238 | d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT); | 238 | d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT); |
| 239 | if (!d->smp) | 239 | if (!d->smp) |
| 240 | goto err3; | 240 | goto err3; |
| 241 | #endif | 241 | #endif |
| @@ -253,7 +253,7 @@ int __init register_intc_controller(struct intc_desc *desc) | |||
| 253 | } | 253 | } |
| 254 | 254 | ||
| 255 | if (hw->prio_regs) { | 255 | if (hw->prio_regs) { |
| 256 | d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio), | 256 | d->prio = kcalloc(hw->nr_vectors, sizeof(*d->prio), |
| 257 | GFP_NOWAIT); | 257 | GFP_NOWAIT); |
| 258 | if (!d->prio) | 258 | if (!d->prio) |
| 259 | goto err4; | 259 | goto err4; |
| @@ -269,7 +269,7 @@ int __init register_intc_controller(struct intc_desc *desc) | |||
| 269 | } | 269 | } |
| 270 | 270 | ||
| 271 | if (hw->sense_regs) { | 271 | if (hw->sense_regs) { |
| 272 | d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense), | 272 | d->sense = kcalloc(hw->nr_vectors, sizeof(*d->sense), |
| 273 | GFP_NOWAIT); | 273 | GFP_NOWAIT); |
| 274 | if (!d->sense) | 274 | if (!d->sense) |
| 275 | goto err5; | 275 | goto err5; |
diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 7525039d812c..2e45988d1259 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c | |||
| @@ -161,7 +161,7 @@ int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, | |||
| 161 | void *sendbuf = NULL; | 161 | void *sendbuf = NULL; |
| 162 | 162 | ||
| 163 | if (length) { | 163 | if (length) { |
| 164 | sendbuf = kzalloc(length * 4, GFP_KERNEL); | 164 | sendbuf = kcalloc(length, 4, GFP_KERNEL); |
| 165 | if (!sendbuf) { | 165 | if (!sendbuf) { |
| 166 | ret = -ENOMEM; | 166 | ret = -ENOMEM; |
| 167 | goto out; | 167 | goto out; |
diff --git a/drivers/slimbus/qcom-ctrl.c b/drivers/slimbus/qcom-ctrl.c index bb36a8fbc9b1..db1f5135846a 100644 --- a/drivers/slimbus/qcom-ctrl.c +++ b/drivers/slimbus/qcom-ctrl.c | |||
| @@ -540,7 +540,7 @@ static int qcom_slim_probe(struct platform_device *pdev) | |||
| 540 | ctrl->tx.sl_sz = SLIM_MSGQ_BUF_LEN; | 540 | ctrl->tx.sl_sz = SLIM_MSGQ_BUF_LEN; |
| 541 | ctrl->rx.n = QCOM_RX_MSGS; | 541 | ctrl->rx.n = QCOM_RX_MSGS; |
| 542 | ctrl->rx.sl_sz = SLIM_MSGQ_BUF_LEN; | 542 | ctrl->rx.sl_sz = SLIM_MSGQ_BUF_LEN; |
| 543 | ctrl->wr_comp = kzalloc(sizeof(struct completion *) * QCOM_TX_MSGS, | 543 | ctrl->wr_comp = kcalloc(QCOM_TX_MSGS, sizeof(struct completion *), |
| 544 | GFP_KERNEL); | 544 | GFP_KERNEL); |
| 545 | if (!ctrl->wr_comp) | 545 | if (!ctrl->wr_comp) |
| 546 | return -ENOMEM; | 546 | return -ENOMEM; |
diff --git a/drivers/soc/bcm/raspberrypi-power.c b/drivers/soc/bcm/raspberrypi-power.c index f7ed1187518b..a78dfe0a2b50 100644 --- a/drivers/soc/bcm/raspberrypi-power.c +++ b/drivers/soc/bcm/raspberrypi-power.c | |||
| @@ -165,8 +165,10 @@ static int rpi_power_probe(struct platform_device *pdev) | |||
| 165 | return -ENOMEM; | 165 | return -ENOMEM; |
| 166 | 166 | ||
| 167 | rpi_domains->xlate.domains = | 167 | rpi_domains->xlate.domains = |
| 168 | devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) * | 168 | devm_kcalloc(dev, |
| 169 | RPI_POWER_DOMAIN_COUNT, GFP_KERNEL); | 169 | RPI_POWER_DOMAIN_COUNT, |
| 170 | sizeof(*rpi_domains->xlate.domains), | ||
| 171 | GFP_KERNEL); | ||
| 170 | if (!rpi_domains->xlate.domains) | 172 | if (!rpi_domains->xlate.domains) |
| 171 | return -ENOMEM; | 173 | return -ENOMEM; |
| 172 | 174 | ||
diff --git a/drivers/soc/fsl/qbman/qman.c b/drivers/soc/fsl/qbman/qman.c index ba3cfa8e279b..ecb22749df0b 100644 --- a/drivers/soc/fsl/qbman/qman.c +++ b/drivers/soc/fsl/qbman/qman.c | |||
| @@ -1021,7 +1021,8 @@ int qman_alloc_fq_table(u32 _num_fqids) | |||
| 1021 | { | 1021 | { |
| 1022 | num_fqids = _num_fqids; | 1022 | num_fqids = _num_fqids; |
| 1023 | 1023 | ||
| 1024 | fq_table = vzalloc(num_fqids * 2 * sizeof(struct qman_fq *)); | 1024 | fq_table = vzalloc(array3_size(sizeof(struct qman_fq *), |
| 1025 | num_fqids, 2)); | ||
| 1025 | if (!fq_table) | 1026 | if (!fq_table) |
| 1026 | return -ENOMEM; | 1027 | return -ENOMEM; |
| 1027 | 1028 | ||
| @@ -1181,7 +1182,7 @@ static int qman_create_portal(struct qman_portal *portal, | |||
| 1181 | qm_dqrr_set_ithresh(p, QMAN_PIRQ_DQRR_ITHRESH); | 1182 | qm_dqrr_set_ithresh(p, QMAN_PIRQ_DQRR_ITHRESH); |
| 1182 | qm_mr_set_ithresh(p, QMAN_PIRQ_MR_ITHRESH); | 1183 | qm_mr_set_ithresh(p, QMAN_PIRQ_MR_ITHRESH); |
| 1183 | qm_out(p, QM_REG_ITPR, QMAN_PIRQ_IPERIOD); | 1184 | qm_out(p, QM_REG_ITPR, QMAN_PIRQ_IPERIOD); |
| 1184 | portal->cgrs = kmalloc(2 * sizeof(*cgrs), GFP_KERNEL); | 1185 | portal->cgrs = kmalloc_array(2, sizeof(*cgrs), GFP_KERNEL); |
| 1185 | if (!portal->cgrs) | 1186 | if (!portal->cgrs) |
| 1186 | goto fail_cgrs; | 1187 | goto fail_cgrs; |
| 1187 | /* initial snapshot is no-depletion */ | 1188 | /* initial snapshot is no-depletion */ |
diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index 128e3dd3186d..5b24bb4bfbf6 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c | |||
| @@ -376,15 +376,15 @@ static struct scp *init_scp(struct platform_device *pdev, | |||
| 376 | if (IS_ERR(scp->base)) | 376 | if (IS_ERR(scp->base)) |
| 377 | return ERR_CAST(scp->base); | 377 | return ERR_CAST(scp->base); |
| 378 | 378 | ||
| 379 | scp->domains = devm_kzalloc(&pdev->dev, | 379 | scp->domains = devm_kcalloc(&pdev->dev, |
| 380 | sizeof(*scp->domains) * num, GFP_KERNEL); | 380 | num, sizeof(*scp->domains), GFP_KERNEL); |
| 381 | if (!scp->domains) | 381 | if (!scp->domains) |
| 382 | return ERR_PTR(-ENOMEM); | 382 | return ERR_PTR(-ENOMEM); |
| 383 | 383 | ||
| 384 | pd_data = &scp->pd_data; | 384 | pd_data = &scp->pd_data; |
| 385 | 385 | ||
| 386 | pd_data->domains = devm_kzalloc(&pdev->dev, | 386 | pd_data->domains = devm_kcalloc(&pdev->dev, |
| 387 | sizeof(*pd_data->domains) * num, GFP_KERNEL); | 387 | num, sizeof(*pd_data->domains), GFP_KERNEL); |
| 388 | if (!pd_data->domains) | 388 | if (!pd_data->domains) |
| 389 | return ERR_PTR(-ENOMEM); | 389 | return ERR_PTR(-ENOMEM); |
| 390 | 390 | ||
diff --git a/drivers/soc/ti/knav_qmss_acc.c b/drivers/soc/ti/knav_qmss_acc.c index 3d7225f4e77f..316e82e46f6c 100644 --- a/drivers/soc/ti/knav_qmss_acc.c +++ b/drivers/soc/ti/knav_qmss_acc.c | |||
| @@ -405,8 +405,8 @@ static int knav_acc_init_queue(struct knav_range_info *range, | |||
| 405 | { | 405 | { |
| 406 | unsigned id = kq->id - range->queue_base; | 406 | unsigned id = kq->id - range->queue_base; |
| 407 | 407 | ||
| 408 | kq->descs = devm_kzalloc(range->kdev->dev, | 408 | kq->descs = devm_kcalloc(range->kdev->dev, |
| 409 | ACC_DESCS_MAX * sizeof(u32), GFP_KERNEL); | 409 | ACC_DESCS_MAX, sizeof(u32), GFP_KERNEL); |
| 410 | if (!kq->descs) | 410 | if (!kq->descs) |
| 411 | return -ENOMEM; | 411 | return -ENOMEM; |
| 412 | 412 | ||
| @@ -552,7 +552,7 @@ int knav_init_acc_range(struct knav_device *kdev, | |||
| 552 | info->list_size = list_size; | 552 | info->list_size = list_size; |
| 553 | mem_size = PAGE_ALIGN(list_size * 2); | 553 | mem_size = PAGE_ALIGN(list_size * 2); |
| 554 | info->mem_size = mem_size; | 554 | info->mem_size = mem_size; |
| 555 | range->acc = devm_kzalloc(kdev->dev, channels * sizeof(*range->acc), | 555 | range->acc = devm_kcalloc(kdev->dev, channels, sizeof(*range->acc), |
| 556 | GFP_KERNEL); | 556 | GFP_KERNEL); |
| 557 | if (!range->acc) | 557 | if (!range->acc) |
| 558 | return -ENOMEM; | 558 | return -ENOMEM; |
diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index 60d59b003aa4..577084bb911b 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c | |||
| @@ -923,9 +923,10 @@ static int davinci_spi_probe(struct platform_device *pdev) | |||
| 923 | /* pdata in dspi is now updated and point pdata to that */ | 923 | /* pdata in dspi is now updated and point pdata to that */ |
| 924 | pdata = &dspi->pdata; | 924 | pdata = &dspi->pdata; |
| 925 | 925 | ||
| 926 | dspi->bytes_per_word = devm_kzalloc(&pdev->dev, | 926 | dspi->bytes_per_word = devm_kcalloc(&pdev->dev, |
| 927 | sizeof(*dspi->bytes_per_word) * | 927 | pdata->num_chipselect, |
| 928 | pdata->num_chipselect, GFP_KERNEL); | 928 | sizeof(*dspi->bytes_per_word), |
| 929 | GFP_KERNEL); | ||
| 929 | if (dspi->bytes_per_word == NULL) { | 930 | if (dspi->bytes_per_word == NULL) { |
| 930 | ret = -ENOMEM; | 931 | ret = -ENOMEM; |
| 931 | goto free_master; | 932 | goto free_master; |
diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index e5cc07357746..f1526757aaf6 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c | |||
| @@ -671,8 +671,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) | |||
| 671 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); | 671 | master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); |
| 672 | 672 | ||
| 673 | master->num_chipselect = info->num_chipselect; | 673 | master->num_chipselect = info->num_chipselect; |
| 674 | master->cs_gpios = devm_kzalloc(&master->dev, | 674 | master->cs_gpios = devm_kcalloc(&master->dev, |
| 675 | sizeof(int) * master->num_chipselect, | 675 | master->num_chipselect, sizeof(int), |
| 676 | GFP_KERNEL); | 676 | GFP_KERNEL); |
| 677 | if (!master->cs_gpios) { | 677 | if (!master->cs_gpios) { |
| 678 | error = -ENOMEM; | 678 | error = -ENOMEM; |
diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c index b85a93cad44a..6ae92d4dca19 100644 --- a/drivers/spi/spi-gpio.c +++ b/drivers/spi/spi-gpio.c | |||
| @@ -373,8 +373,9 @@ static int spi_gpio_probe(struct platform_device *pdev) | |||
| 373 | 373 | ||
| 374 | spi_gpio = spi_master_get_devdata(master); | 374 | spi_gpio = spi_master_get_devdata(master); |
| 375 | 375 | ||
| 376 | spi_gpio->cs_gpios = devm_kzalloc(&pdev->dev, | 376 | spi_gpio->cs_gpios = devm_kcalloc(&pdev->dev, |
| 377 | pdata->num_chipselect * sizeof(*spi_gpio->cs_gpios), | 377 | pdata->num_chipselect, |
| 378 | sizeof(*spi_gpio->cs_gpios), | ||
| 378 | GFP_KERNEL); | 379 | GFP_KERNEL); |
| 379 | if (!spi_gpio->cs_gpios) | 380 | if (!spi_gpio->cs_gpios) |
| 380 | return -ENOMEM; | 381 | return -ENOMEM; |
diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index 866246f21041..d3b21faf6b1f 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c | |||
| @@ -1511,8 +1511,9 @@ static int spi_imx_probe(struct platform_device *pdev) | |||
| 1511 | if (mxc_platform_info) { | 1511 | if (mxc_platform_info) { |
| 1512 | master->num_chipselect = mxc_platform_info->num_chipselect; | 1512 | master->num_chipselect = mxc_platform_info->num_chipselect; |
| 1513 | if (mxc_platform_info->chipselect) { | 1513 | if (mxc_platform_info->chipselect) { |
| 1514 | master->cs_gpios = devm_kzalloc(&master->dev, | 1514 | master->cs_gpios = devm_kcalloc(&master->dev, |
| 1515 | sizeof(int) * master->num_chipselect, GFP_KERNEL); | 1515 | master->num_chipselect, sizeof(int), |
| 1516 | GFP_KERNEL); | ||
| 1516 | if (!master->cs_gpios) | 1517 | if (!master->cs_gpios) |
| 1517 | return -ENOMEM; | 1518 | return -ENOMEM; |
| 1518 | 1519 | ||
diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c index b5911282a611..085f580be7ec 100644 --- a/drivers/spi/spi-oc-tiny.c +++ b/drivers/spi/spi-oc-tiny.c | |||
| @@ -213,8 +213,8 @@ static int tiny_spi_of_probe(struct platform_device *pdev) | |||
| 213 | return 0; | 213 | return 0; |
| 214 | hw->gpio_cs_count = of_gpio_count(np); | 214 | hw->gpio_cs_count = of_gpio_count(np); |
| 215 | if (hw->gpio_cs_count > 0) { | 215 | if (hw->gpio_cs_count > 0) { |
| 216 | hw->gpio_cs = devm_kzalloc(&pdev->dev, | 216 | hw->gpio_cs = devm_kcalloc(&pdev->dev, |
| 217 | hw->gpio_cs_count * sizeof(unsigned int), | 217 | hw->gpio_cs_count, sizeof(unsigned int), |
| 218 | GFP_KERNEL); | 218 | GFP_KERNEL); |
| 219 | if (!hw->gpio_cs) | 219 | if (!hw->gpio_cs) |
| 220 | return -ENOMEM; | 220 | return -ENOMEM; |
diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 4797c57f4263..1af8c96b940e 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c | |||
| @@ -2135,7 +2135,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) | |||
| 2135 | pl022->master_info = platform_info; | 2135 | pl022->master_info = platform_info; |
| 2136 | pl022->adev = adev; | 2136 | pl022->adev = adev; |
| 2137 | pl022->vendor = id->data; | 2137 | pl022->vendor = id->data; |
| 2138 | pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), | 2138 | pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int), |
| 2139 | GFP_KERNEL); | 2139 | GFP_KERNEL); |
| 2140 | if (!pl022->chipselects) { | 2140 | if (!pl022->chipselects) { |
| 2141 | status = -ENOMEM; | 2141 | status = -ENOMEM; |
diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index efc624f9e490..ec395a6baf9c 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c | |||
| @@ -2049,7 +2049,7 @@ static int of_spi_register_master(struct spi_controller *ctlr) | |||
| 2049 | else if (nb < 0) | 2049 | else if (nb < 0) |
| 2050 | return nb; | 2050 | return nb; |
| 2051 | 2051 | ||
| 2052 | cs = devm_kzalloc(&ctlr->dev, sizeof(int) * ctlr->num_chipselect, | 2052 | cs = devm_kcalloc(&ctlr->dev, ctlr->num_chipselect, sizeof(int), |
| 2053 | GFP_KERNEL); | 2053 | GFP_KERNEL); |
| 2054 | ctlr->cs_gpios = cs; | 2054 | ctlr->cs_gpios = cs; |
| 2055 | 2055 | ||
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c index 772dad65396e..e8c440329708 100644 --- a/drivers/staging/android/ion/ion_heap.c +++ b/drivers/staging/android/ion/ion_heap.c | |||
| @@ -25,7 +25,8 @@ void *ion_heap_map_kernel(struct ion_heap *heap, | |||
| 25 | pgprot_t pgprot; | 25 | pgprot_t pgprot; |
| 26 | struct sg_table *table = buffer->sg_table; | 26 | struct sg_table *table = buffer->sg_table; |
| 27 | int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; | 27 | int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; |
| 28 | struct page **pages = vmalloc(sizeof(struct page *) * npages); | 28 | struct page **pages = vmalloc(array_size(npages, |
| 29 | sizeof(struct page *))); | ||
| 29 | struct page **tmp = pages; | 30 | struct page **tmp = pages; |
| 30 | 31 | ||
| 31 | if (!pages) | 32 | if (!pages) |
diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c index 15e57f701630..b71078339e86 100644 --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c | |||
| @@ -144,7 +144,7 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb, | |||
| 144 | __u8 *data; | 144 | __u8 *data; |
| 145 | 145 | ||
| 146 | items = le32_to_cpu(gbenum->items); | 146 | items = le32_to_cpu(gbenum->items); |
| 147 | strings = devm_kzalloc(gb->dev, sizeof(char *) * items, GFP_KERNEL); | 147 | strings = devm_kcalloc(gb->dev, items, sizeof(char *), GFP_KERNEL); |
| 148 | data = gbenum->names; | 148 | data = gbenum->names; |
| 149 | 149 | ||
| 150 | for (i = 0; i < items; i++) { | 150 | for (i = 0; i < items; i++) { |
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c index 341f729a9779..6dded10f4155 100644 --- a/drivers/staging/greybus/camera.c +++ b/drivers/staging/greybus/camera.c | |||
| @@ -1175,8 +1175,9 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam) | |||
| 1175 | 1175 | ||
| 1176 | gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get()); | 1176 | gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get()); |
| 1177 | 1177 | ||
| 1178 | gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) * | 1178 | gcam->debugfs.buffers = |
| 1179 | GB_CAMERA_DEBUGFS_BUFFER_MAX); | 1179 | vmalloc(array_size(GB_CAMERA_DEBUGFS_BUFFER_MAX, |
| 1180 | sizeof(*gcam->debugfs.buffers))); | ||
| 1180 | if (!gcam->debugfs.buffers) | 1181 | if (!gcam->debugfs.buffers) |
| 1181 | return -ENOMEM; | 1182 | return -ENOMEM; |
| 1182 | 1183 | ||
diff --git a/drivers/staging/media/imx/imx-media-dev.c b/drivers/staging/media/imx/imx-media-dev.c index 289d775c4820..b0be80f05767 100644 --- a/drivers/staging/media/imx/imx-media-dev.c +++ b/drivers/staging/media/imx/imx-media-dev.c | |||
| @@ -303,9 +303,9 @@ static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd) | |||
| 303 | 303 | ||
| 304 | list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { | 304 | list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) { |
| 305 | entity = &sd->entity; | 305 | entity = &sd->entity; |
| 306 | vdev_lists = devm_kzalloc( | 306 | vdev_lists = devm_kcalloc( |
| 307 | imxmd->md.dev, | 307 | imxmd->md.dev, |
| 308 | entity->num_pads * sizeof(*vdev_lists), | 308 | entity->num_pads, sizeof(*vdev_lists), |
| 309 | GFP_KERNEL); | 309 | GFP_KERNEL); |
| 310 | if (!vdev_lists) | 310 | if (!vdev_lists) |
| 311 | return -ENOMEM; | 311 | return -ENOMEM; |
| @@ -544,7 +544,7 @@ static int imx_media_probe(struct platform_device *pdev) | |||
| 544 | goto unreg_dev; | 544 | goto unreg_dev; |
| 545 | } | 545 | } |
| 546 | 546 | ||
| 547 | subdevs = devm_kzalloc(imxmd->md.dev, sizeof(*subdevs) * num_subdevs, | 547 | subdevs = devm_kcalloc(imxmd->md.dev, num_subdevs, sizeof(*subdevs), |
| 548 | GFP_KERNEL); | 548 | GFP_KERNEL); |
| 549 | if (!subdevs) { | 549 | if (!subdevs) { |
| 550 | ret = -ENOMEM; | 550 | ret = -ENOMEM; |
diff --git a/drivers/staging/media/zoran/zoran_driver.c b/drivers/staging/media/zoran/zoran_driver.c index d2e13fffbc6b..d7842224fff6 100644 --- a/drivers/staging/media/zoran/zoran_driver.c +++ b/drivers/staging/media/zoran/zoran_driver.c | |||
| @@ -941,7 +941,7 @@ static int zoran_open(struct file *file) | |||
| 941 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows | 941 | /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows |
| 942 | * on norm-change! */ | 942 | * on norm-change! */ |
| 943 | fh->overlay_mask = | 943 | fh->overlay_mask = |
| 944 | kmalloc(((768 + 31) / 32) * 576 * 4, GFP_KERNEL); | 944 | kmalloc(array3_size((768 + 31) / 32, 576, 4), GFP_KERNEL); |
| 945 | if (!fh->overlay_mask) { | 945 | if (!fh->overlay_mask) { |
| 946 | dprintk(1, | 946 | dprintk(1, |
| 947 | KERN_ERR | 947 | KERN_ERR |
| @@ -1220,7 +1220,8 @@ static int setup_window(struct zoran_fh *fh, | |||
| 1220 | } | 1220 | } |
| 1221 | } else if (clipcount) { | 1221 | } else if (clipcount) { |
| 1222 | /* write our own bitmap from the clips */ | 1222 | /* write our own bitmap from the clips */ |
| 1223 | vcp = vmalloc(sizeof(struct v4l2_clip) * (clipcount + 4)); | 1223 | vcp = vmalloc(array_size(sizeof(struct v4l2_clip), |
| 1224 | clipcount + 4)); | ||
| 1224 | if (vcp == NULL) { | 1225 | if (vcp == NULL) { |
| 1225 | dprintk(1, | 1226 | dprintk(1, |
| 1226 | KERN_ERR | 1227 | KERN_ERR |
diff --git a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c index 2d9ab2620b82..0c3e498ae99c 100644 --- a/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +++ b/drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c | |||
| @@ -143,7 +143,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, | |||
| 143 | if (!max_maps) | 143 | if (!max_maps) |
| 144 | return max_maps; | 144 | return max_maps; |
| 145 | 145 | ||
| 146 | *map = kzalloc(max_maps * sizeof(struct pinctrl_map), GFP_KERNEL); | 146 | *map = kcalloc(max_maps, sizeof(struct pinctrl_map), GFP_KERNEL); |
| 147 | if (!*map) | 147 | if (!*map) |
| 148 | return -ENOMEM; | 148 | return -ENOMEM; |
| 149 | 149 | ||
| @@ -287,7 +287,8 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) | |||
| 287 | } | 287 | } |
| 288 | 288 | ||
| 289 | /* allocate the group names array needed by the gpio function */ | 289 | /* allocate the group names array needed by the gpio function */ |
| 290 | p->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL); | 290 | p->group_names = devm_kcalloc(p->dev, p->group_count, sizeof(char *), |
| 291 | GFP_KERNEL); | ||
| 291 | if (!p->group_names) | 292 | if (!p->group_names) |
| 292 | return -1; | 293 | return -1; |
| 293 | 294 | ||
| @@ -300,8 +301,12 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) | |||
| 300 | p->func_count++; | 301 | p->func_count++; |
| 301 | 302 | ||
| 302 | /* allocate our function and group mapping index buffers */ | 303 | /* allocate our function and group mapping index buffers */ |
| 303 | f = p->func = devm_kzalloc(p->dev, sizeof(struct rt2880_pmx_func) * p->func_count, GFP_KERNEL); | 304 | f = p->func = devm_kcalloc(p->dev, |
| 304 | gpio_func.groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL); | 305 | p->func_count, |
| 306 | sizeof(struct rt2880_pmx_func), | ||
| 307 | GFP_KERNEL); | ||
| 308 | gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int), | ||
| 309 | GFP_KERNEL); | ||
| 305 | if (!f || !gpio_func.groups) | 310 | if (!f || !gpio_func.groups) |
| 306 | return -1; | 311 | return -1; |
| 307 | 312 | ||
| @@ -337,7 +342,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) | |||
| 337 | if (!p->func[i]->pin_count) | 342 | if (!p->func[i]->pin_count) |
| 338 | continue; | 343 | continue; |
| 339 | 344 | ||
| 340 | p->func[i]->pins = devm_kzalloc(p->dev, sizeof(int) * p->func[i]->pin_count, GFP_KERNEL); | 345 | p->func[i]->pins = devm_kcalloc(p->dev, |
| 346 | p->func[i]->pin_count, | ||
| 347 | sizeof(int), | ||
| 348 | GFP_KERNEL); | ||
| 341 | for (j = 0; j < p->func[i]->pin_count; j++) | 349 | for (j = 0; j < p->func[i]->pin_count; j++) |
| 342 | p->func[i]->pins[j] = p->func[i]->pin_first + j; | 350 | p->func[i]->pins[j] = p->func[i]->pin_first + j; |
| 343 | 351 | ||
| @@ -347,11 +355,11 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) | |||
| 347 | } | 355 | } |
| 348 | 356 | ||
| 349 | /* the buffer that tells us which pins are gpio */ | 357 | /* the buffer that tells us which pins are gpio */ |
| 350 | p->gpio = devm_kzalloc(p->dev,sizeof(uint8_t) * p->max_pins, | 358 | p->gpio = devm_kcalloc(p->dev,p->max_pins, sizeof(uint8_t), |
| 351 | GFP_KERNEL); | 359 | GFP_KERNEL); |
| 352 | /* the pads needed to tell pinctrl about our pins */ | 360 | /* the pads needed to tell pinctrl about our pins */ |
| 353 | p->pads = devm_kzalloc(p->dev, | 361 | p->pads = devm_kcalloc(p->dev, |
| 354 | sizeof(struct pinctrl_pin_desc) * p->max_pins, | 362 | p->max_pins, sizeof(struct pinctrl_pin_desc), |
| 355 | GFP_KERNEL); | 363 | GFP_KERNEL); |
| 356 | if (!p->pads || !p->gpio ) { | 364 | if (!p->pads || !p->gpio ) { |
| 357 | dev_err(p->dev, "Failed to allocate gpio data\n"); | 365 | dev_err(p->dev, "Failed to allocate gpio data\n"); |
diff --git a/drivers/staging/rtl8188eu/core/rtw_mlme.c b/drivers/staging/rtl8188eu/core/rtw_mlme.c index 24e92998a30c..50e7cae32f75 100644 --- a/drivers/staging/rtl8188eu/core/rtw_mlme.c +++ b/drivers/staging/rtl8188eu/core/rtw_mlme.c | |||
| @@ -53,7 +53,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) | |||
| 53 | 53 | ||
| 54 | memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); | 54 | memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); |
| 55 | 55 | ||
| 56 | pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); | 56 | pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network))); |
| 57 | 57 | ||
| 58 | if (!pbuf) { | 58 | if (!pbuf) { |
| 59 | res = _FAIL; | 59 | res = _FAIL; |
diff --git a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c index 37a610d05ad2..f2cdcc2bcab4 100644 --- a/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +++ b/drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c | |||
| @@ -597,8 +597,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, | |||
| 597 | bool bMatchWinStart = false, bPktInBuf = false; | 597 | bool bMatchWinStart = false, bPktInBuf = false; |
| 598 | IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); | 598 | IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize); |
| 599 | 599 | ||
| 600 | prxbIndicateArray = kmalloc(sizeof(struct ieee80211_rxb *) * | 600 | prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE, |
| 601 | REORDER_WIN_SIZE, GFP_KERNEL); | 601 | sizeof(struct ieee80211_rxb *), |
| 602 | GFP_KERNEL); | ||
| 602 | if (!prxbIndicateArray) | 603 | if (!prxbIndicateArray) |
| 603 | return; | 604 | return; |
| 604 | 605 | ||
diff --git a/drivers/staging/rtl8192u/r8192U_core.c b/drivers/staging/rtl8192u/r8192U_core.c index a4df95cc7f60..8b17400f6c13 100644 --- a/drivers/staging/rtl8192u/r8192U_core.c +++ b/drivers/staging/rtl8192u/r8192U_core.c | |||
| @@ -1640,8 +1640,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) | |||
| 1640 | { | 1640 | { |
| 1641 | struct r8192_priv *priv = ieee80211_priv(dev); | 1641 | struct r8192_priv *priv = ieee80211_priv(dev); |
| 1642 | 1642 | ||
| 1643 | priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1), | 1643 | priv->rx_urb = kmalloc_array(MAX_RX_URB + 1, sizeof(struct urb *), |
| 1644 | GFP_KERNEL); | 1644 | GFP_KERNEL); |
| 1645 | if (!priv->rx_urb) | 1645 | if (!priv->rx_urb) |
| 1646 | return -ENOMEM; | 1646 | return -ENOMEM; |
| 1647 | 1647 | ||
diff --git a/drivers/staging/rtl8723bs/core/rtw_mlme.c b/drivers/staging/rtl8723bs/core/rtw_mlme.c index cc4f115e082c..f9392b8db49b 100644 --- a/drivers/staging/rtl8723bs/core/rtw_mlme.c +++ b/drivers/staging/rtl8723bs/core/rtw_mlme.c | |||
| @@ -37,7 +37,7 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) | |||
| 37 | 37 | ||
| 38 | memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); | 38 | memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid)); |
| 39 | 39 | ||
| 40 | pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network))); | 40 | pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network))); |
| 41 | 41 | ||
| 42 | if (pbuf == NULL) { | 42 | if (pbuf == NULL) { |
| 43 | res = _FAIL; | 43 | res = _FAIL; |
diff --git a/drivers/staging/rtlwifi/efuse.c b/drivers/staging/rtlwifi/efuse.c index d7c7d146a84d..1dc71455f270 100644 --- a/drivers/staging/rtlwifi/efuse.c +++ b/drivers/staging/rtlwifi/efuse.c | |||
| @@ -237,8 +237,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) | |||
| 237 | } | 237 | } |
| 238 | 238 | ||
| 239 | /* allocate memory for efuse_tbl and efuse_word */ | 239 | /* allocate memory for efuse_tbl and efuse_word */ |
| 240 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] * | 240 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE], |
| 241 | sizeof(u8), GFP_ATOMIC); | 241 | GFP_ATOMIC); |
| 242 | if (!efuse_tbl) | 242 | if (!efuse_tbl) |
| 243 | return; | 243 | return; |
| 244 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); | 244 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); |
diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c index 821256b95e22..b89ef15e3c20 100644 --- a/drivers/staging/rts5208/ms.c +++ b/drivers/staging/rts5208/ms.c | |||
| @@ -2618,7 +2618,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) | |||
| 2618 | segment = &ms_card->segment[seg_no]; | 2618 | segment = &ms_card->segment[seg_no]; |
| 2619 | 2619 | ||
| 2620 | if (!segment->l2p_table) { | 2620 | if (!segment->l2p_table) { |
| 2621 | segment->l2p_table = vmalloc(table_size * 2); | 2621 | segment->l2p_table = vmalloc(array_size(table_size, 2)); |
| 2622 | if (!segment->l2p_table) { | 2622 | if (!segment->l2p_table) { |
| 2623 | rtsx_trace(chip); | 2623 | rtsx_trace(chip); |
| 2624 | goto BUILD_FAIL; | 2624 | goto BUILD_FAIL; |
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c index 4ad472dd9daf..8a823466ca2b 100644 --- a/drivers/staging/rts5208/rtsx_chip.c +++ b/drivers/staging/rts5208/rtsx_chip.c | |||
| @@ -1660,13 +1660,13 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, | |||
| 1660 | 1660 | ||
| 1661 | dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); | 1661 | dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); |
| 1662 | 1662 | ||
| 1663 | data = vzalloc(dw_len * 4); | 1663 | data = vzalloc(array_size(dw_len, 4)); |
| 1664 | if (!data) { | 1664 | if (!data) { |
| 1665 | rtsx_trace(chip); | 1665 | rtsx_trace(chip); |
| 1666 | return STATUS_NOMEM; | 1666 | return STATUS_NOMEM; |
| 1667 | } | 1667 | } |
| 1668 | 1668 | ||
| 1669 | mask = vzalloc(dw_len * 4); | 1669 | mask = vzalloc(array_size(dw_len, 4)); |
| 1670 | if (!mask) { | 1670 | if (!mask) { |
| 1671 | vfree(data); | 1671 | vfree(data); |
| 1672 | rtsx_trace(chip); | 1672 | rtsx_trace(chip); |
| @@ -1721,7 +1721,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, | |||
| 1721 | 1721 | ||
| 1722 | dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); | 1722 | dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); |
| 1723 | 1723 | ||
| 1724 | data = vmalloc(dw_len * 4); | 1724 | data = vmalloc(array_size(dw_len, 4)); |
| 1725 | if (!data) { | 1725 | if (!data) { |
| 1726 | rtsx_trace(chip); | 1726 | rtsx_trace(chip); |
| 1727 | return STATUS_NOMEM; | 1727 | return STATUS_NOMEM; |
diff --git a/drivers/staging/unisys/visorhba/visorhba_main.c b/drivers/staging/unisys/visorhba/visorhba_main.c index 167e98f8688e..4fc521c51c0e 100644 --- a/drivers/staging/unisys/visorhba/visorhba_main.c +++ b/drivers/staging/unisys/visorhba/visorhba_main.c | |||
| @@ -865,7 +865,7 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, | |||
| 865 | if (cmdrsp->scsi.no_disk_result == 0) | 865 | if (cmdrsp->scsi.no_disk_result == 0) |
| 866 | return; | 866 | return; |
| 867 | 867 | ||
| 868 | buf = kzalloc(sizeof(char) * 36, GFP_KERNEL); | 868 | buf = kzalloc(36, GFP_KERNEL); |
| 869 | if (!buf) | 869 | if (!buf) |
| 870 | return; | 870 | return; |
| 871 | 871 | ||
diff --git a/drivers/target/target_core_transport.c b/drivers/target/target_core_transport.c index f0e8f0f4ccb4..ee5081ba5313 100644 --- a/drivers/target/target_core_transport.c +++ b/drivers/target/target_core_transport.c | |||
| @@ -250,10 +250,10 @@ int transport_alloc_session_tags(struct se_session *se_sess, | |||
| 250 | { | 250 | { |
| 251 | int rc; | 251 | int rc; |
| 252 | 252 | ||
| 253 | se_sess->sess_cmd_map = kzalloc(tag_num * tag_size, | 253 | se_sess->sess_cmd_map = kcalloc(tag_size, tag_num, |
| 254 | GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL); | 254 | GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL); |
| 255 | if (!se_sess->sess_cmd_map) { | 255 | if (!se_sess->sess_cmd_map) { |
| 256 | se_sess->sess_cmd_map = vzalloc(tag_num * tag_size); | 256 | se_sess->sess_cmd_map = vzalloc(array_size(tag_size, tag_num)); |
| 257 | if (!se_sess->sess_cmd_map) { | 257 | if (!se_sess->sess_cmd_map) { |
| 258 | pr_err("Unable to allocate se_sess->sess_cmd_map\n"); | 258 | pr_err("Unable to allocate se_sess->sess_cmd_map\n"); |
| 259 | return -ENOMEM; | 259 | return -ENOMEM; |
diff --git a/drivers/target/target_core_user.c b/drivers/target/target_core_user.c index 94b183efd236..7f96dfa32b9c 100644 --- a/drivers/target/target_core_user.c +++ b/drivers/target/target_core_user.c | |||
| @@ -1717,8 +1717,9 @@ static int tcmu_configure_device(struct se_device *dev) | |||
| 1717 | 1717 | ||
| 1718 | info = &udev->uio_info; | 1718 | info = &udev->uio_info; |
| 1719 | 1719 | ||
| 1720 | udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) * | 1720 | udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks), |
| 1721 | sizeof(unsigned long), GFP_KERNEL); | 1721 | sizeof(unsigned long), |
| 1722 | GFP_KERNEL); | ||
| 1722 | if (!udev->data_bitmap) { | 1723 | if (!udev->data_bitmap) { |
| 1723 | ret = -ENOMEM; | 1724 | ret = -ENOMEM; |
| 1724 | goto err_bitmap_alloc; | 1725 | goto err_bitmap_alloc; |
diff --git a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c index c719167e9f28..45e7e5cbdffb 100644 --- a/drivers/thermal/int340x_thermal/acpi_thermal_rel.c +++ b/drivers/thermal/int340x_thermal/acpi_thermal_rel.c | |||
| @@ -96,7 +96,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp, | |||
| 96 | } | 96 | } |
| 97 | 97 | ||
| 98 | *trt_count = p->package.count; | 98 | *trt_count = p->package.count; |
| 99 | trts = kzalloc(*trt_count * sizeof(struct trt), GFP_KERNEL); | 99 | trts = kcalloc(*trt_count, sizeof(struct trt), GFP_KERNEL); |
| 100 | if (!trts) { | 100 | if (!trts) { |
| 101 | result = -ENOMEM; | 101 | result = -ENOMEM; |
| 102 | goto end; | 102 | goto end; |
| @@ -178,7 +178,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp, | |||
| 178 | 178 | ||
| 179 | /* ignore p->package.elements[0], as this is _ART Revision field */ | 179 | /* ignore p->package.elements[0], as this is _ART Revision field */ |
| 180 | *art_count = p->package.count - 1; | 180 | *art_count = p->package.count - 1; |
| 181 | arts = kzalloc(*art_count * sizeof(struct art), GFP_KERNEL); | 181 | arts = kcalloc(*art_count, sizeof(struct art), GFP_KERNEL); |
| 182 | if (!arts) { | 182 | if (!arts) { |
| 183 | result = -ENOMEM; | 183 | result = -ENOMEM; |
| 184 | goto end; | 184 | goto end; |
diff --git a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c index dfdf6dbc2ddc..9ec27ac1856b 100644 --- a/drivers/thermal/int340x_thermal/int340x_thermal_zone.c +++ b/drivers/thermal/int340x_thermal/int340x_thermal_zone.c | |||
| @@ -239,9 +239,10 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, | |||
| 239 | if (ACPI_FAILURE(status)) | 239 | if (ACPI_FAILURE(status)) |
| 240 | trip_cnt = 0; | 240 | trip_cnt = 0; |
| 241 | else { | 241 | else { |
| 242 | int34x_thermal_zone->aux_trips = kzalloc( | 242 | int34x_thermal_zone->aux_trips = |
| 243 | sizeof(*int34x_thermal_zone->aux_trips) * | 243 | kcalloc(trip_cnt, |
| 244 | trip_cnt, GFP_KERNEL); | 244 | sizeof(*int34x_thermal_zone->aux_trips), |
| 245 | GFP_KERNEL); | ||
| 245 | if (!int34x_thermal_zone->aux_trips) { | 246 | if (!int34x_thermal_zone->aux_trips) { |
| 246 | ret = -ENOMEM; | 247 | ret = -ENOMEM; |
| 247 | goto err_trip_alloc; | 248 | goto err_trip_alloc; |
diff --git a/drivers/thermal/of-thermal.c b/drivers/thermal/of-thermal.c index eea2fce82bf7..977a8307fbb1 100644 --- a/drivers/thermal/of-thermal.c +++ b/drivers/thermal/of-thermal.c | |||
| @@ -853,7 +853,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) | |||
| 853 | if (tz->ntrips == 0) /* must have at least one child */ | 853 | if (tz->ntrips == 0) /* must have at least one child */ |
| 854 | goto finish; | 854 | goto finish; |
| 855 | 855 | ||
| 856 | tz->trips = kzalloc(tz->ntrips * sizeof(*tz->trips), GFP_KERNEL); | 856 | tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL); |
| 857 | if (!tz->trips) { | 857 | if (!tz->trips) { |
| 858 | ret = -ENOMEM; | 858 | ret = -ENOMEM; |
| 859 | goto free_tz; | 859 | goto free_tz; |
| @@ -879,7 +879,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) | |||
| 879 | if (tz->num_tbps == 0) | 879 | if (tz->num_tbps == 0) |
| 880 | goto finish; | 880 | goto finish; |
| 881 | 881 | ||
| 882 | tz->tbps = kzalloc(tz->num_tbps * sizeof(*tz->tbps), GFP_KERNEL); | 882 | tz->tbps = kcalloc(tz->num_tbps, sizeof(*tz->tbps), GFP_KERNEL); |
| 883 | if (!tz->tbps) { | 883 | if (!tz->tbps) { |
| 884 | ret = -ENOMEM; | 884 | ret = -ENOMEM; |
| 885 | goto free_trips; | 885 | goto free_trips; |
diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 207a79838643..ed28110a3535 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c | |||
| @@ -1318,8 +1318,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
| 1318 | return PTR_ERR(tegra->clock_soctherm); | 1318 | return PTR_ERR(tegra->clock_soctherm); |
| 1319 | } | 1319 | } |
| 1320 | 1320 | ||
| 1321 | tegra->calib = devm_kzalloc(&pdev->dev, | 1321 | tegra->calib = devm_kcalloc(&pdev->dev, |
| 1322 | sizeof(u32) * soc->num_tsensors, | 1322 | soc->num_tsensors, sizeof(u32), |
| 1323 | GFP_KERNEL); | 1323 | GFP_KERNEL); |
| 1324 | if (!tegra->calib) | 1324 | if (!tegra->calib) |
| 1325 | return -ENOMEM; | 1325 | return -ENOMEM; |
| @@ -1338,8 +1338,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) | |||
| 1338 | return err; | 1338 | return err; |
| 1339 | } | 1339 | } |
| 1340 | 1340 | ||
| 1341 | tegra->thermctl_tzs = devm_kzalloc(&pdev->dev, | 1341 | tegra->thermctl_tzs = devm_kcalloc(&pdev->dev, |
| 1342 | sizeof(*z) * soc->num_ttgs, | 1342 | soc->num_ttgs, sizeof(*z), |
| 1343 | GFP_KERNEL); | 1343 | GFP_KERNEL); |
| 1344 | if (!tegra->thermctl_tzs) | 1344 | if (!tegra->thermctl_tzs) |
| 1345 | return -ENOMEM; | 1345 | return -ENOMEM; |
diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c index 46d3005335c7..bf1c628d4a7a 100644 --- a/drivers/thermal/thermal-generic-adc.c +++ b/drivers/thermal/thermal-generic-adc.c | |||
| @@ -87,8 +87,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev, | |||
| 87 | return -EINVAL; | 87 | return -EINVAL; |
| 88 | } | 88 | } |
| 89 | 89 | ||
| 90 | gti->lookup_table = devm_kzalloc(dev, sizeof(*gti->lookup_table) * | 90 | gti->lookup_table = devm_kcalloc(dev, |
| 91 | ntable, GFP_KERNEL); | 91 | ntable, sizeof(*gti->lookup_table), |
| 92 | GFP_KERNEL); | ||
| 92 | if (!gti->lookup_table) | 93 | if (!gti->lookup_table) |
| 93 | return -ENOMEM; | 94 | return -ENOMEM; |
| 94 | 95 | ||
diff --git a/drivers/thermal/x86_pkg_temp_thermal.c b/drivers/thermal/x86_pkg_temp_thermal.c index 1a6c88b10a39..1ef937d799e4 100644 --- a/drivers/thermal/x86_pkg_temp_thermal.c +++ b/drivers/thermal/x86_pkg_temp_thermal.c | |||
| @@ -516,7 +516,8 @@ static int __init pkg_temp_thermal_init(void) | |||
| 516 | return -ENODEV; | 516 | return -ENODEV; |
| 517 | 517 | ||
| 518 | max_packages = topology_max_packages(); | 518 | max_packages = topology_max_packages(); |
| 519 | packages = kzalloc(max_packages * sizeof(struct pkg_device *), GFP_KERNEL); | 519 | packages = kcalloc(max_packages, sizeof(struct pkg_device *), |
| 520 | GFP_KERNEL); | ||
| 520 | if (!packages) | 521 | if (!packages) |
| 521 | return -ENOMEM; | 522 | return -ENOMEM; |
| 522 | 523 | ||
diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c index 47ac56817c43..eea4049b5dcc 100644 --- a/drivers/tty/ehv_bytechan.c +++ b/drivers/tty/ehv_bytechan.c | |||
| @@ -754,7 +754,7 @@ static int __init ehv_bc_init(void) | |||
| 754 | * array, then you can use pointer math (e.g. "bc - bcs") to get its | 754 | * array, then you can use pointer math (e.g. "bc - bcs") to get its |
| 755 | * tty index. | 755 | * tty index. |
| 756 | */ | 756 | */ |
| 757 | bcs = kzalloc(count * sizeof(struct ehv_bc_data), GFP_KERNEL); | 757 | bcs = kcalloc(count, sizeof(struct ehv_bc_data), GFP_KERNEL); |
| 758 | if (!bcs) | 758 | if (!bcs) |
| 759 | return -ENOMEM; | 759 | return -ENOMEM; |
| 760 | 760 | ||
diff --git a/drivers/tty/goldfish.c b/drivers/tty/goldfish.c index 1c1bd0afcd48..37caba7c3aff 100644 --- a/drivers/tty/goldfish.c +++ b/drivers/tty/goldfish.c | |||
| @@ -245,8 +245,9 @@ static int goldfish_tty_create_driver(void) | |||
| 245 | int ret; | 245 | int ret; |
| 246 | struct tty_driver *tty; | 246 | struct tty_driver *tty; |
| 247 | 247 | ||
| 248 | goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) * | 248 | goldfish_ttys = kcalloc(goldfish_tty_line_count, |
| 249 | goldfish_tty_line_count, GFP_KERNEL); | 249 | sizeof(*goldfish_ttys), |
| 250 | GFP_KERNEL); | ||
| 250 | if (goldfish_ttys == NULL) { | 251 | if (goldfish_ttys == NULL) { |
| 251 | ret = -ENOMEM; | 252 | ret = -ENOMEM; |
| 252 | goto err_alloc_goldfish_ttys_failed; | 253 | goto err_alloc_goldfish_ttys_failed; |
diff --git a/drivers/tty/hvc/hvc_iucv.c b/drivers/tty/hvc/hvc_iucv.c index a74680729825..2af1e5751bd6 100644 --- a/drivers/tty/hvc/hvc_iucv.c +++ b/drivers/tty/hvc/hvc_iucv.c | |||
| @@ -1252,7 +1252,7 @@ static int hvc_iucv_setup_filter(const char *val) | |||
| 1252 | if (size > MAX_VMID_FILTER) | 1252 | if (size > MAX_VMID_FILTER) |
| 1253 | return -ENOSPC; | 1253 | return -ENOSPC; |
| 1254 | 1254 | ||
| 1255 | array = kzalloc(size * 8, GFP_KERNEL); | 1255 | array = kcalloc(size, 8, GFP_KERNEL); |
| 1256 | if (!array) | 1256 | if (!array) |
| 1257 | return -ENOMEM; | 1257 | return -ENOMEM; |
| 1258 | 1258 | ||
diff --git a/drivers/tty/hvc/hvcs.c b/drivers/tty/hvc/hvcs.c index 1db1d97e72e7..cb4db1b3ca3c 100644 --- a/drivers/tty/hvc/hvcs.c +++ b/drivers/tty/hvc/hvcs.c | |||
| @@ -1441,7 +1441,8 @@ static int hvcs_alloc_index_list(int n) | |||
| 1441 | { | 1441 | { |
| 1442 | int i; | 1442 | int i; |
| 1443 | 1443 | ||
| 1444 | hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL); | 1444 | hvcs_index_list = kmalloc_array(n, sizeof(hvcs_index_count), |
| 1445 | GFP_KERNEL); | ||
| 1445 | if (!hvcs_index_list) | 1446 | if (!hvcs_index_list) |
| 1446 | return -ENOMEM; | 1447 | return -ENOMEM; |
| 1447 | hvcs_index_count = n; | 1448 | hvcs_index_count = n; |
diff --git a/drivers/tty/isicom.c b/drivers/tty/isicom.c index bdd3027ef01b..8d96e86966f1 100644 --- a/drivers/tty/isicom.c +++ b/drivers/tty/isicom.c | |||
| @@ -1477,7 +1477,7 @@ static int load_firmware(struct pci_dev *pdev, | |||
| 1477 | goto errrelfw; | 1477 | goto errrelfw; |
| 1478 | } | 1478 | } |
| 1479 | 1479 | ||
| 1480 | data = kmalloc(word_count * 2, GFP_KERNEL); | 1480 | data = kmalloc_array(word_count, 2, GFP_KERNEL); |
| 1481 | if (data == NULL) { | 1481 | if (data == NULL) { |
| 1482 | dev_err(&pdev->dev, "Card%d, firmware upload " | 1482 | dev_err(&pdev->dev, "Card%d, firmware upload " |
| 1483 | "failed, not enough memory\n", index + 1); | 1483 | "failed, not enough memory\n", index + 1); |
diff --git a/drivers/tty/serial/atmel_serial.c b/drivers/tty/serial/atmel_serial.c index 55b3eff148b1..8e4428725848 100644 --- a/drivers/tty/serial/atmel_serial.c +++ b/drivers/tty/serial/atmel_serial.c | |||
| @@ -2738,8 +2738,9 @@ static int atmel_serial_probe(struct platform_device *pdev) | |||
| 2738 | 2738 | ||
| 2739 | if (!atmel_use_pdc_rx(&atmel_port->uart)) { | 2739 | if (!atmel_use_pdc_rx(&atmel_port->uart)) { |
| 2740 | ret = -ENOMEM; | 2740 | ret = -ENOMEM; |
| 2741 | data = kmalloc(sizeof(struct atmel_uart_char) | 2741 | data = kmalloc_array(ATMEL_SERIAL_RINGSIZE, |
| 2742 | * ATMEL_SERIAL_RINGSIZE, GFP_KERNEL); | 2742 | sizeof(struct atmel_uart_char), |
| 2743 | GFP_KERNEL); | ||
| 2743 | if (!data) | 2744 | if (!data) |
| 2744 | goto err_alloc_ring; | 2745 | goto err_alloc_ring; |
| 2745 | atmel_port->rx_ring.buf = data; | 2746 | atmel_port->rx_ring.buf = data; |
diff --git a/drivers/tty/serial/pch_uart.c b/drivers/tty/serial/pch_uart.c index 760d5dd0aada..cb85002a10d8 100644 --- a/drivers/tty/serial/pch_uart.c +++ b/drivers/tty/serial/pch_uart.c | |||
| @@ -991,7 +991,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) | |||
| 991 | 991 | ||
| 992 | priv->tx_dma_use = 1; | 992 | priv->tx_dma_use = 1; |
| 993 | 993 | ||
| 994 | priv->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC); | 994 | priv->sg_tx_p = kcalloc(num, sizeof(struct scatterlist), GFP_ATOMIC); |
| 995 | if (!priv->sg_tx_p) { | 995 | if (!priv->sg_tx_p) { |
| 996 | dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__); | 996 | dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__); |
| 997 | return 0; | 997 | return 0; |
diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c index 520b43b23543..5690c09cc041 100644 --- a/drivers/tty/serial/rp2.c +++ b/drivers/tty/serial/rp2.c | |||
| @@ -774,7 +774,7 @@ static int rp2_probe(struct pci_dev *pdev, | |||
| 774 | 774 | ||
| 775 | rp2_init_card(card); | 775 | rp2_init_card(card); |
| 776 | 776 | ||
| 777 | ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports, | 777 | ports = devm_kcalloc(&pdev->dev, card->n_ports, sizeof(*ports), |
| 778 | GFP_KERNEL); | 778 | GFP_KERNEL); |
| 779 | if (!ports) | 779 | if (!ports) |
| 780 | return -ENOMEM; | 780 | return -ENOMEM; |
diff --git a/drivers/tty/serial/serial_core.c b/drivers/tty/serial/serial_core.c index 890b8832aff2..9c14a453f73c 100644 --- a/drivers/tty/serial/serial_core.c +++ b/drivers/tty/serial/serial_core.c | |||
| @@ -2445,7 +2445,7 @@ int uart_register_driver(struct uart_driver *drv) | |||
| 2445 | * Maybe we should be using a slab cache for this, especially if | 2445 | * Maybe we should be using a slab cache for this, especially if |
| 2446 | * we have a large number of ports to handle. | 2446 | * we have a large number of ports to handle. |
| 2447 | */ | 2447 | */ |
| 2448 | drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL); | 2448 | drv->state = kcalloc(drv->nr, sizeof(struct uart_state), GFP_KERNEL); |
| 2449 | if (!drv->state) | 2449 | if (!drv->state) |
| 2450 | goto out; | 2450 | goto out; |
| 2451 | 2451 | ||
diff --git a/drivers/tty/serial/sunsab.c b/drivers/tty/serial/sunsab.c index b93d0225f8c9..72131b5e132e 100644 --- a/drivers/tty/serial/sunsab.c +++ b/drivers/tty/serial/sunsab.c | |||
| @@ -1125,8 +1125,9 @@ static int __init sunsab_init(void) | |||
| 1125 | } | 1125 | } |
| 1126 | 1126 | ||
| 1127 | if (num_channels) { | 1127 | if (num_channels) { |
| 1128 | sunsab_ports = kzalloc(sizeof(struct uart_sunsab_port) * | 1128 | sunsab_ports = kcalloc(num_channels, |
| 1129 | num_channels, GFP_KERNEL); | 1129 | sizeof(struct uart_sunsab_port), |
| 1130 | GFP_KERNEL); | ||
| 1130 | if (!sunsab_ports) | 1131 | if (!sunsab_ports) |
| 1131 | return -ENOMEM; | 1132 | return -ENOMEM; |
| 1132 | 1133 | ||
diff --git a/drivers/tty/vt/consolemap.c b/drivers/tty/vt/consolemap.c index 722a6690c70d..7c7ada0b3ea0 100644 --- a/drivers/tty/vt/consolemap.c +++ b/drivers/tty/vt/consolemap.c | |||
| @@ -231,7 +231,7 @@ static void set_inverse_trans_unicode(struct vc_data *conp, | |||
| 231 | q = p->inverse_trans_unicode; | 231 | q = p->inverse_trans_unicode; |
| 232 | if (!q) { | 232 | if (!q) { |
| 233 | q = p->inverse_trans_unicode = | 233 | q = p->inverse_trans_unicode = |
| 234 | kmalloc(MAX_GLYPH * sizeof(u16), GFP_KERNEL); | 234 | kmalloc_array(MAX_GLYPH, sizeof(u16), GFP_KERNEL); |
| 235 | if (!q) | 235 | if (!q) |
| 236 | return; | 236 | return; |
| 237 | } | 237 | } |
| @@ -479,7 +479,8 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) | |||
| 479 | 479 | ||
| 480 | p1 = p->uni_pgdir[n = unicode >> 11]; | 480 | p1 = p->uni_pgdir[n = unicode >> 11]; |
| 481 | if (!p1) { | 481 | if (!p1) { |
| 482 | p1 = p->uni_pgdir[n] = kmalloc(32*sizeof(u16 *), GFP_KERNEL); | 482 | p1 = p->uni_pgdir[n] = kmalloc_array(32, sizeof(u16 *), |
| 483 | GFP_KERNEL); | ||
| 483 | if (!p1) return -ENOMEM; | 484 | if (!p1) return -ENOMEM; |
| 484 | for (i = 0; i < 32; i++) | 485 | for (i = 0; i < 32; i++) |
| 485 | p1[i] = NULL; | 486 | p1[i] = NULL; |
| @@ -487,7 +488,7 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) | |||
| 487 | 488 | ||
| 488 | p2 = p1[n = (unicode >> 6) & 0x1f]; | 489 | p2 = p1[n = (unicode >> 6) & 0x1f]; |
| 489 | if (!p2) { | 490 | if (!p2) { |
| 490 | p2 = p1[n] = kmalloc(64*sizeof(u16), GFP_KERNEL); | 491 | p2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL); |
| 491 | if (!p2) return -ENOMEM; | 492 | if (!p2) return -ENOMEM; |
| 492 | memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */ | 493 | memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */ |
| 493 | } | 494 | } |
diff --git a/drivers/tty/vt/keyboard.c b/drivers/tty/vt/keyboard.c index 5d412df8e943..d5b4a2b44ab8 100644 --- a/drivers/tty/vt/keyboard.c +++ b/drivers/tty/vt/keyboard.c | |||
| @@ -1624,7 +1624,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) | |||
| 1624 | struct kbdiacr *dia; | 1624 | struct kbdiacr *dia; |
| 1625 | int i; | 1625 | int i; |
| 1626 | 1626 | ||
| 1627 | dia = kmalloc(MAX_DIACR * sizeof(struct kbdiacr), | 1627 | dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr), |
| 1628 | GFP_KERNEL); | 1628 | GFP_KERNEL); |
| 1629 | if (!dia) | 1629 | if (!dia) |
| 1630 | return -ENOMEM; | 1630 | return -ENOMEM; |
| @@ -1657,7 +1657,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) | |||
| 1657 | struct kbdiacrsuc __user *a = udp; | 1657 | struct kbdiacrsuc __user *a = udp; |
| 1658 | void *buf; | 1658 | void *buf; |
| 1659 | 1659 | ||
| 1660 | buf = kmalloc(MAX_DIACR * sizeof(struct kbdiacruc), | 1660 | buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc), |
| 1661 | GFP_KERNEL); | 1661 | GFP_KERNEL); |
| 1662 | if (buf == NULL) | 1662 | if (buf == NULL) |
| 1663 | return -ENOMEM; | 1663 | return -ENOMEM; |
diff --git a/drivers/tty/vt/selection.c b/drivers/tty/vt/selection.c index 7851383fbd6c..90ea1cc52b7a 100644 --- a/drivers/tty/vt/selection.c +++ b/drivers/tty/vt/selection.c | |||
| @@ -280,7 +280,8 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t | |||
| 280 | 280 | ||
| 281 | /* Allocate a new buffer before freeing the old one ... */ | 281 | /* Allocate a new buffer before freeing the old one ... */ |
| 282 | multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */ | 282 | multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */ |
| 283 | bp = kmalloc(((sel_end-sel_start)/2+1)*multiplier, GFP_KERNEL); | 283 | bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier, |
| 284 | GFP_KERNEL); | ||
| 284 | if (!bp) { | 285 | if (!bp) { |
| 285 | printk(KERN_WARNING "selection: kmalloc() failed\n"); | 286 | printk(KERN_WARNING "selection: kmalloc() failed\n"); |
| 286 | clear_selection(); | 287 | clear_selection(); |
diff --git a/drivers/uio/uio_pruss.c b/drivers/uio/uio_pruss.c index 31d5b1d3b5af..91aea8823af5 100644 --- a/drivers/uio/uio_pruss.c +++ b/drivers/uio/uio_pruss.c | |||
| @@ -129,7 +129,7 @@ static int pruss_probe(struct platform_device *pdev) | |||
| 129 | if (!gdev) | 129 | if (!gdev) |
| 130 | return -ENOMEM; | 130 | return -ENOMEM; |
| 131 | 131 | ||
| 132 | gdev->info = kzalloc(sizeof(*p) * MAX_PRUSS_EVT, GFP_KERNEL); | 132 | gdev->info = kcalloc(MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL); |
| 133 | if (!gdev->info) { | 133 | if (!gdev->info) { |
| 134 | kfree(gdev); | 134 | kfree(gdev); |
| 135 | return -ENOMEM; | 135 | return -ENOMEM; |
diff --git a/drivers/usb/core/devio.c b/drivers/usb/core/devio.c index 76e16c5251b9..476dcc5f2da3 100644 --- a/drivers/usb/core/devio.c +++ b/drivers/usb/core/devio.c | |||
| @@ -897,7 +897,7 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps, | |||
| 897 | if (num_streams_ret && (num_streams < 2 || num_streams > 65536)) | 897 | if (num_streams_ret && (num_streams < 2 || num_streams > 65536)) |
| 898 | return -EINVAL; | 898 | return -EINVAL; |
| 899 | 899 | ||
| 900 | eps = kmalloc(num_eps * sizeof(*eps), GFP_KERNEL); | 900 | eps = kmalloc_array(num_eps, sizeof(*eps), GFP_KERNEL); |
| 901 | if (!eps) | 901 | if (!eps) |
| 902 | return -ENOMEM; | 902 | return -ENOMEM; |
| 903 | 903 | ||
| @@ -1602,8 +1602,9 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb | |||
| 1602 | as->mem_usage = u; | 1602 | as->mem_usage = u; |
| 1603 | 1603 | ||
| 1604 | if (num_sgs) { | 1604 | if (num_sgs) { |
| 1605 | as->urb->sg = kmalloc(num_sgs * sizeof(struct scatterlist), | 1605 | as->urb->sg = kmalloc_array(num_sgs, |
| 1606 | GFP_KERNEL); | 1606 | sizeof(struct scatterlist), |
| 1607 | GFP_KERNEL); | ||
| 1607 | if (!as->urb->sg) { | 1608 | if (!as->urb->sg) { |
| 1608 | ret = -ENOMEM; | 1609 | ret = -ENOMEM; |
| 1609 | goto error; | 1610 | goto error; |
diff --git a/drivers/usb/core/hub.c b/drivers/usb/core/hub.c index 26c2438d2889..fcae521df29b 100644 --- a/drivers/usb/core/hub.c +++ b/drivers/usb/core/hub.c | |||
| @@ -1376,7 +1376,7 @@ static int hub_configure(struct usb_hub *hub, | |||
| 1376 | dev_info(hub_dev, "%d port%s detected\n", maxchild, | 1376 | dev_info(hub_dev, "%d port%s detected\n", maxchild, |
| 1377 | (maxchild == 1) ? "" : "s"); | 1377 | (maxchild == 1) ? "" : "s"); |
| 1378 | 1378 | ||
| 1379 | hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL); | 1379 | hub->ports = kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL); |
| 1380 | if (!hub->ports) { | 1380 | if (!hub->ports) { |
| 1381 | ret = -ENOMEM; | 1381 | ret = -ENOMEM; |
| 1382 | goto fail; | 1382 | goto fail; |
diff --git a/drivers/usb/core/message.c b/drivers/usb/core/message.c index 7b137003c2be..1a15392326fc 100644 --- a/drivers/usb/core/message.c +++ b/drivers/usb/core/message.c | |||
| @@ -390,7 +390,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, | |||
| 390 | } | 390 | } |
| 391 | 391 | ||
| 392 | /* initialize all the urbs we'll use */ | 392 | /* initialize all the urbs we'll use */ |
| 393 | io->urbs = kmalloc(io->entries * sizeof(*io->urbs), mem_flags); | 393 | io->urbs = kmalloc_array(io->entries, sizeof(*io->urbs), mem_flags); |
| 394 | if (!io->urbs) | 394 | if (!io->urbs) |
| 395 | goto nomem; | 395 | goto nomem; |
| 396 | 396 | ||
| @@ -1824,8 +1824,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration) | |||
| 1824 | n = nintf = 0; | 1824 | n = nintf = 0; |
| 1825 | if (cp) { | 1825 | if (cp) { |
| 1826 | nintf = cp->desc.bNumInterfaces; | 1826 | nintf = cp->desc.bNumInterfaces; |
| 1827 | new_interfaces = kmalloc(nintf * sizeof(*new_interfaces), | 1827 | new_interfaces = kmalloc_array(nintf, sizeof(*new_interfaces), |
| 1828 | GFP_NOIO); | 1828 | GFP_NOIO); |
| 1829 | if (!new_interfaces) | 1829 | if (!new_interfaces) |
| 1830 | return -ENOMEM; | 1830 | return -ENOMEM; |
| 1831 | 1831 | ||
diff --git a/drivers/usb/dwc2/hcd.c b/drivers/usb/dwc2/hcd.c index 1faefea16cec..edaf0b6af4f0 100644 --- a/drivers/usb/dwc2/hcd.c +++ b/drivers/usb/dwc2/hcd.c | |||
| @@ -5079,13 +5079,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) | |||
| 5079 | dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg); | 5079 | dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg); |
| 5080 | 5080 | ||
| 5081 | #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS | 5081 | #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS |
| 5082 | hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) * | 5082 | hsotg->frame_num_array = kcalloc(FRAME_NUM_ARRAY_SIZE, |
| 5083 | FRAME_NUM_ARRAY_SIZE, GFP_KERNEL); | 5083 | sizeof(*hsotg->frame_num_array), |
| 5084 | GFP_KERNEL); | ||
| 5084 | if (!hsotg->frame_num_array) | 5085 | if (!hsotg->frame_num_array) |
| 5085 | goto error1; | 5086 | goto error1; |
| 5086 | hsotg->last_frame_num_array = kzalloc( | 5087 | hsotg->last_frame_num_array = |
| 5087 | sizeof(*hsotg->last_frame_num_array) * | 5088 | kcalloc(FRAME_NUM_ARRAY_SIZE, |
| 5088 | FRAME_NUM_ARRAY_SIZE, GFP_KERNEL); | 5089 | sizeof(*hsotg->last_frame_num_array), GFP_KERNEL); |
| 5089 | if (!hsotg->last_frame_num_array) | 5090 | if (!hsotg->last_frame_num_array) |
| 5090 | goto error1; | 5091 | goto error1; |
| 5091 | #endif | 5092 | #endif |
diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index a4d99bf50f2f..17147b8c771e 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c | |||
| @@ -2036,7 +2036,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, | |||
| 2036 | udc->num_ep = usba_config_fifo_table(udc); | 2036 | udc->num_ep = usba_config_fifo_table(udc); |
| 2037 | } | 2037 | } |
| 2038 | 2038 | ||
| 2039 | eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * udc->num_ep, | 2039 | eps = devm_kcalloc(&pdev->dev, udc->num_ep, sizeof(struct usba_ep), |
| 2040 | GFP_KERNEL); | 2040 | GFP_KERNEL); |
| 2041 | if (!eps) | 2041 | if (!eps) |
| 2042 | return ERR_PTR(-ENOMEM); | 2042 | return ERR_PTR(-ENOMEM); |
diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index 03149b9d7ea7..a4d9b5e1e50e 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c | |||
| @@ -138,9 +138,9 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) | |||
| 138 | __func__, ep, num_tabs); | 138 | __func__, ep, num_tabs); |
| 139 | 139 | ||
| 140 | /* Allocate memory for table array */ | 140 | /* Allocate memory for table array */ |
| 141 | ep->bd_list.bd_table_array = kzalloc( | 141 | ep->bd_list.bd_table_array = kcalloc(num_tabs, |
| 142 | num_tabs * sizeof(struct bd_table *), | 142 | sizeof(struct bd_table *), |
| 143 | GFP_ATOMIC); | 143 | GFP_ATOMIC); |
| 144 | if (!ep->bd_list.bd_table_array) | 144 | if (!ep->bd_list.bd_table_array) |
| 145 | return -ENOMEM; | 145 | return -ENOMEM; |
| 146 | 146 | ||
diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index 9a3f7db26a5e..be59309e848c 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c | |||
| @@ -2246,7 +2246,7 @@ static int struct_udc_setup(struct fsl_udc *udc, | |||
| 2246 | pdata = dev_get_platdata(&pdev->dev); | 2246 | pdata = dev_get_platdata(&pdev->dev); |
| 2247 | udc->phy_mode = pdata->phy_mode; | 2247 | udc->phy_mode = pdata->phy_mode; |
| 2248 | 2248 | ||
| 2249 | udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL); | 2249 | udc->eps = kcalloc(udc->max_ep, sizeof(struct fsl_ep), GFP_KERNEL); |
| 2250 | if (!udc->eps) | 2250 | if (!udc->eps) |
| 2251 | return -1; | 2251 | return -1; |
| 2252 | 2252 | ||
diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 977ea1a02cf9..7cf98c793e04 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c | |||
| @@ -2427,7 +2427,8 @@ static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev, | |||
| 2427 | if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES) | 2427 | if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES) |
| 2428 | usb3->num_usb3_eps = USB3_MAX_NUM_PIPES; | 2428 | usb3->num_usb3_eps = USB3_MAX_NUM_PIPES; |
| 2429 | 2429 | ||
| 2430 | usb3->usb3_ep = devm_kzalloc(dev, sizeof(*usb3_ep) * usb3->num_usb3_eps, | 2430 | usb3->usb3_ep = devm_kcalloc(dev, |
| 2431 | usb3->num_usb3_eps, sizeof(*usb3_ep), | ||
| 2431 | GFP_KERNEL); | 2432 | GFP_KERNEL); |
| 2432 | if (!usb3->usb3_ep) | 2433 | if (!usb3->usb3_ep) |
| 2433 | return -ENOMEM; | 2434 | return -ENOMEM; |
diff --git a/drivers/usb/host/ehci-sched.c b/drivers/usb/host/ehci-sched.c index e56db44708bc..1d87295682b8 100644 --- a/drivers/usb/host/ehci-sched.c +++ b/drivers/usb/host/ehci-sched.c | |||
| @@ -117,8 +117,9 @@ static struct ehci_tt *find_tt(struct usb_device *udev) | |||
| 117 | if (utt->multi) { | 117 | if (utt->multi) { |
| 118 | tt_index = utt->hcpriv; | 118 | tt_index = utt->hcpriv; |
| 119 | if (!tt_index) { /* Create the index array */ | 119 | if (!tt_index) { /* Create the index array */ |
| 120 | tt_index = kzalloc(utt->hub->maxchild * | 120 | tt_index = kcalloc(utt->hub->maxchild, |
| 121 | sizeof(*tt_index), GFP_ATOMIC); | 121 | sizeof(*tt_index), |
| 122 | GFP_ATOMIC); | ||
| 122 | if (!tt_index) | 123 | if (!tt_index) |
| 123 | return ERR_PTR(-ENOMEM); | 124 | return ERR_PTR(-ENOMEM); |
| 124 | utt->hcpriv = tt_index; | 125 | utt->hcpriv = tt_index; |
diff --git a/drivers/usb/host/fhci-tds.c b/drivers/usb/host/fhci-tds.c index 3a4e8f616751..f3308ce25043 100644 --- a/drivers/usb/host/fhci-tds.c +++ b/drivers/usb/host/fhci-tds.c | |||
| @@ -189,7 +189,7 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem, | |||
| 189 | goto err; | 189 | goto err; |
| 190 | } | 190 | } |
| 191 | 191 | ||
| 192 | buff = kmalloc(1028 * sizeof(*buff), GFP_KERNEL); | 192 | buff = kmalloc_array(1028, sizeof(*buff), GFP_KERNEL); |
| 193 | if (!buff) { | 193 | if (!buff) { |
| 194 | kfree(pkt); | 194 | kfree(pkt); |
| 195 | err_for = "buffer"; | 195 | err_for = "buffer"; |
diff --git a/drivers/usb/host/imx21-hcd.c b/drivers/usb/host/imx21-hcd.c index 3a8bbfe43a8e..6e3dad19d369 100644 --- a/drivers/usb/host/imx21-hcd.c +++ b/drivers/usb/host/imx21-hcd.c | |||
| @@ -741,8 +741,8 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd, | |||
| 741 | if (urb_priv == NULL) | 741 | if (urb_priv == NULL) |
| 742 | return -ENOMEM; | 742 | return -ENOMEM; |
| 743 | 743 | ||
| 744 | urb_priv->isoc_td = kzalloc( | 744 | urb_priv->isoc_td = kcalloc(urb->number_of_packets, sizeof(struct td), |
| 745 | sizeof(struct td) * urb->number_of_packets, mem_flags); | 745 | mem_flags); |
| 746 | if (urb_priv->isoc_td == NULL) { | 746 | if (urb_priv->isoc_td == NULL) { |
| 747 | ret = -ENOMEM; | 747 | ret = -ENOMEM; |
| 748 | goto alloc_td_failed; | 748 | goto alloc_td_failed; |
diff --git a/drivers/usb/host/ohci-dbg.c b/drivers/usb/host/ohci-dbg.c index d3ee1f52aaab..4f267dc93882 100644 --- a/drivers/usb/host/ohci-dbg.c +++ b/drivers/usb/host/ohci-dbg.c | |||
| @@ -492,7 +492,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) | |||
| 492 | char *next; | 492 | char *next; |
| 493 | unsigned i; | 493 | unsigned i; |
| 494 | 494 | ||
| 495 | seen = kmalloc(DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC); | 495 | seen = kmalloc_array(DBG_SCHED_LIMIT, sizeof(*seen), GFP_ATOMIC); |
| 496 | if (!seen) | 496 | if (!seen) |
| 497 | return 0; | 497 | return 0; |
| 498 | seen_count = 0; | 498 | seen_count = 0; |
diff --git a/drivers/usb/host/xhci-mem.c b/drivers/usb/host/xhci-mem.c index 4fe74711938e..acbd3d7b8828 100644 --- a/drivers/usb/host/xhci-mem.c +++ b/drivers/usb/host/xhci-mem.c | |||
| @@ -2274,8 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) | |||
| 2274 | xhci->hw_ports[i].hw_portnum = i; | 2274 | xhci->hw_ports[i].hw_portnum = i; |
| 2275 | } | 2275 | } |
| 2276 | 2276 | ||
| 2277 | xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags, | 2277 | xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags, |
| 2278 | dev_to_node(dev)); | 2278 | dev_to_node(dev)); |
| 2279 | if (!xhci->rh_bw) | 2279 | if (!xhci->rh_bw) |
| 2280 | return -ENOMEM; | 2280 | return -ENOMEM; |
| 2281 | for (i = 0; i < num_ports; i++) { | 2281 | for (i = 0; i < num_ports; i++) { |
diff --git a/drivers/usb/misc/ldusb.c b/drivers/usb/misc/ldusb.c index 236a60f53099..c2e255f02a72 100644 --- a/drivers/usb/misc/ldusb.c +++ b/drivers/usb/misc/ldusb.c | |||
| @@ -695,7 +695,10 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
| 695 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); | 695 | dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n"); |
| 696 | 696 | ||
| 697 | dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); | 697 | dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint); |
| 698 | dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL); | 698 | dev->ring_buffer = |
| 699 | kmalloc_array(ring_buffer_size, | ||
| 700 | sizeof(size_t) + dev->interrupt_in_endpoint_size, | ||
| 701 | GFP_KERNEL); | ||
| 699 | if (!dev->ring_buffer) | 702 | if (!dev->ring_buffer) |
| 700 | goto error; | 703 | goto error; |
| 701 | dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); | 704 | dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL); |
| @@ -706,7 +709,9 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * | |||
| 706 | goto error; | 709 | goto error; |
| 707 | dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) : | 710 | dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) : |
| 708 | udev->descriptor.bMaxPacketSize0; | 711 | udev->descriptor.bMaxPacketSize0; |
| 709 | dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL); | 712 | dev->interrupt_out_buffer = |
| 713 | kmalloc_array(write_buffer_size, | ||
| 714 | dev->interrupt_out_endpoint_size, GFP_KERNEL); | ||
| 710 | if (!dev->interrupt_out_buffer) | 715 | if (!dev->interrupt_out_buffer) |
| 711 | goto error; | 716 | goto error; |
| 712 | dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); | 717 | dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL); |
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c index a0d6e0af957c..c4f017e1d17a 100644 --- a/drivers/usb/misc/sisusbvga/sisusb_con.c +++ b/drivers/usb/misc/sisusbvga/sisusb_con.c | |||
| @@ -1243,7 +1243,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font, | |||
| 1243 | } | 1243 | } |
| 1244 | 1244 | ||
| 1245 | if (!sisusb->font_backup) | 1245 | if (!sisusb->font_backup) |
| 1246 | sisusb->font_backup = vmalloc(charcount * 32); | 1246 | sisusb->font_backup = vmalloc(array_size(charcount, 32)); |
| 1247 | 1247 | ||
| 1248 | if (sisusb->font_backup) { | 1248 | if (sisusb->font_backup) { |
| 1249 | memcpy(sisusb->font_backup, font->data, charcount * 32); | 1249 | memcpy(sisusb->font_backup, font->data, charcount * 32); |
diff --git a/drivers/usb/mon/mon_bin.c b/drivers/usb/mon/mon_bin.c index 34e866ad4a81..ad2c082bd0fb 100644 --- a/drivers/usb/mon/mon_bin.c +++ b/drivers/usb/mon/mon_bin.c | |||
| @@ -1024,7 +1024,8 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg | |||
| 1024 | return -EINVAL; | 1024 | return -EINVAL; |
| 1025 | 1025 | ||
| 1026 | size = CHUNK_ALIGN(arg); | 1026 | size = CHUNK_ALIGN(arg); |
| 1027 | vec = kzalloc(sizeof(struct mon_pgmap) * (size / CHUNK_SIZE), GFP_KERNEL); | 1027 | vec = kcalloc(size / CHUNK_SIZE, sizeof(struct mon_pgmap), |
| 1028 | GFP_KERNEL); | ||
| 1028 | if (vec == NULL) { | 1029 | if (vec == NULL) { |
| 1029 | ret = -ENOMEM; | 1030 | ret = -ENOMEM; |
| 1030 | break; | 1031 | break; |
diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index 34ee9ebe12a3..33d059c40616 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c | |||
| @@ -1068,7 +1068,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) | |||
| 1068 | if (!gpriv) | 1068 | if (!gpriv) |
| 1069 | return -ENOMEM; | 1069 | return -ENOMEM; |
| 1070 | 1070 | ||
| 1071 | uep = kzalloc(sizeof(struct usbhsg_uep) * pipe_size, GFP_KERNEL); | 1071 | uep = kcalloc(pipe_size, sizeof(struct usbhsg_uep), GFP_KERNEL); |
| 1072 | if (!uep) { | 1072 | if (!uep) { |
| 1073 | ret = -ENOMEM; | 1073 | ret = -ENOMEM; |
| 1074 | goto usbhs_mod_gadget_probe_err_gpriv; | 1074 | goto usbhs_mod_gadget_probe_err_gpriv; |
diff --git a/drivers/usb/renesas_usbhs/pipe.c b/drivers/usb/renesas_usbhs/pipe.c index 9677e0e31475..c4922b96c93b 100644 --- a/drivers/usb/renesas_usbhs/pipe.c +++ b/drivers/usb/renesas_usbhs/pipe.c | |||
| @@ -803,7 +803,8 @@ int usbhs_pipe_probe(struct usbhs_priv *priv) | |||
| 803 | return -EINVAL; | 803 | return -EINVAL; |
| 804 | } | 804 | } |
| 805 | 805 | ||
| 806 | info->pipe = kzalloc(sizeof(struct usbhs_pipe) * pipe_size, GFP_KERNEL); | 806 | info->pipe = kcalloc(pipe_size, sizeof(struct usbhs_pipe), |
| 807 | GFP_KERNEL); | ||
| 807 | if (!info->pipe) | 808 | if (!info->pipe) |
| 808 | return -ENOMEM; | 809 | return -ENOMEM; |
| 809 | 810 | ||
diff --git a/drivers/usb/serial/iuu_phoenix.c b/drivers/usb/serial/iuu_phoenix.c index 62c91e360baf..2fb71303ec3a 100644 --- a/drivers/usb/serial/iuu_phoenix.c +++ b/drivers/usb/serial/iuu_phoenix.c | |||
| @@ -736,7 +736,7 @@ static int iuu_uart_on(struct usb_serial_port *port) | |||
| 736 | int status; | 736 | int status; |
| 737 | u8 *buf; | 737 | u8 *buf; |
| 738 | 738 | ||
| 739 | buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL); | 739 | buf = kmalloc(4, GFP_KERNEL); |
| 740 | 740 | ||
| 741 | if (!buf) | 741 | if (!buf) |
| 742 | return -ENOMEM; | 742 | return -ENOMEM; |
| @@ -790,7 +790,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, | |||
| 790 | unsigned int T1FrekvensHZ = 0; | 790 | unsigned int T1FrekvensHZ = 0; |
| 791 | 791 | ||
| 792 | dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base); | 792 | dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base); |
| 793 | dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL); | 793 | dataout = kmalloc(5, GFP_KERNEL); |
| 794 | 794 | ||
| 795 | if (!dataout) | 795 | if (!dataout) |
| 796 | return -ENOMEM; | 796 | return -ENOMEM; |
diff --git a/drivers/usb/storage/alauda.c b/drivers/usb/storage/alauda.c index 900591df8bb2..6b8edf6178df 100644 --- a/drivers/usb/storage/alauda.c +++ b/drivers/usb/storage/alauda.c | |||
| @@ -1025,7 +1025,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address, | |||
| 1025 | * We also need a temporary block buffer, where we read in the old data, | 1025 | * We also need a temporary block buffer, where we read in the old data, |
| 1026 | * overwrite parts with the new data, and manipulate the redundancy data | 1026 | * overwrite parts with the new data, and manipulate the redundancy data |
| 1027 | */ | 1027 | */ |
| 1028 | blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO); | 1028 | blockbuffer = kmalloc_array(pagesize + 64, blocksize, GFP_NOIO); |
| 1029 | if (!blockbuffer) { | 1029 | if (!blockbuffer) { |
| 1030 | kfree(buffer); | 1030 | kfree(buffer); |
| 1031 | return USB_STOR_TRANSPORT_ERROR; | 1031 | return USB_STOR_TRANSPORT_ERROR; |
diff --git a/drivers/usb/storage/ene_ub6250.c b/drivers/usb/storage/ene_ub6250.c index 93cf57ac47d6..4d261e4de9ad 100644 --- a/drivers/usb/storage/ene_ub6250.c +++ b/drivers/usb/storage/ene_ub6250.c | |||
| @@ -807,8 +807,12 @@ static int ms_lib_alloc_logicalmap(struct us_data *us) | |||
| 807 | u32 i; | 807 | u32 i; |
| 808 | struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; | 808 | struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra; |
| 809 | 809 | ||
| 810 | info->MS_Lib.Phy2LogMap = kmalloc(info->MS_Lib.NumberOfPhyBlock * sizeof(u16), GFP_KERNEL); | 810 | info->MS_Lib.Phy2LogMap = kmalloc_array(info->MS_Lib.NumberOfPhyBlock, |
| 811 | info->MS_Lib.Log2PhyMap = kmalloc(info->MS_Lib.NumberOfLogBlock * sizeof(u16), GFP_KERNEL); | 811 | sizeof(u16), |
| 812 | GFP_KERNEL); | ||
| 813 | info->MS_Lib.Log2PhyMap = kmalloc_array(info->MS_Lib.NumberOfLogBlock, | ||
| 814 | sizeof(u16), | ||
| 815 | GFP_KERNEL); | ||
| 812 | 816 | ||
| 813 | if ((info->MS_Lib.Phy2LogMap == NULL) || (info->MS_Lib.Log2PhyMap == NULL)) { | 817 | if ((info->MS_Lib.Phy2LogMap == NULL) || (info->MS_Lib.Log2PhyMap == NULL)) { |
| 814 | ms_lib_free_logicalmap(us); | 818 | ms_lib_free_logicalmap(us); |
| @@ -1113,8 +1117,12 @@ static int ms_lib_alloc_writebuf(struct us_data *us) | |||
| 1113 | 1117 | ||
| 1114 | info->MS_Lib.wrtblk = (u16)-1; | 1118 | info->MS_Lib.wrtblk = (u16)-1; |
| 1115 | 1119 | ||
| 1116 | info->MS_Lib.blkpag = kmalloc(info->MS_Lib.PagesPerBlock * info->MS_Lib.BytesPerSector, GFP_KERNEL); | 1120 | info->MS_Lib.blkpag = kmalloc_array(info->MS_Lib.PagesPerBlock, |
| 1117 | info->MS_Lib.blkext = kmalloc(info->MS_Lib.PagesPerBlock * sizeof(struct ms_lib_type_extdat), GFP_KERNEL); | 1121 | info->MS_Lib.BytesPerSector, |
| 1122 | GFP_KERNEL); | ||
| 1123 | info->MS_Lib.blkext = kmalloc_array(info->MS_Lib.PagesPerBlock, | ||
| 1124 | sizeof(struct ms_lib_type_extdat), | ||
| 1125 | GFP_KERNEL); | ||
| 1118 | 1126 | ||
| 1119 | if ((info->MS_Lib.blkpag == NULL) || (info->MS_Lib.blkext == NULL)) { | 1127 | if ((info->MS_Lib.blkpag == NULL) || (info->MS_Lib.blkext == NULL)) { |
| 1120 | ms_lib_free_writebuf(us); | 1128 | ms_lib_free_writebuf(us); |
diff --git a/drivers/usb/storage/sddr09.c b/drivers/usb/storage/sddr09.c index 1cf7dbfe277c..bc9da736bdfc 100644 --- a/drivers/usb/storage/sddr09.c +++ b/drivers/usb/storage/sddr09.c | |||
| @@ -1231,8 +1231,8 @@ sddr09_read_map(struct us_data *us) { | |||
| 1231 | 1231 | ||
| 1232 | kfree(info->lba_to_pba); | 1232 | kfree(info->lba_to_pba); |
| 1233 | kfree(info->pba_to_lba); | 1233 | kfree(info->pba_to_lba); |
| 1234 | info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); | 1234 | info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); |
| 1235 | info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); | 1235 | info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); |
| 1236 | 1236 | ||
| 1237 | if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { | 1237 | if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { |
| 1238 | printk(KERN_WARNING "sddr09_read_map: out of memory\n"); | 1238 | printk(KERN_WARNING "sddr09_read_map: out of memory\n"); |
diff --git a/drivers/usb/storage/sddr55.c b/drivers/usb/storage/sddr55.c index 8c814b2ec9b2..b8527c55335b 100644 --- a/drivers/usb/storage/sddr55.c +++ b/drivers/usb/storage/sddr55.c | |||
| @@ -651,7 +651,7 @@ static int sddr55_read_map(struct us_data *us) { | |||
| 651 | 651 | ||
| 652 | numblocks = info->capacity >> (info->blockshift + info->pageshift); | 652 | numblocks = info->capacity >> (info->blockshift + info->pageshift); |
| 653 | 653 | ||
| 654 | buffer = kmalloc( numblocks * 2, GFP_NOIO ); | 654 | buffer = kmalloc_array(numblocks, 2, GFP_NOIO ); |
| 655 | 655 | ||
| 656 | if (!buffer) | 656 | if (!buffer) |
| 657 | return -1; | 657 | return -1; |
| @@ -684,8 +684,8 @@ static int sddr55_read_map(struct us_data *us) { | |||
| 684 | 684 | ||
| 685 | kfree(info->lba_to_pba); | 685 | kfree(info->lba_to_pba); |
| 686 | kfree(info->pba_to_lba); | 686 | kfree(info->pba_to_lba); |
| 687 | info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO); | 687 | info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); |
| 688 | info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO); | 688 | info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO); |
| 689 | 689 | ||
| 690 | if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { | 690 | if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) { |
| 691 | kfree(info->lba_to_pba); | 691 | kfree(info->lba_to_pba); |
diff --git a/drivers/usb/wusbcore/wa-rpipe.c b/drivers/usb/wusbcore/wa-rpipe.c index d0f1a6698460..38884aac862b 100644 --- a/drivers/usb/wusbcore/wa-rpipe.c +++ b/drivers/usb/wusbcore/wa-rpipe.c | |||
| @@ -470,7 +470,8 @@ error: | |||
| 470 | int wa_rpipes_create(struct wahc *wa) | 470 | int wa_rpipes_create(struct wahc *wa) |
| 471 | { | 471 | { |
| 472 | wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes); | 472 | wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes); |
| 473 | wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long), | 473 | wa->rpipe_bm = kcalloc(BITS_TO_LONGS(wa->rpipes), |
| 474 | sizeof(unsigned long), | ||
| 474 | GFP_KERNEL); | 475 | GFP_KERNEL); |
| 475 | if (wa->rpipe_bm == NULL) | 476 | if (wa->rpipe_bm == NULL) |
| 476 | return -ENOMEM; | 477 | return -ENOMEM; |
diff --git a/drivers/uwb/est.c b/drivers/uwb/est.c index f3e232584284..ad30ddfe30b3 100644 --- a/drivers/uwb/est.c +++ b/drivers/uwb/est.c | |||
| @@ -217,7 +217,7 @@ static | |||
| 217 | int uwb_est_grow(void) | 217 | int uwb_est_grow(void) |
| 218 | { | 218 | { |
| 219 | size_t actual_size = uwb_est_size * sizeof(uwb_est[0]); | 219 | size_t actual_size = uwb_est_size * sizeof(uwb_est[0]); |
| 220 | void *new = kmalloc(2 * actual_size, GFP_ATOMIC); | 220 | void *new = kmalloc_array(2, actual_size, GFP_ATOMIC); |
| 221 | if (new == NULL) | 221 | if (new == NULL) |
| 222 | return -ENOMEM; | 222 | return -ENOMEM; |
| 223 | memcpy(new, uwb_est, actual_size); | 223 | memcpy(new, uwb_est, actual_size); |
diff --git a/drivers/uwb/i1480/dfu/usb.c b/drivers/uwb/i1480/dfu/usb.c index a50cf45e530f..c0430a41e24b 100644 --- a/drivers/uwb/i1480/dfu/usb.c +++ b/drivers/uwb/i1480/dfu/usb.c | |||
| @@ -376,7 +376,7 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id) | |||
| 376 | 376 | ||
| 377 | i1480 = &i1480_usb->i1480; | 377 | i1480 = &i1480_usb->i1480; |
| 378 | i1480->buf_size = 512; | 378 | i1480->buf_size = 512; |
| 379 | i1480->cmd_buf = kmalloc(2 * i1480->buf_size, GFP_KERNEL); | 379 | i1480->cmd_buf = kmalloc_array(2, i1480->buf_size, GFP_KERNEL); |
| 380 | if (i1480->cmd_buf == NULL) { | 380 | if (i1480->cmd_buf == NULL) { |
| 381 | dev_err(dev, "Cannot allocate transfer buffers\n"); | 381 | dev_err(dev, "Cannot allocate transfer buffers\n"); |
| 382 | result = -ENOMEM; | 382 | result = -ENOMEM; |
diff --git a/drivers/vhost/net.c b/drivers/vhost/net.c index e7cf7d21cfb5..686dc670fd29 100644 --- a/drivers/vhost/net.c +++ b/drivers/vhost/net.c | |||
| @@ -274,8 +274,10 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n) | |||
| 274 | zcopy = vhost_net_zcopy_mask & (0x1 << i); | 274 | zcopy = vhost_net_zcopy_mask & (0x1 << i); |
| 275 | if (!zcopy) | 275 | if (!zcopy) |
| 276 | continue; | 276 | continue; |
| 277 | n->vqs[i].ubuf_info = kmalloc(sizeof(*n->vqs[i].ubuf_info) * | 277 | n->vqs[i].ubuf_info = |
| 278 | UIO_MAXIOV, GFP_KERNEL); | 278 | kmalloc_array(UIO_MAXIOV, |
| 279 | sizeof(*n->vqs[i].ubuf_info), | ||
| 280 | GFP_KERNEL); | ||
| 279 | if (!n->vqs[i].ubuf_info) | 281 | if (!n->vqs[i].ubuf_info) |
| 280 | goto err; | 282 | goto err; |
| 281 | } | 283 | } |
| @@ -943,7 +945,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) | |||
| 943 | n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_RETRY_MAYFAIL); | 945 | n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_RETRY_MAYFAIL); |
| 944 | if (!n) | 946 | if (!n) |
| 945 | return -ENOMEM; | 947 | return -ENOMEM; |
| 946 | vqs = kmalloc(VHOST_NET_VQ_MAX * sizeof(*vqs), GFP_KERNEL); | 948 | vqs = kmalloc_array(VHOST_NET_VQ_MAX, sizeof(*vqs), GFP_KERNEL); |
| 947 | if (!vqs) { | 949 | if (!vqs) { |
| 948 | kvfree(n); | 950 | kvfree(n); |
| 949 | return -ENOMEM; | 951 | return -ENOMEM; |
diff --git a/drivers/vhost/scsi.c b/drivers/vhost/scsi.c index 7ad57094d736..17fcd3b2e686 100644 --- a/drivers/vhost/scsi.c +++ b/drivers/vhost/scsi.c | |||
| @@ -1378,7 +1378,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) | |||
| 1378 | goto err_vs; | 1378 | goto err_vs; |
| 1379 | } | 1379 | } |
| 1380 | 1380 | ||
| 1381 | vqs = kmalloc(VHOST_SCSI_MAX_VQ * sizeof(*vqs), GFP_KERNEL); | 1381 | vqs = kmalloc_array(VHOST_SCSI_MAX_VQ, sizeof(*vqs), GFP_KERNEL); |
| 1382 | if (!vqs) | 1382 | if (!vqs) |
| 1383 | goto err_vqs; | 1383 | goto err_vqs; |
| 1384 | 1384 | ||
| @@ -1685,22 +1685,25 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg, | |||
| 1685 | for (i = 0; i < VHOST_SCSI_DEFAULT_TAGS; i++) { | 1685 | for (i = 0; i < VHOST_SCSI_DEFAULT_TAGS; i++) { |
| 1686 | tv_cmd = &((struct vhost_scsi_cmd *)se_sess->sess_cmd_map)[i]; | 1686 | tv_cmd = &((struct vhost_scsi_cmd *)se_sess->sess_cmd_map)[i]; |
| 1687 | 1687 | ||
| 1688 | tv_cmd->tvc_sgl = kzalloc(sizeof(struct scatterlist) * | 1688 | tv_cmd->tvc_sgl = kcalloc(VHOST_SCSI_PREALLOC_SGLS, |
| 1689 | VHOST_SCSI_PREALLOC_SGLS, GFP_KERNEL); | 1689 | sizeof(struct scatterlist), |
| 1690 | GFP_KERNEL); | ||
| 1690 | if (!tv_cmd->tvc_sgl) { | 1691 | if (!tv_cmd->tvc_sgl) { |
| 1691 | pr_err("Unable to allocate tv_cmd->tvc_sgl\n"); | 1692 | pr_err("Unable to allocate tv_cmd->tvc_sgl\n"); |
| 1692 | goto out; | 1693 | goto out; |
| 1693 | } | 1694 | } |
| 1694 | 1695 | ||
| 1695 | tv_cmd->tvc_upages = kzalloc(sizeof(struct page *) * | 1696 | tv_cmd->tvc_upages = kcalloc(VHOST_SCSI_PREALLOC_UPAGES, |
| 1696 | VHOST_SCSI_PREALLOC_UPAGES, GFP_KERNEL); | 1697 | sizeof(struct page *), |
| 1698 | GFP_KERNEL); | ||
| 1697 | if (!tv_cmd->tvc_upages) { | 1699 | if (!tv_cmd->tvc_upages) { |
| 1698 | pr_err("Unable to allocate tv_cmd->tvc_upages\n"); | 1700 | pr_err("Unable to allocate tv_cmd->tvc_upages\n"); |
| 1699 | goto out; | 1701 | goto out; |
| 1700 | } | 1702 | } |
| 1701 | 1703 | ||
| 1702 | tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) * | 1704 | tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS, |
| 1703 | VHOST_SCSI_PREALLOC_PROT_SGLS, GFP_KERNEL); | 1705 | sizeof(struct scatterlist), |
| 1706 | GFP_KERNEL); | ||
| 1704 | if (!tv_cmd->tvc_prot_sgl) { | 1707 | if (!tv_cmd->tvc_prot_sgl) { |
| 1705 | pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); | 1708 | pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n"); |
| 1706 | goto out; | 1709 | goto out; |
diff --git a/drivers/vhost/test.c b/drivers/vhost/test.c index 906b8f0f19f7..40589850eb33 100644 --- a/drivers/vhost/test.c +++ b/drivers/vhost/test.c | |||
| @@ -107,7 +107,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) | |||
| 107 | 107 | ||
| 108 | if (!n) | 108 | if (!n) |
| 109 | return -ENOMEM; | 109 | return -ENOMEM; |
| 110 | vqs = kmalloc(VHOST_TEST_VQ_MAX * sizeof(*vqs), GFP_KERNEL); | 110 | vqs = kmalloc_array(VHOST_TEST_VQ_MAX, sizeof(*vqs), GFP_KERNEL); |
| 111 | if (!vqs) { | 111 | if (!vqs) { |
| 112 | kfree(n); | 112 | kfree(n); |
| 113 | return -ENOMEM; | 113 | return -ENOMEM; |
diff --git a/drivers/vhost/vhost.c b/drivers/vhost/vhost.c index 895eaa25807c..ce8c95b6365b 100644 --- a/drivers/vhost/vhost.c +++ b/drivers/vhost/vhost.c | |||
| @@ -385,10 +385,13 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) | |||
| 385 | 385 | ||
| 386 | for (i = 0; i < dev->nvqs; ++i) { | 386 | for (i = 0; i < dev->nvqs; ++i) { |
| 387 | vq = dev->vqs[i]; | 387 | vq = dev->vqs[i]; |
| 388 | vq->indirect = kmalloc(sizeof *vq->indirect * UIO_MAXIOV, | 388 | vq->indirect = kmalloc_array(UIO_MAXIOV, |
| 389 | GFP_KERNEL); | 389 | sizeof(*vq->indirect), |
| 390 | vq->log = kmalloc(sizeof *vq->log * UIO_MAXIOV, GFP_KERNEL); | 390 | GFP_KERNEL); |
| 391 | vq->heads = kmalloc(sizeof *vq->heads * UIO_MAXIOV, GFP_KERNEL); | 391 | vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log), |
| 392 | GFP_KERNEL); | ||
| 393 | vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads), | ||
| 394 | GFP_KERNEL); | ||
| 392 | if (!vq->indirect || !vq->log || !vq->heads) | 395 | if (!vq->indirect || !vq->log || !vq->heads) |
| 393 | goto err_nomem; | 396 | goto err_nomem; |
| 394 | } | 397 | } |
| @@ -1286,7 +1289,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) | |||
| 1286 | return -EOPNOTSUPP; | 1289 | return -EOPNOTSUPP; |
| 1287 | if (mem.nregions > max_mem_regions) | 1290 | if (mem.nregions > max_mem_regions) |
| 1288 | return -E2BIG; | 1291 | return -E2BIG; |
| 1289 | newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL); | 1292 | newmem = kvzalloc(struct_size(newmem, regions, mem.nregions), |
| 1293 | GFP_KERNEL); | ||
| 1290 | if (!newmem) | 1294 | if (!newmem) |
| 1291 | return -ENOMEM; | 1295 | return -ENOMEM; |
| 1292 | 1296 | ||
diff --git a/drivers/vhost/vringh.c b/drivers/vhost/vringh.c index bb8971f2a634..a94d700a4503 100644 --- a/drivers/vhost/vringh.c +++ b/drivers/vhost/vringh.c | |||
| @@ -191,7 +191,7 @@ static int resize_iovec(struct vringh_kiov *iov, gfp_t gfp) | |||
| 191 | if (flag) | 191 | if (flag) |
| 192 | new = krealloc(iov->iov, new_num * sizeof(struct iovec), gfp); | 192 | new = krealloc(iov->iov, new_num * sizeof(struct iovec), gfp); |
| 193 | else { | 193 | else { |
| 194 | new = kmalloc(new_num * sizeof(struct iovec), gfp); | 194 | new = kmalloc_array(new_num, sizeof(struct iovec), gfp); |
| 195 | if (new) { | 195 | if (new) { |
| 196 | memcpy(new, iov->iov, | 196 | memcpy(new, iov->iov, |
| 197 | iov->max_num * sizeof(struct iovec)); | 197 | iov->max_num * sizeof(struct iovec)); |
diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index e7315bf14d60..16119bde9750 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c | |||
| @@ -223,7 +223,7 @@ static int adp8860_led_probe(struct i2c_client *client) | |||
| 223 | struct led_info *cur_led; | 223 | struct led_info *cur_led; |
| 224 | int ret, i; | 224 | int ret, i; |
| 225 | 225 | ||
| 226 | led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds, | 226 | led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led), |
| 227 | GFP_KERNEL); | 227 | GFP_KERNEL); |
| 228 | if (led == NULL) | 228 | if (led == NULL) |
| 229 | return -ENOMEM; | 229 | return -ENOMEM; |
diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 058d1def2d1f..4fec9aa92d9b 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c | |||
| @@ -246,7 +246,7 @@ static int adp8870_led_probe(struct i2c_client *client) | |||
| 246 | struct led_info *cur_led; | 246 | struct led_info *cur_led; |
| 247 | int ret, i; | 247 | int ret, i; |
| 248 | 248 | ||
| 249 | led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led), | 249 | led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led), |
| 250 | GFP_KERNEL); | 250 | GFP_KERNEL); |
| 251 | if (led == NULL) | 251 | if (led == NULL) |
| 252 | return -ENOMEM; | 252 | return -ENOMEM; |
diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 939f057836e1..73612485ed07 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c | |||
| @@ -374,7 +374,7 @@ static int lp855x_parse_dt(struct lp855x *lp) | |||
| 374 | struct device_node *child; | 374 | struct device_node *child; |
| 375 | int i = 0; | 375 | int i = 0; |
| 376 | 376 | ||
| 377 | rom = devm_kzalloc(dev, sizeof(*rom) * rom_length, GFP_KERNEL); | 377 | rom = devm_kcalloc(dev, rom_length, sizeof(*rom), GFP_KERNEL); |
| 378 | if (!rom) | 378 | if (!rom) |
| 379 | return -ENOMEM; | 379 | return -ENOMEM; |
| 380 | 380 | ||
diff --git a/drivers/video/console/sticore.c b/drivers/video/console/sticore.c index 08b822656846..ff45dca3ee46 100644 --- a/drivers/video/console/sticore.c +++ b/drivers/video/console/sticore.c | |||
| @@ -649,7 +649,7 @@ static void *sti_bmode_font_raw(struct sti_cooked_font *f) | |||
| 649 | unsigned char *n, *p, *q; | 649 | unsigned char *n, *p, *q; |
| 650 | int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font); | 650 | int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font); |
| 651 | 651 | ||
| 652 | n = kzalloc(4*size, STI_LOWMEM); | 652 | n = kcalloc(4, size, STI_LOWMEM); |
| 653 | if (!n) | 653 | if (!n) |
| 654 | return NULL; | 654 | return NULL; |
| 655 | p = n + 3; | 655 | p = n + 3; |
diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c index 7c9a672e9811..d555a78df5c6 100644 --- a/drivers/video/fbdev/au1100fb.c +++ b/drivers/video/fbdev/au1100fb.c | |||
| @@ -501,7 +501,7 @@ static int au1100fb_drv_probe(struct platform_device *dev) | |||
| 501 | fbdev->info.fix = au1100fb_fix; | 501 | fbdev->info.fix = au1100fb_fix; |
| 502 | 502 | ||
| 503 | fbdev->info.pseudo_palette = | 503 | fbdev->info.pseudo_palette = |
| 504 | devm_kzalloc(&dev->dev, sizeof(u32) * 16, GFP_KERNEL); | 504 | devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL); |
| 505 | if (!fbdev->info.pseudo_palette) | 505 | if (!fbdev->info.pseudo_palette) |
| 506 | return -ENOMEM; | 506 | return -ENOMEM; |
| 507 | 507 | ||
diff --git a/drivers/video/fbdev/broadsheetfb.c b/drivers/video/fbdev/broadsheetfb.c index 9f9a7bef1ff6..d6ba348deb9f 100644 --- a/drivers/video/fbdev/broadsheetfb.c +++ b/drivers/video/fbdev/broadsheetfb.c | |||
| @@ -617,7 +617,7 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, | |||
| 617 | int tail_start_addr; | 617 | int tail_start_addr; |
| 618 | int start_sector_addr; | 618 | int start_sector_addr; |
| 619 | 619 | ||
| 620 | sector_buffer = kzalloc(sizeof(char)*sector_size, GFP_KERNEL); | 620 | sector_buffer = kzalloc(sector_size, GFP_KERNEL); |
| 621 | if (!sector_buffer) | 621 | if (!sector_buffer) |
| 622 | return -ENOMEM; | 622 | return -ENOMEM; |
| 623 | 623 | ||
diff --git a/drivers/video/fbdev/core/bitblit.c b/drivers/video/fbdev/core/bitblit.c index 790900d646c0..ca935c09a261 100644 --- a/drivers/video/fbdev/core/bitblit.c +++ b/drivers/video/fbdev/core/bitblit.c | |||
| @@ -269,7 +269,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 269 | if (attribute) { | 269 | if (attribute) { |
| 270 | u8 *dst; | 270 | u8 *dst; |
| 271 | 271 | ||
| 272 | dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC); | 272 | dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC); |
| 273 | if (!dst) | 273 | if (!dst) |
| 274 | return; | 274 | return; |
| 275 | kfree(ops->cursor_data); | 275 | kfree(ops->cursor_data); |
| @@ -312,7 +312,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 312 | vc->vc_cursor_type != ops->p->cursor_shape || | 312 | vc->vc_cursor_type != ops->p->cursor_shape || |
| 313 | ops->cursor_state.mask == NULL || | 313 | ops->cursor_state.mask == NULL || |
| 314 | ops->cursor_reset) { | 314 | ops->cursor_reset) { |
| 315 | char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC); | 315 | char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC); |
| 316 | int cur_height, size, i = 0; | 316 | int cur_height, size, i = 0; |
| 317 | u8 msk = 0xff; | 317 | u8 msk = 0xff; |
| 318 | 318 | ||
diff --git a/drivers/video/fbdev/core/fbcon.c b/drivers/video/fbdev/core/fbcon.c index 3e330e0f56ed..c910e74d46ff 100644 --- a/drivers/video/fbdev/core/fbcon.c +++ b/drivers/video/fbdev/core/fbcon.c | |||
| @@ -591,7 +591,8 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, | |||
| 591 | if (scr_readw(r) != vc->vc_video_erase_char) | 591 | if (scr_readw(r) != vc->vc_video_erase_char) |
| 592 | break; | 592 | break; |
| 593 | if (r != q && new_rows >= rows + logo_lines) { | 593 | if (r != q && new_rows >= rows + logo_lines) { |
| 594 | save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL); | 594 | save = kmalloc(array3_size(logo_lines, new_cols, 2), |
| 595 | GFP_KERNEL); | ||
| 595 | if (save) { | 596 | if (save) { |
| 596 | int i = cols < new_cols ? cols : new_cols; | 597 | int i = cols < new_cols ? cols : new_cols; |
| 597 | scr_memsetw(save, erase, logo_lines * new_cols * 2); | 598 | scr_memsetw(save, erase, logo_lines * new_cols * 2); |
diff --git a/drivers/video/fbdev/core/fbcon_ccw.c b/drivers/video/fbdev/core/fbcon_ccw.c index 37a8b0b22566..dfa9a8aa4509 100644 --- a/drivers/video/fbdev/core/fbcon_ccw.c +++ b/drivers/video/fbdev/core/fbcon_ccw.c | |||
| @@ -258,7 +258,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 258 | if (attribute) { | 258 | if (attribute) { |
| 259 | u8 *dst; | 259 | u8 *dst; |
| 260 | 260 | ||
| 261 | dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC); | 261 | dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC); |
| 262 | if (!dst) | 262 | if (!dst) |
| 263 | return; | 263 | return; |
| 264 | kfree(ops->cursor_data); | 264 | kfree(ops->cursor_data); |
| @@ -304,14 +304,15 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 304 | vc->vc_cursor_type != ops->p->cursor_shape || | 304 | vc->vc_cursor_type != ops->p->cursor_shape || |
| 305 | ops->cursor_state.mask == NULL || | 305 | ops->cursor_state.mask == NULL || |
| 306 | ops->cursor_reset) { | 306 | ops->cursor_reset) { |
| 307 | char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC); | 307 | char *tmp, *mask = kmalloc_array(w, vc->vc_font.width, |
| 308 | GFP_ATOMIC); | ||
| 308 | int cur_height, size, i = 0; | 309 | int cur_height, size, i = 0; |
| 309 | int width = (vc->vc_font.width + 7)/8; | 310 | int width = (vc->vc_font.width + 7)/8; |
| 310 | 311 | ||
| 311 | if (!mask) | 312 | if (!mask) |
| 312 | return; | 313 | return; |
| 313 | 314 | ||
| 314 | tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC); | 315 | tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC); |
| 315 | 316 | ||
| 316 | if (!tmp) { | 317 | if (!tmp) { |
| 317 | kfree(mask); | 318 | kfree(mask); |
diff --git a/drivers/video/fbdev/core/fbcon_cw.c b/drivers/video/fbdev/core/fbcon_cw.c index 1888f8c866e8..ce08251bfd38 100644 --- a/drivers/video/fbdev/core/fbcon_cw.c +++ b/drivers/video/fbdev/core/fbcon_cw.c | |||
| @@ -241,7 +241,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 241 | if (attribute) { | 241 | if (attribute) { |
| 242 | u8 *dst; | 242 | u8 *dst; |
| 243 | 243 | ||
| 244 | dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC); | 244 | dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC); |
| 245 | if (!dst) | 245 | if (!dst) |
| 246 | return; | 246 | return; |
| 247 | kfree(ops->cursor_data); | 247 | kfree(ops->cursor_data); |
| @@ -287,14 +287,15 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 287 | vc->vc_cursor_type != ops->p->cursor_shape || | 287 | vc->vc_cursor_type != ops->p->cursor_shape || |
| 288 | ops->cursor_state.mask == NULL || | 288 | ops->cursor_state.mask == NULL || |
| 289 | ops->cursor_reset) { | 289 | ops->cursor_reset) { |
| 290 | char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC); | 290 | char *tmp, *mask = kmalloc_array(w, vc->vc_font.width, |
| 291 | GFP_ATOMIC); | ||
| 291 | int cur_height, size, i = 0; | 292 | int cur_height, size, i = 0; |
| 292 | int width = (vc->vc_font.width + 7)/8; | 293 | int width = (vc->vc_font.width + 7)/8; |
| 293 | 294 | ||
| 294 | if (!mask) | 295 | if (!mask) |
| 295 | return; | 296 | return; |
| 296 | 297 | ||
| 297 | tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC); | 298 | tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC); |
| 298 | 299 | ||
| 299 | if (!tmp) { | 300 | if (!tmp) { |
| 300 | kfree(mask); | 301 | kfree(mask); |
diff --git a/drivers/video/fbdev/core/fbcon_rotate.c b/drivers/video/fbdev/core/fbcon_rotate.c index 8a51e4d95cc5..c0d445294aa7 100644 --- a/drivers/video/fbdev/core/fbcon_rotate.c +++ b/drivers/video/fbdev/core/fbcon_rotate.c | |||
| @@ -46,7 +46,7 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) | |||
| 46 | info->fbops->fb_sync(info); | 46 | info->fbops->fb_sync(info); |
| 47 | 47 | ||
| 48 | if (ops->fd_size < d_cellsize * len) { | 48 | if (ops->fd_size < d_cellsize * len) { |
| 49 | dst = kmalloc(d_cellsize * len, GFP_KERNEL); | 49 | dst = kmalloc_array(len, d_cellsize, GFP_KERNEL); |
| 50 | 50 | ||
| 51 | if (dst == NULL) { | 51 | if (dst == NULL) { |
| 52 | err = -ENOMEM; | 52 | err = -ENOMEM; |
diff --git a/drivers/video/fbdev/core/fbcon_ud.c b/drivers/video/fbdev/core/fbcon_ud.c index f98eee263597..1936afc78fec 100644 --- a/drivers/video/fbdev/core/fbcon_ud.c +++ b/drivers/video/fbdev/core/fbcon_ud.c | |||
| @@ -289,7 +289,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 289 | if (attribute) { | 289 | if (attribute) { |
| 290 | u8 *dst; | 290 | u8 *dst; |
| 291 | 291 | ||
| 292 | dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC); | 292 | dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC); |
| 293 | if (!dst) | 293 | if (!dst) |
| 294 | return; | 294 | return; |
| 295 | kfree(ops->cursor_data); | 295 | kfree(ops->cursor_data); |
| @@ -335,7 +335,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, | |||
| 335 | vc->vc_cursor_type != ops->p->cursor_shape || | 335 | vc->vc_cursor_type != ops->p->cursor_shape || |
| 336 | ops->cursor_state.mask == NULL || | 336 | ops->cursor_state.mask == NULL || |
| 337 | ops->cursor_reset) { | 337 | ops->cursor_reset) { |
| 338 | char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC); | 338 | char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC); |
| 339 | int cur_height, size, i = 0; | 339 | int cur_height, size, i = 0; |
| 340 | u8 msk = 0xff; | 340 | u8 msk = 0xff; |
| 341 | 341 | ||
diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 924d0730ffe2..609438d2465b 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c | |||
| @@ -489,7 +489,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, | |||
| 489 | } | 489 | } |
| 490 | 490 | ||
| 491 | if (fb_logo.depth <= 4) { | 491 | if (fb_logo.depth <= 4) { |
| 492 | logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL); | 492 | logo_new = kmalloc_array(logo->width, logo->height, |
| 493 | GFP_KERNEL); | ||
| 493 | if (logo_new == NULL) { | 494 | if (logo_new == NULL) { |
| 494 | kfree(palette); | 495 | kfree(palette); |
| 495 | if (saved_pseudo_palette) | 496 | if (saved_pseudo_palette) |
| @@ -506,8 +507,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, | |||
| 506 | image.height = logo->height; | 507 | image.height = logo->height; |
| 507 | 508 | ||
| 508 | if (rotate) { | 509 | if (rotate) { |
| 509 | logo_rotate = kmalloc(logo->width * | 510 | logo_rotate = kmalloc_array(logo->width, logo->height, |
| 510 | logo->height, GFP_KERNEL); | 511 | GFP_KERNEL); |
| 511 | if (logo_rotate) | 512 | if (logo_rotate) |
| 512 | fb_rotate_logo(info, logo_rotate, &image, rotate); | 513 | fb_rotate_logo(info, logo_rotate, &image, rotate); |
| 513 | } | 514 | } |
diff --git a/drivers/video/fbdev/core/fbmon.c b/drivers/video/fbdev/core/fbmon.c index 2b2d67328514..852d86c1c527 100644 --- a/drivers/video/fbdev/core/fbmon.c +++ b/drivers/video/fbdev/core/fbmon.c | |||
| @@ -620,7 +620,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, | |||
| 620 | int num = 0, i, first = 1; | 620 | int num = 0, i, first = 1; |
| 621 | int ver, rev; | 621 | int ver, rev; |
| 622 | 622 | ||
| 623 | mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL); | 623 | mode = kcalloc(50, sizeof(struct fb_videomode), GFP_KERNEL); |
| 624 | if (mode == NULL) | 624 | if (mode == NULL) |
| 625 | return NULL; | 625 | return NULL; |
| 626 | 626 | ||
| @@ -671,7 +671,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, | |||
| 671 | } | 671 | } |
| 672 | 672 | ||
| 673 | *dbsize = num; | 673 | *dbsize = num; |
| 674 | m = kmalloc(num * sizeof(struct fb_videomode), GFP_KERNEL); | 674 | m = kmalloc_array(num, sizeof(struct fb_videomode), GFP_KERNEL); |
| 675 | if (!m) | 675 | if (!m) |
| 676 | return mode; | 676 | return mode; |
| 677 | memmove(m, mode, num * sizeof(struct fb_videomode)); | 677 | memmove(m, mode, num * sizeof(struct fb_videomode)); |
| @@ -1055,8 +1055,9 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs) | |||
| 1055 | if (!(num + svd_n)) | 1055 | if (!(num + svd_n)) |
| 1056 | return; | 1056 | return; |
| 1057 | 1057 | ||
| 1058 | m = kzalloc((specs->modedb_len + num + svd_n) * | 1058 | m = kcalloc(specs->modedb_len + num + svd_n, |
| 1059 | sizeof(struct fb_videomode), GFP_KERNEL); | 1059 | sizeof(struct fb_videomode), |
| 1060 | GFP_KERNEL); | ||
| 1060 | 1061 | ||
| 1061 | if (!m) | 1062 | if (!m) |
| 1062 | return; | 1063 | return; |
diff --git a/drivers/video/fbdev/imxfb.c b/drivers/video/fbdev/imxfb.c index ba82f97fb42b..c4eb8661f751 100644 --- a/drivers/video/fbdev/imxfb.c +++ b/drivers/video/fbdev/imxfb.c | |||
| @@ -662,7 +662,7 @@ static int imxfb_init_fbinfo(struct platform_device *pdev) | |||
| 662 | 662 | ||
| 663 | pr_debug("%s\n",__func__); | 663 | pr_debug("%s\n",__func__); |
| 664 | 664 | ||
| 665 | info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL); | 665 | info->pseudo_palette = kmalloc_array(16, sizeof(u32), GFP_KERNEL); |
| 666 | if (!info->pseudo_palette) | 666 | if (!info->pseudo_palette) |
| 667 | return -ENOMEM; | 667 | return -ENOMEM; |
| 668 | 668 | ||
diff --git a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c index fe92eed6da70..8dd296d257dd 100644 --- a/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c +++ b/drivers/video/fbdev/mb862xx/mb862xxfb_accel.c | |||
| @@ -245,7 +245,7 @@ static void mb86290fb_imageblit(struct fb_info *info, | |||
| 245 | return; | 245 | return; |
| 246 | } | 246 | } |
| 247 | 247 | ||
| 248 | cmd = kmalloc(cmdlen * 4, GFP_DMA); | 248 | cmd = kmalloc_array(cmdlen, 4, GFP_DMA); |
| 249 | if (!cmd) | 249 | if (!cmd) |
| 250 | return cfb_imageblit(info, image); | 250 | return cfb_imageblit(info, image); |
| 251 | cmdfn(cmd, step, dx, dy, width, height, fgcolor, bgcolor, image, info); | 251 | cmdfn(cmd, step, dx, dy, width, height, fgcolor, bgcolor, image, info); |
diff --git a/drivers/video/fbdev/mmp/fb/mmpfb.c b/drivers/video/fbdev/mmp/fb/mmpfb.c index 92279e02dd94..f27697e07c55 100644 --- a/drivers/video/fbdev/mmp/fb/mmpfb.c +++ b/drivers/video/fbdev/mmp/fb/mmpfb.c | |||
| @@ -493,8 +493,8 @@ static int modes_setup(struct mmpfb_info *fbi) | |||
| 493 | return 0; | 493 | return 0; |
| 494 | } | 494 | } |
| 495 | /* put videomode list to info structure */ | 495 | /* put videomode list to info structure */ |
| 496 | videomodes = kzalloc(sizeof(struct fb_videomode) * videomode_num, | 496 | videomodes = kcalloc(videomode_num, sizeof(struct fb_videomode), |
| 497 | GFP_KERNEL); | 497 | GFP_KERNEL); |
| 498 | if (!videomodes) { | 498 | if (!videomodes) { |
| 499 | dev_err(fbi->dev, "can't malloc video modes\n"); | 499 | dev_err(fbi->dev, "can't malloc video modes\n"); |
| 500 | return -ENOMEM; | 500 | return -ENOMEM; |
diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 246bea3a7d9b..12c8bd1d24d5 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c | |||
| @@ -931,7 +931,7 @@ static int mxsfb_probe(struct platform_device *pdev) | |||
| 931 | if (IS_ERR(host->reg_lcd)) | 931 | if (IS_ERR(host->reg_lcd)) |
| 932 | host->reg_lcd = NULL; | 932 | host->reg_lcd = NULL; |
| 933 | 933 | ||
| 934 | fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16, | 934 | fb_info->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32), |
| 935 | GFP_KERNEL); | 935 | GFP_KERNEL); |
| 936 | if (!fb_info->pseudo_palette) { | 936 | if (!fb_info->pseudo_palette) { |
| 937 | ret = -ENOMEM; | 937 | ret = -ENOMEM; |
diff --git a/drivers/video/fbdev/nvidia/nvidia.c b/drivers/video/fbdev/nvidia/nvidia.c index 418a2d0d06a9..2e50120bcfae 100644 --- a/drivers/video/fbdev/nvidia/nvidia.c +++ b/drivers/video/fbdev/nvidia/nvidia.c | |||
| @@ -566,7 +566,7 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor) | |||
| 566 | u8 *msk = (u8 *) cursor->mask; | 566 | u8 *msk = (u8 *) cursor->mask; |
| 567 | u8 *src; | 567 | u8 *src; |
| 568 | 568 | ||
| 569 | src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC); | 569 | src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC); |
| 570 | 570 | ||
| 571 | if (src) { | 571 | if (src) { |
| 572 | switch (cursor->rop) { | 572 | switch (cursor->rop) { |
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/manager.c b/drivers/video/fbdev/omap2/omapfb/dss/manager.c index 69f86d2cc274..d21c641e1f3c 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/manager.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/manager.c | |||
| @@ -42,8 +42,8 @@ int dss_init_overlay_managers(void) | |||
| 42 | 42 | ||
| 43 | num_managers = dss_feat_get_num_mgrs(); | 43 | num_managers = dss_feat_get_num_mgrs(); |
| 44 | 44 | ||
| 45 | managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers, | 45 | managers = kcalloc(num_managers, sizeof(struct omap_overlay_manager), |
| 46 | GFP_KERNEL); | 46 | GFP_KERNEL); |
| 47 | 47 | ||
| 48 | BUG_ON(managers == NULL); | 48 | BUG_ON(managers == NULL); |
| 49 | 49 | ||
diff --git a/drivers/video/fbdev/omap2/omapfb/dss/overlay.c b/drivers/video/fbdev/omap2/omapfb/dss/overlay.c index d6c5d75d2ef8..be17a4785a5e 100644 --- a/drivers/video/fbdev/omap2/omapfb/dss/overlay.c +++ b/drivers/video/fbdev/omap2/omapfb/dss/overlay.c | |||
| @@ -59,8 +59,8 @@ void dss_init_overlays(struct platform_device *pdev) | |||
| 59 | 59 | ||
| 60 | num_overlays = dss_feat_get_num_ovls(); | 60 | num_overlays = dss_feat_get_num_ovls(); |
| 61 | 61 | ||
| 62 | overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays, | 62 | overlays = kcalloc(num_overlays, sizeof(struct omap_overlay), |
| 63 | GFP_KERNEL); | 63 | GFP_KERNEL); |
| 64 | 64 | ||
| 65 | BUG_ON(overlays == NULL); | 65 | BUG_ON(overlays == NULL); |
| 66 | 66 | ||
diff --git a/drivers/video/fbdev/omap2/omapfb/vrfb.c b/drivers/video/fbdev/omap2/omapfb/vrfb.c index f346b02eee1d..f355ecfac3b1 100644 --- a/drivers/video/fbdev/omap2/omapfb/vrfb.c +++ b/drivers/video/fbdev/omap2/omapfb/vrfb.c | |||
| @@ -359,8 +359,8 @@ static int __init vrfb_probe(struct platform_device *pdev) | |||
| 359 | 359 | ||
| 360 | num_ctxs = pdev->num_resources - 1; | 360 | num_ctxs = pdev->num_resources - 1; |
| 361 | 361 | ||
| 362 | ctxs = devm_kzalloc(&pdev->dev, | 362 | ctxs = devm_kcalloc(&pdev->dev, |
| 363 | sizeof(struct vrfb_ctx) * num_ctxs, | 363 | num_ctxs, sizeof(struct vrfb_ctx), |
| 364 | GFP_KERNEL); | 364 | GFP_KERNEL); |
| 365 | 365 | ||
| 366 | if (!ctxs) | 366 | if (!ctxs) |
diff --git a/drivers/video/fbdev/pvr2fb.c b/drivers/video/fbdev/pvr2fb.c index a582d3ae7ac1..8a53d1de611d 100644 --- a/drivers/video/fbdev/pvr2fb.c +++ b/drivers/video/fbdev/pvr2fb.c | |||
| @@ -682,7 +682,7 @@ static ssize_t pvr2fb_write(struct fb_info *info, const char *buf, | |||
| 682 | 682 | ||
| 683 | nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT; | 683 | nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT; |
| 684 | 684 | ||
| 685 | pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL); | 685 | pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); |
| 686 | if (!pages) | 686 | if (!pages) |
| 687 | return -ENOMEM; | 687 | return -ENOMEM; |
| 688 | 688 | ||
diff --git a/drivers/video/fbdev/riva/fbdev.c b/drivers/video/fbdev/riva/fbdev.c index ff8282374f37..cc242ba057d3 100644 --- a/drivers/video/fbdev/riva/fbdev.c +++ b/drivers/video/fbdev/riva/fbdev.c | |||
| @@ -1615,7 +1615,7 @@ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor) | |||
| 1615 | u8 *msk = (u8 *) cursor->mask; | 1615 | u8 *msk = (u8 *) cursor->mask; |
| 1616 | u8 *src; | 1616 | u8 *src; |
| 1617 | 1617 | ||
| 1618 | src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC); | 1618 | src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC); |
| 1619 | 1619 | ||
| 1620 | if (src) { | 1620 | if (src) { |
| 1621 | switch (cursor->rop) { | 1621 | switch (cursor->rop) { |
diff --git a/drivers/video/fbdev/uvesafb.c b/drivers/video/fbdev/uvesafb.c index 73676eb0244a..440a6636d8f0 100644 --- a/drivers/video/fbdev/uvesafb.c +++ b/drivers/video/fbdev/uvesafb.c | |||
| @@ -486,8 +486,9 @@ static int uvesafb_vbe_getmodes(struct uvesafb_ktask *task, | |||
| 486 | mode++; | 486 | mode++; |
| 487 | } | 487 | } |
| 488 | 488 | ||
| 489 | par->vbe_modes = kzalloc(sizeof(struct vbe_mode_ib) * | 489 | par->vbe_modes = kcalloc(par->vbe_modes_cnt, |
| 490 | par->vbe_modes_cnt, GFP_KERNEL); | 490 | sizeof(struct vbe_mode_ib), |
| 491 | GFP_KERNEL); | ||
| 491 | if (!par->vbe_modes) | 492 | if (!par->vbe_modes) |
| 492 | return -ENOMEM; | 493 | return -ENOMEM; |
| 493 | 494 | ||
| @@ -858,7 +859,7 @@ static int uvesafb_vbe_init_mode(struct fb_info *info) | |||
| 858 | * Convert the modelist into a modedb so that we can use it with | 859 | * Convert the modelist into a modedb so that we can use it with |
| 859 | * fb_find_mode(). | 860 | * fb_find_mode(). |
| 860 | */ | 861 | */ |
| 861 | mode = kzalloc(i * sizeof(*mode), GFP_KERNEL); | 862 | mode = kcalloc(i, sizeof(*mode), GFP_KERNEL); |
| 862 | if (mode) { | 863 | if (mode) { |
| 863 | i = 0; | 864 | i = 0; |
| 864 | list_for_each(pos, &info->modelist) { | 865 | list_for_each(pos, &info->modelist) { |
| @@ -1044,7 +1045,8 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) | |||
| 1044 | info->cmap.len || cmap->start < info->cmap.start) | 1045 | info->cmap.len || cmap->start < info->cmap.start) |
| 1045 | return -EINVAL; | 1046 | return -EINVAL; |
| 1046 | 1047 | ||
| 1047 | entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL); | 1048 | entries = kmalloc_array(cmap->len, sizeof(*entries), |
| 1049 | GFP_KERNEL); | ||
| 1048 | if (!entries) | 1050 | if (!entries) |
| 1049 | return -ENOMEM; | 1051 | return -ENOMEM; |
| 1050 | 1052 | ||
diff --git a/drivers/video/fbdev/via/viafbdev.c b/drivers/video/fbdev/via/viafbdev.c index 9b45125988fb..52f577b0669b 100644 --- a/drivers/video/fbdev/via/viafbdev.c +++ b/drivers/video/fbdev/via/viafbdev.c | |||
| @@ -596,7 +596,8 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) | |||
| 596 | break; | 596 | break; |
| 597 | 597 | ||
| 598 | case VIAFB_GET_GAMMA_LUT: | 598 | case VIAFB_GET_GAMMA_LUT: |
| 599 | viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL); | 599 | viafb_gamma_table = kmalloc_array(256, sizeof(u32), |
| 600 | GFP_KERNEL); | ||
| 600 | if (!viafb_gamma_table) | 601 | if (!viafb_gamma_table) |
| 601 | return -ENOMEM; | 602 | return -ENOMEM; |
| 602 | viafb_get_gamma_table(viafb_gamma_table); | 603 | viafb_get_gamma_table(viafb_gamma_table); |
diff --git a/drivers/video/fbdev/w100fb.c b/drivers/video/fbdev/w100fb.c index 035ff6e02894..696106ecdff0 100644 --- a/drivers/video/fbdev/w100fb.c +++ b/drivers/video/fbdev/w100fb.c | |||
| @@ -693,7 +693,8 @@ int w100fb_probe(struct platform_device *pdev) | |||
| 693 | goto out; | 693 | goto out; |
| 694 | } | 694 | } |
| 695 | 695 | ||
| 696 | info->pseudo_palette = kmalloc(sizeof (u32) * MAX_PALETTES, GFP_KERNEL); | 696 | info->pseudo_palette = kmalloc_array(MAX_PALETTES, sizeof(u32), |
| 697 | GFP_KERNEL); | ||
| 697 | if (!info->pseudo_palette) { | 698 | if (!info->pseudo_palette) { |
| 698 | err = -ENOMEM; | 699 | err = -ENOMEM; |
| 699 | goto out; | 700 | goto out; |
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c index 46f63960fa9e..6a4bbc9e1fb0 100644 --- a/drivers/video/fbdev/xen-fbfront.c +++ b/drivers/video/fbdev/xen-fbfront.c | |||
| @@ -412,7 +412,7 @@ static int xenfb_probe(struct xenbus_device *dev, | |||
| 412 | 412 | ||
| 413 | info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; | 413 | info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; |
| 414 | 414 | ||
| 415 | info->gfns = vmalloc(sizeof(unsigned long) * info->nr_pages); | 415 | info->gfns = vmalloc(array_size(sizeof(unsigned long), info->nr_pages)); |
| 416 | if (!info->gfns) | 416 | if (!info->gfns) |
| 417 | goto error_nomem; | 417 | goto error_nomem; |
| 418 | 418 | ||
diff --git a/drivers/video/of_display_timing.c b/drivers/video/of_display_timing.c index 83b8963c9657..5244e93ceafc 100644 --- a/drivers/video/of_display_timing.c +++ b/drivers/video/of_display_timing.c | |||
| @@ -181,8 +181,9 @@ struct display_timings *of_get_display_timings(const struct device_node *np) | |||
| 181 | goto entryfail; | 181 | goto entryfail; |
| 182 | } | 182 | } |
| 183 | 183 | ||
| 184 | disp->timings = kzalloc(sizeof(struct display_timing *) * | 184 | disp->timings = kcalloc(disp->num_timings, |
| 185 | disp->num_timings, GFP_KERNEL); | 185 | sizeof(struct display_timing *), |
| 186 | GFP_KERNEL); | ||
| 186 | if (!disp->timings) { | 187 | if (!disp->timings) { |
| 187 | pr_err("%pOF: could not allocate timings array\n", np); | 188 | pr_err("%pOF: could not allocate timings array\n", np); |
| 188 | goto entryfail; | 189 | goto entryfail; |
diff --git a/drivers/virt/fsl_hypervisor.c b/drivers/virt/fsl_hypervisor.c index 4e05d7f711fe..8ba726e600e9 100644 --- a/drivers/virt/fsl_hypervisor.c +++ b/drivers/virt/fsl_hypervisor.c | |||
| @@ -223,7 +223,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) | |||
| 223 | * 'pages' is an array of struct page pointers that's initialized by | 223 | * 'pages' is an array of struct page pointers that's initialized by |
| 224 | * get_user_pages(). | 224 | * get_user_pages(). |
| 225 | */ | 225 | */ |
| 226 | pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL); | 226 | pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL); |
| 227 | if (!pages) { | 227 | if (!pages) { |
| 228 | pr_debug("fsl-hv: could not allocate page list\n"); | 228 | pr_debug("fsl-hv: could not allocate page list\n"); |
| 229 | return -ENOMEM; | 229 | return -ENOMEM; |
diff --git a/drivers/virt/vboxguest/vboxguest_core.c b/drivers/virt/vboxguest/vboxguest_core.c index 2f3856a95856..3093655c7b92 100644 --- a/drivers/virt/vboxguest/vboxguest_core.c +++ b/drivers/virt/vboxguest/vboxguest_core.c | |||
| @@ -69,7 +69,7 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev) | |||
| 69 | /* Add 4M so that we can align the vmap to 4MiB as the host requires. */ | 69 | /* Add 4M so that we can align the vmap to 4MiB as the host requires. */ |
| 70 | size = PAGE_ALIGN(req->hypervisor_size) + SZ_4M; | 70 | size = PAGE_ALIGN(req->hypervisor_size) + SZ_4M; |
| 71 | 71 | ||
| 72 | pages = kmalloc(sizeof(*pages) * (size >> PAGE_SHIFT), GFP_KERNEL); | 72 | pages = kmalloc_array(size >> PAGE_SHIFT, sizeof(*pages), GFP_KERNEL); |
| 73 | if (!pages) | 73 | if (!pages) |
| 74 | goto out; | 74 | goto out; |
| 75 | 75 | ||
| @@ -262,8 +262,9 @@ static int vbg_balloon_inflate(struct vbg_dev *gdev, u32 chunk_idx) | |||
| 262 | struct page **pages; | 262 | struct page **pages; |
| 263 | int i, rc, ret; | 263 | int i, rc, ret; |
| 264 | 264 | ||
| 265 | pages = kmalloc(sizeof(*pages) * VMMDEV_MEMORY_BALLOON_CHUNK_PAGES, | 265 | pages = kmalloc_array(VMMDEV_MEMORY_BALLOON_CHUNK_PAGES, |
| 266 | GFP_KERNEL | __GFP_NOWARN); | 266 | sizeof(*pages), |
| 267 | GFP_KERNEL | __GFP_NOWARN); | ||
| 267 | if (!pages) | 268 | if (!pages) |
| 268 | return -ENOMEM; | 269 | return -ENOMEM; |
| 269 | 270 | ||
diff --git a/drivers/virtio/virtio_pci_common.c b/drivers/virtio/virtio_pci_common.c index 48d4d1cf1cb6..b563a4499cc8 100644 --- a/drivers/virtio/virtio_pci_common.c +++ b/drivers/virtio/virtio_pci_common.c | |||
| @@ -113,12 +113,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, | |||
| 113 | 113 | ||
| 114 | vp_dev->msix_vectors = nvectors; | 114 | vp_dev->msix_vectors = nvectors; |
| 115 | 115 | ||
| 116 | vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names, | 116 | vp_dev->msix_names = kmalloc_array(nvectors, |
| 117 | GFP_KERNEL); | 117 | sizeof(*vp_dev->msix_names), |
| 118 | GFP_KERNEL); | ||
| 118 | if (!vp_dev->msix_names) | 119 | if (!vp_dev->msix_names) |
| 119 | goto error; | 120 | goto error; |
| 120 | vp_dev->msix_affinity_masks | 121 | vp_dev->msix_affinity_masks |
| 121 | = kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks, | 122 | = kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks), |
| 122 | GFP_KERNEL); | 123 | GFP_KERNEL); |
| 123 | if (!vp_dev->msix_affinity_masks) | 124 | if (!vp_dev->msix_affinity_masks) |
| 124 | goto error; | 125 | goto error; |
diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 21d464a29cf8..814b395007b2 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c | |||
| @@ -247,7 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq, | |||
| 247 | */ | 247 | */ |
| 248 | gfp &= ~__GFP_HIGHMEM; | 248 | gfp &= ~__GFP_HIGHMEM; |
| 249 | 249 | ||
| 250 | desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp); | 250 | desc = kmalloc_array(total_sg, sizeof(struct vring_desc), gfp); |
| 251 | if (!desc) | 251 | if (!desc) |
| 252 | return NULL; | 252 | return NULL; |
| 253 | 253 | ||
diff --git a/drivers/xen/arm-device.c b/drivers/xen/arm-device.c index 85dd20e05726..3e789c77f568 100644 --- a/drivers/xen/arm-device.c +++ b/drivers/xen/arm-device.c | |||
| @@ -70,9 +70,9 @@ static int xen_map_device_mmio(const struct resource *resources, | |||
| 70 | if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) | 70 | if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0)) |
| 71 | continue; | 71 | continue; |
| 72 | 72 | ||
| 73 | gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL); | 73 | gpfns = kcalloc(nr, sizeof(xen_pfn_t), GFP_KERNEL); |
| 74 | idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL); | 74 | idxs = kcalloc(nr, sizeof(xen_ulong_t), GFP_KERNEL); |
| 75 | errs = kzalloc(sizeof(int) * nr, GFP_KERNEL); | 75 | errs = kcalloc(nr, sizeof(int), GFP_KERNEL); |
| 76 | if (!gpfns || !idxs || !errs) { | 76 | if (!gpfns || !idxs || !errs) { |
| 77 | kfree(gpfns); | 77 | kfree(gpfns); |
| 78 | kfree(idxs); | 78 | kfree(idxs); |
diff --git a/drivers/xen/evtchn.c b/drivers/xen/evtchn.c index 8cac07ab60ab..6d1a5e58968f 100644 --- a/drivers/xen/evtchn.c +++ b/drivers/xen/evtchn.c | |||
| @@ -322,7 +322,7 @@ static int evtchn_resize_ring(struct per_user_data *u) | |||
| 322 | else | 322 | else |
| 323 | new_size = 2 * u->ring_size; | 323 | new_size = 2 * u->ring_size; |
| 324 | 324 | ||
| 325 | new_ring = kvmalloc(new_size * sizeof(*new_ring), GFP_KERNEL); | 325 | new_ring = kvmalloc_array(new_size, sizeof(*new_ring), GFP_KERNEL); |
| 326 | if (!new_ring) | 326 | if (!new_ring) |
| 327 | return -ENOMEM; | 327 | return -ENOMEM; |
| 328 | 328 | ||
diff --git a/drivers/xen/grant-table.c b/drivers/xen/grant-table.c index 27be107d6480..2473b0a9e6e4 100644 --- a/drivers/xen/grant-table.c +++ b/drivers/xen/grant-table.c | |||
| @@ -1137,7 +1137,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx) | |||
| 1137 | /* No need for kzalloc as it is initialized in following hypercall | 1137 | /* No need for kzalloc as it is initialized in following hypercall |
| 1138 | * GNTTABOP_setup_table. | 1138 | * GNTTABOP_setup_table. |
| 1139 | */ | 1139 | */ |
| 1140 | frames = kmalloc(nr_gframes * sizeof(unsigned long), GFP_ATOMIC); | 1140 | frames = kmalloc_array(nr_gframes, sizeof(unsigned long), GFP_ATOMIC); |
| 1141 | if (!frames) | 1141 | if (!frames) |
| 1142 | return -ENOMEM; | 1142 | return -ENOMEM; |
| 1143 | 1143 | ||
| @@ -1300,8 +1300,9 @@ int gnttab_init(void) | |||
| 1300 | max_nr_glist_frames = (max_nr_grant_frames * | 1300 | max_nr_glist_frames = (max_nr_grant_frames * |
| 1301 | gnttab_interface->grefs_per_grant_frame / RPP); | 1301 | gnttab_interface->grefs_per_grant_frame / RPP); |
| 1302 | 1302 | ||
| 1303 | gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *), | 1303 | gnttab_list = kmalloc_array(max_nr_glist_frames, |
| 1304 | GFP_KERNEL); | 1304 | sizeof(grant_ref_t *), |
| 1305 | GFP_KERNEL); | ||
| 1305 | if (gnttab_list == NULL) | 1306 | if (gnttab_list == NULL) |
| 1306 | return -ENOMEM; | 1307 | return -ENOMEM; |
| 1307 | 1308 | ||
diff --git a/drivers/xen/xen-pciback/pciback_ops.c b/drivers/xen/xen-pciback/pciback_ops.c index ee2c891b55c6..ea4a08b83fa0 100644 --- a/drivers/xen/xen-pciback/pciback_ops.c +++ b/drivers/xen/xen-pciback/pciback_ops.c | |||
| @@ -234,7 +234,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev, | |||
| 234 | if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY)) | 234 | if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY)) |
| 235 | return -ENXIO; | 235 | return -ENXIO; |
| 236 | 236 | ||
| 237 | entries = kmalloc(op->value * sizeof(*entries), GFP_KERNEL); | 237 | entries = kmalloc_array(op->value, sizeof(*entries), GFP_KERNEL); |
| 238 | if (entries == NULL) | 238 | if (entries == NULL) |
| 239 | return -ENOMEM; | 239 | return -ENOMEM; |
| 240 | 240 | ||
diff --git a/fs/9p/fid.c b/fs/9p/fid.c index ed4f8519b627..a9ef46f02354 100644 --- a/fs/9p/fid.c +++ b/fs/9p/fid.c | |||
| @@ -100,7 +100,7 @@ static int build_path_from_dentry(struct v9fs_session_info *v9ses, | |||
| 100 | for (ds = dentry; !IS_ROOT(ds); ds = ds->d_parent) | 100 | for (ds = dentry; !IS_ROOT(ds); ds = ds->d_parent) |
| 101 | n++; | 101 | n++; |
| 102 | 102 | ||
| 103 | wnames = kmalloc(sizeof(char *) * n, GFP_KERNEL); | 103 | wnames = kmalloc_array(n, sizeof(char *), GFP_KERNEL); |
| 104 | if (!wnames) | 104 | if (!wnames) |
| 105 | goto err_out; | 105 | goto err_out; |
| 106 | 106 | ||
diff --git a/fs/adfs/super.c b/fs/adfs/super.c index cfda2c7caedc..71fa525d63a0 100644 --- a/fs/adfs/super.c +++ b/fs/adfs/super.c | |||
| @@ -313,7 +313,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di | |||
| 313 | 313 | ||
| 314 | asb->s_ids_per_zone = zone_size / (asb->s_idlen + 1); | 314 | asb->s_ids_per_zone = zone_size / (asb->s_idlen + 1); |
| 315 | 315 | ||
| 316 | dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL); | 316 | dm = kmalloc_array(nzones, sizeof(*dm), GFP_KERNEL); |
| 317 | if (dm == NULL) { | 317 | if (dm == NULL) { |
| 318 | adfs_error(sb, "not enough memory"); | 318 | adfs_error(sb, "not enough memory"); |
| 319 | return ERR_PTR(-ENOMEM); | 319 | return ERR_PTR(-ENOMEM); |
diff --git a/fs/afs/cmservice.c b/fs/afs/cmservice.c index c332c95a6940..238fd28cfdd2 100644 --- a/fs/afs/cmservice.c +++ b/fs/afs/cmservice.c | |||
| @@ -191,7 +191,8 @@ static int afs_deliver_cb_callback(struct afs_call *call) | |||
| 191 | if (call->count > AFSCBMAX) | 191 | if (call->count > AFSCBMAX) |
| 192 | return afs_protocol_error(call, -EBADMSG); | 192 | return afs_protocol_error(call, -EBADMSG); |
| 193 | 193 | ||
| 194 | call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL); | 194 | call->buffer = kmalloc(array3_size(call->count, 3, 4), |
| 195 | GFP_KERNEL); | ||
| 195 | if (!call->buffer) | 196 | if (!call->buffer) |
| 196 | return -ENOMEM; | 197 | return -ENOMEM; |
| 197 | call->offset = 0; | 198 | call->offset = 0; |
| @@ -330,7 +331,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call) | |||
| 330 | switch (call->unmarshall) { | 331 | switch (call->unmarshall) { |
| 331 | case 0: | 332 | case 0: |
| 332 | call->offset = 0; | 333 | call->offset = 0; |
| 333 | call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL); | 334 | call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL); |
| 334 | if (!call->buffer) | 335 | if (!call->buffer) |
| 335 | return -ENOMEM; | 336 | return -ENOMEM; |
| 336 | call->unmarshall++; | 337 | call->unmarshall++; |
| @@ -453,7 +454,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call) | |||
| 453 | switch (call->unmarshall) { | 454 | switch (call->unmarshall) { |
| 454 | case 0: | 455 | case 0: |
| 455 | call->offset = 0; | 456 | call->offset = 0; |
| 456 | call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL); | 457 | call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL); |
| 457 | if (!call->buffer) | 458 | if (!call->buffer) |
| 458 | return -ENOMEM; | 459 | return -ENOMEM; |
| 459 | call->unmarshall++; | 460 | call->unmarshall++; |
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c index 4ad6f669fe34..070b6184642d 100644 --- a/fs/binfmt_elf.c +++ b/fs/binfmt_elf.c | |||
| @@ -2010,7 +2010,7 @@ static int elf_note_info_init(struct elf_note_info *info) | |||
| 2010 | INIT_LIST_HEAD(&info->thread_list); | 2010 | INIT_LIST_HEAD(&info->thread_list); |
| 2011 | 2011 | ||
| 2012 | /* Allocate space for ELF notes */ | 2012 | /* Allocate space for ELF notes */ |
| 2013 | info->notes = kmalloc(8 * sizeof(struct memelfnote), GFP_KERNEL); | 2013 | info->notes = kmalloc_array(8, sizeof(struct memelfnote), GFP_KERNEL); |
| 2014 | if (!info->notes) | 2014 | if (!info->notes) |
| 2015 | return 0; | 2015 | return 0; |
| 2016 | info->psinfo = kmalloc(sizeof(*info->psinfo), GFP_KERNEL); | 2016 | info->psinfo = kmalloc(sizeof(*info->psinfo), GFP_KERNEL); |
| @@ -2294,7 +2294,7 @@ static int elf_core_dump(struct coredump_params *cprm) | |||
| 2294 | 2294 | ||
| 2295 | if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz)) | 2295 | if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz)) |
| 2296 | goto end_coredump; | 2296 | goto end_coredump; |
| 2297 | vma_filesz = vmalloc((segs - 1) * sizeof(*vma_filesz)); | 2297 | vma_filesz = vmalloc(array_size(sizeof(*vma_filesz), (segs - 1))); |
| 2298 | if (!vma_filesz) | 2298 | if (!vma_filesz) |
| 2299 | goto end_coredump; | 2299 | goto end_coredump; |
| 2300 | 2300 | ||
diff --git a/fs/binfmt_elf_fdpic.c b/fs/binfmt_elf_fdpic.c index d90993adeffa..b53bb3729ac1 100644 --- a/fs/binfmt_elf_fdpic.c +++ b/fs/binfmt_elf_fdpic.c | |||
| @@ -1600,7 +1600,8 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) | |||
| 1600 | psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); | 1600 | psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL); |
| 1601 | if (!psinfo) | 1601 | if (!psinfo) |
| 1602 | goto cleanup; | 1602 | goto cleanup; |
| 1603 | notes = kmalloc(NUM_NOTES * sizeof(struct memelfnote), GFP_KERNEL); | 1603 | notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote), |
| 1604 | GFP_KERNEL); | ||
| 1604 | if (!notes) | 1605 | if (!notes) |
| 1605 | goto cleanup; | 1606 | goto cleanup; |
| 1606 | fpu = kmalloc(sizeof(*fpu), GFP_KERNEL); | 1607 | fpu = kmalloc(sizeof(*fpu), GFP_KERNEL); |
diff --git a/fs/block_dev.c b/fs/block_dev.c index 05e12aea2404..0dd87aaeb39a 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c | |||
| @@ -205,7 +205,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, | |||
| 205 | if (nr_pages <= DIO_INLINE_BIO_VECS) | 205 | if (nr_pages <= DIO_INLINE_BIO_VECS) |
| 206 | vecs = inline_vecs; | 206 | vecs = inline_vecs; |
| 207 | else { | 207 | else { |
| 208 | vecs = kmalloc(nr_pages * sizeof(struct bio_vec), GFP_KERNEL); | 208 | vecs = kmalloc_array(nr_pages, sizeof(struct bio_vec), |
| 209 | GFP_KERNEL); | ||
| 209 | if (!vecs) | 210 | if (!vecs) |
| 210 | return -ENOMEM; | 211 | return -ENOMEM; |
| 211 | } | 212 | } |
diff --git a/fs/btrfs/check-integrity.c b/fs/btrfs/check-integrity.c index dc062b195c46..a3fdb4fe967d 100644 --- a/fs/btrfs/check-integrity.c +++ b/fs/btrfs/check-integrity.c | |||
| @@ -1603,8 +1603,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, | |||
| 1603 | 1603 | ||
| 1604 | num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >> | 1604 | num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >> |
| 1605 | PAGE_SHIFT; | 1605 | PAGE_SHIFT; |
| 1606 | block_ctx->mem_to_free = kzalloc((sizeof(*block_ctx->datav) + | 1606 | block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) + |
| 1607 | sizeof(*block_ctx->pagev)) * | 1607 | sizeof(*block_ctx->pagev), |
| 1608 | num_pages, GFP_NOFS); | 1608 | num_pages, GFP_NOFS); |
| 1609 | if (!block_ctx->mem_to_free) | 1609 | if (!block_ctx->mem_to_free) |
| 1610 | return -ENOMEM; | 1610 | return -ENOMEM; |
diff --git a/fs/ceph/addr.c b/fs/ceph/addr.c index 5f7ad3d0df2e..c9cb2f33a6d6 100644 --- a/fs/ceph/addr.c +++ b/fs/ceph/addr.c | |||
| @@ -370,7 +370,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, | |||
| 370 | 370 | ||
| 371 | /* build page vector */ | 371 | /* build page vector */ |
| 372 | nr_pages = calc_pages_for(0, len); | 372 | nr_pages = calc_pages_for(0, len); |
| 373 | pages = kmalloc(sizeof(*pages) * nr_pages, GFP_KERNEL); | 373 | pages = kmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL); |
| 374 | if (!pages) { | 374 | if (!pages) { |
| 375 | ret = -ENOMEM; | 375 | ret = -ENOMEM; |
| 376 | goto out_put; | 376 | goto out_put; |
| @@ -966,8 +966,9 @@ get_more_pages: | |||
| 966 | 966 | ||
| 967 | BUG_ON(pages); | 967 | BUG_ON(pages); |
| 968 | max_pages = calc_pages_for(0, (u64)len); | 968 | max_pages = calc_pages_for(0, (u64)len); |
| 969 | pages = kmalloc(max_pages * sizeof (*pages), | 969 | pages = kmalloc_array(max_pages, |
| 970 | GFP_NOFS); | 970 | sizeof(*pages), |
| 971 | GFP_NOFS); | ||
| 971 | if (!pages) { | 972 | if (!pages) { |
| 972 | pool = fsc->wb_pagevec_pool; | 973 | pool = fsc->wb_pagevec_pool; |
| 973 | pages = mempool_alloc(pool, GFP_NOFS); | 974 | pages = mempool_alloc(pool, GFP_NOFS); |
| @@ -1113,8 +1114,8 @@ new_request: | |||
| 1113 | 1114 | ||
| 1114 | /* allocate new pages array for next request */ | 1115 | /* allocate new pages array for next request */ |
| 1115 | data_pages = pages; | 1116 | data_pages = pages; |
| 1116 | pages = kmalloc(locked_pages * sizeof (*pages), | 1117 | pages = kmalloc_array(locked_pages, sizeof(*pages), |
| 1117 | GFP_NOFS); | 1118 | GFP_NOFS); |
| 1118 | if (!pages) { | 1119 | if (!pages) { |
| 1119 | pool = fsc->wb_pagevec_pool; | 1120 | pool = fsc->wb_pagevec_pool; |
| 1120 | pages = mempool_alloc(pool, GFP_NOFS); | 1121 | pages = mempool_alloc(pool, GFP_NOFS); |
diff --git a/fs/ceph/mds_client.c b/fs/ceph/mds_client.c index 5ece2e6ad154..cf8d24812cc0 100644 --- a/fs/ceph/mds_client.c +++ b/fs/ceph/mds_client.c | |||
| @@ -2992,8 +2992,9 @@ encode_again: | |||
| 2992 | num_flock_locks = 0; | 2992 | num_flock_locks = 0; |
| 2993 | } | 2993 | } |
| 2994 | if (num_fcntl_locks + num_flock_locks > 0) { | 2994 | if (num_fcntl_locks + num_flock_locks > 0) { |
| 2995 | flocks = kmalloc((num_fcntl_locks + num_flock_locks) * | 2995 | flocks = kmalloc_array(num_fcntl_locks + num_flock_locks, |
| 2996 | sizeof(struct ceph_filelock), GFP_NOFS); | 2996 | sizeof(struct ceph_filelock), |
| 2997 | GFP_NOFS); | ||
| 2997 | if (!flocks) { | 2998 | if (!flocks) { |
| 2998 | err = -ENOMEM; | 2999 | err = -ENOMEM; |
| 2999 | goto out_free; | 3000 | goto out_free; |
diff --git a/fs/cifs/asn1.c b/fs/cifs/asn1.c index a3b56544c21b..3d19595eb352 100644 --- a/fs/cifs/asn1.c +++ b/fs/cifs/asn1.c | |||
| @@ -428,7 +428,7 @@ asn1_oid_decode(struct asn1_ctx *ctx, | |||
| 428 | if (size < 2 || size > UINT_MAX/sizeof(unsigned long)) | 428 | if (size < 2 || size > UINT_MAX/sizeof(unsigned long)) |
| 429 | return 0; | 429 | return 0; |
| 430 | 430 | ||
| 431 | *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC); | 431 | *oid = kmalloc_array(size, sizeof(unsigned long), GFP_ATOMIC); |
| 432 | if (*oid == NULL) | 432 | if (*oid == NULL) |
| 433 | return 0; | 433 | return 0; |
| 434 | 434 | ||
diff --git a/fs/cifs/cifsacl.c b/fs/cifs/cifsacl.c index 13a8a77322c9..1d377b7f2860 100644 --- a/fs/cifs/cifsacl.c +++ b/fs/cifs/cifsacl.c | |||
| @@ -747,8 +747,8 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, | |||
| 747 | 747 | ||
| 748 | if (num_aces > ULONG_MAX / sizeof(struct cifs_ace *)) | 748 | if (num_aces > ULONG_MAX / sizeof(struct cifs_ace *)) |
| 749 | return; | 749 | return; |
| 750 | ppace = kmalloc(num_aces * sizeof(struct cifs_ace *), | 750 | ppace = kmalloc_array(num_aces, sizeof(struct cifs_ace *), |
| 751 | GFP_KERNEL); | 751 | GFP_KERNEL); |
| 752 | if (!ppace) | 752 | if (!ppace) |
| 753 | return; | 753 | return; |
| 754 | 754 | ||
diff --git a/fs/cifs/cifssmb.c b/fs/cifs/cifssmb.c index 5aca336642c0..42329b25877d 100644 --- a/fs/cifs/cifssmb.c +++ b/fs/cifs/cifssmb.c | |||
| @@ -2077,7 +2077,7 @@ struct cifs_writedata * | |||
| 2077 | cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete) | 2077 | cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete) |
| 2078 | { | 2078 | { |
| 2079 | struct page **pages = | 2079 | struct page **pages = |
| 2080 | kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); | 2080 | kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS); |
| 2081 | if (pages) | 2081 | if (pages) |
| 2082 | return cifs_writedata_direct_alloc(pages, complete); | 2082 | return cifs_writedata_direct_alloc(pages, complete); |
| 2083 | 2083 | ||
diff --git a/fs/cifs/file.c b/fs/cifs/file.c index 87eece6fbd48..8d41ca7bfcf1 100644 --- a/fs/cifs/file.c +++ b/fs/cifs/file.c | |||
| @@ -2900,7 +2900,7 @@ static struct cifs_readdata * | |||
| 2900 | cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete) | 2900 | cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete) |
| 2901 | { | 2901 | { |
| 2902 | struct page **pages = | 2902 | struct page **pages = |
| 2903 | kzalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL); | 2903 | kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL); |
| 2904 | struct cifs_readdata *ret = NULL; | 2904 | struct cifs_readdata *ret = NULL; |
| 2905 | 2905 | ||
| 2906 | if (pages) { | 2906 | if (pages) { |
diff --git a/fs/cifs/inode.c b/fs/cifs/inode.c index 745fd7fe8d0e..a94071c7b408 100644 --- a/fs/cifs/inode.c +++ b/fs/cifs/inode.c | |||
| @@ -1792,7 +1792,7 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, | |||
| 1792 | * with unix extensions enabled. | 1792 | * with unix extensions enabled. |
| 1793 | */ | 1793 | */ |
| 1794 | info_buf_source = | 1794 | info_buf_source = |
| 1795 | kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO), | 1795 | kmalloc_array(2, sizeof(FILE_UNIX_BASIC_INFO), |
| 1796 | GFP_KERNEL); | 1796 | GFP_KERNEL); |
| 1797 | if (info_buf_source == NULL) { | 1797 | if (info_buf_source == NULL) { |
| 1798 | rc = -ENOMEM; | 1798 | rc = -ENOMEM; |
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c index f90d4ad6624c..af29ade195c0 100644 --- a/fs/cifs/misc.c +++ b/fs/cifs/misc.c | |||
| @@ -789,7 +789,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) | |||
| 789 | GFP_KERNEL); | 789 | GFP_KERNEL); |
| 790 | 790 | ||
| 791 | if (!bv) { | 791 | if (!bv) { |
| 792 | bv = vmalloc(max_pages * sizeof(struct bio_vec)); | 792 | bv = vmalloc(array_size(max_pages, sizeof(struct bio_vec))); |
| 793 | if (!bv) | 793 | if (!bv) |
| 794 | return -ENOMEM; | 794 | return -ENOMEM; |
| 795 | } | 795 | } |
| @@ -799,7 +799,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) | |||
| 799 | GFP_KERNEL); | 799 | GFP_KERNEL); |
| 800 | 800 | ||
| 801 | if (!pages) { | 801 | if (!pages) { |
| 802 | pages = vmalloc(max_pages * sizeof(struct page *)); | 802 | pages = vmalloc(array_size(max_pages, sizeof(struct page *))); |
| 803 | if (!pages) { | 803 | if (!pages) { |
| 804 | kvfree(bv); | 804 | kvfree(bv); |
| 805 | return -ENOMEM; | 805 | return -ENOMEM; |
diff --git a/fs/cifs/smb2pdu.c b/fs/cifs/smb2pdu.c index 48e2004c75fb..af032e1a3eac 100644 --- a/fs/cifs/smb2pdu.c +++ b/fs/cifs/smb2pdu.c | |||
| @@ -3471,7 +3471,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3471 | if (!num) | 3471 | if (!num) |
| 3472 | return -EINVAL; | 3472 | return -EINVAL; |
| 3473 | 3473 | ||
| 3474 | iov = kmalloc(sizeof(struct kvec) * num, GFP_KERNEL); | 3474 | iov = kmalloc_array(num, sizeof(struct kvec), GFP_KERNEL); |
| 3475 | if (!iov) | 3475 | if (!iov) |
| 3476 | return -ENOMEM; | 3476 | return -ENOMEM; |
| 3477 | 3477 | ||
| @@ -3535,7 +3535,7 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3535 | int rc; | 3535 | int rc; |
| 3536 | int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX)); | 3536 | int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX)); |
| 3537 | 3537 | ||
| 3538 | data = kmalloc(sizeof(void *) * 2, GFP_KERNEL); | 3538 | data = kmalloc_array(2, sizeof(void *), GFP_KERNEL); |
| 3539 | if (!data) | 3539 | if (!data) |
| 3540 | return -ENOMEM; | 3540 | return -ENOMEM; |
| 3541 | 3541 | ||
| @@ -3583,7 +3583,7 @@ SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon, | |||
| 3583 | int rc; | 3583 | int rc; |
| 3584 | int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX)); | 3584 | int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX)); |
| 3585 | 3585 | ||
| 3586 | data = kmalloc(sizeof(void *) * 2, GFP_KERNEL); | 3586 | data = kmalloc_array(2, sizeof(void *), GFP_KERNEL); |
| 3587 | if (!data) | 3587 | if (!data) |
| 3588 | return -ENOMEM; | 3588 | return -ENOMEM; |
| 3589 | 3589 | ||
diff --git a/fs/cifs/transport.c b/fs/cifs/transport.c index 24887a0898c0..1f1a68f89110 100644 --- a/fs/cifs/transport.c +++ b/fs/cifs/transport.c | |||
| @@ -844,8 +844,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, | |||
| 844 | int rc; | 844 | int rc; |
| 845 | 845 | ||
| 846 | if (n_vec + 1 > CIFS_MAX_IOV_SIZE) { | 846 | if (n_vec + 1 > CIFS_MAX_IOV_SIZE) { |
| 847 | new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), | 847 | new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec), |
| 848 | GFP_KERNEL); | 848 | GFP_KERNEL); |
| 849 | if (!new_iov) { | 849 | if (!new_iov) { |
| 850 | /* otherwise cifs_send_recv below sets resp_buf_type */ | 850 | /* otherwise cifs_send_recv below sets resp_buf_type */ |
| 851 | *resp_buf_type = CIFS_NO_BUFFER; | 851 | *resp_buf_type = CIFS_NO_BUFFER; |
| @@ -886,8 +886,8 @@ smb2_send_recv(const unsigned int xid, struct cifs_ses *ses, | |||
| 886 | __be32 rfc1002_marker; | 886 | __be32 rfc1002_marker; |
| 887 | 887 | ||
| 888 | if (n_vec + 1 > CIFS_MAX_IOV_SIZE) { | 888 | if (n_vec + 1 > CIFS_MAX_IOV_SIZE) { |
| 889 | new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1), | 889 | new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec), |
| 890 | GFP_KERNEL); | 890 | GFP_KERNEL); |
| 891 | if (!new_iov) | 891 | if (!new_iov) |
| 892 | return -ENOMEM; | 892 | return -ENOMEM; |
| 893 | } else | 893 | } else |
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c index 78a7c855b06b..5ba94be006ee 100644 --- a/fs/dlm/lockspace.c +++ b/fs/dlm/lockspace.c | |||
| @@ -517,7 +517,7 @@ static int new_lockspace(const char *name, const char *cluster, | |||
| 517 | size = dlm_config.ci_rsbtbl_size; | 517 | size = dlm_config.ci_rsbtbl_size; |
| 518 | ls->ls_rsbtbl_size = size; | 518 | ls->ls_rsbtbl_size = size; |
| 519 | 519 | ||
| 520 | ls->ls_rsbtbl = vmalloc(sizeof(struct dlm_rsbtable) * size); | 520 | ls->ls_rsbtbl = vmalloc(array_size(size, sizeof(struct dlm_rsbtable))); |
| 521 | if (!ls->ls_rsbtbl) | 521 | if (!ls->ls_rsbtbl) |
| 522 | goto out_lsfree; | 522 | goto out_lsfree; |
| 523 | for (i = 0; i < size; i++) { | 523 | for (i = 0; i < size; i++) { |
diff --git a/fs/exofs/inode.c b/fs/exofs/inode.c index 0ac62811b341..5f81fcd383a4 100644 --- a/fs/exofs/inode.c +++ b/fs/exofs/inode.c | |||
| @@ -110,8 +110,8 @@ static int pcol_try_alloc(struct page_collect *pcol) | |||
| 110 | pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages); | 110 | pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages); |
| 111 | 111 | ||
| 112 | for (; pages; pages >>= 1) { | 112 | for (; pages; pages >>= 1) { |
| 113 | pcol->pages = kmalloc(pages * sizeof(struct page *), | 113 | pcol->pages = kmalloc_array(pages, sizeof(struct page *), |
| 114 | GFP_KERNEL); | 114 | GFP_KERNEL); |
| 115 | if (likely(pcol->pages)) { | 115 | if (likely(pcol->pages)) { |
| 116 | pcol->alloc_pages = pages; | 116 | pcol->alloc_pages = pages; |
| 117 | return 0; | 117 | return 0; |
diff --git a/fs/ext2/super.c b/fs/ext2/super.c index c09289a42dc5..25ab1274090f 100644 --- a/fs/ext2/super.c +++ b/fs/ext2/super.c | |||
| @@ -1082,7 +1082,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) | |||
| 1082 | / EXT2_BLOCKS_PER_GROUP(sb)) + 1; | 1082 | / EXT2_BLOCKS_PER_GROUP(sb)) + 1; |
| 1083 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / | 1083 | db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) / |
| 1084 | EXT2_DESC_PER_BLOCK(sb); | 1084 | EXT2_DESC_PER_BLOCK(sb); |
| 1085 | sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL); | 1085 | sbi->s_group_desc = kmalloc_array (db_count, |
| 1086 | sizeof(struct buffer_head *), | ||
| 1087 | GFP_KERNEL); | ||
| 1086 | if (sbi->s_group_desc == NULL) { | 1088 | if (sbi->s_group_desc == NULL) { |
| 1087 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); | 1089 | ext2_msg(sb, KERN_ERR, "error: not enough memory"); |
| 1088 | goto failed_mount; | 1090 | goto failed_mount; |
diff --git a/fs/ext4/extents.c b/fs/ext4/extents.c index c969275ce3ee..0057fe3f248d 100644 --- a/fs/ext4/extents.c +++ b/fs/ext4/extents.c | |||
| @@ -577,7 +577,7 @@ int ext4_ext_precache(struct inode *inode) | |||
| 577 | down_read(&ei->i_data_sem); | 577 | down_read(&ei->i_data_sem); |
| 578 | depth = ext_depth(inode); | 578 | depth = ext_depth(inode); |
| 579 | 579 | ||
| 580 | path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), | 580 | path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), |
| 581 | GFP_NOFS); | 581 | GFP_NOFS); |
| 582 | if (path == NULL) { | 582 | if (path == NULL) { |
| 583 | up_read(&ei->i_data_sem); | 583 | up_read(&ei->i_data_sem); |
| @@ -879,7 +879,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block, | |||
| 879 | } | 879 | } |
| 880 | if (!path) { | 880 | if (!path) { |
| 881 | /* account possible depth increase */ | 881 | /* account possible depth increase */ |
| 882 | path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2), | 882 | path = kcalloc(depth + 2, sizeof(struct ext4_ext_path), |
| 883 | GFP_NOFS); | 883 | GFP_NOFS); |
| 884 | if (unlikely(!path)) | 884 | if (unlikely(!path)) |
| 885 | return ERR_PTR(-ENOMEM); | 885 | return ERR_PTR(-ENOMEM); |
| @@ -1063,7 +1063,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, | |||
| 1063 | * We need this to handle errors and free blocks | 1063 | * We need this to handle errors and free blocks |
| 1064 | * upon them. | 1064 | * upon them. |
| 1065 | */ | 1065 | */ |
| 1066 | ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS); | 1066 | ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), GFP_NOFS); |
| 1067 | if (!ablocks) | 1067 | if (!ablocks) |
| 1068 | return -ENOMEM; | 1068 | return -ENOMEM; |
| 1069 | 1069 | ||
| @@ -2921,7 +2921,7 @@ again: | |||
| 2921 | path[k].p_block = | 2921 | path[k].p_block = |
| 2922 | le16_to_cpu(path[k].p_hdr->eh_entries)+1; | 2922 | le16_to_cpu(path[k].p_hdr->eh_entries)+1; |
| 2923 | } else { | 2923 | } else { |
| 2924 | path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1), | 2924 | path = kcalloc(depth + 1, sizeof(struct ext4_ext_path), |
| 2925 | GFP_NOFS); | 2925 | GFP_NOFS); |
| 2926 | if (path == NULL) { | 2926 | if (path == NULL) { |
| 2927 | ext4_journal_stop(handle); | 2927 | ext4_journal_stop(handle); |
diff --git a/fs/ext4/resize.c b/fs/ext4/resize.c index d792b7689d92..e5fb38451a73 100644 --- a/fs/ext4/resize.c +++ b/fs/ext4/resize.c | |||
| @@ -204,12 +204,14 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size) | |||
| 204 | goto out2; | 204 | goto out2; |
| 205 | flex_gd->count = flexbg_size; | 205 | flex_gd->count = flexbg_size; |
| 206 | 206 | ||
| 207 | flex_gd->groups = kmalloc(sizeof(struct ext4_new_group_data) * | 207 | flex_gd->groups = kmalloc_array(flexbg_size, |
| 208 | flexbg_size, GFP_NOFS); | 208 | sizeof(struct ext4_new_group_data), |
| 209 | GFP_NOFS); | ||
| 209 | if (flex_gd->groups == NULL) | 210 | if (flex_gd->groups == NULL) |
| 210 | goto out2; | 211 | goto out2; |
| 211 | 212 | ||
| 212 | flex_gd->bg_flags = kmalloc(flexbg_size * sizeof(__u16), GFP_NOFS); | 213 | flex_gd->bg_flags = kmalloc_array(flexbg_size, sizeof(__u16), |
| 214 | GFP_NOFS); | ||
| 213 | if (flex_gd->bg_flags == NULL) | 215 | if (flex_gd->bg_flags == NULL) |
| 214 | goto out1; | 216 | goto out1; |
| 215 | 217 | ||
| @@ -969,7 +971,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode, | |||
| 969 | int res, i; | 971 | int res, i; |
| 970 | int err; | 972 | int err; |
| 971 | 973 | ||
| 972 | primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_NOFS); | 974 | primary = kmalloc_array(reserved_gdb, sizeof(*primary), GFP_NOFS); |
| 973 | if (!primary) | 975 | if (!primary) |
| 974 | return -ENOMEM; | 976 | return -ENOMEM; |
| 975 | 977 | ||
diff --git a/fs/ext4/super.c b/fs/ext4/super.c index 00fe75a71c4b..0c4c2201b3aa 100644 --- a/fs/ext4/super.c +++ b/fs/ext4/super.c | |||
| @@ -3993,9 +3993,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) | |||
| 3993 | goto failed_mount; | 3993 | goto failed_mount; |
| 3994 | } | 3994 | } |
| 3995 | } | 3995 | } |
| 3996 | sbi->s_group_desc = kvmalloc(db_count * | 3996 | sbi->s_group_desc = kvmalloc_array(db_count, |
| 3997 | sizeof(struct buffer_head *), | 3997 | sizeof(struct buffer_head *), |
| 3998 | GFP_KERNEL); | 3998 | GFP_KERNEL); |
| 3999 | if (sbi->s_group_desc == NULL) { | 3999 | if (sbi->s_group_desc == NULL) { |
| 4000 | ext4_msg(sb, KERN_ERR, "not enough memory"); | 4000 | ext4_msg(sb, KERN_ERR, "not enough memory"); |
| 4001 | ret = -ENOMEM; | 4001 | ret = -ENOMEM; |
diff --git a/fs/f2fs/checkpoint.c b/fs/f2fs/checkpoint.c index 9624a8f7254b..9f1c96caebda 100644 --- a/fs/f2fs/checkpoint.c +++ b/fs/f2fs/checkpoint.c | |||
| @@ -806,7 +806,8 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi) | |||
| 806 | block_t cp_blk_no; | 806 | block_t cp_blk_no; |
| 807 | int i; | 807 | int i; |
| 808 | 808 | ||
| 809 | sbi->ckpt = f2fs_kzalloc(sbi, cp_blks * blk_size, GFP_KERNEL); | 809 | sbi->ckpt = f2fs_kzalloc(sbi, array_size(blk_size, cp_blks), |
| 810 | GFP_KERNEL); | ||
| 810 | if (!sbi->ckpt) | 811 | if (!sbi->ckpt) |
| 811 | return -ENOMEM; | 812 | return -ENOMEM; |
| 812 | /* | 813 | /* |
diff --git a/fs/f2fs/file.c b/fs/f2fs/file.c index 13f2f6845e87..cadb425c02d7 100644 --- a/fs/f2fs/file.c +++ b/fs/f2fs/file.c | |||
| @@ -1122,12 +1122,14 @@ static int __exchange_data_block(struct inode *src_inode, | |||
| 1122 | olen = min((pgoff_t)4 * ADDRS_PER_BLOCK, len); | 1122 | olen = min((pgoff_t)4 * ADDRS_PER_BLOCK, len); |
| 1123 | 1123 | ||
| 1124 | src_blkaddr = f2fs_kvzalloc(F2FS_I_SB(src_inode), | 1124 | src_blkaddr = f2fs_kvzalloc(F2FS_I_SB(src_inode), |
| 1125 | sizeof(block_t) * olen, GFP_KERNEL); | 1125 | array_size(olen, sizeof(block_t)), |
| 1126 | GFP_KERNEL); | ||
| 1126 | if (!src_blkaddr) | 1127 | if (!src_blkaddr) |
| 1127 | return -ENOMEM; | 1128 | return -ENOMEM; |
| 1128 | 1129 | ||
| 1129 | do_replace = f2fs_kvzalloc(F2FS_I_SB(src_inode), | 1130 | do_replace = f2fs_kvzalloc(F2FS_I_SB(src_inode), |
| 1130 | sizeof(int) * olen, GFP_KERNEL); | 1131 | array_size(olen, sizeof(int)), |
| 1132 | GFP_KERNEL); | ||
| 1131 | if (!do_replace) { | 1133 | if (!do_replace) { |
| 1132 | kvfree(src_blkaddr); | 1134 | kvfree(src_blkaddr); |
| 1133 | return -ENOMEM; | 1135 | return -ENOMEM; |
diff --git a/fs/f2fs/node.c b/fs/f2fs/node.c index 47d0e64a95a8..10643b11bd59 100644 --- a/fs/f2fs/node.c +++ b/fs/f2fs/node.c | |||
| @@ -2753,8 +2753,10 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi) | |||
| 2753 | struct f2fs_nm_info *nm_i = NM_I(sbi); | 2753 | struct f2fs_nm_info *nm_i = NM_I(sbi); |
| 2754 | int i; | 2754 | int i; |
| 2755 | 2755 | ||
| 2756 | nm_i->free_nid_bitmap = f2fs_kzalloc(sbi, nm_i->nat_blocks * | 2756 | nm_i->free_nid_bitmap = |
| 2757 | sizeof(unsigned char *), GFP_KERNEL); | 2757 | f2fs_kzalloc(sbi, array_size(sizeof(unsigned char *), |
| 2758 | nm_i->nat_blocks), | ||
| 2759 | GFP_KERNEL); | ||
| 2758 | if (!nm_i->free_nid_bitmap) | 2760 | if (!nm_i->free_nid_bitmap) |
| 2759 | return -ENOMEM; | 2761 | return -ENOMEM; |
| 2760 | 2762 | ||
| @@ -2770,8 +2772,10 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi) | |||
| 2770 | if (!nm_i->nat_block_bitmap) | 2772 | if (!nm_i->nat_block_bitmap) |
| 2771 | return -ENOMEM; | 2773 | return -ENOMEM; |
| 2772 | 2774 | ||
| 2773 | nm_i->free_nid_count = f2fs_kvzalloc(sbi, nm_i->nat_blocks * | 2775 | nm_i->free_nid_count = |
| 2774 | sizeof(unsigned short), GFP_KERNEL); | 2776 | f2fs_kvzalloc(sbi, array_size(sizeof(unsigned short), |
| 2777 | nm_i->nat_blocks), | ||
| 2778 | GFP_KERNEL); | ||
| 2775 | if (!nm_i->free_nid_count) | 2779 | if (!nm_i->free_nid_count) |
| 2776 | return -ENOMEM; | 2780 | return -ENOMEM; |
| 2777 | return 0; | 2781 | return 0; |
diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c index 6dbdf2c48fba..9efce174c51a 100644 --- a/fs/f2fs/segment.c +++ b/fs/f2fs/segment.c | |||
| @@ -3517,8 +3517,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi) | |||
| 3517 | 3517 | ||
| 3518 | SM_I(sbi)->sit_info = sit_i; | 3518 | SM_I(sbi)->sit_info = sit_i; |
| 3519 | 3519 | ||
| 3520 | sit_i->sentries = f2fs_kvzalloc(sbi, MAIN_SEGS(sbi) * | 3520 | sit_i->sentries = |
| 3521 | sizeof(struct seg_entry), GFP_KERNEL); | 3521 | f2fs_kvzalloc(sbi, array_size(sizeof(struct seg_entry), |
| 3522 | MAIN_SEGS(sbi)), | ||
| 3523 | GFP_KERNEL); | ||
| 3522 | if (!sit_i->sentries) | 3524 | if (!sit_i->sentries) |
| 3523 | return -ENOMEM; | 3525 | return -ENOMEM; |
| 3524 | 3526 | ||
| @@ -3558,8 +3560,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi) | |||
| 3558 | return -ENOMEM; | 3560 | return -ENOMEM; |
| 3559 | 3561 | ||
| 3560 | if (sbi->segs_per_sec > 1) { | 3562 | if (sbi->segs_per_sec > 1) { |
| 3561 | sit_i->sec_entries = f2fs_kvzalloc(sbi, MAIN_SECS(sbi) * | 3563 | sit_i->sec_entries = |
| 3562 | sizeof(struct sec_entry), GFP_KERNEL); | 3564 | f2fs_kvzalloc(sbi, array_size(sizeof(struct sec_entry), |
| 3565 | MAIN_SECS(sbi)), | ||
| 3566 | GFP_KERNEL); | ||
| 3563 | if (!sit_i->sec_entries) | 3567 | if (!sit_i->sec_entries) |
| 3564 | return -ENOMEM; | 3568 | return -ENOMEM; |
| 3565 | } | 3569 | } |
| @@ -3635,7 +3639,8 @@ static int build_curseg(struct f2fs_sb_info *sbi) | |||
| 3635 | struct curseg_info *array; | 3639 | struct curseg_info *array; |
| 3636 | int i; | 3640 | int i; |
| 3637 | 3641 | ||
| 3638 | array = f2fs_kzalloc(sbi, sizeof(*array) * NR_CURSEG_TYPE, GFP_KERNEL); | 3642 | array = f2fs_kzalloc(sbi, array_size(NR_CURSEG_TYPE, sizeof(*array)), |
| 3643 | GFP_KERNEL); | ||
| 3639 | if (!array) | 3644 | if (!array) |
| 3640 | return -ENOMEM; | 3645 | return -ENOMEM; |
| 3641 | 3646 | ||
diff --git a/fs/f2fs/super.c b/fs/f2fs/super.c index e7441e8d1ff8..3995e926ba3a 100644 --- a/fs/f2fs/super.c +++ b/fs/f2fs/super.c | |||
| @@ -2419,8 +2419,10 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) | |||
| 2419 | 2419 | ||
| 2420 | #define F2FS_REPORT_NR_ZONES 4096 | 2420 | #define F2FS_REPORT_NR_ZONES 4096 |
| 2421 | 2421 | ||
| 2422 | zones = f2fs_kzalloc(sbi, sizeof(struct blk_zone) * | 2422 | zones = f2fs_kzalloc(sbi, |
| 2423 | F2FS_REPORT_NR_ZONES, GFP_KERNEL); | 2423 | array_size(F2FS_REPORT_NR_ZONES, |
| 2424 | sizeof(struct blk_zone)), | ||
| 2425 | GFP_KERNEL); | ||
| 2424 | if (!zones) | 2426 | if (!zones) |
| 2425 | return -ENOMEM; | 2427 | return -ENOMEM; |
| 2426 | 2428 | ||
| @@ -2560,8 +2562,10 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) | |||
| 2560 | * Initialize multiple devices information, or single | 2562 | * Initialize multiple devices information, or single |
| 2561 | * zoned block device information. | 2563 | * zoned block device information. |
| 2562 | */ | 2564 | */ |
| 2563 | sbi->devs = f2fs_kzalloc(sbi, sizeof(struct f2fs_dev_info) * | 2565 | sbi->devs = f2fs_kzalloc(sbi, |
| 2564 | max_devices, GFP_KERNEL); | 2566 | array_size(max_devices, |
| 2567 | sizeof(struct f2fs_dev_info)), | ||
| 2568 | GFP_KERNEL); | ||
| 2565 | if (!sbi->devs) | 2569 | if (!sbi->devs) |
| 2566 | return -ENOMEM; | 2570 | return -ENOMEM; |
| 2567 | 2571 | ||
| @@ -2783,9 +2787,11 @@ try_onemore: | |||
| 2783 | int n = (i == META) ? 1: NR_TEMP_TYPE; | 2787 | int n = (i == META) ? 1: NR_TEMP_TYPE; |
| 2784 | int j; | 2788 | int j; |
| 2785 | 2789 | ||
| 2786 | sbi->write_io[i] = f2fs_kmalloc(sbi, | 2790 | sbi->write_io[i] = |
| 2787 | n * sizeof(struct f2fs_bio_info), | 2791 | f2fs_kmalloc(sbi, |
| 2788 | GFP_KERNEL); | 2792 | array_size(n, |
| 2793 | sizeof(struct f2fs_bio_info)), | ||
| 2794 | GFP_KERNEL); | ||
| 2789 | if (!sbi->write_io[i]) { | 2795 | if (!sbi->write_io[i]) { |
| 2790 | err = -ENOMEM; | 2796 | err = -ENOMEM; |
| 2791 | goto free_options; | 2797 | goto free_options; |
diff --git a/fs/fat/namei_vfat.c b/fs/fat/namei_vfat.c index 4f4362d5a04c..d4e23f8ddcf6 100644 --- a/fs/fat/namei_vfat.c +++ b/fs/fat/namei_vfat.c | |||
| @@ -664,7 +664,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname, | |||
| 664 | if (len == 0) | 664 | if (len == 0) |
| 665 | return -ENOENT; | 665 | return -ENOENT; |
| 666 | 666 | ||
| 667 | slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS); | 667 | slots = kmalloc_array(MSDOS_SLOTS, sizeof(*slots), GFP_NOFS); |
| 668 | if (slots == NULL) | 668 | if (slots == NULL) |
| 669 | return -ENOMEM; | 669 | return -ENOMEM; |
| 670 | 670 | ||
diff --git a/fs/fuse/dev.c b/fs/fuse/dev.c index e03ca14f40e9..c6b88fa85e2e 100644 --- a/fs/fuse/dev.c +++ b/fs/fuse/dev.c | |||
| @@ -64,9 +64,12 @@ static struct fuse_req *__fuse_request_alloc(unsigned npages, gfp_t flags) | |||
| 64 | pages = req->inline_pages; | 64 | pages = req->inline_pages; |
| 65 | page_descs = req->inline_page_descs; | 65 | page_descs = req->inline_page_descs; |
| 66 | } else { | 66 | } else { |
| 67 | pages = kmalloc(sizeof(struct page *) * npages, flags); | 67 | pages = kmalloc_array(npages, sizeof(struct page *), |
| 68 | page_descs = kmalloc(sizeof(struct fuse_page_desc) * | 68 | flags); |
| 69 | npages, flags); | 69 | page_descs = |
| 70 | kmalloc_array(npages, | ||
| 71 | sizeof(struct fuse_page_desc), | ||
| 72 | flags); | ||
| 70 | } | 73 | } |
| 71 | 74 | ||
| 72 | if (!pages || !page_descs) { | 75 | if (!pages || !page_descs) { |
| @@ -1359,7 +1362,8 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos, | |||
| 1359 | if (!fud) | 1362 | if (!fud) |
| 1360 | return -EPERM; | 1363 | return -EPERM; |
| 1361 | 1364 | ||
| 1362 | bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL); | 1365 | bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), |
| 1366 | GFP_KERNEL); | ||
| 1363 | if (!bufs) | 1367 | if (!bufs) |
| 1364 | return -ENOMEM; | 1368 | return -ENOMEM; |
| 1365 | 1369 | ||
| @@ -1940,7 +1944,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, | |||
| 1940 | if (!fud) | 1944 | if (!fud) |
| 1941 | return -EPERM; | 1945 | return -EPERM; |
| 1942 | 1946 | ||
| 1943 | bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL); | 1947 | bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer), |
| 1948 | GFP_KERNEL); | ||
| 1944 | if (!bufs) | 1949 | if (!bufs) |
| 1945 | return -ENOMEM; | 1950 | return -ENOMEM; |
| 1946 | 1951 | ||
diff --git a/fs/gfs2/dir.c b/fs/gfs2/dir.c index d9fb0ad6cc30..3090c445e8fc 100644 --- a/fs/gfs2/dir.c +++ b/fs/gfs2/dir.c | |||
| @@ -1055,7 +1055,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) | |||
| 1055 | /* Change the pointers. | 1055 | /* Change the pointers. |
| 1056 | Don't bother distinguishing stuffed from non-stuffed. | 1056 | Don't bother distinguishing stuffed from non-stuffed. |
| 1057 | This code is complicated enough already. */ | 1057 | This code is complicated enough already. */ |
| 1058 | lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS); | 1058 | lp = kmalloc_array(half_len, sizeof(__be64), GFP_NOFS); |
| 1059 | if (!lp) { | 1059 | if (!lp) { |
| 1060 | error = -ENOMEM; | 1060 | error = -ENOMEM; |
| 1061 | goto fail_brelse; | 1061 | goto fail_brelse; |
| @@ -1169,7 +1169,7 @@ static int dir_double_exhash(struct gfs2_inode *dip) | |||
| 1169 | if (IS_ERR(hc)) | 1169 | if (IS_ERR(hc)) |
| 1170 | return PTR_ERR(hc); | 1170 | return PTR_ERR(hc); |
| 1171 | 1171 | ||
| 1172 | hc2 = kmalloc(hsize_bytes * 2, GFP_NOFS | __GFP_NOWARN); | 1172 | hc2 = kmalloc_array(hsize_bytes, 2, GFP_NOFS | __GFP_NOWARN); |
| 1173 | if (hc2 == NULL) | 1173 | if (hc2 == NULL) |
| 1174 | hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL); | 1174 | hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL); |
| 1175 | 1175 | ||
| @@ -1596,7 +1596,7 @@ int gfs2_dir_read(struct inode *inode, struct dir_context *ctx, | |||
| 1596 | 1596 | ||
| 1597 | error = -ENOMEM; | 1597 | error = -ENOMEM; |
| 1598 | /* 96 is max number of dirents which can be stuffed into an inode */ | 1598 | /* 96 is max number of dirents which can be stuffed into an inode */ |
| 1599 | darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_NOFS); | 1599 | darr = kmalloc_array(96, sizeof(struct gfs2_dirent *), GFP_NOFS); |
| 1600 | if (darr) { | 1600 | if (darr) { |
| 1601 | g.pdent = (const struct gfs2_dirent **)darr; | 1601 | g.pdent = (const struct gfs2_dirent **)darr; |
| 1602 | g.offset = 0; | 1602 | g.offset = 0; |
diff --git a/fs/gfs2/glock.c b/fs/gfs2/glock.c index 097bd3c0f270..4614ee25f621 100644 --- a/fs/gfs2/glock.c +++ b/fs/gfs2/glock.c | |||
| @@ -1303,7 +1303,8 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs) | |||
| 1303 | default: | 1303 | default: |
| 1304 | if (num_gh <= 4) | 1304 | if (num_gh <= 4) |
| 1305 | break; | 1305 | break; |
| 1306 | pph = kmalloc(num_gh * sizeof(struct gfs2_holder *), GFP_NOFS); | 1306 | pph = kmalloc_array(num_gh, sizeof(struct gfs2_holder *), |
| 1307 | GFP_NOFS); | ||
| 1307 | if (!pph) | 1308 | if (!pph) |
| 1308 | return -ENOMEM; | 1309 | return -ENOMEM; |
| 1309 | } | 1310 | } |
diff --git a/fs/gfs2/quota.c b/fs/gfs2/quota.c index e8585dfd209f..0efae7a0ee80 100644 --- a/fs/gfs2/quota.c +++ b/fs/gfs2/quota.c | |||
| @@ -886,7 +886,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) | |||
| 886 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), | 886 | gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota), |
| 887 | &data_blocks, &ind_blocks); | 887 | &data_blocks, &ind_blocks); |
| 888 | 888 | ||
| 889 | ghs = kmalloc(num_qd * sizeof(struct gfs2_holder), GFP_NOFS); | 889 | ghs = kmalloc_array(num_qd, sizeof(struct gfs2_holder), GFP_NOFS); |
| 890 | if (!ghs) | 890 | if (!ghs) |
| 891 | return -ENOMEM; | 891 | return -ENOMEM; |
| 892 | 892 | ||
diff --git a/fs/gfs2/rgrp.c b/fs/gfs2/rgrp.c index 6bc5cfe710d1..33abcf29bc05 100644 --- a/fs/gfs2/rgrp.c +++ b/fs/gfs2/rgrp.c | |||
| @@ -2605,8 +2605,9 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state) | |||
| 2605 | { | 2605 | { |
| 2606 | unsigned int x; | 2606 | unsigned int x; |
| 2607 | 2607 | ||
| 2608 | rlist->rl_ghs = kmalloc(rlist->rl_rgrps * sizeof(struct gfs2_holder), | 2608 | rlist->rl_ghs = kmalloc_array(rlist->rl_rgrps, |
| 2609 | GFP_NOFS | __GFP_NOFAIL); | 2609 | sizeof(struct gfs2_holder), |
| 2610 | GFP_NOFS | __GFP_NOFAIL); | ||
| 2610 | for (x = 0; x < rlist->rl_rgrps; x++) | 2611 | for (x = 0; x < rlist->rl_rgrps; x++) |
| 2611 | gfs2_holder_init(rlist->rl_rgd[x]->rd_gl, | 2612 | gfs2_holder_init(rlist->rl_rgd[x]->rd_gl, |
| 2612 | state, 0, | 2613 | state, 0, |
diff --git a/fs/gfs2/super.c b/fs/gfs2/super.c index cf5c7f3080d2..af0d5b01cf0b 100644 --- a/fs/gfs2/super.c +++ b/fs/gfs2/super.c | |||
| @@ -1097,7 +1097,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host | |||
| 1097 | int error = 0, err; | 1097 | int error = 0, err; |
| 1098 | 1098 | ||
| 1099 | memset(sc, 0, sizeof(struct gfs2_statfs_change_host)); | 1099 | memset(sc, 0, sizeof(struct gfs2_statfs_change_host)); |
| 1100 | gha = kmalloc(slots * sizeof(struct gfs2_holder), GFP_KERNEL); | 1100 | gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL); |
| 1101 | if (!gha) | 1101 | if (!gha) |
| 1102 | return -ENOMEM; | 1102 | return -ENOMEM; |
| 1103 | for (x = 0; x < slots; x++) | 1103 | for (x = 0; x < slots; x++) |
diff --git a/fs/hpfs/dnode.c b/fs/hpfs/dnode.c index a4ad18afbdec..4ada525c5c43 100644 --- a/fs/hpfs/dnode.c +++ b/fs/hpfs/dnode.c | |||
| @@ -33,7 +33,8 @@ int hpfs_add_pos(struct inode *inode, loff_t *pos) | |||
| 33 | if (hpfs_inode->i_rddir_off[i] == pos) | 33 | if (hpfs_inode->i_rddir_off[i] == pos) |
| 34 | return 0; | 34 | return 0; |
| 35 | if (!(i&0x0f)) { | 35 | if (!(i&0x0f)) { |
| 36 | if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) { | 36 | ppos = kmalloc_array(i + 0x11, sizeof(loff_t *), GFP_NOFS); |
| 37 | if (!ppos) { | ||
| 37 | pr_err("out of memory for position list\n"); | 38 | pr_err("out of memory for position list\n"); |
| 38 | return -ENOMEM; | 39 | return -ENOMEM; |
| 39 | } | 40 | } |
diff --git a/fs/hpfs/map.c b/fs/hpfs/map.c index 7c49f1ef0c85..ecd9fccd1663 100644 --- a/fs/hpfs/map.c +++ b/fs/hpfs/map.c | |||
| @@ -115,7 +115,7 @@ __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) | |||
| 115 | int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; | 115 | int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21; |
| 116 | int i; | 116 | int i; |
| 117 | __le32 *b; | 117 | __le32 *b; |
| 118 | if (!(b = kmalloc(n * 512, GFP_KERNEL))) { | 118 | if (!(b = kmalloc_array(n, 512, GFP_KERNEL))) { |
| 119 | pr_err("can't allocate memory for bitmap directory\n"); | 119 | pr_err("can't allocate memory for bitmap directory\n"); |
| 120 | return NULL; | 120 | return NULL; |
| 121 | } | 121 | } |
diff --git a/fs/jbd2/revoke.c b/fs/jbd2/revoke.c index 240779e4689c..a1143e57a718 100644 --- a/fs/jbd2/revoke.c +++ b/fs/jbd2/revoke.c | |||
| @@ -223,7 +223,7 @@ static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size) | |||
| 223 | table->hash_size = hash_size; | 223 | table->hash_size = hash_size; |
| 224 | table->hash_shift = shift; | 224 | table->hash_shift = shift; |
| 225 | table->hash_table = | 225 | table->hash_table = |
| 226 | kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL); | 226 | kmalloc_array(hash_size, sizeof(struct list_head), GFP_KERNEL); |
| 227 | if (!table->hash_table) { | 227 | if (!table->hash_table) { |
| 228 | kmem_cache_free(jbd2_revoke_table_cache, table); | 228 | kmem_cache_free(jbd2_revoke_table_cache, table); |
| 229 | table = NULL; | 229 | table = NULL; |
diff --git a/fs/jffs2/acl.c b/fs/jffs2/acl.c index 7ebacf14837f..093ffbd82395 100644 --- a/fs/jffs2/acl.c +++ b/fs/jffs2/acl.c | |||
| @@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) | |||
| 133 | size_t i; | 133 | size_t i; |
| 134 | 134 | ||
| 135 | *size = jffs2_acl_size(acl->a_count); | 135 | *size = jffs2_acl_size(acl->a_count); |
| 136 | header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL); | 136 | header = kmalloc(struct_size(header, a_entries, acl->a_count), |
| 137 | GFP_KERNEL); | ||
| 137 | if (!header) | 138 | if (!header) |
| 138 | return ERR_PTR(-ENOMEM); | 139 | return ERR_PTR(-ENOMEM); |
| 139 | header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); | 140 | header->a_version = cpu_to_je32(JFFS2_ACL_VERSION); |
diff --git a/fs/jffs2/acl.h b/fs/jffs2/acl.h index 2e2b5745c3b7..12d0271bdde3 100644 --- a/fs/jffs2/acl.h +++ b/fs/jffs2/acl.h | |||
| @@ -22,6 +22,7 @@ struct jffs2_acl_entry_short { | |||
| 22 | 22 | ||
| 23 | struct jffs2_acl_header { | 23 | struct jffs2_acl_header { |
| 24 | jint32_t a_version; | 24 | jint32_t a_version; |
| 25 | struct jffs2_acl_entry a_entries[]; | ||
| 25 | }; | 26 | }; |
| 26 | 27 | ||
| 27 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL | 28 | #ifdef CONFIG_JFFS2_FS_POSIX_ACL |
diff --git a/fs/jffs2/wbuf.c b/fs/jffs2/wbuf.c index 2cfe487708e0..c6821a509481 100644 --- a/fs/jffs2/wbuf.c +++ b/fs/jffs2/wbuf.c | |||
| @@ -1208,7 +1208,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) | |||
| 1208 | if (!c->wbuf) | 1208 | if (!c->wbuf) |
| 1209 | return -ENOMEM; | 1209 | return -ENOMEM; |
| 1210 | 1210 | ||
| 1211 | c->oobbuf = kmalloc(NR_OOB_SCAN_PAGES * c->oobavail, GFP_KERNEL); | 1211 | c->oobbuf = kmalloc_array(NR_OOB_SCAN_PAGES, c->oobavail, GFP_KERNEL); |
| 1212 | if (!c->oobbuf) { | 1212 | if (!c->oobbuf) { |
| 1213 | kfree(c->wbuf); | 1213 | kfree(c->wbuf); |
| 1214 | return -ENOMEM; | 1214 | return -ENOMEM; |
diff --git a/fs/jfs/jfs_dmap.c b/fs/jfs/jfs_dmap.c index 2d514c7affc2..49263e220dbc 100644 --- a/fs/jfs/jfs_dmap.c +++ b/fs/jfs/jfs_dmap.c | |||
| @@ -1641,7 +1641,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) | |||
| 1641 | max_ranges = nblocks; | 1641 | max_ranges = nblocks; |
| 1642 | do_div(max_ranges, minlen); | 1642 | do_div(max_ranges, minlen); |
| 1643 | range_cnt = min_t(u64, max_ranges + 1, 32 * 1024); | 1643 | range_cnt = min_t(u64, max_ranges + 1, 32 * 1024); |
| 1644 | totrim = kmalloc(sizeof(struct range2trim) * range_cnt, GFP_NOFS); | 1644 | totrim = kmalloc_array(range_cnt, sizeof(struct range2trim), GFP_NOFS); |
| 1645 | if (totrim == NULL) { | 1645 | if (totrim == NULL) { |
| 1646 | jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n"); | 1646 | jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n"); |
| 1647 | IWRITE_UNLOCK(ipbmap); | 1647 | IWRITE_UNLOCK(ipbmap); |
diff --git a/fs/jfs/jfs_dtree.c b/fs/jfs/jfs_dtree.c index de2bcb36e079..52bae3f5c914 100644 --- a/fs/jfs/jfs_dtree.c +++ b/fs/jfs/jfs_dtree.c | |||
| @@ -594,7 +594,8 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data, | |||
| 594 | struct component_name ciKey; | 594 | struct component_name ciKey; |
| 595 | struct super_block *sb = ip->i_sb; | 595 | struct super_block *sb = ip->i_sb; |
| 596 | 596 | ||
| 597 | ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS); | 597 | ciKey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t), |
| 598 | GFP_NOFS); | ||
| 598 | if (!ciKey.name) { | 599 | if (!ciKey.name) { |
| 599 | rc = -ENOMEM; | 600 | rc = -ENOMEM; |
| 600 | goto dtSearch_Exit2; | 601 | goto dtSearch_Exit2; |
| @@ -957,7 +958,7 @@ static int dtSplitUp(tid_t tid, | |||
| 957 | smp = split->mp; | 958 | smp = split->mp; |
| 958 | sp = DT_PAGE(ip, smp); | 959 | sp = DT_PAGE(ip, smp); |
| 959 | 960 | ||
| 960 | key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS); | 961 | key.name = kmalloc_array(JFS_NAME_MAX + 2, sizeof(wchar_t), GFP_NOFS); |
| 961 | if (!key.name) { | 962 | if (!key.name) { |
| 962 | DT_PUTPAGE(smp); | 963 | DT_PUTPAGE(smp); |
| 963 | rc = -ENOMEM; | 964 | rc = -ENOMEM; |
| @@ -3779,12 +3780,12 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp, | |||
| 3779 | struct component_name lkey; | 3780 | struct component_name lkey; |
| 3780 | struct component_name rkey; | 3781 | struct component_name rkey; |
| 3781 | 3782 | ||
| 3782 | lkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), | 3783 | lkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t), |
| 3783 | GFP_KERNEL); | 3784 | GFP_KERNEL); |
| 3784 | if (lkey.name == NULL) | 3785 | if (lkey.name == NULL) |
| 3785 | return -ENOMEM; | 3786 | return -ENOMEM; |
| 3786 | 3787 | ||
| 3787 | rkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), | 3788 | rkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t), |
| 3788 | GFP_KERNEL); | 3789 | GFP_KERNEL); |
| 3789 | if (rkey.name == NULL) { | 3790 | if (rkey.name == NULL) { |
| 3790 | kfree(lkey.name); | 3791 | kfree(lkey.name); |
diff --git a/fs/jfs/jfs_unicode.c b/fs/jfs/jfs_unicode.c index c7de6f5bbefc..0148e2e4d97a 100644 --- a/fs/jfs/jfs_unicode.c +++ b/fs/jfs/jfs_unicode.c | |||
| @@ -121,7 +121,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry) | |||
| 121 | return -ENAMETOOLONG; | 121 | return -ENAMETOOLONG; |
| 122 | 122 | ||
| 123 | uniName->name = | 123 | uniName->name = |
| 124 | kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS); | 124 | kmalloc_array(length + 1, sizeof(wchar_t), GFP_NOFS); |
| 125 | 125 | ||
| 126 | if (uniName->name == NULL) | 126 | if (uniName->name == NULL) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
diff --git a/fs/mbcache.c b/fs/mbcache.c index bf41e2e72c18..081ccf0caee3 100644 --- a/fs/mbcache.c +++ b/fs/mbcache.c | |||
| @@ -353,8 +353,9 @@ struct mb_cache *mb_cache_create(int bucket_bits) | |||
| 353 | cache->c_max_entries = bucket_count << 4; | 353 | cache->c_max_entries = bucket_count << 4; |
| 354 | INIT_LIST_HEAD(&cache->c_list); | 354 | INIT_LIST_HEAD(&cache->c_list); |
| 355 | spin_lock_init(&cache->c_list_lock); | 355 | spin_lock_init(&cache->c_list_lock); |
| 356 | cache->c_hash = kmalloc(bucket_count * sizeof(struct hlist_bl_head), | 356 | cache->c_hash = kmalloc_array(bucket_count, |
| 357 | GFP_KERNEL); | 357 | sizeof(struct hlist_bl_head), |
| 358 | GFP_KERNEL); | ||
| 358 | if (!cache->c_hash) { | 359 | if (!cache->c_hash) { |
| 359 | kfree(cache); | 360 | kfree(cache); |
| 360 | goto err_out; | 361 | goto err_out; |
diff --git a/fs/namei.c b/fs/namei.c index 6df1f61855d6..2490ddb8bc90 100644 --- a/fs/namei.c +++ b/fs/namei.c | |||
| @@ -537,12 +537,12 @@ static int __nd_alloc_stack(struct nameidata *nd) | |||
| 537 | struct saved *p; | 537 | struct saved *p; |
| 538 | 538 | ||
| 539 | if (nd->flags & LOOKUP_RCU) { | 539 | if (nd->flags & LOOKUP_RCU) { |
| 540 | p= kmalloc(MAXSYMLINKS * sizeof(struct saved), | 540 | p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved), |
| 541 | GFP_ATOMIC); | 541 | GFP_ATOMIC); |
| 542 | if (unlikely(!p)) | 542 | if (unlikely(!p)) |
| 543 | return -ECHILD; | 543 | return -ECHILD; |
| 544 | } else { | 544 | } else { |
| 545 | p= kmalloc(MAXSYMLINKS * sizeof(struct saved), | 545 | p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved), |
| 546 | GFP_KERNEL); | 546 | GFP_KERNEL); |
| 547 | if (unlikely(!p)) | 547 | if (unlikely(!p)) |
| 548 | return -ENOMEM; | 548 | return -ENOMEM; |
diff --git a/fs/nfs/flexfilelayout/flexfilelayout.c b/fs/nfs/flexfilelayout/flexfilelayout.c index 3ae038d9c292..d4a07acad598 100644 --- a/fs/nfs/flexfilelayout/flexfilelayout.c +++ b/fs/nfs/flexfilelayout/flexfilelayout.c | |||
| @@ -461,7 +461,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, | |||
| 461 | fh_count = be32_to_cpup(p); | 461 | fh_count = be32_to_cpup(p); |
| 462 | 462 | ||
| 463 | fls->mirror_array[i]->fh_versions = | 463 | fls->mirror_array[i]->fh_versions = |
| 464 | kzalloc(fh_count * sizeof(struct nfs_fh), | 464 | kcalloc(fh_count, sizeof(struct nfs_fh), |
| 465 | gfp_flags); | 465 | gfp_flags); |
| 466 | if (fls->mirror_array[i]->fh_versions == NULL) { | 466 | if (fls->mirror_array[i]->fh_versions == NULL) { |
| 467 | rc = -ENOMEM; | 467 | rc = -ENOMEM; |
diff --git a/fs/nfs/flexfilelayout/flexfilelayoutdev.c b/fs/nfs/flexfilelayout/flexfilelayoutdev.c index d62279d3fc5d..59aa04976331 100644 --- a/fs/nfs/flexfilelayout/flexfilelayoutdev.c +++ b/fs/nfs/flexfilelayout/flexfilelayoutdev.c | |||
| @@ -99,7 +99,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, | |||
| 99 | version_count = be32_to_cpup(p); | 99 | version_count = be32_to_cpup(p); |
| 100 | dprintk("%s: version count %d\n", __func__, version_count); | 100 | dprintk("%s: version count %d\n", __func__, version_count); |
| 101 | 101 | ||
| 102 | ds_versions = kzalloc(version_count * sizeof(struct nfs4_ff_ds_version), | 102 | ds_versions = kcalloc(version_count, |
| 103 | sizeof(struct nfs4_ff_ds_version), | ||
| 103 | gfp_flags); | 104 | gfp_flags); |
| 104 | if (!ds_versions) | 105 | if (!ds_versions) |
| 105 | goto out_scratch; | 106 | goto out_scratch; |
diff --git a/fs/nfsd/export.c b/fs/nfsd/export.c index 8ceb25a10ea0..a1143f7c2201 100644 --- a/fs/nfsd/export.c +++ b/fs/nfsd/export.c | |||
| @@ -404,8 +404,9 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc) | |||
| 404 | if (fsloc->locations_count == 0) | 404 | if (fsloc->locations_count == 0) |
| 405 | return 0; | 405 | return 0; |
| 406 | 406 | ||
| 407 | fsloc->locations = kzalloc(fsloc->locations_count | 407 | fsloc->locations = kcalloc(fsloc->locations_count, |
| 408 | * sizeof(struct nfsd4_fs_location), GFP_KERNEL); | 408 | sizeof(struct nfsd4_fs_location), |
| 409 | GFP_KERNEL); | ||
| 409 | if (!fsloc->locations) | 410 | if (!fsloc->locations) |
| 410 | return -ENOMEM; | 411 | return -ENOMEM; |
| 411 | for (i=0; i < fsloc->locations_count; i++) { | 412 | for (i=0; i < fsloc->locations_count; i++) { |
diff --git a/fs/nfsd/nfs4recover.c b/fs/nfsd/nfs4recover.c index 66eaeb1e8c2c..9c247fa1e959 100644 --- a/fs/nfsd/nfs4recover.c +++ b/fs/nfsd/nfs4recover.c | |||
| @@ -510,8 +510,9 @@ nfs4_legacy_state_init(struct net *net) | |||
| 510 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 510 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
| 511 | int i; | 511 | int i; |
| 512 | 512 | ||
| 513 | nn->reclaim_str_hashtbl = kmalloc(sizeof(struct list_head) * | 513 | nn->reclaim_str_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, |
| 514 | CLIENT_HASH_SIZE, GFP_KERNEL); | 514 | sizeof(struct list_head), |
| 515 | GFP_KERNEL); | ||
| 515 | if (!nn->reclaim_str_hashtbl) | 516 | if (!nn->reclaim_str_hashtbl) |
| 516 | return -ENOMEM; | 517 | return -ENOMEM; |
| 517 | 518 | ||
diff --git a/fs/nfsd/nfs4state.c b/fs/nfsd/nfs4state.c index 3b40d1b57613..857141446d6b 100644 --- a/fs/nfsd/nfs4state.c +++ b/fs/nfsd/nfs4state.c | |||
| @@ -1807,8 +1807,9 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name) | |||
| 1807 | clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL); | 1807 | clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL); |
| 1808 | if (clp->cl_name.data == NULL) | 1808 | if (clp->cl_name.data == NULL) |
| 1809 | goto err_no_name; | 1809 | goto err_no_name; |
| 1810 | clp->cl_ownerstr_hashtbl = kmalloc(sizeof(struct list_head) * | 1810 | clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE, |
| 1811 | OWNER_HASH_SIZE, GFP_KERNEL); | 1811 | sizeof(struct list_head), |
| 1812 | GFP_KERNEL); | ||
| 1812 | if (!clp->cl_ownerstr_hashtbl) | 1813 | if (!clp->cl_ownerstr_hashtbl) |
| 1813 | goto err_no_hashtbl; | 1814 | goto err_no_hashtbl; |
| 1814 | for (i = 0; i < OWNER_HASH_SIZE; i++) | 1815 | for (i = 0; i < OWNER_HASH_SIZE; i++) |
| @@ -7096,16 +7097,19 @@ static int nfs4_state_create_net(struct net *net) | |||
| 7096 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); | 7097 | struct nfsd_net *nn = net_generic(net, nfsd_net_id); |
| 7097 | int i; | 7098 | int i; |
| 7098 | 7099 | ||
| 7099 | nn->conf_id_hashtbl = kmalloc(sizeof(struct list_head) * | 7100 | nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, |
| 7100 | CLIENT_HASH_SIZE, GFP_KERNEL); | 7101 | sizeof(struct list_head), |
| 7102 | GFP_KERNEL); | ||
| 7101 | if (!nn->conf_id_hashtbl) | 7103 | if (!nn->conf_id_hashtbl) |
| 7102 | goto err; | 7104 | goto err; |
| 7103 | nn->unconf_id_hashtbl = kmalloc(sizeof(struct list_head) * | 7105 | nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE, |
| 7104 | CLIENT_HASH_SIZE, GFP_KERNEL); | 7106 | sizeof(struct list_head), |
| 7107 | GFP_KERNEL); | ||
| 7105 | if (!nn->unconf_id_hashtbl) | 7108 | if (!nn->unconf_id_hashtbl) |
| 7106 | goto err_unconf_id; | 7109 | goto err_unconf_id; |
| 7107 | nn->sessionid_hashtbl = kmalloc(sizeof(struct list_head) * | 7110 | nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE, |
| 7108 | SESSION_HASH_SIZE, GFP_KERNEL); | 7111 | sizeof(struct list_head), |
| 7112 | GFP_KERNEL); | ||
| 7109 | if (!nn->sessionid_hashtbl) | 7113 | if (!nn->sessionid_hashtbl) |
| 7110 | goto err_sessionid; | 7114 | goto err_sessionid; |
| 7111 | 7115 | ||
diff --git a/fs/nfsd/nfscache.c b/fs/nfsd/nfscache.c index 637f87c39183..dbdeb9d6af03 100644 --- a/fs/nfsd/nfscache.c +++ b/fs/nfsd/nfscache.c | |||
| @@ -177,7 +177,8 @@ int nfsd_reply_cache_init(void) | |||
| 177 | 177 | ||
| 178 | drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL); | 178 | drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL); |
| 179 | if (!drc_hashtbl) { | 179 | if (!drc_hashtbl) { |
| 180 | drc_hashtbl = vzalloc(hashsize * sizeof(*drc_hashtbl)); | 180 | drc_hashtbl = vzalloc(array_size(hashsize, |
| 181 | sizeof(*drc_hashtbl))); | ||
| 181 | if (!drc_hashtbl) | 182 | if (!drc_hashtbl) |
| 182 | goto out_nomem; | 183 | goto out_nomem; |
| 183 | } | 184 | } |
diff --git a/fs/ntfs/compress.c b/fs/ntfs/compress.c index f8eb04387ca4..fbd0090d7d0c 100644 --- a/fs/ntfs/compress.c +++ b/fs/ntfs/compress.c | |||
| @@ -527,7 +527,7 @@ int ntfs_read_compressed_block(struct page *page) | |||
| 527 | BUG_ON(ni->type != AT_DATA); | 527 | BUG_ON(ni->type != AT_DATA); |
| 528 | BUG_ON(ni->name_len); | 528 | BUG_ON(ni->name_len); |
| 529 | 529 | ||
| 530 | pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS); | 530 | pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_NOFS); |
| 531 | 531 | ||
| 532 | /* Allocate memory to store the buffer heads we need. */ | 532 | /* Allocate memory to store the buffer heads we need. */ |
| 533 | bhs_size = cb_size / block_size * sizeof(struct buffer_head *); | 533 | bhs_size = cb_size / block_size * sizeof(struct buffer_head *); |
diff --git a/fs/ocfs2/cluster/tcp.c b/fs/ocfs2/cluster/tcp.c index e5076185cc1e..1296f78ae966 100644 --- a/fs/ocfs2/cluster/tcp.c +++ b/fs/ocfs2/cluster/tcp.c | |||
| @@ -1078,7 +1078,7 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, | |||
| 1078 | o2net_set_nst_sock_container(&nst, sc); | 1078 | o2net_set_nst_sock_container(&nst, sc); |
| 1079 | 1079 | ||
| 1080 | veclen = caller_veclen + 1; | 1080 | veclen = caller_veclen + 1; |
| 1081 | vec = kmalloc(sizeof(struct kvec) * veclen, GFP_ATOMIC); | 1081 | vec = kmalloc_array(veclen, sizeof(struct kvec), GFP_ATOMIC); |
| 1082 | if (vec == NULL) { | 1082 | if (vec == NULL) { |
| 1083 | mlog(0, "failed to %zu element kvec!\n", veclen); | 1083 | mlog(0, "failed to %zu element kvec!\n", veclen); |
| 1084 | ret = -ENOMEM; | 1084 | ret = -ENOMEM; |
diff --git a/fs/ocfs2/dlm/dlmdomain.c b/fs/ocfs2/dlm/dlmdomain.c index 425081be6161..2acd58ba9b7b 100644 --- a/fs/ocfs2/dlm/dlmdomain.c +++ b/fs/ocfs2/dlm/dlmdomain.c | |||
| @@ -86,7 +86,7 @@ static void dlm_free_pagevec(void **vec, int pages) | |||
| 86 | 86 | ||
| 87 | static void **dlm_alloc_pagevec(int pages) | 87 | static void **dlm_alloc_pagevec(int pages) |
| 88 | { | 88 | { |
| 89 | void **vec = kmalloc(pages * sizeof(void *), GFP_KERNEL); | 89 | void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL); |
| 90 | int i; | 90 | int i; |
| 91 | 91 | ||
| 92 | if (!vec) | 92 | if (!vec) |
diff --git a/fs/ocfs2/journal.c b/fs/ocfs2/journal.c index e5dcea6cee5f..bd3475694e83 100644 --- a/fs/ocfs2/journal.c +++ b/fs/ocfs2/journal.c | |||
| @@ -1383,7 +1383,7 @@ static int __ocfs2_recovery_thread(void *arg) | |||
| 1383 | goto bail; | 1383 | goto bail; |
| 1384 | } | 1384 | } |
| 1385 | 1385 | ||
| 1386 | rm_quota = kzalloc(osb->max_slots * sizeof(int), GFP_NOFS); | 1386 | rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS); |
| 1387 | if (!rm_quota) { | 1387 | if (!rm_quota) { |
| 1388 | status = -ENOMEM; | 1388 | status = -ENOMEM; |
| 1389 | goto bail; | 1389 | goto bail; |
diff --git a/fs/ocfs2/sysfile.c b/fs/ocfs2/sysfile.c index af155c183123..5965f3878d49 100644 --- a/fs/ocfs2/sysfile.c +++ b/fs/ocfs2/sysfile.c | |||
| @@ -69,10 +69,11 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb, | |||
| 69 | spin_unlock(&osb->osb_lock); | 69 | spin_unlock(&osb->osb_lock); |
| 70 | 70 | ||
| 71 | if (unlikely(!local_system_inodes)) { | 71 | if (unlikely(!local_system_inodes)) { |
| 72 | local_system_inodes = kzalloc(sizeof(struct inode *) * | 72 | local_system_inodes = |
| 73 | NUM_LOCAL_SYSTEM_INODES * | 73 | kzalloc(array3_size(sizeof(struct inode *), |
| 74 | osb->max_slots, | 74 | NUM_LOCAL_SYSTEM_INODES, |
| 75 | GFP_NOFS); | 75 | osb->max_slots), |
| 76 | GFP_NOFS); | ||
| 76 | if (!local_system_inodes) { | 77 | if (!local_system_inodes) { |
| 77 | mlog_errno(-ENOMEM); | 78 | mlog_errno(-ENOMEM); |
| 78 | /* | 79 | /* |
diff --git a/fs/overlayfs/namei.c b/fs/overlayfs/namei.c index 08801b45df00..c993dd8db739 100644 --- a/fs/overlayfs/namei.c +++ b/fs/overlayfs/namei.c | |||
| @@ -612,7 +612,7 @@ static int ovl_get_index_name_fh(struct ovl_fh *fh, struct qstr *name) | |||
| 612 | { | 612 | { |
| 613 | char *n, *s; | 613 | char *n, *s; |
| 614 | 614 | ||
| 615 | n = kzalloc(fh->len * 2, GFP_KERNEL); | 615 | n = kcalloc(fh->len, 2, GFP_KERNEL); |
| 616 | if (!n) | 616 | if (!n) |
| 617 | return -ENOMEM; | 617 | return -ENOMEM; |
| 618 | 618 | ||
diff --git a/fs/proc/base.c b/fs/proc/base.c index 4aa9ce5df02f..80aa42506b8b 100644 --- a/fs/proc/base.c +++ b/fs/proc/base.c | |||
| @@ -389,7 +389,8 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, | |||
| 389 | unsigned long *entries; | 389 | unsigned long *entries; |
| 390 | int err; | 390 | int err; |
| 391 | 391 | ||
| 392 | entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL); | 392 | entries = kmalloc_array(MAX_STACK_TRACE_DEPTH, sizeof(*entries), |
| 393 | GFP_KERNEL); | ||
| 393 | if (!entries) | 394 | if (!entries) |
| 394 | return -ENOMEM; | 395 | return -ENOMEM; |
| 395 | 396 | ||
diff --git a/fs/proc/proc_sysctl.c b/fs/proc/proc_sysctl.c index 4d765e5e91ed..89921a0d2ebb 100644 --- a/fs/proc/proc_sysctl.c +++ b/fs/proc/proc_sysctl.c | |||
| @@ -1426,7 +1426,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, | |||
| 1426 | /* If there are mixed files and directories we need a new table */ | 1426 | /* If there are mixed files and directories we need a new table */ |
| 1427 | if (nr_dirs && nr_files) { | 1427 | if (nr_dirs && nr_files) { |
| 1428 | struct ctl_table *new; | 1428 | struct ctl_table *new; |
| 1429 | files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1), | 1429 | files = kcalloc(nr_files + 1, sizeof(struct ctl_table), |
| 1430 | GFP_KERNEL); | 1430 | GFP_KERNEL); |
| 1431 | if (!files) | 1431 | if (!files) |
| 1432 | goto out; | 1432 | goto out; |
diff --git a/fs/proc/task_mmu.c b/fs/proc/task_mmu.c index 597969db9e90..e9679016271f 100644 --- a/fs/proc/task_mmu.c +++ b/fs/proc/task_mmu.c | |||
| @@ -1473,7 +1473,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, | |||
| 1473 | pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN); | 1473 | pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN); |
| 1474 | 1474 | ||
| 1475 | pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT); | 1475 | pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT); |
| 1476 | pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_KERNEL); | 1476 | pm.buffer = kmalloc_array(pm.len, PM_ENTRY_BYTES, GFP_KERNEL); |
| 1477 | ret = -ENOMEM; | 1477 | ret = -ENOMEM; |
| 1478 | if (!pm.buffer) | 1478 | if (!pm.buffer) |
| 1479 | goto out_mm; | 1479 | goto out_mm; |
diff --git a/fs/read_write.c b/fs/read_write.c index e83bd9744b5d..153f8f690490 100644 --- a/fs/read_write.c +++ b/fs/read_write.c | |||
| @@ -778,7 +778,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, | |||
| 778 | goto out; | 778 | goto out; |
| 779 | } | 779 | } |
| 780 | if (nr_segs > fast_segs) { | 780 | if (nr_segs > fast_segs) { |
| 781 | iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL); | 781 | iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL); |
| 782 | if (iov == NULL) { | 782 | if (iov == NULL) { |
| 783 | ret = -ENOMEM; | 783 | ret = -ENOMEM; |
| 784 | goto out; | 784 | goto out; |
| @@ -849,7 +849,7 @@ ssize_t compat_rw_copy_check_uvector(int type, | |||
| 849 | goto out; | 849 | goto out; |
| 850 | if (nr_segs > fast_segs) { | 850 | if (nr_segs > fast_segs) { |
| 851 | ret = -ENOMEM; | 851 | ret = -ENOMEM; |
| 852 | iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL); | 852 | iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL); |
| 853 | if (iov == NULL) | 853 | if (iov == NULL) |
| 854 | goto out; | 854 | goto out; |
| 855 | } | 855 | } |
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c index edc8ef78b63f..bf708ac287b4 100644 --- a/fs/reiserfs/bitmap.c +++ b/fs/reiserfs/bitmap.c | |||
| @@ -1456,7 +1456,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb) | |||
| 1456 | struct reiserfs_bitmap_info *bitmap; | 1456 | struct reiserfs_bitmap_info *bitmap; |
| 1457 | unsigned int bmap_nr = reiserfs_bmap_count(sb); | 1457 | unsigned int bmap_nr = reiserfs_bmap_count(sb); |
| 1458 | 1458 | ||
| 1459 | bitmap = vmalloc(sizeof(*bitmap) * bmap_nr); | 1459 | bitmap = vmalloc(array_size(bmap_nr, sizeof(*bitmap))); |
| 1460 | if (bitmap == NULL) | 1460 | if (bitmap == NULL) |
| 1461 | return -ENOMEM; | 1461 | return -ENOMEM; |
| 1462 | 1462 | ||
diff --git a/fs/reiserfs/inode.c b/fs/reiserfs/inode.c index b13fc024d2ee..132ec4406ed0 100644 --- a/fs/reiserfs/inode.c +++ b/fs/reiserfs/inode.c | |||
| @@ -1044,7 +1044,8 @@ research: | |||
| 1044 | if (blocks_needed == 1) { | 1044 | if (blocks_needed == 1) { |
| 1045 | un = &unf_single; | 1045 | un = &unf_single; |
| 1046 | } else { | 1046 | } else { |
| 1047 | un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_NOFS); | 1047 | un = kcalloc(min(blocks_needed, max_to_insert), |
| 1048 | UNFM_P_SIZE, GFP_NOFS); | ||
| 1048 | if (!un) { | 1049 | if (!un) { |
| 1049 | un = &unf_single; | 1050 | un = &unf_single; |
| 1050 | blocks_needed = 1; | 1051 | blocks_needed = 1; |
diff --git a/fs/reiserfs/journal.c b/fs/reiserfs/journal.c index 23148c3ed675..52eb5d293a34 100644 --- a/fs/reiserfs/journal.c +++ b/fs/reiserfs/journal.c | |||
| @@ -350,7 +350,8 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes) | |||
| 350 | if (num_cnodes <= 0) { | 350 | if (num_cnodes <= 0) { |
| 351 | return NULL; | 351 | return NULL; |
| 352 | } | 352 | } |
| 353 | head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode)); | 353 | head = vzalloc(array_size(num_cnodes, |
| 354 | sizeof(struct reiserfs_journal_cnode))); | ||
| 354 | if (!head) { | 355 | if (!head) { |
| 355 | return NULL; | 356 | return NULL; |
| 356 | } | 357 | } |
| @@ -2192,10 +2193,12 @@ static int journal_read_transaction(struct super_block *sb, | |||
| 2192 | * now we know we've got a good transaction, and it was | 2193 | * now we know we've got a good transaction, and it was |
| 2193 | * inside the valid time ranges | 2194 | * inside the valid time ranges |
| 2194 | */ | 2195 | */ |
| 2195 | log_blocks = kmalloc(get_desc_trans_len(desc) * | 2196 | log_blocks = kmalloc_array(get_desc_trans_len(desc), |
| 2196 | sizeof(struct buffer_head *), GFP_NOFS); | 2197 | sizeof(struct buffer_head *), |
| 2197 | real_blocks = kmalloc(get_desc_trans_len(desc) * | 2198 | GFP_NOFS); |
| 2198 | sizeof(struct buffer_head *), GFP_NOFS); | 2199 | real_blocks = kmalloc_array(get_desc_trans_len(desc), |
| 2200 | sizeof(struct buffer_head *), | ||
| 2201 | GFP_NOFS); | ||
| 2199 | if (!log_blocks || !real_blocks) { | 2202 | if (!log_blocks || !real_blocks) { |
| 2200 | brelse(c_bh); | 2203 | brelse(c_bh); |
| 2201 | brelse(d_bh); | 2204 | brelse(d_bh); |
diff --git a/fs/reiserfs/resize.c b/fs/reiserfs/resize.c index 6052d323bc9a..8096c74c38ac 100644 --- a/fs/reiserfs/resize.c +++ b/fs/reiserfs/resize.c | |||
| @@ -120,7 +120,8 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) | |||
| 120 | * array of bitmap block pointers | 120 | * array of bitmap block pointers |
| 121 | */ | 121 | */ |
| 122 | bitmap = | 122 | bitmap = |
| 123 | vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new); | 123 | vzalloc(array_size(bmap_nr_new, |
| 124 | sizeof(struct reiserfs_bitmap_info))); | ||
| 124 | if (!bitmap) { | 125 | if (!bitmap) { |
| 125 | /* | 126 | /* |
| 126 | * Journal bitmaps are still supersized, but the | 127 | * Journal bitmaps are still supersized, but the |
diff --git a/fs/select.c b/fs/select.c index bc3cc0f98896..317891ff8165 100644 --- a/fs/select.c +++ b/fs/select.c | |||
| @@ -1236,7 +1236,7 @@ static int compat_core_sys_select(int n, compat_ulong_t __user *inp, | |||
| 1236 | size = FDS_BYTES(n); | 1236 | size = FDS_BYTES(n); |
| 1237 | bits = stack_fds; | 1237 | bits = stack_fds; |
| 1238 | if (size > sizeof(stack_fds) / 6) { | 1238 | if (size > sizeof(stack_fds) / 6) { |
| 1239 | bits = kmalloc(6 * size, GFP_KERNEL); | 1239 | bits = kmalloc_array(6, size, GFP_KERNEL); |
| 1240 | ret = -ENOMEM; | 1240 | ret = -ENOMEM; |
| 1241 | if (!bits) | 1241 | if (!bits) |
| 1242 | goto out_nofds; | 1242 | goto out_nofds; |
diff --git a/fs/splice.c b/fs/splice.c index 005d09cf3fa8..2365ab073a27 100644 --- a/fs/splice.c +++ b/fs/splice.c | |||
| @@ -259,8 +259,9 @@ int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc | |||
| 259 | if (buffers <= PIPE_DEF_BUFFERS) | 259 | if (buffers <= PIPE_DEF_BUFFERS) |
| 260 | return 0; | 260 | return 0; |
| 261 | 261 | ||
| 262 | spd->pages = kmalloc(buffers * sizeof(struct page *), GFP_KERNEL); | 262 | spd->pages = kmalloc_array(buffers, sizeof(struct page *), GFP_KERNEL); |
| 263 | spd->partial = kmalloc(buffers * sizeof(struct partial_page), GFP_KERNEL); | 263 | spd->partial = kmalloc_array(buffers, sizeof(struct partial_page), |
| 264 | GFP_KERNEL); | ||
| 264 | 265 | ||
| 265 | if (spd->pages && spd->partial) | 266 | if (spd->pages && spd->partial) |
| 266 | return 0; | 267 | return 0; |
| @@ -395,7 +396,7 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos, | |||
| 395 | 396 | ||
| 396 | vec = __vec; | 397 | vec = __vec; |
| 397 | if (nr_pages > PIPE_DEF_BUFFERS) { | 398 | if (nr_pages > PIPE_DEF_BUFFERS) { |
| 398 | vec = kmalloc(nr_pages * sizeof(struct kvec), GFP_KERNEL); | 399 | vec = kmalloc_array(nr_pages, sizeof(struct kvec), GFP_KERNEL); |
| 399 | if (unlikely(!vec)) { | 400 | if (unlikely(!vec)) { |
| 400 | res = -ENOMEM; | 401 | res = -ENOMEM; |
| 401 | goto out; | 402 | goto out; |
diff --git a/fs/ubifs/journal.c b/fs/ubifs/journal.c index da8afdfccaa6..07b4956e0425 100644 --- a/fs/ubifs/journal.c +++ b/fs/ubifs/journal.c | |||
| @@ -1282,10 +1282,11 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in | |||
| 1282 | int *new_len) | 1282 | int *new_len) |
| 1283 | { | 1283 | { |
| 1284 | void *buf; | 1284 | void *buf; |
| 1285 | int err, dlen, compr_type, out_len, old_dlen; | 1285 | int err, compr_type; |
| 1286 | u32 dlen, out_len, old_dlen; | ||
| 1286 | 1287 | ||
| 1287 | out_len = le32_to_cpu(dn->size); | 1288 | out_len = le32_to_cpu(dn->size); |
| 1288 | buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS); | 1289 | buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS); |
| 1289 | if (!buf) | 1290 | if (!buf) |
| 1290 | return -ENOMEM; | 1291 | return -ENOMEM; |
| 1291 | 1292 | ||
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c index 9a517109da0f..8e99dad18880 100644 --- a/fs/ubifs/lpt.c +++ b/fs/ubifs/lpt.c | |||
| @@ -628,11 +628,12 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, | |||
| 628 | /* Needed by 'ubifs_pack_lsave()' */ | 628 | /* Needed by 'ubifs_pack_lsave()' */ |
| 629 | c->main_first = c->leb_cnt - *main_lebs; | 629 | c->main_first = c->leb_cnt - *main_lebs; |
| 630 | 630 | ||
| 631 | lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_KERNEL); | 631 | lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL); |
| 632 | pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL); | 632 | pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL); |
| 633 | nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL); | 633 | nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL); |
| 634 | buf = vmalloc(c->leb_size); | 634 | buf = vmalloc(c->leb_size); |
| 635 | ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); | 635 | ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops), |
| 636 | c->lpt_lebs)); | ||
| 636 | if (!pnode || !nnode || !buf || !ltab || !lsave) { | 637 | if (!pnode || !nnode || !buf || !ltab || !lsave) { |
| 637 | err = -ENOMEM; | 638 | err = -ENOMEM; |
| 638 | goto out; | 639 | goto out; |
| @@ -1626,7 +1627,8 @@ static int lpt_init_rd(struct ubifs_info *c) | |||
| 1626 | { | 1627 | { |
| 1627 | int err, i; | 1628 | int err, i; |
| 1628 | 1629 | ||
| 1629 | c->ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); | 1630 | c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops), |
| 1631 | c->lpt_lebs)); | ||
| 1630 | if (!c->ltab) | 1632 | if (!c->ltab) |
| 1631 | return -ENOMEM; | 1633 | return -ENOMEM; |
| 1632 | 1634 | ||
| @@ -1636,15 +1638,17 @@ static int lpt_init_rd(struct ubifs_info *c) | |||
| 1636 | return -ENOMEM; | 1638 | return -ENOMEM; |
| 1637 | 1639 | ||
| 1638 | for (i = 0; i < LPROPS_HEAP_CNT; i++) { | 1640 | for (i = 0; i < LPROPS_HEAP_CNT; i++) { |
| 1639 | c->lpt_heap[i].arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ, | 1641 | c->lpt_heap[i].arr = kmalloc_array(LPT_HEAP_SZ, |
| 1640 | GFP_KERNEL); | 1642 | sizeof(void *), |
| 1643 | GFP_KERNEL); | ||
| 1641 | if (!c->lpt_heap[i].arr) | 1644 | if (!c->lpt_heap[i].arr) |
| 1642 | return -ENOMEM; | 1645 | return -ENOMEM; |
| 1643 | c->lpt_heap[i].cnt = 0; | 1646 | c->lpt_heap[i].cnt = 0; |
| 1644 | c->lpt_heap[i].max_cnt = LPT_HEAP_SZ; | 1647 | c->lpt_heap[i].max_cnt = LPT_HEAP_SZ; |
| 1645 | } | 1648 | } |
| 1646 | 1649 | ||
| 1647 | c->dirty_idx.arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ, GFP_KERNEL); | 1650 | c->dirty_idx.arr = kmalloc_array(LPT_HEAP_SZ, sizeof(void *), |
| 1651 | GFP_KERNEL); | ||
| 1648 | if (!c->dirty_idx.arr) | 1652 | if (!c->dirty_idx.arr) |
| 1649 | return -ENOMEM; | 1653 | return -ENOMEM; |
| 1650 | c->dirty_idx.cnt = 0; | 1654 | c->dirty_idx.cnt = 0; |
| @@ -1688,7 +1692,8 @@ static int lpt_init_wr(struct ubifs_info *c) | |||
| 1688 | { | 1692 | { |
| 1689 | int err, i; | 1693 | int err, i; |
| 1690 | 1694 | ||
| 1691 | c->ltab_cmt = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); | 1695 | c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops), |
| 1696 | c->lpt_lebs)); | ||
| 1692 | if (!c->ltab_cmt) | 1697 | if (!c->ltab_cmt) |
| 1693 | return -ENOMEM; | 1698 | return -ENOMEM; |
| 1694 | 1699 | ||
| @@ -1697,7 +1702,7 @@ static int lpt_init_wr(struct ubifs_info *c) | |||
| 1697 | return -ENOMEM; | 1702 | return -ENOMEM; |
| 1698 | 1703 | ||
| 1699 | if (c->big_lpt) { | 1704 | if (c->big_lpt) { |
| 1700 | c->lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_NOFS); | 1705 | c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS); |
| 1701 | if (!c->lsave) | 1706 | if (!c->lsave) |
| 1702 | return -ENOMEM; | 1707 | return -ENOMEM; |
| 1703 | err = read_lsave(c); | 1708 | err = read_lsave(c); |
| @@ -1939,8 +1944,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum, | |||
| 1939 | return err; | 1944 | return err; |
| 1940 | } | 1945 | } |
| 1941 | 1946 | ||
| 1942 | path = kmalloc(sizeof(struct lpt_scan_node) * (c->lpt_hght + 1), | 1947 | path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node), |
| 1943 | GFP_NOFS); | 1948 | GFP_NOFS); |
| 1944 | if (!path) | 1949 | if (!path) |
| 1945 | return -ENOMEM; | 1950 | return -ENOMEM; |
| 1946 | 1951 | ||
diff --git a/fs/ubifs/super.c b/fs/ubifs/super.c index 6c397a389105..c5466c70d620 100644 --- a/fs/ubifs/super.c +++ b/fs/ubifs/super.c | |||
| @@ -1196,7 +1196,8 @@ static int mount_ubifs(struct ubifs_info *c) | |||
| 1196 | * never exceed 64. | 1196 | * never exceed 64. |
| 1197 | */ | 1197 | */ |
| 1198 | err = -ENOMEM; | 1198 | err = -ENOMEM; |
| 1199 | c->bottom_up_buf = kmalloc(BOTTOM_UP_HEIGHT * sizeof(int), GFP_KERNEL); | 1199 | c->bottom_up_buf = kmalloc_array(BOTTOM_UP_HEIGHT, sizeof(int), |
| 1200 | GFP_KERNEL); | ||
| 1200 | if (!c->bottom_up_buf) | 1201 | if (!c->bottom_up_buf) |
| 1201 | goto out_free; | 1202 | goto out_free; |
| 1202 | 1203 | ||
diff --git a/fs/ubifs/tnc.c b/fs/ubifs/tnc.c index ba3d0e0f8615..4a21e7f75e7a 100644 --- a/fs/ubifs/tnc.c +++ b/fs/ubifs/tnc.c | |||
| @@ -1104,8 +1104,9 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, | |||
| 1104 | ubifs_assert(znode); | 1104 | ubifs_assert(znode); |
| 1105 | if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) { | 1105 | if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) { |
| 1106 | kfree(c->bottom_up_buf); | 1106 | kfree(c->bottom_up_buf); |
| 1107 | c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int), | 1107 | c->bottom_up_buf = kmalloc_array(c->zroot.znode->level, |
| 1108 | GFP_NOFS); | 1108 | sizeof(int), |
| 1109 | GFP_NOFS); | ||
| 1109 | if (!c->bottom_up_buf) | 1110 | if (!c->bottom_up_buf) |
| 1110 | return ERR_PTR(-ENOMEM); | 1111 | return ERR_PTR(-ENOMEM); |
| 1111 | path = c->bottom_up_buf; | 1112 | path = c->bottom_up_buf; |
diff --git a/fs/ubifs/tnc_commit.c b/fs/ubifs/tnc_commit.c index aa31f60220ef..a9df94ad46a3 100644 --- a/fs/ubifs/tnc_commit.c +++ b/fs/ubifs/tnc_commit.c | |||
| @@ -366,7 +366,8 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) | |||
| 366 | 366 | ||
| 367 | dbg_gc("%d znodes to write", cnt); | 367 | dbg_gc("%d znodes to write", cnt); |
| 368 | 368 | ||
| 369 | c->gap_lebs = kmalloc(sizeof(int) * (c->lst.idx_lebs + 1), GFP_NOFS); | 369 | c->gap_lebs = kmalloc_array(c->lst.idx_lebs + 1, sizeof(int), |
| 370 | GFP_NOFS); | ||
| 370 | if (!c->gap_lebs) | 371 | if (!c->gap_lebs) |
| 371 | return -ENOMEM; | 372 | return -ENOMEM; |
| 372 | 373 | ||
| @@ -674,7 +675,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt) | |||
| 674 | dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt); | 675 | dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt); |
| 675 | if (!leb_cnt) | 676 | if (!leb_cnt) |
| 676 | return 0; | 677 | return 0; |
| 677 | c->ilebs = kmalloc(leb_cnt * sizeof(int), GFP_NOFS); | 678 | c->ilebs = kmalloc_array(leb_cnt, sizeof(int), GFP_NOFS); |
| 678 | if (!c->ilebs) | 679 | if (!c->ilebs) |
| 679 | return -ENOMEM; | 680 | return -ENOMEM; |
| 680 | for (i = 0; i < leb_cnt; i++) { | 681 | for (i = 0; i < leb_cnt; i++) { |
diff --git a/fs/udf/super.c b/fs/udf/super.c index 0d27d41f5c6e..fc77ea736da7 100644 --- a/fs/udf/super.c +++ b/fs/udf/super.c | |||
| @@ -1585,7 +1585,7 @@ static struct udf_vds_record *handle_partition_descriptor( | |||
| 1585 | struct udf_vds_record *new_loc; | 1585 | struct udf_vds_record *new_loc; |
| 1586 | unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP); | 1586 | unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP); |
| 1587 | 1587 | ||
| 1588 | new_loc = kzalloc(sizeof(*new_loc) * new_size, GFP_KERNEL); | 1588 | new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL); |
| 1589 | if (!new_loc) | 1589 | if (!new_loc) |
| 1590 | return ERR_PTR(-ENOMEM); | 1590 | return ERR_PTR(-ENOMEM); |
| 1591 | memcpy(new_loc, data->part_descs_loc, | 1591 | memcpy(new_loc, data->part_descs_loc, |
| @@ -1644,8 +1644,9 @@ static noinline int udf_process_sequence( | |||
| 1644 | 1644 | ||
| 1645 | memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); | 1645 | memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH); |
| 1646 | data.size_part_descs = PART_DESC_ALLOC_STEP; | 1646 | data.size_part_descs = PART_DESC_ALLOC_STEP; |
| 1647 | data.part_descs_loc = kzalloc(sizeof(*data.part_descs_loc) * | 1647 | data.part_descs_loc = kcalloc(data.size_part_descs, |
| 1648 | data.size_part_descs, GFP_KERNEL); | 1648 | sizeof(*data.part_descs_loc), |
| 1649 | GFP_KERNEL); | ||
| 1649 | if (!data.part_descs_loc) | 1650 | if (!data.part_descs_loc) |
| 1650 | return -ENOMEM; | 1651 | return -ENOMEM; |
| 1651 | 1652 | ||
diff --git a/fs/ufs/super.c b/fs/ufs/super.c index 8254b8b3690f..488088141451 100644 --- a/fs/ufs/super.c +++ b/fs/ufs/super.c | |||
| @@ -541,7 +541,9 @@ static int ufs_read_cylinder_structures(struct super_block *sb) | |||
| 541 | * Read cylinder group (we read only first fragment from block | 541 | * Read cylinder group (we read only first fragment from block |
| 542 | * at this time) and prepare internal data structures for cg caching. | 542 | * at this time) and prepare internal data structures for cg caching. |
| 543 | */ | 543 | */ |
| 544 | if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_NOFS))) | 544 | sbi->s_ucg = kmalloc_array(uspi->s_ncg, sizeof(struct buffer_head *), |
| 545 | GFP_NOFS); | ||
| 546 | if (!sbi->s_ucg) | ||
| 545 | goto failed; | 547 | goto failed; |
| 546 | for (i = 0; i < uspi->s_ncg; i++) | 548 | for (i = 0; i < uspi->s_ncg; i++) |
| 547 | sbi->s_ucg[i] = NULL; | 549 | sbi->s_ucg[i] = NULL; |
diff --git a/include/linux/mm.h b/include/linux/mm.h index 0e493884e6e1..a0fbb9ffe380 100644 --- a/include/linux/mm.h +++ b/include/linux/mm.h | |||
| @@ -575,6 +575,11 @@ static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags) | |||
| 575 | return kvmalloc(bytes, flags); | 575 | return kvmalloc(bytes, flags); |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | static inline void *kvcalloc(size_t n, size_t size, gfp_t flags) | ||
| 579 | { | ||
| 580 | return kvmalloc_array(n, size, flags | __GFP_ZERO); | ||
| 581 | } | ||
| 582 | |||
| 578 | extern void kvfree(const void *addr); | 583 | extern void kvfree(const void *addr); |
| 579 | 584 | ||
| 580 | static inline atomic_t *compound_mapcount_ptr(struct page *page) | 585 | static inline atomic_t *compound_mapcount_ptr(struct page *page) |
diff --git a/include/rdma/ib_verbs.h b/include/rdma/ib_verbs.h index 2043e1a8f851..4c6241bc2039 100644 --- a/include/rdma/ib_verbs.h +++ b/include/rdma/ib_verbs.h | |||
| @@ -2093,10 +2093,7 @@ struct ib_flow_attr { | |||
| 2093 | u32 flags; | 2093 | u32 flags; |
| 2094 | u8 num_of_specs; | 2094 | u8 num_of_specs; |
| 2095 | u8 port; | 2095 | u8 port; |
| 2096 | /* Following are the optional layers according to user request | 2096 | union ib_flow_spec flows[]; |
| 2097 | * struct ib_flow_spec_xxx | ||
| 2098 | * struct ib_flow_spec_yyy | ||
| 2099 | */ | ||
| 2100 | }; | 2097 | }; |
| 2101 | 2098 | ||
| 2102 | struct ib_flow { | 2099 | struct ib_flow { |
| @@ -1945,7 +1945,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, | |||
| 1945 | if (nsops > ns->sc_semopm) | 1945 | if (nsops > ns->sc_semopm) |
| 1946 | return -E2BIG; | 1946 | return -E2BIG; |
| 1947 | if (nsops > SEMOPM_FAST) { | 1947 | if (nsops > SEMOPM_FAST) { |
| 1948 | sops = kvmalloc(sizeof(*sops)*nsops, GFP_KERNEL); | 1948 | sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL); |
| 1949 | if (sops == NULL) | 1949 | if (sops == NULL) |
| 1950 | return -ENOMEM; | 1950 | return -ENOMEM; |
| 1951 | } | 1951 | } |
diff --git a/kernel/bpf/btf.c b/kernel/bpf/btf.c index 8653ab004c73..2d49d18b793a 100644 --- a/kernel/bpf/btf.c +++ b/kernel/bpf/btf.c | |||
| @@ -608,7 +608,7 @@ static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t) | |||
| 608 | new_size = min_t(u32, BTF_MAX_TYPE, | 608 | new_size = min_t(u32, BTF_MAX_TYPE, |
| 609 | btf->types_size + expand_by); | 609 | btf->types_size + expand_by); |
| 610 | 610 | ||
| 611 | new_types = kvzalloc(new_size * sizeof(*new_types), | 611 | new_types = kvcalloc(new_size, sizeof(*new_types), |
| 612 | GFP_KERNEL | __GFP_NOWARN); | 612 | GFP_KERNEL | __GFP_NOWARN); |
| 613 | if (!new_types) | 613 | if (!new_types) |
| 614 | return -ENOMEM; | 614 | return -ENOMEM; |
| @@ -698,17 +698,17 @@ static int env_resolve_init(struct btf_verifier_env *env) | |||
| 698 | u8 *visit_states = NULL; | 698 | u8 *visit_states = NULL; |
| 699 | 699 | ||
| 700 | /* +1 for btf_void */ | 700 | /* +1 for btf_void */ |
| 701 | resolved_sizes = kvzalloc((nr_types + 1) * sizeof(*resolved_sizes), | 701 | resolved_sizes = kvcalloc(nr_types + 1, sizeof(*resolved_sizes), |
| 702 | GFP_KERNEL | __GFP_NOWARN); | 702 | GFP_KERNEL | __GFP_NOWARN); |
| 703 | if (!resolved_sizes) | 703 | if (!resolved_sizes) |
| 704 | goto nomem; | 704 | goto nomem; |
| 705 | 705 | ||
| 706 | resolved_ids = kvzalloc((nr_types + 1) * sizeof(*resolved_ids), | 706 | resolved_ids = kvcalloc(nr_types + 1, sizeof(*resolved_ids), |
| 707 | GFP_KERNEL | __GFP_NOWARN); | 707 | GFP_KERNEL | __GFP_NOWARN); |
| 708 | if (!resolved_ids) | 708 | if (!resolved_ids) |
| 709 | goto nomem; | 709 | goto nomem; |
| 710 | 710 | ||
| 711 | visit_states = kvzalloc((nr_types + 1) * sizeof(*visit_states), | 711 | visit_states = kvcalloc(nr_types + 1, sizeof(*visit_states), |
| 712 | GFP_KERNEL | __GFP_NOWARN); | 712 | GFP_KERNEL | __GFP_NOWARN); |
| 713 | if (!visit_states) | 713 | if (!visit_states) |
| 714 | goto nomem; | 714 | goto nomem; |
diff --git a/kernel/bpf/lpm_trie.c b/kernel/bpf/lpm_trie.c index b4b5b81e7251..1603492c9cc7 100644 --- a/kernel/bpf/lpm_trie.c +++ b/kernel/bpf/lpm_trie.c | |||
| @@ -623,8 +623,9 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) | |||
| 623 | if (!key || key->prefixlen > trie->max_prefixlen) | 623 | if (!key || key->prefixlen > trie->max_prefixlen) |
| 624 | goto find_leftmost; | 624 | goto find_leftmost; |
| 625 | 625 | ||
| 626 | node_stack = kmalloc(trie->max_prefixlen * sizeof(struct lpm_trie_node *), | 626 | node_stack = kmalloc_array(trie->max_prefixlen, |
| 627 | GFP_ATOMIC | __GFP_NOWARN); | 627 | sizeof(struct lpm_trie_node *), |
| 628 | GFP_ATOMIC | __GFP_NOWARN); | ||
| 628 | if (!node_stack) | 629 | if (!node_stack) |
| 629 | return -ENOMEM; | 630 | return -ENOMEM; |
| 630 | 631 | ||
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c index cced0c1e63e2..9e2bf834f13a 100644 --- a/kernel/bpf/verifier.c +++ b/kernel/bpf/verifier.c | |||
| @@ -5206,7 +5206,8 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, u32 prog_len, | |||
| 5206 | 5206 | ||
| 5207 | if (cnt == 1) | 5207 | if (cnt == 1) |
| 5208 | return 0; | 5208 | return 0; |
| 5209 | new_data = vzalloc(sizeof(struct bpf_insn_aux_data) * prog_len); | 5209 | new_data = vzalloc(array_size(prog_len, |
| 5210 | sizeof(struct bpf_insn_aux_data))); | ||
| 5210 | if (!new_data) | 5211 | if (!new_data) |
| 5211 | return -ENOMEM; | 5212 | return -ENOMEM; |
| 5212 | memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off); | 5213 | memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off); |
| @@ -5447,7 +5448,7 @@ static int jit_subprogs(struct bpf_verifier_env *env) | |||
| 5447 | insn->imm = 1; | 5448 | insn->imm = 1; |
| 5448 | } | 5449 | } |
| 5449 | 5450 | ||
| 5450 | func = kzalloc(sizeof(prog) * env->subprog_cnt, GFP_KERNEL); | 5451 | func = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL); |
| 5451 | if (!func) | 5452 | if (!func) |
| 5452 | return -ENOMEM; | 5453 | return -ENOMEM; |
| 5453 | 5454 | ||
| @@ -5870,8 +5871,9 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr) | |||
| 5870 | return -ENOMEM; | 5871 | return -ENOMEM; |
| 5871 | log = &env->log; | 5872 | log = &env->log; |
| 5872 | 5873 | ||
| 5873 | env->insn_aux_data = vzalloc(sizeof(struct bpf_insn_aux_data) * | 5874 | env->insn_aux_data = |
| 5874 | (*prog)->len); | 5875 | vzalloc(array_size(sizeof(struct bpf_insn_aux_data), |
| 5876 | (*prog)->len)); | ||
| 5875 | ret = -ENOMEM; | 5877 | ret = -ENOMEM; |
| 5876 | if (!env->insn_aux_data) | 5878 | if (!env->insn_aux_data) |
| 5877 | goto err_free_env; | 5879 | goto err_free_env; |
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c index e06c97f3ed1a..8b4f0768efd6 100644 --- a/kernel/cgroup/cgroup-v1.c +++ b/kernel/cgroup/cgroup-v1.c | |||
| @@ -195,9 +195,9 @@ struct cgroup_pidlist { | |||
| 195 | static void *pidlist_allocate(int count) | 195 | static void *pidlist_allocate(int count) |
| 196 | { | 196 | { |
| 197 | if (PIDLIST_TOO_LARGE(count)) | 197 | if (PIDLIST_TOO_LARGE(count)) |
| 198 | return vmalloc(count * sizeof(pid_t)); | 198 | return vmalloc(array_size(count, sizeof(pid_t))); |
| 199 | else | 199 | else |
| 200 | return kmalloc(count * sizeof(pid_t), GFP_KERNEL); | 200 | return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL); |
| 201 | } | 201 | } |
| 202 | 202 | ||
| 203 | static void pidlist_free(void *p) | 203 | static void pidlist_free(void *p) |
diff --git a/kernel/cgroup/cpuset.c b/kernel/cgroup/cpuset.c index b42037e6e81d..d8b12e0d39cd 100644 --- a/kernel/cgroup/cpuset.c +++ b/kernel/cgroup/cpuset.c | |||
| @@ -683,7 +683,7 @@ static int generate_sched_domains(cpumask_var_t **domains, | |||
| 683 | goto done; | 683 | goto done; |
| 684 | } | 684 | } |
| 685 | 685 | ||
| 686 | csa = kmalloc(nr_cpusets() * sizeof(cp), GFP_KERNEL); | 686 | csa = kmalloc_array(nr_cpusets(), sizeof(cp), GFP_KERNEL); |
| 687 | if (!csa) | 687 | if (!csa) |
| 688 | goto done; | 688 | goto done; |
| 689 | csn = 0; | 689 | csn = 0; |
| @@ -753,7 +753,8 @@ restart: | |||
| 753 | * The rest of the code, including the scheduler, can deal with | 753 | * The rest of the code, including the scheduler, can deal with |
| 754 | * dattr==NULL case. No need to abort if alloc fails. | 754 | * dattr==NULL case. No need to abort if alloc fails. |
| 755 | */ | 755 | */ |
| 756 | dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL); | 756 | dattr = kmalloc_array(ndoms, sizeof(struct sched_domain_attr), |
| 757 | GFP_KERNEL); | ||
| 757 | 758 | ||
| 758 | for (nslot = 0, i = 0; i < csn; i++) { | 759 | for (nslot = 0, i = 0; i < csn; i++) { |
| 759 | struct cpuset *a = csa[i]; | 760 | struct cpuset *a = csa[i]; |
diff --git a/kernel/debug/kdb/kdb_main.c b/kernel/debug/kdb/kdb_main.c index e405677ee08d..2ddfce8f1e8f 100644 --- a/kernel/debug/kdb/kdb_main.c +++ b/kernel/debug/kdb/kdb_main.c | |||
| @@ -691,7 +691,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0) | |||
| 691 | } | 691 | } |
| 692 | if (!s->usable) | 692 | if (!s->usable) |
| 693 | return KDB_NOTIMP; | 693 | return KDB_NOTIMP; |
| 694 | s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB); | 694 | s->command = kcalloc(s->count + 1, sizeof(*(s->command)), GFP_KDB); |
| 695 | if (!s->command) { | 695 | if (!s->command) { |
| 696 | kdb_printf("Could not allocate new kdb_defcmd table for %s\n", | 696 | kdb_printf("Could not allocate new kdb_defcmd table for %s\n", |
| 697 | cmdstr); | 697 | cmdstr); |
| @@ -729,8 +729,8 @@ static int kdb_defcmd(int argc, const char **argv) | |||
| 729 | kdb_printf("Command only available during kdb_init()\n"); | 729 | kdb_printf("Command only available during kdb_init()\n"); |
| 730 | return KDB_NOTIMP; | 730 | return KDB_NOTIMP; |
| 731 | } | 731 | } |
| 732 | defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set), | 732 | defcmd_set = kmalloc_array(defcmd_set_count + 1, sizeof(*defcmd_set), |
| 733 | GFP_KDB); | 733 | GFP_KDB); |
| 734 | if (!defcmd_set) | 734 | if (!defcmd_set) |
| 735 | goto fail_defcmd; | 735 | goto fail_defcmd; |
| 736 | memcpy(defcmd_set, save_defcmd_set, | 736 | memcpy(defcmd_set, save_defcmd_set, |
| @@ -2706,8 +2706,11 @@ int kdb_register_flags(char *cmd, | |||
| 2706 | } | 2706 | } |
| 2707 | 2707 | ||
| 2708 | if (i >= kdb_max_commands) { | 2708 | if (i >= kdb_max_commands) { |
| 2709 | kdbtab_t *new = kmalloc((kdb_max_commands - KDB_BASE_CMD_MAX + | 2709 | kdbtab_t *new = kmalloc_array(kdb_max_commands - |
| 2710 | kdb_command_extend) * sizeof(*new), GFP_KDB); | 2710 | KDB_BASE_CMD_MAX + |
| 2711 | kdb_command_extend, | ||
| 2712 | sizeof(*new), | ||
| 2713 | GFP_KDB); | ||
| 2711 | if (!new) { | 2714 | if (!new) { |
| 2712 | kdb_printf("Could not allocate new kdb_command " | 2715 | kdb_printf("Could not allocate new kdb_command " |
| 2713 | "table\n"); | 2716 | "table\n"); |
diff --git a/kernel/events/ring_buffer.c b/kernel/events/ring_buffer.c index 1d8ca9ea9979..045a37e9ddee 100644 --- a/kernel/events/ring_buffer.c +++ b/kernel/events/ring_buffer.c | |||
| @@ -614,7 +614,8 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, | |||
| 614 | } | 614 | } |
| 615 | } | 615 | } |
| 616 | 616 | ||
| 617 | rb->aux_pages = kzalloc_node(nr_pages * sizeof(void *), GFP_KERNEL, node); | 617 | rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL, |
| 618 | node); | ||
| 618 | if (!rb->aux_pages) | 619 | if (!rb->aux_pages) |
| 619 | return -ENOMEM; | 620 | return -ENOMEM; |
| 620 | 621 | ||
diff --git a/kernel/events/uprobes.c b/kernel/events/uprobes.c index 1725b902983f..ccc579a7d32e 100644 --- a/kernel/events/uprobes.c +++ b/kernel/events/uprobes.c | |||
| @@ -1184,7 +1184,8 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) | |||
| 1184 | if (unlikely(!area)) | 1184 | if (unlikely(!area)) |
| 1185 | goto out; | 1185 | goto out; |
| 1186 | 1186 | ||
| 1187 | area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long), GFP_KERNEL); | 1187 | area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long), |
| 1188 | GFP_KERNEL); | ||
| 1188 | if (!area->bitmap) | 1189 | if (!area->bitmap) |
| 1189 | goto free_area; | 1190 | goto free_area; |
| 1190 | 1191 | ||
diff --git a/kernel/fail_function.c b/kernel/fail_function.c index 1d5632d8bbcc..5349c91c2298 100644 --- a/kernel/fail_function.c +++ b/kernel/fail_function.c | |||
| @@ -258,7 +258,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer, | |||
| 258 | /* cut off if it is too long */ | 258 | /* cut off if it is too long */ |
| 259 | if (count > KSYM_NAME_LEN) | 259 | if (count > KSYM_NAME_LEN) |
| 260 | count = KSYM_NAME_LEN; | 260 | count = KSYM_NAME_LEN; |
| 261 | buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL); | 261 | buf = kmalloc(count + 1, GFP_KERNEL); |
| 262 | if (!buf) | 262 | if (!buf) |
| 263 | return -ENOMEM; | 263 | return -ENOMEM; |
| 264 | 264 | ||
diff --git a/kernel/kexec_file.c b/kernel/kexec_file.c index 75d8e7cf040e..c6a3b6851372 100644 --- a/kernel/kexec_file.c +++ b/kernel/kexec_file.c | |||
| @@ -793,7 +793,7 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi, | |||
| 793 | * The section headers in kexec_purgatory are read-only. In order to | 793 | * The section headers in kexec_purgatory are read-only. In order to |
| 794 | * have them modifiable make a temporary copy. | 794 | * have them modifiable make a temporary copy. |
| 795 | */ | 795 | */ |
| 796 | sechdrs = vzalloc(pi->ehdr->e_shnum * sizeof(Elf_Shdr)); | 796 | sechdrs = vzalloc(array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum)); |
| 797 | if (!sechdrs) | 797 | if (!sechdrs) |
| 798 | return -ENOMEM; | 798 | return -ENOMEM; |
| 799 | memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff, | 799 | memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff, |
diff --git a/kernel/locking/locktorture.c b/kernel/locking/locktorture.c index 6850ffd69125..8402b3349dca 100644 --- a/kernel/locking/locktorture.c +++ b/kernel/locking/locktorture.c | |||
| @@ -913,7 +913,9 @@ static int __init lock_torture_init(void) | |||
| 913 | /* Initialize the statistics so that each run gets its own numbers. */ | 913 | /* Initialize the statistics so that each run gets its own numbers. */ |
| 914 | if (nwriters_stress) { | 914 | if (nwriters_stress) { |
| 915 | lock_is_write_held = 0; | 915 | lock_is_write_held = 0; |
| 916 | cxt.lwsa = kmalloc(sizeof(*cxt.lwsa) * cxt.nrealwriters_stress, GFP_KERNEL); | 916 | cxt.lwsa = kmalloc_array(cxt.nrealwriters_stress, |
| 917 | sizeof(*cxt.lwsa), | ||
| 918 | GFP_KERNEL); | ||
| 917 | if (cxt.lwsa == NULL) { | 919 | if (cxt.lwsa == NULL) { |
| 918 | VERBOSE_TOROUT_STRING("cxt.lwsa: Out of memory"); | 920 | VERBOSE_TOROUT_STRING("cxt.lwsa: Out of memory"); |
| 919 | firsterr = -ENOMEM; | 921 | firsterr = -ENOMEM; |
| @@ -942,7 +944,9 @@ static int __init lock_torture_init(void) | |||
| 942 | 944 | ||
| 943 | if (nreaders_stress) { | 945 | if (nreaders_stress) { |
| 944 | lock_is_read_held = 0; | 946 | lock_is_read_held = 0; |
| 945 | cxt.lrsa = kmalloc(sizeof(*cxt.lrsa) * cxt.nrealreaders_stress, GFP_KERNEL); | 947 | cxt.lrsa = kmalloc_array(cxt.nrealreaders_stress, |
| 948 | sizeof(*cxt.lrsa), | ||
| 949 | GFP_KERNEL); | ||
| 946 | if (cxt.lrsa == NULL) { | 950 | if (cxt.lrsa == NULL) { |
| 947 | VERBOSE_TOROUT_STRING("cxt.lrsa: Out of memory"); | 951 | VERBOSE_TOROUT_STRING("cxt.lrsa: Out of memory"); |
| 948 | firsterr = -ENOMEM; | 952 | firsterr = -ENOMEM; |
| @@ -985,7 +989,8 @@ static int __init lock_torture_init(void) | |||
| 985 | } | 989 | } |
| 986 | 990 | ||
| 987 | if (nwriters_stress) { | 991 | if (nwriters_stress) { |
| 988 | writer_tasks = kzalloc(cxt.nrealwriters_stress * sizeof(writer_tasks[0]), | 992 | writer_tasks = kcalloc(cxt.nrealwriters_stress, |
| 993 | sizeof(writer_tasks[0]), | ||
| 989 | GFP_KERNEL); | 994 | GFP_KERNEL); |
| 990 | if (writer_tasks == NULL) { | 995 | if (writer_tasks == NULL) { |
| 991 | VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory"); | 996 | VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory"); |
| @@ -995,7 +1000,8 @@ static int __init lock_torture_init(void) | |||
| 995 | } | 1000 | } |
| 996 | 1001 | ||
| 997 | if (cxt.cur_ops->readlock) { | 1002 | if (cxt.cur_ops->readlock) { |
| 998 | reader_tasks = kzalloc(cxt.nrealreaders_stress * sizeof(reader_tasks[0]), | 1003 | reader_tasks = kcalloc(cxt.nrealreaders_stress, |
| 1004 | sizeof(reader_tasks[0]), | ||
| 999 | GFP_KERNEL); | 1005 | GFP_KERNEL); |
| 1000 | if (reader_tasks == NULL) { | 1006 | if (reader_tasks == NULL) { |
| 1001 | VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory"); | 1007 | VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory"); |
diff --git a/kernel/power/swap.c b/kernel/power/swap.c index 1efcb5b0c3ed..c2bcf97d24c8 100644 --- a/kernel/power/swap.c +++ b/kernel/power/swap.c | |||
| @@ -698,7 +698,7 @@ static int save_image_lzo(struct swap_map_handle *handle, | |||
| 698 | goto out_clean; | 698 | goto out_clean; |
| 699 | } | 699 | } |
| 700 | 700 | ||
| 701 | data = vmalloc(sizeof(*data) * nr_threads); | 701 | data = vmalloc(array_size(nr_threads, sizeof(*data))); |
| 702 | if (!data) { | 702 | if (!data) { |
| 703 | pr_err("Failed to allocate LZO data\n"); | 703 | pr_err("Failed to allocate LZO data\n"); |
| 704 | ret = -ENOMEM; | 704 | ret = -ENOMEM; |
| @@ -1183,14 +1183,14 @@ static int load_image_lzo(struct swap_map_handle *handle, | |||
| 1183 | nr_threads = num_online_cpus() - 1; | 1183 | nr_threads = num_online_cpus() - 1; |
| 1184 | nr_threads = clamp_val(nr_threads, 1, LZO_THREADS); | 1184 | nr_threads = clamp_val(nr_threads, 1, LZO_THREADS); |
| 1185 | 1185 | ||
| 1186 | page = vmalloc(sizeof(*page) * LZO_MAX_RD_PAGES); | 1186 | page = vmalloc(array_size(LZO_MAX_RD_PAGES, sizeof(*page))); |
| 1187 | if (!page) { | 1187 | if (!page) { |
| 1188 | pr_err("Failed to allocate LZO page\n"); | 1188 | pr_err("Failed to allocate LZO page\n"); |
| 1189 | ret = -ENOMEM; | 1189 | ret = -ENOMEM; |
| 1190 | goto out_clean; | 1190 | goto out_clean; |
| 1191 | } | 1191 | } |
| 1192 | 1192 | ||
| 1193 | data = vmalloc(sizeof(*data) * nr_threads); | 1193 | data = vmalloc(array_size(nr_threads, sizeof(*data))); |
| 1194 | if (!data) { | 1194 | if (!data) { |
| 1195 | pr_err("Failed to allocate LZO data\n"); | 1195 | pr_err("Failed to allocate LZO data\n"); |
| 1196 | ret = -ENOMEM; | 1196 | ret = -ENOMEM; |
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c index e628fcfd1bde..42fcb7f05fac 100644 --- a/kernel/rcu/rcutorture.c +++ b/kernel/rcu/rcutorture.c | |||
| @@ -831,8 +831,9 @@ rcu_torture_cbflood(void *arg) | |||
| 831 | cbflood_intra_holdoff > 0 && | 831 | cbflood_intra_holdoff > 0 && |
| 832 | cur_ops->call && | 832 | cur_ops->call && |
| 833 | cur_ops->cb_barrier) { | 833 | cur_ops->cb_barrier) { |
| 834 | rhp = vmalloc(sizeof(*rhp) * | 834 | rhp = vmalloc(array3_size(cbflood_n_burst, |
| 835 | cbflood_n_burst * cbflood_n_per_burst); | 835 | cbflood_n_per_burst, |
| 836 | sizeof(*rhp))); | ||
| 836 | err = !rhp; | 837 | err = !rhp; |
| 837 | } | 838 | } |
| 838 | if (err) { | 839 | if (err) { |
diff --git a/kernel/relay.c b/kernel/relay.c index c955b10c973c..9f5326e8a036 100644 --- a/kernel/relay.c +++ b/kernel/relay.c | |||
| @@ -169,7 +169,8 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) | |||
| 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); | 169 | buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL); |
| 170 | if (!buf) | 170 | if (!buf) |
| 171 | return NULL; | 171 | return NULL; |
| 172 | buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL); | 172 | buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *), |
| 173 | GFP_KERNEL); | ||
| 173 | if (!buf->padding) | 174 | if (!buf->padding) |
| 174 | goto free_buf; | 175 | goto free_buf; |
| 175 | 176 | ||
diff --git a/kernel/sched/fair.c b/kernel/sched/fair.c index e497c05aab7f..1866e64792a7 100644 --- a/kernel/sched/fair.c +++ b/kernel/sched/fair.c | |||
| @@ -10215,10 +10215,10 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent) | |||
| 10215 | struct cfs_rq *cfs_rq; | 10215 | struct cfs_rq *cfs_rq; |
| 10216 | int i; | 10216 | int i; |
| 10217 | 10217 | ||
| 10218 | tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL); | 10218 | tg->cfs_rq = kcalloc(nr_cpu_ids, sizeof(cfs_rq), GFP_KERNEL); |
| 10219 | if (!tg->cfs_rq) | 10219 | if (!tg->cfs_rq) |
| 10220 | goto err; | 10220 | goto err; |
| 10221 | tg->se = kzalloc(sizeof(se) * nr_cpu_ids, GFP_KERNEL); | 10221 | tg->se = kcalloc(nr_cpu_ids, sizeof(se), GFP_KERNEL); |
| 10222 | if (!tg->se) | 10222 | if (!tg->se) |
| 10223 | goto err; | 10223 | goto err; |
| 10224 | 10224 | ||
diff --git a/kernel/sched/rt.c b/kernel/sched/rt.c index ef3c4e6f5345..47556b0c9a95 100644 --- a/kernel/sched/rt.c +++ b/kernel/sched/rt.c | |||
| @@ -183,10 +183,10 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) | |||
| 183 | struct sched_rt_entity *rt_se; | 183 | struct sched_rt_entity *rt_se; |
| 184 | int i; | 184 | int i; |
| 185 | 185 | ||
| 186 | tg->rt_rq = kzalloc(sizeof(rt_rq) * nr_cpu_ids, GFP_KERNEL); | 186 | tg->rt_rq = kcalloc(nr_cpu_ids, sizeof(rt_rq), GFP_KERNEL); |
| 187 | if (!tg->rt_rq) | 187 | if (!tg->rt_rq) |
| 188 | goto err; | 188 | goto err; |
| 189 | tg->rt_se = kzalloc(sizeof(rt_se) * nr_cpu_ids, GFP_KERNEL); | 189 | tg->rt_se = kcalloc(nr_cpu_ids, sizeof(rt_se), GFP_KERNEL); |
| 190 | if (!tg->rt_se) | 190 | if (!tg->rt_se) |
| 191 | goto err; | 191 | goto err; |
| 192 | 192 | ||
diff --git a/kernel/sched/topology.c b/kernel/sched/topology.c index 61a1125c1ae4..05a831427bc7 100644 --- a/kernel/sched/topology.c +++ b/kernel/sched/topology.c | |||
| @@ -1750,7 +1750,7 @@ cpumask_var_t *alloc_sched_domains(unsigned int ndoms) | |||
| 1750 | int i; | 1750 | int i; |
| 1751 | cpumask_var_t *doms; | 1751 | cpumask_var_t *doms; |
| 1752 | 1752 | ||
| 1753 | doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL); | 1753 | doms = kmalloc_array(ndoms, sizeof(*doms), GFP_KERNEL); |
| 1754 | if (!doms) | 1754 | if (!doms) |
| 1755 | return NULL; | 1755 | return NULL; |
| 1756 | for (i = 0; i < ndoms; i++) { | 1756 | for (i = 0; i < ndoms; i++) { |
diff --git a/kernel/sysctl.c b/kernel/sysctl.c index 6a78cf70761d..2d9837c0aff4 100644 --- a/kernel/sysctl.c +++ b/kernel/sysctl.c | |||
| @@ -3047,7 +3047,8 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, | |||
| 3047 | if (IS_ERR(kbuf)) | 3047 | if (IS_ERR(kbuf)) |
| 3048 | return PTR_ERR(kbuf); | 3048 | return PTR_ERR(kbuf); |
| 3049 | 3049 | ||
| 3050 | tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long), | 3050 | tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len), |
| 3051 | sizeof(unsigned long), | ||
| 3051 | GFP_KERNEL); | 3052 | GFP_KERNEL); |
| 3052 | if (!tmp_bitmap) { | 3053 | if (!tmp_bitmap) { |
| 3053 | kfree(kbuf); | 3054 | kfree(kbuf); |
diff --git a/kernel/trace/ftrace.c b/kernel/trace/ftrace.c index 8d83bcf9ef69..efed9c1cfb7e 100644 --- a/kernel/trace/ftrace.c +++ b/kernel/trace/ftrace.c | |||
| @@ -728,7 +728,7 @@ static int ftrace_profile_init_cpu(int cpu) | |||
| 728 | */ | 728 | */ |
| 729 | size = FTRACE_PROFILE_HASH_SIZE; | 729 | size = FTRACE_PROFILE_HASH_SIZE; |
| 730 | 730 | ||
| 731 | stat->hash = kzalloc(sizeof(struct hlist_head) * size, GFP_KERNEL); | 731 | stat->hash = kcalloc(size, sizeof(struct hlist_head), GFP_KERNEL); |
| 732 | 732 | ||
| 733 | if (!stat->hash) | 733 | if (!stat->hash) |
| 734 | return -ENOMEM; | 734 | return -ENOMEM; |
| @@ -6830,9 +6830,10 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) | |||
| 6830 | struct task_struct *g, *t; | 6830 | struct task_struct *g, *t; |
| 6831 | 6831 | ||
| 6832 | for (i = 0; i < FTRACE_RETSTACK_ALLOC_SIZE; i++) { | 6832 | for (i = 0; i < FTRACE_RETSTACK_ALLOC_SIZE; i++) { |
| 6833 | ret_stack_list[i] = kmalloc(FTRACE_RETFUNC_DEPTH | 6833 | ret_stack_list[i] = |
| 6834 | * sizeof(struct ftrace_ret_stack), | 6834 | kmalloc_array(FTRACE_RETFUNC_DEPTH, |
| 6835 | GFP_KERNEL); | 6835 | sizeof(struct ftrace_ret_stack), |
| 6836 | GFP_KERNEL); | ||
| 6836 | if (!ret_stack_list[i]) { | 6837 | if (!ret_stack_list[i]) { |
| 6837 | start = 0; | 6838 | start = 0; |
| 6838 | end = i; | 6839 | end = i; |
| @@ -6904,9 +6905,9 @@ static int start_graph_tracing(void) | |||
| 6904 | struct ftrace_ret_stack **ret_stack_list; | 6905 | struct ftrace_ret_stack **ret_stack_list; |
| 6905 | int ret, cpu; | 6906 | int ret, cpu; |
| 6906 | 6907 | ||
| 6907 | ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE * | 6908 | ret_stack_list = kmalloc_array(FTRACE_RETSTACK_ALLOC_SIZE, |
| 6908 | sizeof(struct ftrace_ret_stack *), | 6909 | sizeof(struct ftrace_ret_stack *), |
| 6909 | GFP_KERNEL); | 6910 | GFP_KERNEL); |
| 6910 | 6911 | ||
| 6911 | if (!ret_stack_list) | 6912 | if (!ret_stack_list) |
| 6912 | return -ENOMEM; | 6913 | return -ENOMEM; |
| @@ -7088,9 +7089,10 @@ void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) | |||
| 7088 | 7089 | ||
| 7089 | ret_stack = per_cpu(idle_ret_stack, cpu); | 7090 | ret_stack = per_cpu(idle_ret_stack, cpu); |
| 7090 | if (!ret_stack) { | 7091 | if (!ret_stack) { |
| 7091 | ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH | 7092 | ret_stack = |
| 7092 | * sizeof(struct ftrace_ret_stack), | 7093 | kmalloc_array(FTRACE_RETFUNC_DEPTH, |
| 7093 | GFP_KERNEL); | 7094 | sizeof(struct ftrace_ret_stack), |
| 7095 | GFP_KERNEL); | ||
| 7094 | if (!ret_stack) | 7096 | if (!ret_stack) |
| 7095 | return; | 7097 | return; |
| 7096 | per_cpu(idle_ret_stack, cpu) = ret_stack; | 7098 | per_cpu(idle_ret_stack, cpu) = ret_stack; |
| @@ -7109,9 +7111,9 @@ void ftrace_graph_init_task(struct task_struct *t) | |||
| 7109 | if (ftrace_graph_active) { | 7111 | if (ftrace_graph_active) { |
| 7110 | struct ftrace_ret_stack *ret_stack; | 7112 | struct ftrace_ret_stack *ret_stack; |
| 7111 | 7113 | ||
| 7112 | ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH | 7114 | ret_stack = kmalloc_array(FTRACE_RETFUNC_DEPTH, |
| 7113 | * sizeof(struct ftrace_ret_stack), | 7115 | sizeof(struct ftrace_ret_stack), |
| 7114 | GFP_KERNEL); | 7116 | GFP_KERNEL); |
| 7115 | if (!ret_stack) | 7117 | if (!ret_stack) |
| 7116 | return; | 7118 | return; |
| 7117 | graph_init_task(t, ret_stack); | 7119 | graph_init_task(t, ret_stack); |
diff --git a/kernel/trace/trace.c b/kernel/trace/trace.c index 108ce3e1dc13..c9336e98ac59 100644 --- a/kernel/trace/trace.c +++ b/kernel/trace/trace.c | |||
| @@ -1751,12 +1751,13 @@ static inline void set_cmdline(int idx, const char *cmdline) | |||
| 1751 | static int allocate_cmdlines_buffer(unsigned int val, | 1751 | static int allocate_cmdlines_buffer(unsigned int val, |
| 1752 | struct saved_cmdlines_buffer *s) | 1752 | struct saved_cmdlines_buffer *s) |
| 1753 | { | 1753 | { |
| 1754 | s->map_cmdline_to_pid = kmalloc(val * sizeof(*s->map_cmdline_to_pid), | 1754 | s->map_cmdline_to_pid = kmalloc_array(val, |
| 1755 | GFP_KERNEL); | 1755 | sizeof(*s->map_cmdline_to_pid), |
| 1756 | GFP_KERNEL); | ||
| 1756 | if (!s->map_cmdline_to_pid) | 1757 | if (!s->map_cmdline_to_pid) |
| 1757 | return -ENOMEM; | 1758 | return -ENOMEM; |
| 1758 | 1759 | ||
| 1759 | s->saved_cmdlines = kmalloc(val * TASK_COMM_LEN, GFP_KERNEL); | 1760 | s->saved_cmdlines = kmalloc_array(TASK_COMM_LEN, val, GFP_KERNEL); |
| 1760 | if (!s->saved_cmdlines) { | 1761 | if (!s->saved_cmdlines) { |
| 1761 | kfree(s->map_cmdline_to_pid); | 1762 | kfree(s->map_cmdline_to_pid); |
| 1762 | return -ENOMEM; | 1763 | return -ENOMEM; |
| @@ -4360,7 +4361,8 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled) | |||
| 4360 | 4361 | ||
| 4361 | if (mask == TRACE_ITER_RECORD_TGID) { | 4362 | if (mask == TRACE_ITER_RECORD_TGID) { |
| 4362 | if (!tgid_map) | 4363 | if (!tgid_map) |
| 4363 | tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map), | 4364 | tgid_map = kcalloc(PID_MAX_DEFAULT + 1, |
| 4365 | sizeof(*tgid_map), | ||
| 4364 | GFP_KERNEL); | 4366 | GFP_KERNEL); |
| 4365 | if (!tgid_map) { | 4367 | if (!tgid_map) { |
| 4366 | tr->trace_flags &= ~TRACE_ITER_RECORD_TGID; | 4368 | tr->trace_flags &= ~TRACE_ITER_RECORD_TGID; |
| @@ -5063,7 +5065,7 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start, | |||
| 5063 | * where the head holds the module and length of array, and the | 5065 | * where the head holds the module and length of array, and the |
| 5064 | * tail holds a pointer to the next list. | 5066 | * tail holds a pointer to the next list. |
| 5065 | */ | 5067 | */ |
| 5066 | map_array = kmalloc(sizeof(*map_array) * (len + 2), GFP_KERNEL); | 5068 | map_array = kmalloc_array(len + 2, sizeof(*map_array), GFP_KERNEL); |
| 5067 | if (!map_array) { | 5069 | if (!map_array) { |
| 5068 | pr_warn("Unable to allocate trace eval mapping\n"); | 5070 | pr_warn("Unable to allocate trace eval mapping\n"); |
| 5069 | return; | 5071 | return; |
diff --git a/kernel/trace/trace_events_filter.c b/kernel/trace/trace_events_filter.c index 0171407d231f..e1c818dbc0d7 100644 --- a/kernel/trace/trace_events_filter.c +++ b/kernel/trace/trace_events_filter.c | |||
| @@ -436,15 +436,15 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, | |||
| 436 | 436 | ||
| 437 | nr_preds += 2; /* For TRUE and FALSE */ | 437 | nr_preds += 2; /* For TRUE and FALSE */ |
| 438 | 438 | ||
| 439 | op_stack = kmalloc(sizeof(*op_stack) * nr_parens, GFP_KERNEL); | 439 | op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL); |
| 440 | if (!op_stack) | 440 | if (!op_stack) |
| 441 | return ERR_PTR(-ENOMEM); | 441 | return ERR_PTR(-ENOMEM); |
| 442 | prog_stack = kmalloc(sizeof(*prog_stack) * nr_preds, GFP_KERNEL); | 442 | prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL); |
| 443 | if (!prog_stack) { | 443 | if (!prog_stack) { |
| 444 | parse_error(pe, -ENOMEM, 0); | 444 | parse_error(pe, -ENOMEM, 0); |
| 445 | goto out_free; | 445 | goto out_free; |
| 446 | } | 446 | } |
| 447 | inverts = kmalloc(sizeof(*inverts) * nr_preds, GFP_KERNEL); | 447 | inverts = kmalloc_array(nr_preds, sizeof(*inverts), GFP_KERNEL); |
| 448 | if (!inverts) { | 448 | if (!inverts) { |
| 449 | parse_error(pe, -ENOMEM, 0); | 449 | parse_error(pe, -ENOMEM, 0); |
| 450 | goto out_free; | 450 | goto out_free; |
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c index 5cadb1b8b5fe..752d8042bad4 100644 --- a/kernel/trace/tracing_map.c +++ b/kernel/trace/tracing_map.c | |||
| @@ -1075,7 +1075,7 @@ int tracing_map_sort_entries(struct tracing_map *map, | |||
| 1075 | struct tracing_map_sort_entry *sort_entry, **entries; | 1075 | struct tracing_map_sort_entry *sort_entry, **entries; |
| 1076 | int i, n_entries, ret; | 1076 | int i, n_entries, ret; |
| 1077 | 1077 | ||
| 1078 | entries = vmalloc(map->max_elts * sizeof(sort_entry)); | 1078 | entries = vmalloc(array_size(sizeof(sort_entry), map->max_elts)); |
| 1079 | if (!entries) | 1079 | if (!entries) |
| 1080 | return -ENOMEM; | 1080 | return -ENOMEM; |
| 1081 | 1081 | ||
diff --git a/kernel/user_namespace.c b/kernel/user_namespace.c index 492c255e6c5a..c3d7583fcd21 100644 --- a/kernel/user_namespace.c +++ b/kernel/user_namespace.c | |||
| @@ -764,8 +764,9 @@ static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent) | |||
| 764 | struct uid_gid_extent *forward; | 764 | struct uid_gid_extent *forward; |
| 765 | 765 | ||
| 766 | /* Allocate memory for 340 mappings. */ | 766 | /* Allocate memory for 340 mappings. */ |
| 767 | forward = kmalloc(sizeof(struct uid_gid_extent) * | 767 | forward = kmalloc_array(UID_GID_MAP_MAX_EXTENTS, |
| 768 | UID_GID_MAP_MAX_EXTENTS, GFP_KERNEL); | 768 | sizeof(struct uid_gid_extent), |
| 769 | GFP_KERNEL); | ||
| 769 | if (!forward) | 770 | if (!forward) |
| 770 | return -ENOMEM; | 771 | return -ENOMEM; |
| 771 | 772 | ||
diff --git a/kernel/workqueue.c b/kernel/workqueue.c index 465a28b4cd32..78b192071ef7 100644 --- a/kernel/workqueue.c +++ b/kernel/workqueue.c | |||
| @@ -5638,7 +5638,7 @@ static void __init wq_numa_init(void) | |||
| 5638 | * available. Build one from cpu_to_node() which should have been | 5638 | * available. Build one from cpu_to_node() which should have been |
| 5639 | * fully initialized by now. | 5639 | * fully initialized by now. |
| 5640 | */ | 5640 | */ |
| 5641 | tbl = kzalloc(nr_node_ids * sizeof(tbl[0]), GFP_KERNEL); | 5641 | tbl = kcalloc(nr_node_ids, sizeof(tbl[0]), GFP_KERNEL); |
| 5642 | BUG_ON(!tbl); | 5642 | BUG_ON(!tbl); |
| 5643 | 5643 | ||
| 5644 | for_each_node(node) | 5644 | for_each_node(node) |
diff --git a/lib/argv_split.c b/lib/argv_split.c index 5c35752a9414..1a19a0a93dc1 100644 --- a/lib/argv_split.c +++ b/lib/argv_split.c | |||
| @@ -69,7 +69,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp) | |||
| 69 | return NULL; | 69 | return NULL; |
| 70 | 70 | ||
| 71 | argc = count_argc(argv_str); | 71 | argc = count_argc(argv_str); |
| 72 | argv = kmalloc(sizeof(*argv) * (argc + 2), gfp); | 72 | argv = kmalloc_array(argc + 2, sizeof(*argv), gfp); |
| 73 | if (!argv) { | 73 | if (!argv) { |
| 74 | kfree(argv_str); | 74 | kfree(argv_str); |
| 75 | return NULL; | 75 | return NULL; |
diff --git a/lib/interval_tree_test.c b/lib/interval_tree_test.c index 835242e74aaa..75509a1511a3 100644 --- a/lib/interval_tree_test.c +++ b/lib/interval_tree_test.c | |||
| @@ -64,11 +64,12 @@ static int interval_tree_test_init(void) | |||
| 64 | unsigned long results; | 64 | unsigned long results; |
| 65 | cycles_t time1, time2, time; | 65 | cycles_t time1, time2, time; |
| 66 | 66 | ||
| 67 | nodes = kmalloc(nnodes * sizeof(struct interval_tree_node), GFP_KERNEL); | 67 | nodes = kmalloc_array(nnodes, sizeof(struct interval_tree_node), |
| 68 | GFP_KERNEL); | ||
| 68 | if (!nodes) | 69 | if (!nodes) |
| 69 | return -ENOMEM; | 70 | return -ENOMEM; |
| 70 | 71 | ||
| 71 | queries = kmalloc(nsearches * sizeof(int), GFP_KERNEL); | 72 | queries = kmalloc_array(nsearches, sizeof(int), GFP_KERNEL); |
| 72 | if (!queries) { | 73 | if (!queries) { |
| 73 | kfree(nodes); | 74 | kfree(nodes); |
| 74 | return -ENOMEM; | 75 | return -ENOMEM; |
diff --git a/lib/kfifo.c b/lib/kfifo.c index b0f757bf7213..015656aa8182 100644 --- a/lib/kfifo.c +++ b/lib/kfifo.c | |||
| @@ -54,7 +54,7 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, | |||
| 54 | return -EINVAL; | 54 | return -EINVAL; |
| 55 | } | 55 | } |
| 56 | 56 | ||
| 57 | fifo->data = kmalloc(size * esize, gfp_mask); | 57 | fifo->data = kmalloc_array(esize, size, gfp_mask); |
| 58 | 58 | ||
| 59 | if (!fifo->data) { | 59 | if (!fifo->data) { |
| 60 | fifo->mask = 0; | 60 | fifo->mask = 0; |
diff --git a/lib/lru_cache.c b/lib/lru_cache.c index 28ba40b99337..2b10a4024c35 100644 --- a/lib/lru_cache.c +++ b/lib/lru_cache.c | |||
| @@ -119,7 +119,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, | |||
| 119 | slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL); | 119 | slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL); |
| 120 | if (!slot) | 120 | if (!slot) |
| 121 | goto out_fail; | 121 | goto out_fail; |
| 122 | element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL); | 122 | element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL); |
| 123 | if (!element) | 123 | if (!element) |
| 124 | goto out_fail; | 124 | goto out_fail; |
| 125 | 125 | ||
diff --git a/lib/mpi/mpiutil.c b/lib/mpi/mpiutil.c index 314f4dfa603e..20ed0f766787 100644 --- a/lib/mpi/mpiutil.c +++ b/lib/mpi/mpiutil.c | |||
| @@ -91,14 +91,14 @@ int mpi_resize(MPI a, unsigned nlimbs) | |||
| 91 | return 0; /* no need to do it */ | 91 | return 0; /* no need to do it */ |
| 92 | 92 | ||
| 93 | if (a->d) { | 93 | if (a->d) { |
| 94 | p = kmalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL); | 94 | p = kmalloc_array(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL); |
| 95 | if (!p) | 95 | if (!p) |
| 96 | return -ENOMEM; | 96 | return -ENOMEM; |
| 97 | memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t)); | 97 | memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t)); |
| 98 | kzfree(a->d); | 98 | kzfree(a->d); |
| 99 | a->d = p; | 99 | a->d = p; |
| 100 | } else { | 100 | } else { |
| 101 | a->d = kzalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL); | 101 | a->d = kcalloc(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL); |
| 102 | if (!a->d) | 102 | if (!a->d) |
| 103 | return -ENOMEM; | 103 | return -ENOMEM; |
| 104 | } | 104 | } |
diff --git a/lib/rbtree_test.c b/lib/rbtree_test.c index 7d36c1e27ff6..b7055b2a07d3 100644 --- a/lib/rbtree_test.c +++ b/lib/rbtree_test.c | |||
| @@ -247,7 +247,7 @@ static int __init rbtree_test_init(void) | |||
| 247 | cycles_t time1, time2, time; | 247 | cycles_t time1, time2, time; |
| 248 | struct rb_node *node; | 248 | struct rb_node *node; |
| 249 | 249 | ||
| 250 | nodes = kmalloc(nnodes * sizeof(*nodes), GFP_KERNEL); | 250 | nodes = kmalloc_array(nnodes, sizeof(*nodes), GFP_KERNEL); |
| 251 | if (!nodes) | 251 | if (!nodes) |
| 252 | return -ENOMEM; | 252 | return -ENOMEM; |
| 253 | 253 | ||
diff --git a/lib/reed_solomon/reed_solomon.c b/lib/reed_solomon/reed_solomon.c index dfcf54242fb9..d8bb1a1eba72 100644 --- a/lib/reed_solomon/reed_solomon.c +++ b/lib/reed_solomon/reed_solomon.c | |||
| @@ -88,15 +88,15 @@ static struct rs_codec *codec_init(int symsize, int gfpoly, int (*gffunc)(int), | |||
| 88 | rs->gffunc = gffunc; | 88 | rs->gffunc = gffunc; |
| 89 | 89 | ||
| 90 | /* Allocate the arrays */ | 90 | /* Allocate the arrays */ |
| 91 | rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp); | 91 | rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); |
| 92 | if (rs->alpha_to == NULL) | 92 | if (rs->alpha_to == NULL) |
| 93 | goto err; | 93 | goto err; |
| 94 | 94 | ||
| 95 | rs->index_of = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp); | 95 | rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp); |
| 96 | if (rs->index_of == NULL) | 96 | if (rs->index_of == NULL) |
| 97 | goto err; | 97 | goto err; |
| 98 | 98 | ||
| 99 | rs->genpoly = kmalloc(sizeof(uint16_t) * (rs->nroots + 1), gfp); | 99 | rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp); |
| 100 | if(rs->genpoly == NULL) | 100 | if(rs->genpoly == NULL) |
| 101 | goto err; | 101 | goto err; |
| 102 | 102 | ||
diff --git a/lib/sbitmap.c b/lib/sbitmap.c index 6fdc6267f4a8..fdd1b8aa8ac6 100644 --- a/lib/sbitmap.c +++ b/lib/sbitmap.c | |||
| @@ -52,7 +52,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, | |||
| 52 | return 0; | 52 | return 0; |
| 53 | } | 53 | } |
| 54 | 54 | ||
| 55 | sb->map = kzalloc_node(sb->map_nr * sizeof(*sb->map), flags, node); | 55 | sb->map = kcalloc_node(sb->map_nr, sizeof(*sb->map), flags, node); |
| 56 | if (!sb->map) | 56 | if (!sb->map) |
| 57 | return -ENOMEM; | 57 | return -ENOMEM; |
| 58 | 58 | ||
diff --git a/lib/scatterlist.c b/lib/scatterlist.c index 06dad7a072fd..1642fd507a96 100644 --- a/lib/scatterlist.c +++ b/lib/scatterlist.c | |||
| @@ -170,7 +170,8 @@ static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask) | |||
| 170 | kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask); | 170 | kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask); |
| 171 | return ptr; | 171 | return ptr; |
| 172 | } else | 172 | } else |
| 173 | return kmalloc(nents * sizeof(struct scatterlist), gfp_mask); | 173 | return kmalloc_array(nents, sizeof(struct scatterlist), |
| 174 | gfp_mask); | ||
| 174 | } | 175 | } |
| 175 | 176 | ||
| 176 | static void sg_kfree(struct scatterlist *sg, unsigned int nents) | 177 | static void sg_kfree(struct scatterlist *sg, unsigned int nents) |
diff --git a/lib/test_firmware.c b/lib/test_firmware.c index cee000ac54d8..b984806d7d7b 100644 --- a/lib/test_firmware.c +++ b/lib/test_firmware.c | |||
| @@ -618,8 +618,9 @@ static ssize_t trigger_batched_requests_store(struct device *dev, | |||
| 618 | 618 | ||
| 619 | mutex_lock(&test_fw_mutex); | 619 | mutex_lock(&test_fw_mutex); |
| 620 | 620 | ||
| 621 | test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) * | 621 | test_fw_config->reqs = |
| 622 | test_fw_config->num_requests * 2); | 622 | vzalloc(array3_size(sizeof(struct test_batched_req), |
| 623 | test_fw_config->num_requests, 2)); | ||
| 623 | if (!test_fw_config->reqs) { | 624 | if (!test_fw_config->reqs) { |
| 624 | rc = -ENOMEM; | 625 | rc = -ENOMEM; |
| 625 | goto out_unlock; | 626 | goto out_unlock; |
| @@ -720,8 +721,9 @@ ssize_t trigger_batched_requests_async_store(struct device *dev, | |||
| 720 | 721 | ||
| 721 | mutex_lock(&test_fw_mutex); | 722 | mutex_lock(&test_fw_mutex); |
| 722 | 723 | ||
| 723 | test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) * | 724 | test_fw_config->reqs = |
| 724 | test_fw_config->num_requests * 2); | 725 | vzalloc(array3_size(sizeof(struct test_batched_req), |
| 726 | test_fw_config->num_requests, 2)); | ||
| 725 | if (!test_fw_config->reqs) { | 727 | if (!test_fw_config->reqs) { |
| 726 | rc = -ENOMEM; | 728 | rc = -ENOMEM; |
| 727 | goto out; | 729 | goto out; |
diff --git a/lib/test_kmod.c b/lib/test_kmod.c index 0e5b7a61460b..e3ddd836491f 100644 --- a/lib/test_kmod.c +++ b/lib/test_kmod.c | |||
| @@ -779,8 +779,9 @@ static int kmod_config_sync_info(struct kmod_test_device *test_dev) | |||
| 779 | struct test_config *config = &test_dev->config; | 779 | struct test_config *config = &test_dev->config; |
| 780 | 780 | ||
| 781 | free_test_dev_info(test_dev); | 781 | free_test_dev_info(test_dev); |
| 782 | test_dev->info = vzalloc(config->num_threads * | 782 | test_dev->info = |
| 783 | sizeof(struct kmod_test_device_info)); | 783 | vzalloc(array_size(sizeof(struct kmod_test_device_info), |
| 784 | config->num_threads)); | ||
| 784 | if (!test_dev->info) | 785 | if (!test_dev->info) |
| 785 | return -ENOMEM; | 786 | return -ENOMEM; |
| 786 | 787 | ||
diff --git a/lib/test_overflow.c b/lib/test_overflow.c index aecbbb217305..2278fe05a1b0 100644 --- a/lib/test_overflow.c +++ b/lib/test_overflow.c | |||
| @@ -367,7 +367,7 @@ static int __init test_overflow_allocation(void) | |||
| 367 | 367 | ||
| 368 | /* Create dummy device for devm_kmalloc()-family tests. */ | 368 | /* Create dummy device for devm_kmalloc()-family tests. */ |
| 369 | dev = root_device_register(device_name); | 369 | dev = root_device_register(device_name); |
| 370 | if (!dev) { | 370 | if (IS_ERR(dev)) { |
| 371 | pr_warn("Cannot register test device\n"); | 371 | pr_warn("Cannot register test device\n"); |
| 372 | return 1; | 372 | return 1; |
| 373 | } | 373 | } |
diff --git a/lib/test_rhashtable.c b/lib/test_rhashtable.c index f4000c137dbe..fb6968109113 100644 --- a/lib/test_rhashtable.c +++ b/lib/test_rhashtable.c | |||
| @@ -285,12 +285,14 @@ static int __init test_rhltable(unsigned int entries) | |||
| 285 | if (entries == 0) | 285 | if (entries == 0) |
| 286 | entries = 1; | 286 | entries = 1; |
| 287 | 287 | ||
| 288 | rhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries); | 288 | rhl_test_objects = vzalloc(array_size(entries, |
| 289 | sizeof(*rhl_test_objects))); | ||
| 289 | if (!rhl_test_objects) | 290 | if (!rhl_test_objects) |
| 290 | return -ENOMEM; | 291 | return -ENOMEM; |
| 291 | 292 | ||
| 292 | ret = -ENOMEM; | 293 | ret = -ENOMEM; |
| 293 | obj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long)); | 294 | obj_in_table = vzalloc(array_size(sizeof(unsigned long), |
| 295 | BITS_TO_LONGS(entries))); | ||
| 294 | if (!obj_in_table) | 296 | if (!obj_in_table) |
| 295 | goto out_free; | 297 | goto out_free; |
| 296 | 298 | ||
| @@ -706,7 +708,8 @@ static int __init test_rht_init(void) | |||
| 706 | test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries); | 708 | test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries); |
| 707 | test_rht_params.nelem_hint = size; | 709 | test_rht_params.nelem_hint = size; |
| 708 | 710 | ||
| 709 | objs = vzalloc((test_rht_params.max_size + 1) * sizeof(struct test_obj)); | 711 | objs = vzalloc(array_size(sizeof(struct test_obj), |
| 712 | test_rht_params.max_size + 1)); | ||
| 710 | if (!objs) | 713 | if (!objs) |
| 711 | return -ENOMEM; | 714 | return -ENOMEM; |
| 712 | 715 | ||
| @@ -753,10 +756,10 @@ static int __init test_rht_init(void) | |||
| 753 | pr_info("Testing concurrent rhashtable access from %d threads\n", | 756 | pr_info("Testing concurrent rhashtable access from %d threads\n", |
| 754 | tcount); | 757 | tcount); |
| 755 | sema_init(&prestart_sem, 1 - tcount); | 758 | sema_init(&prestart_sem, 1 - tcount); |
| 756 | tdata = vzalloc(tcount * sizeof(struct thread_data)); | 759 | tdata = vzalloc(array_size(tcount, sizeof(struct thread_data))); |
| 757 | if (!tdata) | 760 | if (!tdata) |
| 758 | return -ENOMEM; | 761 | return -ENOMEM; |
| 759 | objs = vzalloc(tcount * entries * sizeof(struct test_obj)); | 762 | objs = vzalloc(array3_size(sizeof(struct test_obj), tcount, entries)); |
| 760 | if (!objs) { | 763 | if (!objs) { |
| 761 | vfree(tdata); | 764 | vfree(tdata); |
| 762 | return -ENOMEM; | 765 | return -ENOMEM; |
diff --git a/mm/gup_benchmark.c b/mm/gup_benchmark.c index 0f44759486e2..6a473709e9b6 100644 --- a/mm/gup_benchmark.c +++ b/mm/gup_benchmark.c | |||
| @@ -23,7 +23,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd, | |||
| 23 | struct page **pages; | 23 | struct page **pages; |
| 24 | 24 | ||
| 25 | nr_pages = gup->size / PAGE_SIZE; | 25 | nr_pages = gup->size / PAGE_SIZE; |
| 26 | pages = kvzalloc(sizeof(void *) * nr_pages, GFP_KERNEL); | 26 | pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL); |
| 27 | if (!pages) | 27 | if (!pages) |
| 28 | return -ENOMEM; | 28 | return -ENOMEM; |
| 29 | 29 | ||
diff --git a/mm/huge_memory.c b/mm/huge_memory.c index ba8fdc0b6e7f..1cd7c1a57a14 100644 --- a/mm/huge_memory.c +++ b/mm/huge_memory.c | |||
| @@ -1131,8 +1131,8 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd, | |||
| 1131 | unsigned long mmun_start; /* For mmu_notifiers */ | 1131 | unsigned long mmun_start; /* For mmu_notifiers */ |
| 1132 | unsigned long mmun_end; /* For mmu_notifiers */ | 1132 | unsigned long mmun_end; /* For mmu_notifiers */ |
| 1133 | 1133 | ||
| 1134 | pages = kmalloc(sizeof(struct page *) * HPAGE_PMD_NR, | 1134 | pages = kmalloc_array(HPAGE_PMD_NR, sizeof(struct page *), |
| 1135 | GFP_KERNEL); | 1135 | GFP_KERNEL); |
| 1136 | if (unlikely(!pages)) { | 1136 | if (unlikely(!pages)) { |
| 1137 | ret |= VM_FAULT_OOM; | 1137 | ret |= VM_FAULT_OOM; |
| 1138 | goto out; | 1138 | goto out; |
diff --git a/mm/hugetlb.c b/mm/hugetlb.c index 696befffe6f7..3612fbb32e9d 100644 --- a/mm/hugetlb.c +++ b/mm/hugetlb.c | |||
| @@ -2798,7 +2798,8 @@ static int __init hugetlb_init(void) | |||
| 2798 | num_fault_mutexes = 1; | 2798 | num_fault_mutexes = 1; |
| 2799 | #endif | 2799 | #endif |
| 2800 | hugetlb_fault_mutex_table = | 2800 | hugetlb_fault_mutex_table = |
| 2801 | kmalloc(sizeof(struct mutex) * num_fault_mutexes, GFP_KERNEL); | 2801 | kmalloc_array(num_fault_mutexes, sizeof(struct mutex), |
| 2802 | GFP_KERNEL); | ||
| 2802 | BUG_ON(!hugetlb_fault_mutex_table); | 2803 | BUG_ON(!hugetlb_fault_mutex_table); |
| 2803 | 2804 | ||
| 2804 | for (i = 0; i < num_fault_mutexes; i++) | 2805 | for (i = 0; i < num_fault_mutexes; i++) |
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c index 063ff60ecd90..b5fdd43b60c9 100644 --- a/mm/percpu-stats.c +++ b/mm/percpu-stats.c | |||
| @@ -144,7 +144,7 @@ alloc_buffer: | |||
| 144 | spin_unlock_irq(&pcpu_lock); | 144 | spin_unlock_irq(&pcpu_lock); |
| 145 | 145 | ||
| 146 | /* there can be at most this many free and allocated fragments */ | 146 | /* there can be at most this many free and allocated fragments */ |
| 147 | buffer = vmalloc((2 * max_nr_alloc + 1) * sizeof(int)); | 147 | buffer = vmalloc(array_size(sizeof(int), (2 * max_nr_alloc + 1))); |
| 148 | if (!buffer) | 148 | if (!buffer) |
| 149 | return -ENOMEM; | 149 | return -ENOMEM; |
| 150 | 150 | ||
| @@ -4338,7 +4338,8 @@ static int leaks_show(struct seq_file *m, void *p) | |||
| 4338 | if (x[0] == x[1]) { | 4338 | if (x[0] == x[1]) { |
| 4339 | /* Increase the buffer size */ | 4339 | /* Increase the buffer size */ |
| 4340 | mutex_unlock(&slab_mutex); | 4340 | mutex_unlock(&slab_mutex); |
| 4341 | m->private = kzalloc(x[0] * 4 * sizeof(unsigned long), GFP_KERNEL); | 4341 | m->private = kcalloc(x[0] * 4, sizeof(unsigned long), |
| 4342 | GFP_KERNEL); | ||
| 4342 | if (!m->private) { | 4343 | if (!m->private) { |
| 4343 | /* Too bad, we are really out */ | 4344 | /* Too bad, we are really out */ |
| 4344 | m->private = x; | 4345 | m->private = x; |
| @@ -3623,8 +3623,9 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, | |||
| 3623 | #ifdef CONFIG_SLUB_DEBUG | 3623 | #ifdef CONFIG_SLUB_DEBUG |
| 3624 | void *addr = page_address(page); | 3624 | void *addr = page_address(page); |
| 3625 | void *p; | 3625 | void *p; |
| 3626 | unsigned long *map = kzalloc(BITS_TO_LONGS(page->objects) * | 3626 | unsigned long *map = kcalloc(BITS_TO_LONGS(page->objects), |
| 3627 | sizeof(long), GFP_ATOMIC); | 3627 | sizeof(long), |
| 3628 | GFP_ATOMIC); | ||
| 3628 | if (!map) | 3629 | if (!map) |
| 3629 | return; | 3630 | return; |
| 3630 | slab_err(s, page, text, s->name); | 3631 | slab_err(s, page, text, s->name); |
| @@ -4412,8 +4413,9 @@ static long validate_slab_cache(struct kmem_cache *s) | |||
| 4412 | { | 4413 | { |
| 4413 | int node; | 4414 | int node; |
| 4414 | unsigned long count = 0; | 4415 | unsigned long count = 0; |
| 4415 | unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) * | 4416 | unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)), |
| 4416 | sizeof(unsigned long), GFP_KERNEL); | 4417 | sizeof(unsigned long), |
| 4418 | GFP_KERNEL); | ||
| 4417 | struct kmem_cache_node *n; | 4419 | struct kmem_cache_node *n; |
| 4418 | 4420 | ||
| 4419 | if (!map) | 4421 | if (!map) |
| @@ -4573,8 +4575,9 @@ static int list_locations(struct kmem_cache *s, char *buf, | |||
| 4573 | unsigned long i; | 4575 | unsigned long i; |
| 4574 | struct loc_track t = { 0, 0, NULL }; | 4576 | struct loc_track t = { 0, 0, NULL }; |
| 4575 | int node; | 4577 | int node; |
| 4576 | unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) * | 4578 | unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)), |
| 4577 | sizeof(unsigned long), GFP_KERNEL); | 4579 | sizeof(unsigned long), |
| 4580 | GFP_KERNEL); | ||
| 4578 | struct kmem_cache_node *n; | 4581 | struct kmem_cache_node *n; |
| 4579 | 4582 | ||
| 4580 | if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location), | 4583 | if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location), |
| @@ -4750,7 +4753,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, | |||
| 4750 | int x; | 4753 | int x; |
| 4751 | unsigned long *nodes; | 4754 | unsigned long *nodes; |
| 4752 | 4755 | ||
| 4753 | nodes = kzalloc(sizeof(unsigned long) * nr_node_ids, GFP_KERNEL); | 4756 | nodes = kcalloc(nr_node_ids, sizeof(unsigned long), GFP_KERNEL); |
| 4754 | if (!nodes) | 4757 | if (!nodes) |
| 4755 | return -ENOMEM; | 4758 | return -ENOMEM; |
| 4756 | 4759 | ||
| @@ -5293,7 +5296,7 @@ static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) | |||
| 5293 | unsigned long sum = 0; | 5296 | unsigned long sum = 0; |
| 5294 | int cpu; | 5297 | int cpu; |
| 5295 | int len; | 5298 | int len; |
| 5296 | int *data = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL); | 5299 | int *data = kmalloc_array(nr_cpu_ids, sizeof(int), GFP_KERNEL); |
| 5297 | 5300 | ||
| 5298 | if (!data) | 5301 | if (!data) |
| 5299 | return -ENOMEM; | 5302 | return -ENOMEM; |
diff --git a/mm/swap_slots.c b/mm/swap_slots.c index f51ac051c0c9..a791411fed71 100644 --- a/mm/swap_slots.c +++ b/mm/swap_slots.c | |||
| @@ -122,12 +122,12 @@ static int alloc_swap_slot_cache(unsigned int cpu) | |||
| 122 | * as kvzalloc could trigger reclaim and get_swap_page, | 122 | * as kvzalloc could trigger reclaim and get_swap_page, |
| 123 | * which can lock swap_slots_cache_mutex. | 123 | * which can lock swap_slots_cache_mutex. |
| 124 | */ | 124 | */ |
| 125 | slots = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE, | 125 | slots = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t), |
| 126 | GFP_KERNEL); | 126 | GFP_KERNEL); |
| 127 | if (!slots) | 127 | if (!slots) |
| 128 | return -ENOMEM; | 128 | return -ENOMEM; |
| 129 | 129 | ||
| 130 | slots_ret = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE, | 130 | slots_ret = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t), |
| 131 | GFP_KERNEL); | 131 | GFP_KERNEL); |
| 132 | if (!slots_ret) { | 132 | if (!slots_ret) { |
| 133 | kvfree(slots); | 133 | kvfree(slots); |
diff --git a/mm/swap_state.c b/mm/swap_state.c index ab8e59cd18ea..ecee9c6c4cc1 100644 --- a/mm/swap_state.c +++ b/mm/swap_state.c | |||
| @@ -620,7 +620,7 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages) | |||
| 620 | unsigned int i, nr; | 620 | unsigned int i, nr; |
| 621 | 621 | ||
| 622 | nr = DIV_ROUND_UP(nr_pages, SWAP_ADDRESS_SPACE_PAGES); | 622 | nr = DIV_ROUND_UP(nr_pages, SWAP_ADDRESS_SPACE_PAGES); |
| 623 | spaces = kvzalloc(sizeof(struct address_space) * nr, GFP_KERNEL); | 623 | spaces = kvcalloc(nr, sizeof(struct address_space), GFP_KERNEL); |
| 624 | if (!spaces) | 624 | if (!spaces) |
| 625 | return -ENOMEM; | 625 | return -ENOMEM; |
| 626 | for (i = 0; i < nr; i++) { | 626 | for (i = 0; i < nr; i++) { |
diff --git a/mm/swapfile.c b/mm/swapfile.c index 78a015fcec3b..925cf795a652 100644 --- a/mm/swapfile.c +++ b/mm/swapfile.c | |||
| @@ -3196,7 +3196,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
| 3196 | p->cluster_next = 1 + (prandom_u32() % p->highest_bit); | 3196 | p->cluster_next = 1 + (prandom_u32() % p->highest_bit); |
| 3197 | nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER); | 3197 | nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER); |
| 3198 | 3198 | ||
| 3199 | cluster_info = kvzalloc(nr_cluster * sizeof(*cluster_info), | 3199 | cluster_info = kvcalloc(nr_cluster, sizeof(*cluster_info), |
| 3200 | GFP_KERNEL); | 3200 | GFP_KERNEL); |
| 3201 | if (!cluster_info) { | 3201 | if (!cluster_info) { |
| 3202 | error = -ENOMEM; | 3202 | error = -ENOMEM; |
| @@ -3233,7 +3233,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) | |||
| 3233 | } | 3233 | } |
| 3234 | /* frontswap enabled? set up bit-per-page map for frontswap */ | 3234 | /* frontswap enabled? set up bit-per-page map for frontswap */ |
| 3235 | if (IS_ENABLED(CONFIG_FRONTSWAP)) | 3235 | if (IS_ENABLED(CONFIG_FRONTSWAP)) |
| 3236 | frontswap_map = kvzalloc(BITS_TO_LONGS(maxpages) * sizeof(long), | 3236 | frontswap_map = kvcalloc(BITS_TO_LONGS(maxpages), |
| 3237 | sizeof(long), | ||
| 3237 | GFP_KERNEL); | 3238 | GFP_KERNEL); |
| 3238 | 3239 | ||
| 3239 | if (p->bdev &&(swap_flags & SWAP_FLAG_DISCARD) && swap_discardable(p)) { | 3240 | if (p->bdev &&(swap_flags & SWAP_FLAG_DISCARD) && swap_discardable(p)) { |
diff --git a/net/9p/protocol.c b/net/9p/protocol.c index 16e10680518c..931ea00c4fed 100644 --- a/net/9p/protocol.c +++ b/net/9p/protocol.c | |||
| @@ -242,8 +242,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
| 242 | "w", nwname); | 242 | "w", nwname); |
| 243 | if (!errcode) { | 243 | if (!errcode) { |
| 244 | *wnames = | 244 | *wnames = |
| 245 | kmalloc(sizeof(char *) * *nwname, | 245 | kmalloc_array(*nwname, |
| 246 | GFP_NOFS); | 246 | sizeof(char *), |
| 247 | GFP_NOFS); | ||
| 247 | if (!*wnames) | 248 | if (!*wnames) |
| 248 | errcode = -ENOMEM; | 249 | errcode = -ENOMEM; |
| 249 | } | 250 | } |
| @@ -285,9 +286,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, | |||
| 285 | p9pdu_readf(pdu, proto_version, "w", nwqid); | 286 | p9pdu_readf(pdu, proto_version, "w", nwqid); |
| 286 | if (!errcode) { | 287 | if (!errcode) { |
| 287 | *wqids = | 288 | *wqids = |
| 288 | kmalloc(*nwqid * | 289 | kmalloc_array(*nwqid, |
| 289 | sizeof(struct p9_qid), | 290 | sizeof(struct p9_qid), |
| 290 | GFP_NOFS); | 291 | GFP_NOFS); |
| 291 | if (*wqids == NULL) | 292 | if (*wqids == NULL) |
| 292 | errcode = -ENOMEM; | 293 | errcode = -ENOMEM; |
| 293 | } | 294 | } |
diff --git a/net/9p/trans_virtio.c b/net/9p/trans_virtio.c index 4d0372263e5d..05006cbb3361 100644 --- a/net/9p/trans_virtio.c +++ b/net/9p/trans_virtio.c | |||
| @@ -360,7 +360,8 @@ static int p9_get_mapped_pages(struct virtio_chan *chan, | |||
| 360 | nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) - | 360 | nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) - |
| 361 | (unsigned long)p / PAGE_SIZE; | 361 | (unsigned long)p / PAGE_SIZE; |
| 362 | 362 | ||
| 363 | *pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_NOFS); | 363 | *pages = kmalloc_array(nr_pages, sizeof(struct page *), |
| 364 | GFP_NOFS); | ||
| 364 | if (!*pages) | 365 | if (!*pages) |
| 365 | return -ENOMEM; | 366 | return -ENOMEM; |
| 366 | 367 | ||
diff --git a/net/atm/mpc.c b/net/atm/mpc.c index 31e0dcb970f8..75620c2f2617 100644 --- a/net/atm/mpc.c +++ b/net/atm/mpc.c | |||
| @@ -472,7 +472,7 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc, | |||
| 472 | if (mpc->number_of_mps_macs != 0) | 472 | if (mpc->number_of_mps_macs != 0) |
| 473 | kfree(mpc->mps_macs); | 473 | kfree(mpc->mps_macs); |
| 474 | mpc->number_of_mps_macs = 0; | 474 | mpc->number_of_mps_macs = 0; |
| 475 | mpc->mps_macs = kmalloc(num_macs * ETH_ALEN, GFP_KERNEL); | 475 | mpc->mps_macs = kmalloc_array(ETH_ALEN, num_macs, GFP_KERNEL); |
| 476 | if (mpc->mps_macs == NULL) { | 476 | if (mpc->mps_macs == NULL) { |
| 477 | pr_info("(%s) out of mem\n", mpc->dev->name); | 477 | pr_info("(%s) out of mem\n", mpc->dev->name); |
| 478 | return NULL; | 478 | return NULL; |
diff --git a/net/bluetooth/hci_core.c b/net/bluetooth/hci_core.c index 1dec33790198..ee8ef1228263 100644 --- a/net/bluetooth/hci_core.c +++ b/net/bluetooth/hci_core.c | |||
| @@ -1281,7 +1281,7 @@ int hci_inquiry(void __user *arg) | |||
| 1281 | /* cache_dump can't sleep. Therefore we allocate temp buffer and then | 1281 | /* cache_dump can't sleep. Therefore we allocate temp buffer and then |
| 1282 | * copy it to the user space. | 1282 | * copy it to the user space. |
| 1283 | */ | 1283 | */ |
| 1284 | buf = kmalloc(sizeof(struct inquiry_info) * max_rsp, GFP_KERNEL); | 1284 | buf = kmalloc_array(max_rsp, sizeof(struct inquiry_info), GFP_KERNEL); |
| 1285 | if (!buf) { | 1285 | if (!buf) { |
| 1286 | err = -ENOMEM; | 1286 | err = -ENOMEM; |
| 1287 | goto done; | 1287 | goto done; |
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c index 9b7907ebfa01..d17a4736e47c 100644 --- a/net/bluetooth/l2cap_core.c +++ b/net/bluetooth/l2cap_core.c | |||
| @@ -331,7 +331,7 @@ static int l2cap_seq_list_init(struct l2cap_seq_list *seq_list, u16 size) | |||
| 331 | */ | 331 | */ |
| 332 | alloc_size = roundup_pow_of_two(size); | 332 | alloc_size = roundup_pow_of_two(size); |
| 333 | 333 | ||
| 334 | seq_list->list = kmalloc(sizeof(u16) * alloc_size, GFP_KERNEL); | 334 | seq_list->list = kmalloc_array(alloc_size, sizeof(u16), GFP_KERNEL); |
| 335 | if (!seq_list->list) | 335 | if (!seq_list->list) |
| 336 | return -ENOMEM; | 336 | return -ENOMEM; |
| 337 | 337 | ||
diff --git a/net/bridge/br_multicast.c b/net/bridge/br_multicast.c index cb4729539b82..920665dd92db 100644 --- a/net/bridge/br_multicast.c +++ b/net/bridge/br_multicast.c | |||
| @@ -333,7 +333,7 @@ static int br_mdb_rehash(struct net_bridge_mdb_htable __rcu **mdbp, int max, | |||
| 333 | mdb->max = max; | 333 | mdb->max = max; |
| 334 | mdb->old = old; | 334 | mdb->old = old; |
| 335 | 335 | ||
| 336 | mdb->mhash = kzalloc(max * sizeof(*mdb->mhash), GFP_ATOMIC); | 336 | mdb->mhash = kcalloc(max, sizeof(*mdb->mhash), GFP_ATOMIC); |
| 337 | if (!mdb->mhash) { | 337 | if (!mdb->mhash) { |
| 338 | kfree(mdb); | 338 | kfree(mdb); |
| 339 | return -ENOMEM; | 339 | return -ENOMEM; |
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c index 28f68a2ec911..684b66bfa199 100644 --- a/net/bridge/netfilter/ebtables.c +++ b/net/bridge/netfilter/ebtables.c | |||
| @@ -903,12 +903,13 @@ static int translate_table(struct net *net, const char *name, | |||
| 903 | * if an error occurs | 903 | * if an error occurs |
| 904 | */ | 904 | */ |
| 905 | newinfo->chainstack = | 905 | newinfo->chainstack = |
| 906 | vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack))); | 906 | vmalloc(array_size(nr_cpu_ids, |
| 907 | sizeof(*(newinfo->chainstack)))); | ||
| 907 | if (!newinfo->chainstack) | 908 | if (!newinfo->chainstack) |
| 908 | return -ENOMEM; | 909 | return -ENOMEM; |
| 909 | for_each_possible_cpu(i) { | 910 | for_each_possible_cpu(i) { |
| 910 | newinfo->chainstack[i] = | 911 | newinfo->chainstack[i] = |
| 911 | vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0]))); | 912 | vmalloc(array_size(udc_cnt, sizeof(*(newinfo->chainstack[0])))); |
| 912 | if (!newinfo->chainstack[i]) { | 913 | if (!newinfo->chainstack[i]) { |
| 913 | while (i) | 914 | while (i) |
| 914 | vfree(newinfo->chainstack[--i]); | 915 | vfree(newinfo->chainstack[--i]); |
| @@ -918,7 +919,7 @@ static int translate_table(struct net *net, const char *name, | |||
| 918 | } | 919 | } |
| 919 | } | 920 | } |
| 920 | 921 | ||
| 921 | cl_s = vmalloc(udc_cnt * sizeof(*cl_s)); | 922 | cl_s = vmalloc(array_size(udc_cnt, sizeof(*cl_s))); |
| 922 | if (!cl_s) | 923 | if (!cl_s) |
| 923 | return -ENOMEM; | 924 | return -ENOMEM; |
| 924 | i = 0; /* the i'th udc */ | 925 | i = 0; /* the i'th udc */ |
| @@ -1293,7 +1294,7 @@ static int do_update_counters(struct net *net, const char *name, | |||
| 1293 | if (num_counters == 0) | 1294 | if (num_counters == 0) |
| 1294 | return -EINVAL; | 1295 | return -EINVAL; |
| 1295 | 1296 | ||
| 1296 | tmp = vmalloc(num_counters * sizeof(*tmp)); | 1297 | tmp = vmalloc(array_size(num_counters, sizeof(*tmp))); |
| 1297 | if (!tmp) | 1298 | if (!tmp) |
| 1298 | return -ENOMEM; | 1299 | return -ENOMEM; |
| 1299 | 1300 | ||
| @@ -1434,7 +1435,7 @@ static int copy_counters_to_user(struct ebt_table *t, | |||
| 1434 | return -EINVAL; | 1435 | return -EINVAL; |
| 1435 | } | 1436 | } |
| 1436 | 1437 | ||
| 1437 | counterstmp = vmalloc(nentries * sizeof(*counterstmp)); | 1438 | counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp))); |
| 1438 | if (!counterstmp) | 1439 | if (!counterstmp) |
| 1439 | return -ENOMEM; | 1440 | return -ENOMEM; |
| 1440 | 1441 | ||
diff --git a/net/can/bcm.c b/net/can/bcm.c index 97fedff3f0c4..9393f25df08d 100644 --- a/net/can/bcm.c +++ b/net/can/bcm.c | |||
| @@ -923,8 +923,9 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, | |||
| 923 | 923 | ||
| 924 | /* create array for CAN frames and copy the data */ | 924 | /* create array for CAN frames and copy the data */ |
| 925 | if (msg_head->nframes > 1) { | 925 | if (msg_head->nframes > 1) { |
| 926 | op->frames = kmalloc(msg_head->nframes * op->cfsiz, | 926 | op->frames = kmalloc_array(msg_head->nframes, |
| 927 | GFP_KERNEL); | 927 | op->cfsiz, |
| 928 | GFP_KERNEL); | ||
| 928 | if (!op->frames) { | 929 | if (!op->frames) { |
| 929 | kfree(op); | 930 | kfree(op); |
| 930 | return -ENOMEM; | 931 | return -ENOMEM; |
| @@ -1095,15 +1096,17 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, | |||
| 1095 | 1096 | ||
| 1096 | if (msg_head->nframes > 1) { | 1097 | if (msg_head->nframes > 1) { |
| 1097 | /* create array for CAN frames and copy the data */ | 1098 | /* create array for CAN frames and copy the data */ |
| 1098 | op->frames = kmalloc(msg_head->nframes * op->cfsiz, | 1099 | op->frames = kmalloc_array(msg_head->nframes, |
| 1099 | GFP_KERNEL); | 1100 | op->cfsiz, |
| 1101 | GFP_KERNEL); | ||
| 1100 | if (!op->frames) { | 1102 | if (!op->frames) { |
| 1101 | kfree(op); | 1103 | kfree(op); |
| 1102 | return -ENOMEM; | 1104 | return -ENOMEM; |
| 1103 | } | 1105 | } |
| 1104 | 1106 | ||
| 1105 | /* create and init array for received CAN frames */ | 1107 | /* create and init array for received CAN frames */ |
| 1106 | op->last_frames = kzalloc(msg_head->nframes * op->cfsiz, | 1108 | op->last_frames = kcalloc(msg_head->nframes, |
| 1109 | op->cfsiz, | ||
| 1107 | GFP_KERNEL); | 1110 | GFP_KERNEL); |
| 1108 | if (!op->last_frames) { | 1111 | if (!op->last_frames) { |
| 1109 | kfree(op->frames); | 1112 | kfree(op->frames); |
diff --git a/net/ceph/osdmap.c b/net/ceph/osdmap.c index 9645ffd6acfb..e22820e24f50 100644 --- a/net/ceph/osdmap.c +++ b/net/ceph/osdmap.c | |||
| @@ -1299,8 +1299,9 @@ static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) | |||
| 1299 | if (!map->osd_primary_affinity) { | 1299 | if (!map->osd_primary_affinity) { |
| 1300 | int i; | 1300 | int i; |
| 1301 | 1301 | ||
| 1302 | map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32), | 1302 | map->osd_primary_affinity = kmalloc_array(map->max_osd, |
| 1303 | GFP_NOFS); | 1303 | sizeof(u32), |
| 1304 | GFP_NOFS); | ||
| 1304 | if (!map->osd_primary_affinity) | 1305 | if (!map->osd_primary_affinity) |
| 1305 | return -ENOMEM; | 1306 | return -ENOMEM; |
| 1306 | 1307 | ||
diff --git a/net/ceph/pagevec.c b/net/ceph/pagevec.c index a3d0adc828e6..e560d3975f41 100644 --- a/net/ceph/pagevec.c +++ b/net/ceph/pagevec.c | |||
| @@ -20,7 +20,7 @@ struct page **ceph_get_direct_page_vector(const void __user *data, | |||
| 20 | int got = 0; | 20 | int got = 0; |
| 21 | int rc = 0; | 21 | int rc = 0; |
| 22 | 22 | ||
| 23 | pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS); | 23 | pages = kmalloc_array(num_pages, sizeof(*pages), GFP_NOFS); |
| 24 | if (!pages) | 24 | if (!pages) |
| 25 | return ERR_PTR(-ENOMEM); | 25 | return ERR_PTR(-ENOMEM); |
| 26 | 26 | ||
| @@ -74,7 +74,7 @@ struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags) | |||
| 74 | struct page **pages; | 74 | struct page **pages; |
| 75 | int i; | 75 | int i; |
| 76 | 76 | ||
| 77 | pages = kmalloc(sizeof(*pages) * num_pages, flags); | 77 | pages = kmalloc_array(num_pages, sizeof(*pages), flags); |
| 78 | if (!pages) | 78 | if (!pages) |
| 79 | return ERR_PTR(-ENOMEM); | 79 | return ERR_PTR(-ENOMEM); |
| 80 | for (i = 0; i < num_pages; i++) { | 80 | for (i = 0; i < num_pages; i++) { |
diff --git a/net/core/dev.c b/net/core/dev.c index 6e18242a1cae..57b7bab5f70b 100644 --- a/net/core/dev.c +++ b/net/core/dev.c | |||
| @@ -8823,7 +8823,7 @@ static struct hlist_head * __net_init netdev_create_hash(void) | |||
| 8823 | int i; | 8823 | int i; |
| 8824 | struct hlist_head *hash; | 8824 | struct hlist_head *hash; |
| 8825 | 8825 | ||
| 8826 | hash = kmalloc(sizeof(*hash) * NETDEV_HASHENTRIES, GFP_KERNEL); | 8826 | hash = kmalloc_array(NETDEV_HASHENTRIES, sizeof(*hash), GFP_KERNEL); |
| 8827 | if (hash != NULL) | 8827 | if (hash != NULL) |
| 8828 | for (i = 0; i < NETDEV_HASHENTRIES; i++) | 8828 | for (i = 0; i < NETDEV_HASHENTRIES; i++) |
| 8829 | INIT_HLIST_HEAD(&hash[i]); | 8829 | INIT_HLIST_HEAD(&hash[i]); |
diff --git a/net/core/ethtool.c b/net/core/ethtool.c index c15075dc7572..e677a20180cf 100644 --- a/net/core/ethtool.c +++ b/net/core/ethtool.c | |||
| @@ -911,7 +911,7 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev, | |||
| 911 | memset(&info, 0, sizeof(info)); | 911 | memset(&info, 0, sizeof(info)); |
| 912 | info.cmd = ETHTOOL_GSSET_INFO; | 912 | info.cmd = ETHTOOL_GSSET_INFO; |
| 913 | 913 | ||
| 914 | info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER); | 914 | info_buf = kcalloc(n_bits, sizeof(u32), GFP_USER); |
| 915 | if (!info_buf) | 915 | if (!info_buf) |
| 916 | return -ENOMEM; | 916 | return -ENOMEM; |
| 917 | 917 | ||
| @@ -1017,7 +1017,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, | |||
| 1017 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { | 1017 | if (info.cmd == ETHTOOL_GRXCLSRLALL) { |
| 1018 | if (info.rule_cnt > 0) { | 1018 | if (info.rule_cnt > 0) { |
| 1019 | if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32)) | 1019 | if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32)) |
| 1020 | rule_buf = kzalloc(info.rule_cnt * sizeof(u32), | 1020 | rule_buf = kcalloc(info.rule_cnt, sizeof(u32), |
| 1021 | GFP_USER); | 1021 | GFP_USER); |
| 1022 | if (!rule_buf) | 1022 | if (!rule_buf) |
| 1023 | return -ENOMEM; | 1023 | return -ENOMEM; |
| @@ -1816,7 +1816,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr) | |||
| 1816 | return -EFAULT; | 1816 | return -EFAULT; |
| 1817 | 1817 | ||
| 1818 | test.len = test_len; | 1818 | test.len = test_len; |
| 1819 | data = kmalloc(test_len * sizeof(u64), GFP_USER); | 1819 | data = kmalloc_array(test_len, sizeof(u64), GFP_USER); |
| 1820 | if (!data) | 1820 | if (!data) |
| 1821 | return -ENOMEM; | 1821 | return -ENOMEM; |
| 1822 | 1822 | ||
| @@ -1852,7 +1852,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) | |||
| 1852 | WARN_ON_ONCE(!ret); | 1852 | WARN_ON_ONCE(!ret); |
| 1853 | 1853 | ||
| 1854 | gstrings.len = ret; | 1854 | gstrings.len = ret; |
| 1855 | data = vzalloc(gstrings.len * ETH_GSTRING_LEN); | 1855 | data = vzalloc(array_size(gstrings.len, ETH_GSTRING_LEN)); |
| 1856 | if (gstrings.len && !data) | 1856 | if (gstrings.len && !data) |
| 1857 | return -ENOMEM; | 1857 | return -ENOMEM; |
| 1858 | 1858 | ||
| @@ -1952,7 +1952,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) | |||
| 1952 | return -EFAULT; | 1952 | return -EFAULT; |
| 1953 | 1953 | ||
| 1954 | stats.n_stats = n_stats; | 1954 | stats.n_stats = n_stats; |
| 1955 | data = vzalloc(n_stats * sizeof(u64)); | 1955 | data = vzalloc(array_size(n_stats, sizeof(u64))); |
| 1956 | if (n_stats && !data) | 1956 | if (n_stats && !data) |
| 1957 | return -ENOMEM; | 1957 | return -ENOMEM; |
| 1958 | 1958 | ||
| @@ -1996,7 +1996,7 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) | |||
| 1996 | return -EFAULT; | 1996 | return -EFAULT; |
| 1997 | 1997 | ||
| 1998 | stats.n_stats = n_stats; | 1998 | stats.n_stats = n_stats; |
| 1999 | data = vzalloc(n_stats * sizeof(u64)); | 1999 | data = vzalloc(array_size(n_stats, sizeof(u64))); |
| 2000 | if (n_stats && !data) | 2000 | if (n_stats && !data) |
| 2001 | return -ENOMEM; | 2001 | return -ENOMEM; |
| 2002 | 2002 | ||
diff --git a/net/core/pktgen.c b/net/core/pktgen.c index 7e4ede34cc52..49368e21d228 100644 --- a/net/core/pktgen.c +++ b/net/core/pktgen.c | |||
| @@ -3603,7 +3603,8 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) | |||
| 3603 | return -ENOMEM; | 3603 | return -ENOMEM; |
| 3604 | 3604 | ||
| 3605 | strcpy(pkt_dev->odevname, ifname); | 3605 | strcpy(pkt_dev->odevname, ifname); |
| 3606 | pkt_dev->flows = vzalloc_node(MAX_CFLOWS * sizeof(struct flow_state), | 3606 | pkt_dev->flows = vzalloc_node(array_size(MAX_CFLOWS, |
| 3607 | sizeof(struct flow_state)), | ||
| 3607 | node); | 3608 | node); |
| 3608 | if (pkt_dev->flows == NULL) { | 3609 | if (pkt_dev->flows == NULL) { |
| 3609 | kfree(pkt_dev); | 3610 | kfree(pkt_dev); |
diff --git a/net/dcb/dcbnl.c b/net/dcb/dcbnl.c index d2f4e0c1faaf..2589a6b78aa1 100644 --- a/net/dcb/dcbnl.c +++ b/net/dcb/dcbnl.c | |||
| @@ -984,7 +984,8 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, | |||
| 984 | */ | 984 | */ |
| 985 | err = ops->peer_getappinfo(netdev, &info, &app_count); | 985 | err = ops->peer_getappinfo(netdev, &info, &app_count); |
| 986 | if (!err && app_count) { | 986 | if (!err && app_count) { |
| 987 | table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL); | 987 | table = kmalloc_array(app_count, sizeof(struct dcb_app), |
| 988 | GFP_KERNEL); | ||
| 988 | if (!table) | 989 | if (!table) |
| 989 | return -ENOMEM; | 990 | return -ENOMEM; |
| 990 | 991 | ||
diff --git a/net/dccp/ccids/ccid2.c b/net/dccp/ccids/ccid2.c index 385f153fe031..2b75df469220 100644 --- a/net/dccp/ccids/ccid2.c +++ b/net/dccp/ccids/ccid2.c | |||
| @@ -46,7 +46,8 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc) | |||
| 46 | return -ENOMEM; | 46 | return -ENOMEM; |
| 47 | 47 | ||
| 48 | /* allocate buffer and initialize linked list */ | 48 | /* allocate buffer and initialize linked list */ |
| 49 | seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any()); | 49 | seqp = kmalloc_array(CCID2_SEQBUF_LEN, sizeof(struct ccid2_seq), |
| 50 | gfp_any()); | ||
| 50 | if (seqp == NULL) | 51 | if (seqp == NULL) |
| 51 | return -ENOMEM; | 52 | return -ENOMEM; |
| 52 | 53 | ||
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c index dc2960be51e0..b231e40f006a 100644 --- a/net/ieee802154/nl-phy.c +++ b/net/ieee802154/nl-phy.c | |||
| @@ -38,7 +38,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, | |||
| 38 | { | 38 | { |
| 39 | void *hdr; | 39 | void *hdr; |
| 40 | int i, pages = 0; | 40 | int i, pages = 0; |
| 41 | uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL); | 41 | uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL); |
| 42 | 42 | ||
| 43 | pr_debug("%s\n", __func__); | 43 | pr_debug("%s\n", __func__); |
| 44 | 44 | ||
diff --git a/net/ipv4/fib_frontend.c b/net/ipv4/fib_frontend.c index 63aa39b3af03..b21833651394 100644 --- a/net/ipv4/fib_frontend.c +++ b/net/ipv4/fib_frontend.c | |||
| @@ -567,7 +567,7 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, | |||
| 567 | struct nlattr *mx; | 567 | struct nlattr *mx; |
| 568 | int len = 0; | 568 | int len = 0; |
| 569 | 569 | ||
| 570 | mx = kzalloc(3 * nla_total_size(4), GFP_KERNEL); | 570 | mx = kcalloc(3, nla_total_size(4), GFP_KERNEL); |
| 571 | if (!mx) | 571 | if (!mx) |
| 572 | return -ENOMEM; | 572 | return -ENOMEM; |
| 573 | 573 | ||
diff --git a/net/ipv4/route.c b/net/ipv4/route.c index bf4e4adc2d00..1df6e97106d7 100644 --- a/net/ipv4/route.c +++ b/net/ipv4/route.c | |||
| @@ -649,7 +649,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, | |||
| 649 | 649 | ||
| 650 | hash = rcu_dereference(nh->nh_exceptions); | 650 | hash = rcu_dereference(nh->nh_exceptions); |
| 651 | if (!hash) { | 651 | if (!hash) { |
| 652 | hash = kzalloc(FNHE_HASH_SIZE * sizeof(*hash), GFP_ATOMIC); | 652 | hash = kcalloc(FNHE_HASH_SIZE, sizeof(*hash), GFP_ATOMIC); |
| 653 | if (!hash) | 653 | if (!hash) |
| 654 | goto out_unlock; | 654 | goto out_unlock; |
| 655 | rcu_assign_pointer(nh->nh_exceptions, hash); | 655 | rcu_assign_pointer(nh->nh_exceptions, hash); |
| @@ -3146,7 +3146,8 @@ int __init ip_rt_init(void) | |||
| 3146 | { | 3146 | { |
| 3147 | int cpu; | 3147 | int cpu; |
| 3148 | 3148 | ||
| 3149 | ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL); | 3149 | ip_idents = kmalloc_array(IP_IDENTS_SZ, sizeof(*ip_idents), |
| 3150 | GFP_KERNEL); | ||
| 3150 | if (!ip_idents) | 3151 | if (!ip_idents) |
| 3151 | panic("IP: failed to allocate ip_idents\n"); | 3152 | panic("IP: failed to allocate ip_idents\n"); |
| 3152 | 3153 | ||
diff --git a/net/ipv6/icmp.c b/net/ipv6/icmp.c index d8c4b6374377..be491bf6ab6e 100644 --- a/net/ipv6/icmp.c +++ b/net/ipv6/icmp.c | |||
| @@ -956,7 +956,7 @@ static int __net_init icmpv6_sk_init(struct net *net) | |||
| 956 | int err, i, j; | 956 | int err, i, j; |
| 957 | 957 | ||
| 958 | net->ipv6.icmp_sk = | 958 | net->ipv6.icmp_sk = |
| 959 | kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL); | 959 | kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL); |
| 960 | if (!net->ipv6.icmp_sk) | 960 | if (!net->ipv6.icmp_sk) |
| 961 | return -ENOMEM; | 961 | return -ENOMEM; |
| 962 | 962 | ||
diff --git a/net/ipv6/ila/ila_xlat.c b/net/ipv6/ila/ila_xlat.c index 44c39c5f0638..10ae13560b40 100644 --- a/net/ipv6/ila/ila_xlat.c +++ b/net/ipv6/ila/ila_xlat.c | |||
| @@ -42,7 +42,8 @@ static int alloc_ila_locks(struct ila_net *ilan) | |||
| 42 | size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU); | 42 | size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU); |
| 43 | 43 | ||
| 44 | if (sizeof(spinlock_t) != 0) { | 44 | if (sizeof(spinlock_t) != 0) { |
| 45 | ilan->locks = kvmalloc(size * sizeof(spinlock_t), GFP_KERNEL); | 45 | ilan->locks = kvmalloc_array(size, sizeof(spinlock_t), |
| 46 | GFP_KERNEL); | ||
| 46 | if (!ilan->locks) | 47 | if (!ilan->locks) |
| 47 | return -ENOMEM; | 48 | return -ENOMEM; |
| 48 | for (i = 0; i < size; i++) | 49 | for (i = 0; i < size; i++) |
diff --git a/net/mac80211/chan.c b/net/mac80211/chan.c index 89178b46b32f..d9558ffb8acf 100644 --- a/net/mac80211/chan.c +++ b/net/mac80211/chan.c | |||
| @@ -1186,7 +1186,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local, | |||
| 1186 | lockdep_assert_held(&local->mtx); | 1186 | lockdep_assert_held(&local->mtx); |
| 1187 | lockdep_assert_held(&local->chanctx_mtx); | 1187 | lockdep_assert_held(&local->chanctx_mtx); |
| 1188 | 1188 | ||
| 1189 | vif_chsw = kzalloc(sizeof(vif_chsw[0]) * n_vifs, GFP_KERNEL); | 1189 | vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL); |
| 1190 | if (!vif_chsw) | 1190 | if (!vif_chsw) |
| 1191 | return -ENOMEM; | 1191 | return -ENOMEM; |
| 1192 | 1192 | ||
diff --git a/net/mac80211/main.c b/net/mac80211/main.c index 4d2e797e3f16..fb1b1f9e7e5e 100644 --- a/net/mac80211/main.c +++ b/net/mac80211/main.c | |||
| @@ -772,7 +772,7 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local) | |||
| 772 | if (have_mfp) | 772 | if (have_mfp) |
| 773 | n_suites += 4; | 773 | n_suites += 4; |
| 774 | 774 | ||
| 775 | suites = kmalloc(sizeof(u32) * n_suites, GFP_KERNEL); | 775 | suites = kmalloc_array(n_suites, sizeof(u32), GFP_KERNEL); |
| 776 | if (!suites) | 776 | if (!suites) |
| 777 | return -ENOMEM; | 777 | return -ENOMEM; |
| 778 | 778 | ||
diff --git a/net/mac80211/rc80211_minstrel.c b/net/mac80211/rc80211_minstrel.c index 8221bc5582ab..76048b53c5b2 100644 --- a/net/mac80211/rc80211_minstrel.c +++ b/net/mac80211/rc80211_minstrel.c | |||
| @@ -592,11 +592,11 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) | |||
| 592 | max_rates = sband->n_bitrates; | 592 | max_rates = sband->n_bitrates; |
| 593 | } | 593 | } |
| 594 | 594 | ||
| 595 | mi->r = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp); | 595 | mi->r = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp); |
| 596 | if (!mi->r) | 596 | if (!mi->r) |
| 597 | goto error; | 597 | goto error; |
| 598 | 598 | ||
| 599 | mi->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp); | 599 | mi->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp); |
| 600 | if (!mi->sample_table) | 600 | if (!mi->sample_table) |
| 601 | goto error1; | 601 | goto error1; |
| 602 | 602 | ||
diff --git a/net/mac80211/rc80211_minstrel_ht.c b/net/mac80211/rc80211_minstrel_ht.c index fb586b6e5d49..67ebdeaffbbc 100644 --- a/net/mac80211/rc80211_minstrel_ht.c +++ b/net/mac80211/rc80211_minstrel_ht.c | |||
| @@ -1313,11 +1313,11 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) | |||
| 1313 | if (!msp) | 1313 | if (!msp) |
| 1314 | return NULL; | 1314 | return NULL; |
| 1315 | 1315 | ||
| 1316 | msp->ratelist = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp); | 1316 | msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp); |
| 1317 | if (!msp->ratelist) | 1317 | if (!msp->ratelist) |
| 1318 | goto error; | 1318 | goto error; |
| 1319 | 1319 | ||
| 1320 | msp->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp); | 1320 | msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp); |
| 1321 | if (!msp->sample_table) | 1321 | if (!msp->sample_table) |
| 1322 | goto error1; | 1322 | goto error1; |
| 1323 | 1323 | ||
diff --git a/net/mac80211/scan.c b/net/mac80211/scan.c index a3b1bcc2b461..2e917a6d239d 100644 --- a/net/mac80211/scan.c +++ b/net/mac80211/scan.c | |||
| @@ -1157,7 +1157,7 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, | |||
| 1157 | } | 1157 | } |
| 1158 | } | 1158 | } |
| 1159 | 1159 | ||
| 1160 | ie = kzalloc(num_bands * iebufsz, GFP_KERNEL); | 1160 | ie = kcalloc(iebufsz, num_bands, GFP_KERNEL); |
| 1161 | if (!ie) { | 1161 | if (!ie) { |
| 1162 | ret = -ENOMEM; | 1162 | ret = -ENOMEM; |
| 1163 | goto out; | 1163 | goto out; |
diff --git a/net/mac80211/util.c b/net/mac80211/util.c index 2d82c88efd0b..5e2e511c4a6f 100644 --- a/net/mac80211/util.c +++ b/net/mac80211/util.c | |||
| @@ -1803,8 +1803,9 @@ static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata) | |||
| 1803 | if (WARN_ON(res)) | 1803 | if (WARN_ON(res)) |
| 1804 | return res; | 1804 | return res; |
| 1805 | 1805 | ||
| 1806 | funcs = kzalloc((sdata->local->hw.max_nan_de_entries + 1) * | 1806 | funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1, |
| 1807 | sizeof(*funcs), GFP_KERNEL); | 1807 | sizeof(*funcs), |
| 1808 | GFP_KERNEL); | ||
| 1808 | if (!funcs) | 1809 | if (!funcs) |
| 1809 | return -ENOMEM; | 1810 | return -ENOMEM; |
| 1810 | 1811 | ||
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c index 61c3a389da89..99e0aa350dc5 100644 --- a/net/netfilter/ipvs/ip_vs_conn.c +++ b/net/netfilter/ipvs/ip_vs_conn.c | |||
| @@ -1380,7 +1380,8 @@ int __init ip_vs_conn_init(void) | |||
| 1380 | /* | 1380 | /* |
| 1381 | * Allocate the connection hash table and initialize its list heads | 1381 | * Allocate the connection hash table and initialize its list heads |
| 1382 | */ | 1382 | */ |
| 1383 | ip_vs_conn_tab = vmalloc(ip_vs_conn_tab_size * sizeof(*ip_vs_conn_tab)); | 1383 | ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size, |
| 1384 | sizeof(*ip_vs_conn_tab))); | ||
| 1384 | if (!ip_vs_conn_tab) | 1385 | if (!ip_vs_conn_tab) |
| 1385 | return -ENOMEM; | 1386 | return -ENOMEM; |
| 1386 | 1387 | ||
diff --git a/net/netfilter/nf_conntrack_proto.c b/net/netfilter/nf_conntrack_proto.c index afdeca53e88b..d88841fbc560 100644 --- a/net/netfilter/nf_conntrack_proto.c +++ b/net/netfilter/nf_conntrack_proto.c | |||
| @@ -402,7 +402,8 @@ int nf_ct_l4proto_register_one(const struct nf_conntrack_l4proto *l4proto) | |||
| 402 | struct nf_conntrack_l4proto __rcu **proto_array; | 402 | struct nf_conntrack_l4proto __rcu **proto_array; |
| 403 | int i; | 403 | int i; |
| 404 | 404 | ||
| 405 | proto_array = kmalloc(MAX_NF_CT_PROTO * | 405 | proto_array = |
| 406 | kmalloc_array(MAX_NF_CT_PROTO, | ||
| 406 | sizeof(struct nf_conntrack_l4proto *), | 407 | sizeof(struct nf_conntrack_l4proto *), |
| 407 | GFP_KERNEL); | 408 | GFP_KERNEL); |
| 408 | if (proto_array == NULL) { | 409 | if (proto_array == NULL) { |
diff --git a/net/netfilter/nf_nat_core.c b/net/netfilter/nf_nat_core.c index b7df32a56e7e..46f9df99d276 100644 --- a/net/netfilter/nf_nat_core.c +++ b/net/netfilter/nf_nat_core.c | |||
| @@ -691,8 +691,9 @@ int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto) | |||
| 691 | 691 | ||
| 692 | mutex_lock(&nf_nat_proto_mutex); | 692 | mutex_lock(&nf_nat_proto_mutex); |
| 693 | if (nf_nat_l4protos[l3proto] == NULL) { | 693 | if (nf_nat_l4protos[l3proto] == NULL) { |
| 694 | l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto *), | 694 | l4protos = kmalloc_array(IPPROTO_MAX, |
| 695 | GFP_KERNEL); | 695 | sizeof(struct nf_nat_l4proto *), |
| 696 | GFP_KERNEL); | ||
| 696 | if (l4protos == NULL) { | 697 | if (l4protos == NULL) { |
| 697 | ret = -ENOMEM; | 698 | ret = -ENOMEM; |
| 698 | goto out; | 699 | goto out; |
diff --git a/net/netfilter/nf_tables_api.c b/net/netfilter/nf_tables_api.c index ca4c4d994ddb..f0411fbffe77 100644 --- a/net/netfilter/nf_tables_api.c +++ b/net/netfilter/nf_tables_api.c | |||
| @@ -5303,7 +5303,7 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx, | |||
| 5303 | if (err < 0) | 5303 | if (err < 0) |
| 5304 | return err; | 5304 | return err; |
| 5305 | 5305 | ||
| 5306 | ops = kzalloc(sizeof(struct nf_hook_ops) * n, GFP_KERNEL); | 5306 | ops = kcalloc(n, sizeof(struct nf_hook_ops), GFP_KERNEL); |
| 5307 | if (!ops) | 5307 | if (!ops) |
| 5308 | return -ENOMEM; | 5308 | return -ENOMEM; |
| 5309 | 5309 | ||
| @@ -7164,8 +7164,8 @@ static int __init nf_tables_module_init(void) | |||
| 7164 | 7164 | ||
| 7165 | nft_chain_filter_init(); | 7165 | nft_chain_filter_init(); |
| 7166 | 7166 | ||
| 7167 | info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS, | 7167 | info = kmalloc_array(NFT_RULE_MAXEXPRS, sizeof(struct nft_expr_info), |
| 7168 | GFP_KERNEL); | 7168 | GFP_KERNEL); |
| 7169 | if (info == NULL) { | 7169 | if (info == NULL) { |
| 7170 | err = -ENOMEM; | 7170 | err = -ENOMEM; |
| 7171 | goto err1; | 7171 | goto err1; |
diff --git a/net/netfilter/nfnetlink_cthelper.c b/net/netfilter/nfnetlink_cthelper.c index cb5b5f207777..e5d27b2e4eba 100644 --- a/net/netfilter/nfnetlink_cthelper.c +++ b/net/netfilter/nfnetlink_cthelper.c | |||
| @@ -190,8 +190,9 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper, | |||
| 190 | if (class_max > NF_CT_MAX_EXPECT_CLASSES) | 190 | if (class_max > NF_CT_MAX_EXPECT_CLASSES) |
| 191 | return -EOVERFLOW; | 191 | return -EOVERFLOW; |
| 192 | 192 | ||
| 193 | expect_policy = kzalloc(sizeof(struct nf_conntrack_expect_policy) * | 193 | expect_policy = kcalloc(class_max, |
| 194 | class_max, GFP_KERNEL); | 194 | sizeof(struct nf_conntrack_expect_policy), |
| 195 | GFP_KERNEL); | ||
| 195 | if (expect_policy == NULL) | 196 | if (expect_policy == NULL) |
| 196 | return -ENOMEM; | 197 | return -ENOMEM; |
| 197 | 198 | ||
diff --git a/net/netfilter/x_tables.c b/net/netfilter/x_tables.c index df9ab71b0ed9..d0d8397c9588 100644 --- a/net/netfilter/x_tables.c +++ b/net/netfilter/x_tables.c | |||
| @@ -1904,7 +1904,7 @@ static int __init xt_init(void) | |||
| 1904 | seqcount_init(&per_cpu(xt_recseq, i)); | 1904 | seqcount_init(&per_cpu(xt_recseq, i)); |
| 1905 | } | 1905 | } |
| 1906 | 1906 | ||
| 1907 | xt = kmalloc(sizeof(struct xt_af) * NFPROTO_NUMPROTO, GFP_KERNEL); | 1907 | xt = kmalloc_array(NFPROTO_NUMPROTO, sizeof(struct xt_af), GFP_KERNEL); |
| 1908 | if (!xt) | 1908 | if (!xt) |
| 1909 | return -ENOMEM; | 1909 | return -ENOMEM; |
| 1910 | 1910 | ||
diff --git a/net/netlink/genetlink.c b/net/netlink/genetlink.c index b9ce82c9440f..25eeb6d2a75a 100644 --- a/net/netlink/genetlink.c +++ b/net/netlink/genetlink.c | |||
| @@ -352,8 +352,9 @@ int genl_register_family(struct genl_family *family) | |||
| 352 | } | 352 | } |
| 353 | 353 | ||
| 354 | if (family->maxattr && !family->parallel_ops) { | 354 | if (family->maxattr && !family->parallel_ops) { |
| 355 | family->attrbuf = kmalloc((family->maxattr+1) * | 355 | family->attrbuf = kmalloc_array(family->maxattr + 1, |
| 356 | sizeof(struct nlattr *), GFP_KERNEL); | 356 | sizeof(struct nlattr *), |
| 357 | GFP_KERNEL); | ||
| 357 | if (family->attrbuf == NULL) { | 358 | if (family->attrbuf == NULL) { |
| 358 | err = -ENOMEM; | 359 | err = -ENOMEM; |
| 359 | goto errout_locked; | 360 | goto errout_locked; |
| @@ -566,8 +567,9 @@ static int genl_family_rcv_msg(const struct genl_family *family, | |||
| 566 | return -EOPNOTSUPP; | 567 | return -EOPNOTSUPP; |
| 567 | 568 | ||
| 568 | if (family->maxattr && family->parallel_ops) { | 569 | if (family->maxattr && family->parallel_ops) { |
| 569 | attrbuf = kmalloc((family->maxattr+1) * | 570 | attrbuf = kmalloc_array(family->maxattr + 1, |
| 570 | sizeof(struct nlattr *), GFP_KERNEL); | 571 | sizeof(struct nlattr *), |
| 572 | GFP_KERNEL); | ||
| 571 | if (attrbuf == NULL) | 573 | if (attrbuf == NULL) |
| 572 | return -ENOMEM; | 574 | return -ENOMEM; |
| 573 | } else | 575 | } else |
diff --git a/net/netrom/af_netrom.c b/net/netrom/af_netrom.c index b97eb766a1d5..93fbcafbf388 100644 --- a/net/netrom/af_netrom.c +++ b/net/netrom/af_netrom.c | |||
| @@ -1395,7 +1395,7 @@ static int __init nr_proto_init(void) | |||
| 1395 | return -1; | 1395 | return -1; |
| 1396 | } | 1396 | } |
| 1397 | 1397 | ||
| 1398 | dev_nr = kzalloc(nr_ndevs * sizeof(struct net_device *), GFP_KERNEL); | 1398 | dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL); |
| 1399 | if (dev_nr == NULL) { | 1399 | if (dev_nr == NULL) { |
| 1400 | printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n"); | 1400 | printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n"); |
| 1401 | return -1; | 1401 | return -1; |
diff --git a/net/openvswitch/datapath.c b/net/openvswitch/datapath.c index a61818e94396..0f5ce77460d4 100644 --- a/net/openvswitch/datapath.c +++ b/net/openvswitch/datapath.c | |||
| @@ -1578,8 +1578,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) | |||
| 1578 | goto err_destroy_table; | 1578 | goto err_destroy_table; |
| 1579 | } | 1579 | } |
| 1580 | 1580 | ||
| 1581 | dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head), | 1581 | dp->ports = kmalloc_array(DP_VPORT_HASH_BUCKETS, |
| 1582 | GFP_KERNEL); | 1582 | sizeof(struct hlist_head), |
| 1583 | GFP_KERNEL); | ||
| 1583 | if (!dp->ports) { | 1584 | if (!dp->ports) { |
| 1584 | err = -ENOMEM; | 1585 | err = -ENOMEM; |
| 1585 | goto err_destroy_percpu; | 1586 | goto err_destroy_percpu; |
diff --git a/net/openvswitch/vport.c b/net/openvswitch/vport.c index f81c1d0ddff4..19f6765566e7 100644 --- a/net/openvswitch/vport.c +++ b/net/openvswitch/vport.c | |||
| @@ -47,7 +47,7 @@ static struct hlist_head *dev_table; | |||
| 47 | */ | 47 | */ |
| 48 | int ovs_vport_init(void) | 48 | int ovs_vport_init(void) |
| 49 | { | 49 | { |
| 50 | dev_table = kzalloc(VPORT_HASH_BUCKETS * sizeof(struct hlist_head), | 50 | dev_table = kcalloc(VPORT_HASH_BUCKETS, sizeof(struct hlist_head), |
| 51 | GFP_KERNEL); | 51 | GFP_KERNEL); |
| 52 | if (!dev_table) | 52 | if (!dev_table) |
| 53 | return -ENOMEM; | 53 | return -ENOMEM; |
diff --git a/net/packet/af_packet.c b/net/packet/af_packet.c index ee018564b2b4..50809748c127 100644 --- a/net/packet/af_packet.c +++ b/net/packet/af_packet.c | |||
| @@ -4161,7 +4161,7 @@ static char *alloc_one_pg_vec_page(unsigned long order) | |||
| 4161 | return buffer; | 4161 | return buffer; |
| 4162 | 4162 | ||
| 4163 | /* __get_free_pages failed, fall back to vmalloc */ | 4163 | /* __get_free_pages failed, fall back to vmalloc */ |
| 4164 | buffer = vzalloc((1 << order) * PAGE_SIZE); | 4164 | buffer = vzalloc(array_size((1 << order), PAGE_SIZE)); |
| 4165 | if (buffer) | 4165 | if (buffer) |
| 4166 | return buffer; | 4166 | return buffer; |
| 4167 | 4167 | ||
diff --git a/net/rds/ib.c b/net/rds/ib.c index 02deee29e7f1..b6ad38e48f62 100644 --- a/net/rds/ib.c +++ b/net/rds/ib.c | |||
| @@ -163,7 +163,8 @@ static void rds_ib_add_one(struct ib_device *device) | |||
| 163 | rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom; | 163 | rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom; |
| 164 | rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom; | 164 | rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom; |
| 165 | 165 | ||
| 166 | rds_ibdev->vector_load = kzalloc(sizeof(int) * device->num_comp_vectors, | 166 | rds_ibdev->vector_load = kcalloc(device->num_comp_vectors, |
| 167 | sizeof(int), | ||
| 167 | GFP_KERNEL); | 168 | GFP_KERNEL); |
| 168 | if (!rds_ibdev->vector_load) { | 169 | if (!rds_ibdev->vector_load) { |
| 169 | pr_err("RDS/IB: %s failed to allocate vector memory\n", | 170 | pr_err("RDS/IB: %s failed to allocate vector memory\n", |
diff --git a/net/rds/ib_cm.c b/net/rds/ib_cm.c index 13b38ad0fa4a..f1684ae6abfd 100644 --- a/net/rds/ib_cm.c +++ b/net/rds/ib_cm.c | |||
| @@ -526,7 +526,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn) | |||
| 526 | goto recv_hdrs_dma_out; | 526 | goto recv_hdrs_dma_out; |
| 527 | } | 527 | } |
| 528 | 528 | ||
| 529 | ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work), | 529 | ic->i_sends = vzalloc_node(array_size(sizeof(struct rds_ib_send_work), |
| 530 | ic->i_send_ring.w_nr), | ||
| 530 | ibdev_to_node(dev)); | 531 | ibdev_to_node(dev)); |
| 531 | if (!ic->i_sends) { | 532 | if (!ic->i_sends) { |
| 532 | ret = -ENOMEM; | 533 | ret = -ENOMEM; |
| @@ -534,7 +535,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn) | |||
| 534 | goto ack_dma_out; | 535 | goto ack_dma_out; |
| 535 | } | 536 | } |
| 536 | 537 | ||
| 537 | ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work), | 538 | ic->i_recvs = vzalloc_node(array_size(sizeof(struct rds_ib_recv_work), |
| 539 | ic->i_recv_ring.w_nr), | ||
| 538 | ibdev_to_node(dev)); | 540 | ibdev_to_node(dev)); |
| 539 | if (!ic->i_recvs) { | 541 | if (!ic->i_recvs) { |
| 540 | ret = -ENOMEM; | 542 | ret = -ENOMEM; |
diff --git a/net/rds/info.c b/net/rds/info.c index 140a44a5f7b7..e367a97a18c8 100644 --- a/net/rds/info.c +++ b/net/rds/info.c | |||
| @@ -188,7 +188,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, | |||
| 188 | nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK)) | 188 | nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK)) |
| 189 | >> PAGE_SHIFT; | 189 | >> PAGE_SHIFT; |
| 190 | 190 | ||
| 191 | pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL); | 191 | pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL); |
| 192 | if (!pages) { | 192 | if (!pages) { |
| 193 | ret = -ENOMEM; | 193 | ret = -ENOMEM; |
| 194 | goto out; | 194 | goto out; |
diff --git a/net/rose/af_rose.c b/net/rose/af_rose.c index 5b73fea849df..ebe42e7eb456 100644 --- a/net/rose/af_rose.c +++ b/net/rose/af_rose.c | |||
| @@ -1514,7 +1514,8 @@ static int __init rose_proto_init(void) | |||
| 1514 | 1514 | ||
| 1515 | rose_callsign = null_ax25_address; | 1515 | rose_callsign = null_ax25_address; |
| 1516 | 1516 | ||
| 1517 | dev_rose = kzalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL); | 1517 | dev_rose = kcalloc(rose_ndevs, sizeof(struct net_device *), |
| 1518 | GFP_KERNEL); | ||
| 1518 | if (dev_rose == NULL) { | 1519 | if (dev_rose == NULL) { |
| 1519 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); | 1520 | printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n"); |
| 1520 | rc = -ENOMEM; | 1521 | rc = -ENOMEM; |
diff --git a/net/rxrpc/rxkad.c b/net/rxrpc/rxkad.c index 6c0ae27fff84..278ac0807a60 100644 --- a/net/rxrpc/rxkad.c +++ b/net/rxrpc/rxkad.c | |||
| @@ -432,7 +432,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, | |||
| 432 | 432 | ||
| 433 | sg = _sg; | 433 | sg = _sg; |
| 434 | if (unlikely(nsg > 4)) { | 434 | if (unlikely(nsg > 4)) { |
| 435 | sg = kmalloc(sizeof(*sg) * nsg, GFP_NOIO); | 435 | sg = kmalloc_array(nsg, sizeof(*sg), GFP_NOIO); |
| 436 | if (!sg) | 436 | if (!sg) |
| 437 | goto nomem; | 437 | goto nomem; |
| 438 | } | 438 | } |
diff --git a/net/sched/sch_fq_codel.c b/net/sched/sch_fq_codel.c index 22fa13cf5d8b..cd2e0e342fb6 100644 --- a/net/sched/sch_fq_codel.c +++ b/net/sched/sch_fq_codel.c | |||
| @@ -489,11 +489,12 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, | |||
| 489 | return err; | 489 | return err; |
| 490 | 490 | ||
| 491 | if (!q->flows) { | 491 | if (!q->flows) { |
| 492 | q->flows = kvzalloc(q->flows_cnt * | 492 | q->flows = kvcalloc(q->flows_cnt, |
| 493 | sizeof(struct fq_codel_flow), GFP_KERNEL); | 493 | sizeof(struct fq_codel_flow), |
| 494 | GFP_KERNEL); | ||
| 494 | if (!q->flows) | 495 | if (!q->flows) |
| 495 | return -ENOMEM; | 496 | return -ENOMEM; |
| 496 | q->backlogs = kvzalloc(q->flows_cnt * sizeof(u32), GFP_KERNEL); | 497 | q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL); |
| 497 | if (!q->backlogs) | 498 | if (!q->backlogs) |
| 498 | return -ENOMEM; | 499 | return -ENOMEM; |
| 499 | for (i = 0; i < q->flows_cnt; i++) { | 500 | for (i = 0; i < q->flows_cnt; i++) { |
diff --git a/net/sched/sch_hhf.c b/net/sched/sch_hhf.c index bce2632212d3..c3a8388dcdf6 100644 --- a/net/sched/sch_hhf.c +++ b/net/sched/sch_hhf.c | |||
| @@ -599,8 +599,8 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, | |||
| 599 | 599 | ||
| 600 | if (!q->hh_flows) { | 600 | if (!q->hh_flows) { |
| 601 | /* Initialize heavy-hitter flow table. */ | 601 | /* Initialize heavy-hitter flow table. */ |
| 602 | q->hh_flows = kvzalloc(HH_FLOWS_CNT * | 602 | q->hh_flows = kvcalloc(HH_FLOWS_CNT, sizeof(struct list_head), |
| 603 | sizeof(struct list_head), GFP_KERNEL); | 603 | GFP_KERNEL); |
| 604 | if (!q->hh_flows) | 604 | if (!q->hh_flows) |
| 605 | return -ENOMEM; | 605 | return -ENOMEM; |
| 606 | for (i = 0; i < HH_FLOWS_CNT; i++) | 606 | for (i = 0; i < HH_FLOWS_CNT; i++) |
| @@ -614,8 +614,9 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, | |||
| 614 | 614 | ||
| 615 | /* Initialize heavy-hitter filter arrays. */ | 615 | /* Initialize heavy-hitter filter arrays. */ |
| 616 | for (i = 0; i < HHF_ARRAYS_CNT; i++) { | 616 | for (i = 0; i < HHF_ARRAYS_CNT; i++) { |
| 617 | q->hhf_arrays[i] = kvzalloc(HHF_ARRAYS_LEN * | 617 | q->hhf_arrays[i] = kvcalloc(HHF_ARRAYS_LEN, |
| 618 | sizeof(u32), GFP_KERNEL); | 618 | sizeof(u32), |
| 619 | GFP_KERNEL); | ||
| 619 | if (!q->hhf_arrays[i]) { | 620 | if (!q->hhf_arrays[i]) { |
| 620 | /* Note: hhf_destroy() will be called | 621 | /* Note: hhf_destroy() will be called |
| 621 | * by our caller. | 622 | * by our caller. |
diff --git a/net/sctp/auth.c b/net/sctp/auth.c index e64630cd3331..5b537613946f 100644 --- a/net/sctp/auth.c +++ b/net/sctp/auth.c | |||
| @@ -482,8 +482,9 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) | |||
| 482 | return 0; | 482 | return 0; |
| 483 | 483 | ||
| 484 | /* Allocated the array of pointers to transorms */ | 484 | /* Allocated the array of pointers to transorms */ |
| 485 | ep->auth_hmacs = kzalloc(sizeof(struct crypto_shash *) * | 485 | ep->auth_hmacs = kcalloc(SCTP_AUTH_NUM_HMACS, |
| 486 | SCTP_AUTH_NUM_HMACS, gfp); | 486 | sizeof(struct crypto_shash *), |
| 487 | gfp); | ||
| 487 | if (!ep->auth_hmacs) | 488 | if (!ep->auth_hmacs) |
| 488 | return -ENOMEM; | 489 | return -ENOMEM; |
| 489 | 490 | ||
diff --git a/net/sctp/protocol.c b/net/sctp/protocol.c index 11d93377ba5e..5dffbc493008 100644 --- a/net/sctp/protocol.c +++ b/net/sctp/protocol.c | |||
| @@ -1438,7 +1438,7 @@ static __init int sctp_init(void) | |||
| 1438 | /* Allocate and initialize the endpoint hash table. */ | 1438 | /* Allocate and initialize the endpoint hash table. */ |
| 1439 | sctp_ep_hashsize = 64; | 1439 | sctp_ep_hashsize = 64; |
| 1440 | sctp_ep_hashtable = | 1440 | sctp_ep_hashtable = |
| 1441 | kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL); | 1441 | kmalloc_array(64, sizeof(struct sctp_hashbucket), GFP_KERNEL); |
| 1442 | if (!sctp_ep_hashtable) { | 1442 | if (!sctp_ep_hashtable) { |
| 1443 | pr_err("Failed endpoint_hash alloc\n"); | 1443 | pr_err("Failed endpoint_hash alloc\n"); |
| 1444 | status = -ENOMEM; | 1444 | status = -ENOMEM; |
diff --git a/net/smc/smc_wr.c b/net/smc/smc_wr.c index cc7c1bb60fe8..dbd2605d1962 100644 --- a/net/smc/smc_wr.c +++ b/net/smc/smc_wr.c | |||
| @@ -584,9 +584,9 @@ int smc_wr_alloc_link_mem(struct smc_link *link) | |||
| 584 | GFP_KERNEL); | 584 | GFP_KERNEL); |
| 585 | if (!link->wr_rx_sges) | 585 | if (!link->wr_rx_sges) |
| 586 | goto no_mem_wr_tx_sges; | 586 | goto no_mem_wr_tx_sges; |
| 587 | link->wr_tx_mask = kzalloc( | 587 | link->wr_tx_mask = kcalloc(BITS_TO_LONGS(SMC_WR_BUF_CNT), |
| 588 | BITS_TO_LONGS(SMC_WR_BUF_CNT) * sizeof(*link->wr_tx_mask), | 588 | sizeof(*link->wr_tx_mask), |
| 589 | GFP_KERNEL); | 589 | GFP_KERNEL); |
| 590 | if (!link->wr_tx_mask) | 590 | if (!link->wr_tx_mask) |
| 591 | goto no_mem_wr_rx_sges; | 591 | goto no_mem_wr_rx_sges; |
| 592 | link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT, | 592 | link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT, |
diff --git a/net/sunrpc/auth_gss/auth_gss.c b/net/sunrpc/auth_gss/auth_gss.c index 9463af4b32e8..be8f103d22fd 100644 --- a/net/sunrpc/auth_gss/auth_gss.c +++ b/net/sunrpc/auth_gss/auth_gss.c | |||
| @@ -1753,7 +1753,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp) | |||
| 1753 | last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_SHIFT; | 1753 | last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_SHIFT; |
| 1754 | rqstp->rq_enc_pages_num = last - first + 1 + 1; | 1754 | rqstp->rq_enc_pages_num = last - first + 1 + 1; |
| 1755 | rqstp->rq_enc_pages | 1755 | rqstp->rq_enc_pages |
| 1756 | = kmalloc(rqstp->rq_enc_pages_num * sizeof(struct page *), | 1756 | = kmalloc_array(rqstp->rq_enc_pages_num, |
| 1757 | sizeof(struct page *), | ||
| 1757 | GFP_NOFS); | 1758 | GFP_NOFS); |
| 1758 | if (!rqstp->rq_enc_pages) | 1759 | if (!rqstp->rq_enc_pages) |
| 1759 | goto out; | 1760 | goto out; |
diff --git a/net/sunrpc/auth_gss/gss_rpc_upcall.c b/net/sunrpc/auth_gss/gss_rpc_upcall.c index d98e2b610ce8..1c7c49dbf8ba 100644 --- a/net/sunrpc/auth_gss/gss_rpc_upcall.c +++ b/net/sunrpc/auth_gss/gss_rpc_upcall.c | |||
| @@ -224,7 +224,7 @@ static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg) | |||
| 224 | static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg) | 224 | static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg) |
| 225 | { | 225 | { |
| 226 | arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE); | 226 | arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE); |
| 227 | arg->pages = kzalloc(arg->npages * sizeof(struct page *), GFP_KERNEL); | 227 | arg->pages = kcalloc(arg->npages, sizeof(struct page *), GFP_KERNEL); |
| 228 | /* | 228 | /* |
| 229 | * XXX: actual pages are allocated by xdr layer in | 229 | * XXX: actual pages are allocated by xdr layer in |
| 230 | * xdr_partial_copy_from_skb. | 230 | * xdr_partial_copy_from_skb. |
diff --git a/net/sunrpc/cache.c b/net/sunrpc/cache.c index cdda4744c9b1..109fbe591e7b 100644 --- a/net/sunrpc/cache.c +++ b/net/sunrpc/cache.c | |||
| @@ -1683,7 +1683,7 @@ struct cache_detail *cache_create_net(const struct cache_detail *tmpl, struct ne | |||
| 1683 | if (cd == NULL) | 1683 | if (cd == NULL) |
| 1684 | return ERR_PTR(-ENOMEM); | 1684 | return ERR_PTR(-ENOMEM); |
| 1685 | 1685 | ||
| 1686 | cd->hash_table = kzalloc(cd->hash_size * sizeof(struct hlist_head), | 1686 | cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head), |
| 1687 | GFP_KERNEL); | 1687 | GFP_KERNEL); |
| 1688 | if (cd->hash_table == NULL) { | 1688 | if (cd->hash_table == NULL) { |
| 1689 | kfree(cd); | 1689 | kfree(cd); |
diff --git a/net/tipc/netlink_compat.c b/net/tipc/netlink_compat.c index 4492cda45566..a2f76743c73a 100644 --- a/net/tipc/netlink_compat.c +++ b/net/tipc/netlink_compat.c | |||
| @@ -285,8 +285,9 @@ static int __tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd, | |||
| 285 | if (!trans_buf) | 285 | if (!trans_buf) |
| 286 | return -ENOMEM; | 286 | return -ENOMEM; |
| 287 | 287 | ||
| 288 | attrbuf = kmalloc((tipc_genl_family.maxattr + 1) * | 288 | attrbuf = kmalloc_array(tipc_genl_family.maxattr + 1, |
| 289 | sizeof(struct nlattr *), GFP_KERNEL); | 289 | sizeof(struct nlattr *), |
| 290 | GFP_KERNEL); | ||
| 290 | if (!attrbuf) { | 291 | if (!attrbuf) { |
| 291 | err = -ENOMEM; | 292 | err = -ENOMEM; |
| 292 | goto trans_out; | 293 | goto trans_out; |
diff --git a/net/wireless/nl80211.c b/net/wireless/nl80211.c index 07514ca011b2..c7bbe5f0aae8 100644 --- a/net/wireless/nl80211.c +++ b/net/wireless/nl80211.c | |||
| @@ -10833,7 +10833,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev, | |||
| 10833 | struct nlattr **tb; | 10833 | struct nlattr **tb; |
| 10834 | int err; | 10834 | int err; |
| 10835 | 10835 | ||
| 10836 | tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL); | 10836 | tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL); |
| 10837 | if (!tb) | 10837 | if (!tb) |
| 10838 | return -ENOMEM; | 10838 | return -ENOMEM; |
| 10839 | 10839 | ||
| @@ -11793,7 +11793,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb, | |||
| 11793 | 11793 | ||
| 11794 | func->srf_num_macs = n_entries; | 11794 | func->srf_num_macs = n_entries; |
| 11795 | func->srf_macs = | 11795 | func->srf_macs = |
| 11796 | kzalloc(sizeof(*func->srf_macs) * n_entries, | 11796 | kcalloc(n_entries, sizeof(*func->srf_macs), |
| 11797 | GFP_KERNEL); | 11797 | GFP_KERNEL); |
| 11798 | if (!func->srf_macs) { | 11798 | if (!func->srf_macs) { |
| 11799 | err = -ENOMEM; | 11799 | err = -ENOMEM; |
diff --git a/security/apparmor/policy_unpack.c b/security/apparmor/policy_unpack.c index b9e6b2cafa69..0e566a01d217 100644 --- a/security/apparmor/policy_unpack.c +++ b/security/apparmor/policy_unpack.c | |||
| @@ -475,7 +475,7 @@ static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile) | |||
| 475 | /* currently 4 exec bits and entries 0-3 are reserved iupcx */ | 475 | /* currently 4 exec bits and entries 0-3 are reserved iupcx */ |
| 476 | if (size > 16 - 4) | 476 | if (size > 16 - 4) |
| 477 | goto fail; | 477 | goto fail; |
| 478 | profile->file.trans.table = kzalloc(sizeof(char *) * size, | 478 | profile->file.trans.table = kcalloc(size, sizeof(char *), |
| 479 | GFP_KERNEL); | 479 | GFP_KERNEL); |
| 480 | if (!profile->file.trans.table) | 480 | if (!profile->file.trans.table) |
| 481 | goto fail; | 481 | goto fail; |
diff --git a/security/keys/trusted.c b/security/keys/trusted.c index 423776682025..b69d3b1777c2 100644 --- a/security/keys/trusted.c +++ b/security/keys/trusted.c | |||
| @@ -1148,7 +1148,7 @@ static long trusted_read(const struct key *key, char __user *buffer, | |||
| 1148 | return -EINVAL; | 1148 | return -EINVAL; |
| 1149 | 1149 | ||
| 1150 | if (buffer && buflen >= 2 * p->blob_len) { | 1150 | if (buffer && buflen >= 2 * p->blob_len) { |
| 1151 | ascii_buf = kmalloc(2 * p->blob_len, GFP_KERNEL); | 1151 | ascii_buf = kmalloc_array(2, p->blob_len, GFP_KERNEL); |
| 1152 | if (!ascii_buf) | 1152 | if (!ascii_buf) |
| 1153 | return -ENOMEM; | 1153 | return -ENOMEM; |
| 1154 | 1154 | ||
diff --git a/security/selinux/ss/services.c b/security/selinux/ss/services.c index a2d44824121c..dd2ceec06fef 100644 --- a/security/selinux/ss/services.c +++ b/security/selinux/ss/services.c | |||
| @@ -2118,7 +2118,7 @@ int security_load_policy(struct selinux_state *state, void *data, size_t len) | |||
| 2118 | int rc = 0; | 2118 | int rc = 0; |
| 2119 | struct policy_file file = { data, len }, *fp = &file; | 2119 | struct policy_file file = { data, len }, *fp = &file; |
| 2120 | 2120 | ||
| 2121 | oldpolicydb = kzalloc(2 * sizeof(*oldpolicydb), GFP_KERNEL); | 2121 | oldpolicydb = kcalloc(2, sizeof(*oldpolicydb), GFP_KERNEL); |
| 2122 | if (!oldpolicydb) { | 2122 | if (!oldpolicydb) { |
| 2123 | rc = -ENOMEM; | 2123 | rc = -ENOMEM; |
| 2124 | goto out; | 2124 | goto out; |
diff --git a/sound/core/pcm_compat.c b/sound/core/pcm_compat.c index 39d853bfa5ac..946ab080ac00 100644 --- a/sound/core/pcm_compat.c +++ b/sound/core/pcm_compat.c | |||
| @@ -426,7 +426,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, | |||
| 426 | get_user(frames, &data32->frames)) | 426 | get_user(frames, &data32->frames)) |
| 427 | return -EFAULT; | 427 | return -EFAULT; |
| 428 | bufptr = compat_ptr(buf); | 428 | bufptr = compat_ptr(buf); |
| 429 | bufs = kmalloc(sizeof(void __user *) * ch, GFP_KERNEL); | 429 | bufs = kmalloc_array(ch, sizeof(void __user *), GFP_KERNEL); |
| 430 | if (bufs == NULL) | 430 | if (bufs == NULL) |
| 431 | return -ENOMEM; | 431 | return -ENOMEM; |
| 432 | for (i = 0; i < ch; i++) { | 432 | for (i = 0; i < ch; i++) { |
diff --git a/sound/core/pcm_native.c b/sound/core/pcm_native.c index 04c6301394d0..cecc79772c94 100644 --- a/sound/core/pcm_native.c +++ b/sound/core/pcm_native.c | |||
| @@ -3072,7 +3072,7 @@ static ssize_t snd_pcm_readv(struct kiocb *iocb, struct iov_iter *to) | |||
| 3072 | if (!frame_aligned(runtime, to->iov->iov_len)) | 3072 | if (!frame_aligned(runtime, to->iov->iov_len)) |
| 3073 | return -EINVAL; | 3073 | return -EINVAL; |
| 3074 | frames = bytes_to_samples(runtime, to->iov->iov_len); | 3074 | frames = bytes_to_samples(runtime, to->iov->iov_len); |
| 3075 | bufs = kmalloc(sizeof(void *) * to->nr_segs, GFP_KERNEL); | 3075 | bufs = kmalloc_array(to->nr_segs, sizeof(void *), GFP_KERNEL); |
| 3076 | if (bufs == NULL) | 3076 | if (bufs == NULL) |
| 3077 | return -ENOMEM; | 3077 | return -ENOMEM; |
| 3078 | for (i = 0; i < to->nr_segs; ++i) | 3078 | for (i = 0; i < to->nr_segs; ++i) |
| @@ -3107,7 +3107,7 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from) | |||
| 3107 | !frame_aligned(runtime, from->iov->iov_len)) | 3107 | !frame_aligned(runtime, from->iov->iov_len)) |
| 3108 | return -EINVAL; | 3108 | return -EINVAL; |
| 3109 | frames = bytes_to_samples(runtime, from->iov->iov_len); | 3109 | frames = bytes_to_samples(runtime, from->iov->iov_len); |
| 3110 | bufs = kmalloc(sizeof(void *) * from->nr_segs, GFP_KERNEL); | 3110 | bufs = kmalloc_array(from->nr_segs, sizeof(void *), GFP_KERNEL); |
| 3111 | if (bufs == NULL) | 3111 | if (bufs == NULL) |
| 3112 | return -ENOMEM; | 3112 | return -ENOMEM; |
| 3113 | for (i = 0; i < from->nr_segs; ++i) | 3113 | for (i = 0; i < from->nr_segs; ++i) |
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c index ab1112e90f88..a4c8543176b2 100644 --- a/sound/core/seq/seq_memory.c +++ b/sound/core/seq/seq_memory.c | |||
| @@ -389,7 +389,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) | |||
| 389 | if (snd_BUG_ON(!pool)) | 389 | if (snd_BUG_ON(!pool)) |
| 390 | return -EINVAL; | 390 | return -EINVAL; |
| 391 | 391 | ||
| 392 | cellptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size); | 392 | cellptr = vmalloc(array_size(sizeof(struct snd_seq_event_cell), |
| 393 | pool->size)); | ||
| 393 | if (!cellptr) | 394 | if (!cellptr) |
| 394 | return -ENOMEM; | 395 | return -ENOMEM; |
| 395 | 396 | ||
diff --git a/sound/core/seq/seq_midi_emul.c b/sound/core/seq/seq_midi_emul.c index 9e2912e3e80f..288f839a554b 100644 --- a/sound/core/seq/seq_midi_emul.c +++ b/sound/core/seq/seq_midi_emul.c | |||
| @@ -657,7 +657,7 @@ static struct snd_midi_channel *snd_midi_channel_init_set(int n) | |||
| 657 | struct snd_midi_channel *chan; | 657 | struct snd_midi_channel *chan; |
| 658 | int i; | 658 | int i; |
| 659 | 659 | ||
| 660 | chan = kmalloc(n * sizeof(struct snd_midi_channel), GFP_KERNEL); | 660 | chan = kmalloc_array(n, sizeof(struct snd_midi_channel), GFP_KERNEL); |
| 661 | if (chan) { | 661 | if (chan) { |
| 662 | for (i = 0; i < n; i++) | 662 | for (i = 0; i < n; i++) |
| 663 | snd_midi_channel_init(chan+i, i); | 663 | snd_midi_channel_init(chan+i, i); |
diff --git a/sound/firewire/fireface/ff-protocol-ff400.c b/sound/firewire/fireface/ff-protocol-ff400.c index 12aa15df435d..ad7a0a32557d 100644 --- a/sound/firewire/fireface/ff-protocol-ff400.c +++ b/sound/firewire/fireface/ff-protocol-ff400.c | |||
| @@ -147,7 +147,7 @@ static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable) | |||
| 147 | __le32 *reg; | 147 | __le32 *reg; |
| 148 | int i; | 148 | int i; |
| 149 | 149 | ||
| 150 | reg = kzalloc(sizeof(__le32) * 18, GFP_KERNEL); | 150 | reg = kcalloc(18, sizeof(__le32), GFP_KERNEL); |
| 151 | if (reg == NULL) | 151 | if (reg == NULL) |
| 152 | return -ENOMEM; | 152 | return -ENOMEM; |
| 153 | 153 | ||
diff --git a/sound/firewire/packets-buffer.c b/sound/firewire/packets-buffer.c index ea1506679c66..1ebf00c83409 100644 --- a/sound/firewire/packets-buffer.c +++ b/sound/firewire/packets-buffer.c | |||
| @@ -27,7 +27,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit, | |||
| 27 | void *p; | 27 | void *p; |
| 28 | int err; | 28 | int err; |
| 29 | 29 | ||
| 30 | b->packets = kmalloc(count * sizeof(*b->packets), GFP_KERNEL); | 30 | b->packets = kmalloc_array(count, sizeof(*b->packets), GFP_KERNEL); |
| 31 | if (!b->packets) { | 31 | if (!b->packets) { |
| 32 | err = -ENOMEM; | 32 | err = -ENOMEM; |
| 33 | goto error; | 33 | goto error; |
diff --git a/sound/oss/dmasound/dmasound_core.c b/sound/oss/dmasound/dmasound_core.c index 8c0f8a9ee0ba..fc9bcd47d6a4 100644 --- a/sound/oss/dmasound/dmasound_core.c +++ b/sound/oss/dmasound/dmasound_core.c | |||
| @@ -420,7 +420,7 @@ static int sq_allocate_buffers(struct sound_queue *sq, int num, int size) | |||
| 420 | return 0; | 420 | return 0; |
| 421 | sq->numBufs = num; | 421 | sq->numBufs = num; |
| 422 | sq->bufSize = size; | 422 | sq->bufSize = size; |
| 423 | sq->buffers = kmalloc (num * sizeof(char *), GFP_KERNEL); | 423 | sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL); |
| 424 | if (!sq->buffers) | 424 | if (!sq->buffers) |
| 425 | return -ENOMEM; | 425 | return -ENOMEM; |
| 426 | for (i = 0; i < num; i++) { | 426 | for (i = 0; i < num; i++) { |
diff --git a/sound/pci/cs46xx/cs46xx_lib.c b/sound/pci/cs46xx/cs46xx_lib.c index ed1251c5f449..146e1a3498c7 100644 --- a/sound/pci/cs46xx/cs46xx_lib.c +++ b/sound/pci/cs46xx/cs46xx_lib.c | |||
| @@ -460,7 +460,7 @@ static int load_firmware(struct snd_cs46xx *chip, | |||
| 460 | entry->size = le32_to_cpu(fwdat[fwlen++]); | 460 | entry->size = le32_to_cpu(fwdat[fwlen++]); |
| 461 | if (fwlen + entry->size > fwsize) | 461 | if (fwlen + entry->size > fwsize) |
| 462 | goto error_inval; | 462 | goto error_inval; |
| 463 | entry->data = kmalloc(entry->size * 4, GFP_KERNEL); | 463 | entry->data = kmalloc_array(entry->size, 4, GFP_KERNEL); |
| 464 | if (!entry->data) | 464 | if (!entry->data) |
| 465 | goto error; | 465 | goto error; |
| 466 | memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4); | 466 | memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4); |
| @@ -4036,8 +4036,9 @@ int snd_cs46xx_create(struct snd_card *card, | |||
| 4036 | snd_cs46xx_proc_init(card, chip); | 4036 | snd_cs46xx_proc_init(card, chip); |
| 4037 | 4037 | ||
| 4038 | #ifdef CONFIG_PM_SLEEP | 4038 | #ifdef CONFIG_PM_SLEEP |
| 4039 | chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) * | 4039 | chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs), |
| 4040 | ARRAY_SIZE(saved_regs), GFP_KERNEL); | 4040 | sizeof(*chip->saved_regs), |
| 4041 | GFP_KERNEL); | ||
| 4041 | if (!chip->saved_regs) { | 4042 | if (!chip->saved_regs) { |
| 4042 | snd_cs46xx_free(chip); | 4043 | snd_cs46xx_free(chip); |
| 4043 | return -ENOMEM; | 4044 | return -ENOMEM; |
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c index c44eadef64ae..598d140bb7cb 100644 --- a/sound/pci/cs46xx/dsp_spos.c +++ b/sound/pci/cs46xx/dsp_spos.c | |||
| @@ -240,10 +240,13 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) | |||
| 240 | return NULL; | 240 | return NULL; |
| 241 | 241 | ||
| 242 | /* better to use vmalloc for this big table */ | 242 | /* better to use vmalloc for this big table */ |
| 243 | ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) * | 243 | ins->symbol_table.symbols = |
| 244 | DSP_MAX_SYMBOLS); | 244 | vmalloc(array_size(DSP_MAX_SYMBOLS, |
| 245 | sizeof(struct dsp_symbol_entry))); | ||
| 245 | ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL); | 246 | ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL); |
| 246 | ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL); | 247 | ins->modules = kmalloc_array(DSP_MAX_MODULES, |
| 248 | sizeof(struct dsp_module_desc), | ||
| 249 | GFP_KERNEL); | ||
| 247 | if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) { | 250 | if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) { |
| 248 | cs46xx_dsp_spos_destroy(chip); | 251 | cs46xx_dsp_spos_destroy(chip); |
| 249 | goto error; | 252 | goto error; |
diff --git a/sound/pci/ctxfi/ctatc.c b/sound/pci/ctxfi/ctatc.c index 908658a00377..2ada8444abd9 100644 --- a/sound/pci/ctxfi/ctatc.c +++ b/sound/pci/ctxfi/ctatc.c | |||
| @@ -275,7 +275,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 275 | 275 | ||
| 276 | /* Get AMIXER resource */ | 276 | /* Get AMIXER resource */ |
| 277 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 277 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
| 278 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 278 | apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); |
| 279 | if (!apcm->amixers) { | 279 | if (!apcm->amixers) { |
| 280 | err = -ENOMEM; | 280 | err = -ENOMEM; |
| 281 | goto error1; | 281 | goto error1; |
| @@ -543,18 +543,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) | |||
| 543 | } | 543 | } |
| 544 | 544 | ||
| 545 | if (n_srcc) { | 545 | if (n_srcc) { |
| 546 | apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL); | 546 | apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL); |
| 547 | if (!apcm->srccs) | 547 | if (!apcm->srccs) |
| 548 | return -ENOMEM; | 548 | return -ENOMEM; |
| 549 | } | 549 | } |
| 550 | if (n_amixer) { | 550 | if (n_amixer) { |
| 551 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 551 | apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); |
| 552 | if (!apcm->amixers) { | 552 | if (!apcm->amixers) { |
| 553 | err = -ENOMEM; | 553 | err = -ENOMEM; |
| 554 | goto error1; | 554 | goto error1; |
| 555 | } | 555 | } |
| 556 | } | 556 | } |
| 557 | apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL); | 557 | apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL); |
| 558 | if (!apcm->srcimps) { | 558 | if (!apcm->srcimps) { |
| 559 | err = -ENOMEM; | 559 | err = -ENOMEM; |
| 560 | goto error1; | 560 | goto error1; |
| @@ -819,7 +819,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc, | |||
| 819 | 819 | ||
| 820 | /* Get AMIXER resource */ | 820 | /* Get AMIXER resource */ |
| 821 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; | 821 | n_amixer = (n_amixer < 2) ? 2 : n_amixer; |
| 822 | apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL); | 822 | apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL); |
| 823 | if (!apcm->amixers) { | 823 | if (!apcm->amixers) { |
| 824 | err = -ENOMEM; | 824 | err = -ENOMEM; |
| 825 | goto error1; | 825 | goto error1; |
| @@ -1378,19 +1378,19 @@ static int atc_get_resources(struct ct_atc *atc) | |||
| 1378 | num_daios = ((atc->model == CTSB1270) ? 8 : 7); | 1378 | num_daios = ((atc->model == CTSB1270) ? 8 : 7); |
| 1379 | num_srcs = ((atc->model == CTSB1270) ? 6 : 4); | 1379 | num_srcs = ((atc->model == CTSB1270) ? 6 : 4); |
| 1380 | 1380 | ||
| 1381 | atc->daios = kzalloc(sizeof(void *)*num_daios, GFP_KERNEL); | 1381 | atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL); |
| 1382 | if (!atc->daios) | 1382 | if (!atc->daios) |
| 1383 | return -ENOMEM; | 1383 | return -ENOMEM; |
| 1384 | 1384 | ||
| 1385 | atc->srcs = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL); | 1385 | atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); |
| 1386 | if (!atc->srcs) | 1386 | if (!atc->srcs) |
| 1387 | return -ENOMEM; | 1387 | return -ENOMEM; |
| 1388 | 1388 | ||
| 1389 | atc->srcimps = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL); | 1389 | atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL); |
| 1390 | if (!atc->srcimps) | 1390 | if (!atc->srcimps) |
| 1391 | return -ENOMEM; | 1391 | return -ENOMEM; |
| 1392 | 1392 | ||
| 1393 | atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL); | 1393 | atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL); |
| 1394 | if (!atc->pcm) | 1394 | if (!atc->pcm) |
| 1395 | return -ENOMEM; | 1395 | return -ENOMEM; |
| 1396 | 1396 | ||
diff --git a/sound/pci/ctxfi/ctdaio.c b/sound/pci/ctxfi/ctdaio.c index 7f089cb433e1..f35a7341e446 100644 --- a/sound/pci/ctxfi/ctdaio.c +++ b/sound/pci/ctxfi/ctdaio.c | |||
| @@ -398,7 +398,8 @@ static int dao_rsc_init(struct dao *dao, | |||
| 398 | if (err) | 398 | if (err) |
| 399 | return err; | 399 | return err; |
| 400 | 400 | ||
| 401 | dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL); | 401 | dao->imappers = kzalloc(array3_size(sizeof(void *), desc->msr, 2), |
| 402 | GFP_KERNEL); | ||
| 402 | if (!dao->imappers) { | 403 | if (!dao->imappers) { |
| 403 | err = -ENOMEM; | 404 | err = -ENOMEM; |
| 404 | goto error1; | 405 | goto error1; |
diff --git a/sound/pci/ctxfi/ctmixer.c b/sound/pci/ctxfi/ctmixer.c index 4f4a2a5dedb8..db710d0a609f 100644 --- a/sound/pci/ctxfi/ctmixer.c +++ b/sound/pci/ctxfi/ctmixer.c | |||
| @@ -910,13 +910,14 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer) | |||
| 910 | if (!mixer) | 910 | if (!mixer) |
| 911 | return -ENOMEM; | 911 | return -ENOMEM; |
| 912 | 912 | ||
| 913 | mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM), | 913 | mixer->amixers = kcalloc(NUM_CT_AMIXERS * CHN_NUM, sizeof(void *), |
| 914 | GFP_KERNEL); | 914 | GFP_KERNEL); |
| 915 | if (!mixer->amixers) { | 915 | if (!mixer->amixers) { |
| 916 | err = -ENOMEM; | 916 | err = -ENOMEM; |
| 917 | goto error1; | 917 | goto error1; |
| 918 | } | 918 | } |
| 919 | mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL); | 919 | mixer->sums = kcalloc(NUM_CT_SUMS * CHN_NUM, sizeof(void *), |
| 920 | GFP_KERNEL); | ||
| 920 | if (!mixer->sums) { | 921 | if (!mixer->sums) { |
| 921 | err = -ENOMEM; | 922 | err = -ENOMEM; |
| 922 | goto error2; | 923 | goto error2; |
diff --git a/sound/pci/ctxfi/ctsrc.c b/sound/pci/ctxfi/ctsrc.c index bb4c9c3c89ae..a4fc10723fc6 100644 --- a/sound/pci/ctxfi/ctsrc.c +++ b/sound/pci/ctxfi/ctsrc.c | |||
| @@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp, | |||
| 679 | return err; | 679 | return err; |
| 680 | 680 | ||
| 681 | /* Reserve memory for imapper nodes */ | 681 | /* Reserve memory for imapper nodes */ |
| 682 | srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr, | 682 | srcimp->imappers = kcalloc(desc->msr, sizeof(struct imapper), |
| 683 | GFP_KERNEL); | 683 | GFP_KERNEL); |
| 684 | if (!srcimp->imappers) { | 684 | if (!srcimp->imappers) { |
| 685 | err = -ENOMEM; | 685 | err = -ENOMEM; |
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c index 18267de3a269..61f85ff91cd9 100644 --- a/sound/pci/emu10k1/emu10k1_main.c +++ b/sound/pci/emu10k1/emu10k1_main.c | |||
| @@ -1941,9 +1941,10 @@ int snd_emu10k1_create(struct snd_card *card, | |||
| 1941 | (unsigned long)emu->ptb_pages.addr, | 1941 | (unsigned long)emu->ptb_pages.addr, |
| 1942 | (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes)); | 1942 | (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes)); |
| 1943 | 1943 | ||
| 1944 | emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *)); | 1944 | emu->page_ptr_table = vmalloc(array_size(sizeof(void *), |
| 1945 | emu->page_addr_table = vmalloc(emu->max_cache_pages * | 1945 | emu->max_cache_pages)); |
| 1946 | sizeof(unsigned long)); | 1946 | emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long), |
| 1947 | emu->max_cache_pages)); | ||
| 1947 | if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { | 1948 | if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { |
| 1948 | err = -ENOMEM; | 1949 | err = -ENOMEM; |
| 1949 | goto error; | 1950 | goto error; |
| @@ -2099,7 +2100,7 @@ static int alloc_pm_buffer(struct snd_emu10k1 *emu) | |||
| 2099 | size = ARRAY_SIZE(saved_regs); | 2100 | size = ARRAY_SIZE(saved_regs); |
| 2100 | if (emu->audigy) | 2101 | if (emu->audigy) |
| 2101 | size += ARRAY_SIZE(saved_regs_audigy); | 2102 | size += ARRAY_SIZE(saved_regs_audigy); |
| 2102 | emu->saved_ptr = vmalloc(4 * NUM_G * size); | 2103 | emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size)); |
| 2103 | if (!emu->saved_ptr) | 2104 | if (!emu->saved_ptr) |
| 2104 | return -ENOMEM; | 2105 | return -ENOMEM; |
| 2105 | if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) | 2106 | if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) |
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c index b45a01bb73e5..de2ecbe95d6c 100644 --- a/sound/pci/emu10k1/emufx.c +++ b/sound/pci/emu10k1/emufx.c | |||
| @@ -2683,16 +2683,16 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) | |||
| 2683 | int len; | 2683 | int len; |
| 2684 | 2684 | ||
| 2685 | len = emu->audigy ? 0x200 : 0x100; | 2685 | len = emu->audigy ? 0x200 : 0x100; |
| 2686 | emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL); | 2686 | emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL); |
| 2687 | if (! emu->saved_gpr) | 2687 | if (! emu->saved_gpr) |
| 2688 | return -ENOMEM; | 2688 | return -ENOMEM; |
| 2689 | len = emu->audigy ? 0x100 : 0xa0; | 2689 | len = emu->audigy ? 0x100 : 0xa0; |
| 2690 | emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL); | 2690 | emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL); |
| 2691 | emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL); | 2691 | emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL); |
| 2692 | if (! emu->tram_val_saved || ! emu->tram_addr_saved) | 2692 | if (! emu->tram_val_saved || ! emu->tram_addr_saved) |
| 2693 | return -ENOMEM; | 2693 | return -ENOMEM; |
| 2694 | len = emu->audigy ? 2 * 1024 : 2 * 512; | 2694 | len = emu->audigy ? 2 * 1024 : 2 * 512; |
| 2695 | emu->saved_icode = vmalloc(len * 4); | 2695 | emu->saved_icode = vmalloc(array_size(len, 4)); |
| 2696 | if (! emu->saved_icode) | 2696 | if (! emu->saved_icode) |
| 2697 | return -ENOMEM; | 2697 | return -ENOMEM; |
| 2698 | return 0; | 2698 | return 0; |
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c index a30da78a95b7..4948b95f6665 100644 --- a/sound/pci/emu10k1/p16v.c +++ b/sound/pci/emu10k1/p16v.c | |||
| @@ -874,7 +874,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu) | |||
| 874 | 874 | ||
| 875 | int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) | 875 | int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) |
| 876 | { | 876 | { |
| 877 | emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); | 877 | emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80)); |
| 878 | if (! emu->p16v_saved) | 878 | if (! emu->p16v_saved) |
| 879 | return -ENOMEM; | 879 | return -ENOMEM; |
| 880 | return 0; | 880 | return 0; |
diff --git a/sound/pci/hda/hda_codec.c b/sound/pci/hda/hda_codec.c index 08151f3c0b13..d91c87e41756 100644 --- a/sound/pci/hda/hda_codec.c +++ b/sound/pci/hda/hda_codec.c | |||
| @@ -158,7 +158,7 @@ static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid) | |||
| 158 | len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list)); | 158 | len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list)); |
| 159 | if (len == -ENOSPC) { | 159 | if (len == -ENOSPC) { |
| 160 | len = snd_hda_get_num_raw_conns(codec, nid); | 160 | len = snd_hda_get_num_raw_conns(codec, nid); |
| 161 | result = kmalloc(sizeof(hda_nid_t) * len, GFP_KERNEL); | 161 | result = kmalloc_array(len, sizeof(hda_nid_t), GFP_KERNEL); |
| 162 | if (!result) | 162 | if (!result) |
| 163 | return -ENOMEM; | 163 | return -ENOMEM; |
| 164 | len = snd_hda_get_raw_connections(codec, nid, result, len); | 164 | len = snd_hda_get_raw_connections(codec, nid, result, len); |
| @@ -438,7 +438,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) | |||
| 438 | int i; | 438 | int i; |
| 439 | hda_nid_t nid; | 439 | hda_nid_t nid; |
| 440 | 440 | ||
| 441 | codec->wcaps = kmalloc(codec->core.num_nodes * 4, GFP_KERNEL); | 441 | codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL); |
| 442 | if (!codec->wcaps) | 442 | if (!codec->wcaps) |
| 443 | return -ENOMEM; | 443 | return -ENOMEM; |
| 444 | nid = codec->core.start_nid; | 444 | nid = codec->core.start_nid; |
diff --git a/sound/pci/hda/hda_proc.c b/sound/pci/hda/hda_proc.c index 033aa84365b9..c6b778b2580c 100644 --- a/sound/pci/hda/hda_proc.c +++ b/sound/pci/hda/hda_proc.c | |||
| @@ -825,8 +825,9 @@ static void print_codec_info(struct snd_info_entry *entry, | |||
| 825 | if (wid_caps & AC_WCAP_CONN_LIST) { | 825 | if (wid_caps & AC_WCAP_CONN_LIST) { |
| 826 | conn_len = snd_hda_get_num_raw_conns(codec, nid); | 826 | conn_len = snd_hda_get_num_raw_conns(codec, nid); |
| 827 | if (conn_len > 0) { | 827 | if (conn_len > 0) { |
| 828 | conn = kmalloc(sizeof(hda_nid_t) * conn_len, | 828 | conn = kmalloc_array(conn_len, |
| 829 | GFP_KERNEL); | 829 | sizeof(hda_nid_t), |
| 830 | GFP_KERNEL); | ||
| 830 | if (!conn) | 831 | if (!conn) |
| 831 | return; | 832 | return; |
| 832 | if (snd_hda_get_raw_connections(codec, nid, conn, | 833 | if (snd_hda_get_raw_connections(codec, nid, conn, |
diff --git a/sound/pci/hda/patch_ca0132.c b/sound/pci/hda/patch_ca0132.c index 292e2c592c17..04e949aa01ad 100644 --- a/sound/pci/hda/patch_ca0132.c +++ b/sound/pci/hda/patch_ca0132.c | |||
| @@ -7482,7 +7482,9 @@ static int ca0132_prepare_verbs(struct hda_codec *codec) | |||
| 7482 | spec->chip_init_verbs = ca0132_init_verbs0; | 7482 | spec->chip_init_verbs = ca0132_init_verbs0; |
| 7483 | if (spec->quirk == QUIRK_SBZ) | 7483 | if (spec->quirk == QUIRK_SBZ) |
| 7484 | spec->sbz_init_verbs = sbz_init_verbs; | 7484 | spec->sbz_init_verbs = sbz_init_verbs; |
| 7485 | spec->spec_init_verbs = kzalloc(sizeof(struct hda_verb) * NUM_SPEC_VERBS, GFP_KERNEL); | 7485 | spec->spec_init_verbs = kcalloc(NUM_SPEC_VERBS, |
| 7486 | sizeof(struct hda_verb), | ||
| 7487 | GFP_KERNEL); | ||
| 7486 | if (!spec->spec_init_verbs) | 7488 | if (!spec->spec_init_verbs) |
| 7487 | return -ENOMEM; | 7489 | return -ENOMEM; |
| 7488 | 7490 | ||
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c index 8f20dec97843..224e942f556d 100644 --- a/sound/pci/maestro3.c +++ b/sound/pci/maestro3.c | |||
| @@ -2657,7 +2657,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, | |||
| 2657 | chip->irq = pci->irq; | 2657 | chip->irq = pci->irq; |
| 2658 | 2658 | ||
| 2659 | #ifdef CONFIG_PM_SLEEP | 2659 | #ifdef CONFIG_PM_SLEEP |
| 2660 | chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); | 2660 | chip->suspend_mem = |
| 2661 | vmalloc(array_size(sizeof(u16), | ||
| 2662 | REV_B_CODE_MEMORY_LENGTH + | ||
| 2663 | REV_B_DATA_MEMORY_LENGTH)); | ||
| 2661 | if (chip->suspend_mem == NULL) | 2664 | if (chip->suspend_mem == NULL) |
| 2662 | dev_warn(card->dev, "can't allocate apm buffer\n"); | 2665 | dev_warn(card->dev, "can't allocate apm buffer\n"); |
| 2663 | #endif | 2666 | #endif |
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c index eabd84d9ffee..49c64fae3466 100644 --- a/sound/pci/trident/trident_main.c +++ b/sound/pci/trident/trident_main.c | |||
| @@ -3362,7 +3362,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident) | |||
| 3362 | trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); | 3362 | trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); |
| 3363 | trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); | 3363 | trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); |
| 3364 | /* allocate shadow TLB page table (virtual addresses) */ | 3364 | /* allocate shadow TLB page table (virtual addresses) */ |
| 3365 | trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); | 3365 | trident->tlb.shadow_entries = |
| 3366 | vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES, | ||
| 3367 | sizeof(unsigned long))); | ||
| 3366 | if (!trident->tlb.shadow_entries) | 3368 | if (!trident->tlb.shadow_entries) |
| 3367 | return -ENOMEM; | 3369 | return -ENOMEM; |
| 3368 | 3370 | ||
diff --git a/sound/pci/via82xx.c b/sound/pci/via82xx.c index 3a1c0b8b4ea2..c488c5afa195 100644 --- a/sound/pci/via82xx.c +++ b/sound/pci/via82xx.c | |||
| @@ -439,7 +439,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre | |||
| 439 | return -ENOMEM; | 439 | return -ENOMEM; |
| 440 | } | 440 | } |
| 441 | if (! dev->idx_table) { | 441 | if (! dev->idx_table) { |
| 442 | dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL); | 442 | dev->idx_table = kmalloc_array(VIA_TABLE_SIZE, |
| 443 | sizeof(*dev->idx_table), | ||
| 444 | GFP_KERNEL); | ||
| 443 | if (! dev->idx_table) | 445 | if (! dev->idx_table) |
| 444 | return -ENOMEM; | 446 | return -ENOMEM; |
| 445 | } | 447 | } |
diff --git a/sound/pci/via82xx_modem.c b/sound/pci/via82xx_modem.c index 8a69221c1b86..b13c8688cc8d 100644 --- a/sound/pci/via82xx_modem.c +++ b/sound/pci/via82xx_modem.c | |||
| @@ -292,7 +292,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre | |||
| 292 | return -ENOMEM; | 292 | return -ENOMEM; |
| 293 | } | 293 | } |
| 294 | if (! dev->idx_table) { | 294 | if (! dev->idx_table) { |
| 295 | dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL); | 295 | dev->idx_table = kmalloc_array(VIA_TABLE_SIZE, |
| 296 | sizeof(*dev->idx_table), | ||
| 297 | GFP_KERNEL); | ||
| 296 | if (! dev->idx_table) | 298 | if (! dev->idx_table) |
| 297 | return -ENOMEM; | 299 | return -ENOMEM; |
| 298 | } | 300 | } |
diff --git a/sound/pci/ymfpci/ymfpci_main.c b/sound/pci/ymfpci/ymfpci_main.c index 8ca2e41e5827..6f81396aadc9 100644 --- a/sound/pci/ymfpci/ymfpci_main.c +++ b/sound/pci/ymfpci/ymfpci_main.c | |||
| @@ -2435,8 +2435,8 @@ int snd_ymfpci_create(struct snd_card *card, | |||
| 2435 | goto free_chip; | 2435 | goto free_chip; |
| 2436 | 2436 | ||
| 2437 | #ifdef CONFIG_PM_SLEEP | 2437 | #ifdef CONFIG_PM_SLEEP |
| 2438 | chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32), | 2438 | chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32), |
| 2439 | GFP_KERNEL); | 2439 | GFP_KERNEL); |
| 2440 | if (chip->saved_regs == NULL) { | 2440 | if (chip->saved_regs == NULL) { |
| 2441 | err = -ENOMEM; | 2441 | err = -ENOMEM; |
| 2442 | goto free_chip; | 2442 | goto free_chip; |
diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index fb650659c3a3..a906560d0cdd 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c | |||
| @@ -339,8 +339,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) | |||
| 339 | { | 339 | { |
| 340 | struct au1xpsc_audio_dmadata *dmadata; | 340 | struct au1xpsc_audio_dmadata *dmadata; |
| 341 | 341 | ||
| 342 | dmadata = devm_kzalloc(&pdev->dev, | 342 | dmadata = devm_kcalloc(&pdev->dev, |
| 343 | 2 * sizeof(struct au1xpsc_audio_dmadata), | 343 | 2, sizeof(struct au1xpsc_audio_dmadata), |
| 344 | GFP_KERNEL); | 344 | GFP_KERNEL); |
| 345 | if (!dmadata) | 345 | if (!dmadata) |
| 346 | return -ENOMEM; | 346 | return -ENOMEM; |
diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index 6fa11888672d..38e4a8515709 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c | |||
| @@ -771,7 +771,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) | |||
| 771 | hcp->hcd = *hcd; | 771 | hcp->hcd = *hcd; |
| 772 | mutex_init(&hcp->current_stream_lock); | 772 | mutex_init(&hcp->current_stream_lock); |
| 773 | 773 | ||
| 774 | hcp->daidrv = devm_kzalloc(dev, dai_count * sizeof(*hcp->daidrv), | 774 | hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv), |
| 775 | GFP_KERNEL); | 775 | GFP_KERNEL); |
| 776 | if (!hcp->daidrv) | 776 | if (!hcp->daidrv) |
| 777 | return -ENOMEM; | 777 | return -ENOMEM; |
diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index 712384581ebf..1dc70f452c1b 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c | |||
| @@ -3449,8 +3449,9 @@ static int rt5645_probe(struct snd_soc_component *component) | |||
| 3449 | if (rt5645->pdata.long_name) | 3449 | if (rt5645->pdata.long_name) |
| 3450 | component->card->long_name = rt5645->pdata.long_name; | 3450 | component->card->long_name = rt5645->pdata.long_name; |
| 3451 | 3451 | ||
| 3452 | rt5645->eq_param = devm_kzalloc(component->dev, | 3452 | rt5645->eq_param = devm_kcalloc(component->dev, |
| 3453 | RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL); | 3453 | RT5645_HWEQ_NUM, sizeof(struct rt5645_eq_param_s), |
| 3454 | GFP_KERNEL); | ||
| 3454 | 3455 | ||
| 3455 | return 0; | 3456 | return 0; |
| 3456 | } | 3457 | } |
diff --git a/sound/soc/codecs/wm8904.c b/sound/soc/codecs/wm8904.c index f13ef334c0d7..9037a35b931d 100644 --- a/sound/soc/codecs/wm8904.c +++ b/sound/soc/codecs/wm8904.c | |||
| @@ -2023,8 +2023,9 @@ static void wm8904_handle_pdata(struct snd_soc_component *component) | |||
| 2023 | wm8904_get_drc_enum, wm8904_put_drc_enum); | 2023 | wm8904_get_drc_enum, wm8904_put_drc_enum); |
| 2024 | 2024 | ||
| 2025 | /* We need an array of texts for the enum API */ | 2025 | /* We need an array of texts for the enum API */ |
| 2026 | wm8904->drc_texts = kmalloc(sizeof(char *) | 2026 | wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs, |
| 2027 | * pdata->num_drc_cfgs, GFP_KERNEL); | 2027 | sizeof(char *), |
| 2028 | GFP_KERNEL); | ||
| 2028 | if (!wm8904->drc_texts) | 2029 | if (!wm8904->drc_texts) |
| 2029 | return; | 2030 | return; |
| 2030 | 2031 | ||
diff --git a/sound/soc/codecs/wm8958-dsp2.c b/sound/soc/codecs/wm8958-dsp2.c index 8d495220fa25..108e8bf42a34 100644 --- a/sound/soc/codecs/wm8958-dsp2.c +++ b/sound/soc/codecs/wm8958-dsp2.c | |||
| @@ -932,8 +932,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) | |||
| 932 | }; | 932 | }; |
| 933 | 933 | ||
| 934 | /* We need an array of texts for the enum API */ | 934 | /* We need an array of texts for the enum API */ |
| 935 | wm8994->mbc_texts = kmalloc(sizeof(char *) | 935 | wm8994->mbc_texts = kmalloc_array(pdata->num_mbc_cfgs, |
| 936 | * pdata->num_mbc_cfgs, GFP_KERNEL); | 936 | sizeof(char *), |
| 937 | GFP_KERNEL); | ||
| 937 | if (!wm8994->mbc_texts) | 938 | if (!wm8994->mbc_texts) |
| 938 | return; | 939 | return; |
| 939 | 940 | ||
| @@ -957,8 +958,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) | |||
| 957 | }; | 958 | }; |
| 958 | 959 | ||
| 959 | /* We need an array of texts for the enum API */ | 960 | /* We need an array of texts for the enum API */ |
| 960 | wm8994->vss_texts = kmalloc(sizeof(char *) | 961 | wm8994->vss_texts = kmalloc_array(pdata->num_vss_cfgs, |
| 961 | * pdata->num_vss_cfgs, GFP_KERNEL); | 962 | sizeof(char *), |
| 963 | GFP_KERNEL); | ||
| 962 | if (!wm8994->vss_texts) | 964 | if (!wm8994->vss_texts) |
| 963 | return; | 965 | return; |
| 964 | 966 | ||
| @@ -983,8 +985,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) | |||
| 983 | }; | 985 | }; |
| 984 | 986 | ||
| 985 | /* We need an array of texts for the enum API */ | 987 | /* We need an array of texts for the enum API */ |
| 986 | wm8994->vss_hpf_texts = kmalloc(sizeof(char *) | 988 | wm8994->vss_hpf_texts = kmalloc_array(pdata->num_vss_hpf_cfgs, |
| 987 | * pdata->num_vss_hpf_cfgs, GFP_KERNEL); | 989 | sizeof(char *), |
| 990 | GFP_KERNEL); | ||
| 988 | if (!wm8994->vss_hpf_texts) | 991 | if (!wm8994->vss_hpf_texts) |
| 989 | return; | 992 | return; |
| 990 | 993 | ||
| @@ -1010,8 +1013,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) | |||
| 1010 | }; | 1013 | }; |
| 1011 | 1014 | ||
| 1012 | /* We need an array of texts for the enum API */ | 1015 | /* We need an array of texts for the enum API */ |
| 1013 | wm8994->enh_eq_texts = kmalloc(sizeof(char *) | 1016 | wm8994->enh_eq_texts = kmalloc_array(pdata->num_enh_eq_cfgs, |
| 1014 | * pdata->num_enh_eq_cfgs, GFP_KERNEL); | 1017 | sizeof(char *), |
| 1018 | GFP_KERNEL); | ||
| 1015 | if (!wm8994->enh_eq_texts) | 1019 | if (!wm8994->enh_eq_texts) |
| 1016 | return; | 1020 | return; |
| 1017 | 1021 | ||
diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index 6e9e32a07259..7fdfdf3f6e67 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c | |||
| @@ -3298,8 +3298,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) | |||
| 3298 | }; | 3298 | }; |
| 3299 | 3299 | ||
| 3300 | /* We need an array of texts for the enum API */ | 3300 | /* We need an array of texts for the enum API */ |
| 3301 | wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev, | 3301 | wm8994->drc_texts = devm_kcalloc(wm8994->hubs.component->dev, |
| 3302 | sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); | 3302 | pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL); |
| 3303 | if (!wm8994->drc_texts) | 3303 | if (!wm8994->drc_texts) |
| 3304 | return; | 3304 | return; |
| 3305 | 3305 | ||
diff --git a/sound/soc/codecs/wm_adsp.c b/sound/soc/codecs/wm_adsp.c index 2175dccdf388..2fcdd84021a5 100644 --- a/sound/soc/codecs/wm_adsp.c +++ b/sound/soc/codecs/wm_adsp.c | |||
| @@ -1899,7 +1899,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, | |||
| 1899 | adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", | 1899 | adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n", |
| 1900 | pos + len, be32_to_cpu(val)); | 1900 | pos + len, be32_to_cpu(val)); |
| 1901 | 1901 | ||
| 1902 | alg = kzalloc(len * 2, GFP_KERNEL | GFP_DMA); | 1902 | alg = kcalloc(len, 2, GFP_KERNEL | GFP_DMA); |
| 1903 | if (!alg) | 1903 | if (!alg) |
| 1904 | return ERR_PTR(-ENOMEM); | 1904 | return ERR_PTR(-ENOMEM); |
| 1905 | 1905 | ||
diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 1f96c9dbe9c4..47c0c821d325 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c | |||
| @@ -1868,8 +1868,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
| 1868 | 1868 | ||
| 1869 | mcasp->num_serializer = pdata->num_serializer; | 1869 | mcasp->num_serializer = pdata->num_serializer; |
| 1870 | #ifdef CONFIG_PM_SLEEP | 1870 | #ifdef CONFIG_PM_SLEEP |
| 1871 | mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev, | 1871 | mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev, |
| 1872 | sizeof(u32) * mcasp->num_serializer, | 1872 | mcasp->num_serializer, sizeof(u32), |
| 1873 | GFP_KERNEL); | 1873 | GFP_KERNEL); |
| 1874 | if (!mcasp->context.xrsr_regs) { | 1874 | if (!mcasp->context.xrsr_regs) { |
| 1875 | ret = -ENOMEM; | 1875 | ret = -ENOMEM; |
| @@ -2004,13 +2004,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev) | |||
| 2004 | * bytes. | 2004 | * bytes. |
| 2005 | */ | 2005 | */ |
| 2006 | mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list = | 2006 | mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list = |
| 2007 | devm_kzalloc(mcasp->dev, sizeof(unsigned int) * | 2007 | devm_kcalloc(mcasp->dev, |
| 2008 | (32 + mcasp->num_serializer - 1), | 2008 | 32 + mcasp->num_serializer - 1, |
| 2009 | sizeof(unsigned int), | ||
| 2009 | GFP_KERNEL); | 2010 | GFP_KERNEL); |
| 2010 | 2011 | ||
| 2011 | mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list = | 2012 | mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list = |
| 2012 | devm_kzalloc(mcasp->dev, sizeof(unsigned int) * | 2013 | devm_kcalloc(mcasp->dev, |
| 2013 | (32 + mcasp->num_serializer - 1), | 2014 | 32 + mcasp->num_serializer - 1, |
| 2015 | sizeof(unsigned int), | ||
| 2014 | GFP_KERNEL); | 2016 | GFP_KERNEL); |
| 2015 | 2017 | ||
| 2016 | if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list || | 2018 | if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list || |
diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 1b6164249341..d93bacacbd5b 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c | |||
| @@ -296,8 +296,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) | |||
| 296 | if (num == 0) | 296 | if (num == 0) |
| 297 | return -EINVAL; | 297 | return -EINVAL; |
| 298 | 298 | ||
| 299 | dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); | 299 | dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); |
| 300 | dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); | 300 | dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); |
| 301 | if (!dai_props || !dai_link) | 301 | if (!dai_props || !dai_link) |
| 302 | return -ENOMEM; | 302 | return -ENOMEM; |
| 303 | 303 | ||
diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index a967aa143d51..095ef6426d42 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c | |||
| @@ -348,8 +348,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) | |||
| 348 | if (num == 0) | 348 | if (num == 0) |
| 349 | return -EINVAL; | 349 | return -EINVAL; |
| 350 | 350 | ||
| 351 | dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); | 351 | dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); |
| 352 | dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); | 352 | dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); |
| 353 | if (!dai_props || !dai_link) | 353 | if (!dai_props || !dai_link) |
| 354 | return -ENOMEM; | 354 | return -ENOMEM; |
| 355 | 355 | ||
diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 4a516c428b3d..8b374af86a6e 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c | |||
| @@ -340,8 +340,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node, | |||
| 340 | if (n <= 0) | 340 | if (n <= 0) |
| 341 | return -EINVAL; | 341 | return -EINVAL; |
| 342 | 342 | ||
| 343 | card->aux_dev = devm_kzalloc(dev, | 343 | card->aux_dev = devm_kcalloc(dev, |
| 344 | n * sizeof(*card->aux_dev), GFP_KERNEL); | 344 | n, sizeof(*card->aux_dev), GFP_KERNEL); |
| 345 | if (!card->aux_dev) | 345 | if (!card->aux_dev) |
| 346 | return -ENOMEM; | 346 | return -ENOMEM; |
| 347 | 347 | ||
| @@ -435,8 +435,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
| 435 | if (!priv) | 435 | if (!priv) |
| 436 | return -ENOMEM; | 436 | return -ENOMEM; |
| 437 | 437 | ||
| 438 | dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); | 438 | dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); |
| 439 | dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); | 439 | dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); |
| 440 | if (!dai_props || !dai_link) | 440 | if (!dai_props || !dai_link) |
| 441 | return -ENOMEM; | 441 | return -ENOMEM; |
| 442 | 442 | ||
diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index 48606c63562a..487716559deb 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c | |||
| @@ -246,8 +246,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) | |||
| 246 | 246 | ||
| 247 | num = of_get_child_count(np); | 247 | num = of_get_child_count(np); |
| 248 | 248 | ||
| 249 | dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); | 249 | dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); |
| 250 | dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); | 250 | dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); |
| 251 | if (!dai_props || !dai_link) | 251 | if (!dai_props || !dai_link) |
| 252 | return -ENOMEM; | 252 | return -ENOMEM; |
| 253 | 253 | ||
diff --git a/sound/soc/img/img-i2s-in.c b/sound/soc/img/img-i2s-in.c index d7fbb0a0a28b..388cefd7340a 100644 --- a/sound/soc/img/img-i2s-in.c +++ b/sound/soc/img/img-i2s-in.c | |||
| @@ -509,8 +509,8 @@ static int img_i2s_in_probe(struct platform_device *pdev) | |||
| 509 | 509 | ||
| 510 | pm_runtime_put(&pdev->dev); | 510 | pm_runtime_put(&pdev->dev); |
| 511 | 511 | ||
| 512 | i2s->suspend_ch_ctl = devm_kzalloc(dev, | 512 | i2s->suspend_ch_ctl = devm_kcalloc(dev, |
| 513 | sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL); | 513 | i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL); |
| 514 | if (!i2s->suspend_ch_ctl) { | 514 | if (!i2s->suspend_ch_ctl) { |
| 515 | ret = -ENOMEM; | 515 | ret = -ENOMEM; |
| 516 | goto err_suspend; | 516 | goto err_suspend; |
diff --git a/sound/soc/img/img-i2s-out.c b/sound/soc/img/img-i2s-out.c index 30a95bcef2db..fc2d1dac6333 100644 --- a/sound/soc/img/img-i2s-out.c +++ b/sound/soc/img/img-i2s-out.c | |||
| @@ -479,8 +479,8 @@ static int img_i2s_out_probe(struct platform_device *pdev) | |||
| 479 | return PTR_ERR(i2s->clk_ref); | 479 | return PTR_ERR(i2s->clk_ref); |
| 480 | } | 480 | } |
| 481 | 481 | ||
| 482 | i2s->suspend_ch_ctl = devm_kzalloc(dev, | 482 | i2s->suspend_ch_ctl = devm_kcalloc(dev, |
| 483 | sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL); | 483 | i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL); |
| 484 | if (!i2s->suspend_ch_ctl) | 484 | if (!i2s->suspend_ch_ctl) |
| 485 | return -ENOMEM; | 485 | return -ENOMEM; |
| 486 | 486 | ||
diff --git a/sound/soc/intel/common/sst-ipc.c b/sound/soc/intel/common/sst-ipc.c index 62f3a8e0ec87..dcff13802c00 100644 --- a/sound/soc/intel/common/sst-ipc.c +++ b/sound/soc/intel/common/sst-ipc.c | |||
| @@ -121,8 +121,8 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc) | |||
| 121 | { | 121 | { |
| 122 | int i; | 122 | int i; |
| 123 | 123 | ||
| 124 | ipc->msg = kzalloc(sizeof(struct ipc_message) * | 124 | ipc->msg = kcalloc(IPC_EMPTY_LIST_SIZE, sizeof(struct ipc_message), |
| 125 | IPC_EMPTY_LIST_SIZE, GFP_KERNEL); | 125 | GFP_KERNEL); |
| 126 | if (ipc->msg == NULL) | 126 | if (ipc->msg == NULL) |
| 127 | return -ENOMEM; | 127 | return -ENOMEM; |
| 128 | 128 | ||
diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index 2c5129782959..fcdc716754b6 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c | |||
| @@ -2428,8 +2428,10 @@ static int skl_tplg_get_token(struct device *dev, | |||
| 2428 | 2428 | ||
| 2429 | case SKL_TKN_U8_DYN_IN_PIN: | 2429 | case SKL_TKN_U8_DYN_IN_PIN: |
| 2430 | if (!mconfig->m_in_pin) | 2430 | if (!mconfig->m_in_pin) |
| 2431 | mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE * | 2431 | mconfig->m_in_pin = |
| 2432 | sizeof(*mconfig->m_in_pin), GFP_KERNEL); | 2432 | devm_kcalloc(dev, MAX_IN_QUEUE, |
| 2433 | sizeof(*mconfig->m_in_pin), | ||
| 2434 | GFP_KERNEL); | ||
| 2433 | if (!mconfig->m_in_pin) | 2435 | if (!mconfig->m_in_pin) |
| 2434 | return -ENOMEM; | 2436 | return -ENOMEM; |
| 2435 | 2437 | ||
| @@ -2439,8 +2441,10 @@ static int skl_tplg_get_token(struct device *dev, | |||
| 2439 | 2441 | ||
| 2440 | case SKL_TKN_U8_DYN_OUT_PIN: | 2442 | case SKL_TKN_U8_DYN_OUT_PIN: |
| 2441 | if (!mconfig->m_out_pin) | 2443 | if (!mconfig->m_out_pin) |
| 2442 | mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE * | 2444 | mconfig->m_out_pin = |
| 2443 | sizeof(*mconfig->m_in_pin), GFP_KERNEL); | 2445 | devm_kcalloc(dev, MAX_IN_QUEUE, |
| 2446 | sizeof(*mconfig->m_in_pin), | ||
| 2447 | GFP_KERNEL); | ||
| 2444 | if (!mconfig->m_out_pin) | 2448 | if (!mconfig->m_out_pin) |
| 2445 | return -ENOMEM; | 2449 | return -ENOMEM; |
| 2446 | 2450 | ||
| @@ -2852,14 +2856,14 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, | |||
| 2852 | mconfig->time_slot = dfw->time_slot; | 2856 | mconfig->time_slot = dfw->time_slot; |
| 2853 | mconfig->formats_config.caps_size = dfw->caps.caps_size; | 2857 | mconfig->formats_config.caps_size = dfw->caps.caps_size; |
| 2854 | 2858 | ||
| 2855 | mconfig->m_in_pin = devm_kzalloc(dev, | 2859 | mconfig->m_in_pin = devm_kcalloc(dev, |
| 2856 | MAX_IN_QUEUE * sizeof(*mconfig->m_in_pin), | 2860 | MAX_IN_QUEUE, sizeof(*mconfig->m_in_pin), |
| 2857 | GFP_KERNEL); | 2861 | GFP_KERNEL); |
| 2858 | if (!mconfig->m_in_pin) | 2862 | if (!mconfig->m_in_pin) |
| 2859 | return -ENOMEM; | 2863 | return -ENOMEM; |
| 2860 | 2864 | ||
| 2861 | mconfig->m_out_pin = devm_kzalloc(dev, | 2865 | mconfig->m_out_pin = devm_kcalloc(dev, |
| 2862 | MAX_OUT_QUEUE * sizeof(*mconfig->m_out_pin), | 2866 | MAX_OUT_QUEUE, sizeof(*mconfig->m_out_pin), |
| 2863 | GFP_KERNEL); | 2867 | GFP_KERNEL); |
| 2864 | if (!mconfig->m_out_pin) | 2868 | if (!mconfig->m_out_pin) |
| 2865 | return -ENOMEM; | 2869 | return -ENOMEM; |
diff --git a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c index 828d11c30c6a..968fba4d7533 100644 --- a/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +++ b/sound/soc/mediatek/mt2701/mt2701-afe-pcm.c | |||
| @@ -1347,7 +1347,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) | |||
| 1347 | afe->dev = &pdev->dev; | 1347 | afe->dev = &pdev->dev; |
| 1348 | dev = afe->dev; | 1348 | dev = afe->dev; |
| 1349 | 1349 | ||
| 1350 | afe_priv->i2s_path = devm_kzalloc(dev, afe_priv->soc->i2s_num * | 1350 | afe_priv->i2s_path = devm_kcalloc(dev, |
| 1351 | afe_priv->soc->i2s_num, | ||
| 1351 | sizeof(struct mt2701_i2s_path), | 1352 | sizeof(struct mt2701_i2s_path), |
| 1352 | GFP_KERNEL); | 1353 | GFP_KERNEL); |
| 1353 | if (!afe_priv->i2s_path) | 1354 | if (!afe_priv->i2s_path) |
diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 7c998ea4ebee..12d4513ebe8a 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c | |||
| @@ -425,8 +425,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) | |||
| 425 | if (priv->sspa == NULL) | 425 | if (priv->sspa == NULL) |
| 426 | return -ENOMEM; | 426 | return -ENOMEM; |
| 427 | 427 | ||
| 428 | priv->dma_params = devm_kzalloc(&pdev->dev, | 428 | priv->dma_params = devm_kcalloc(&pdev->dev, |
| 429 | 2 * sizeof(struct snd_dmaengine_dai_dma_data), | 429 | 2, sizeof(struct snd_dmaengine_dai_dma_data), |
| 430 | GFP_KERNEL); | 430 | GFP_KERNEL); |
| 431 | if (priv->dma_params == NULL) | 431 | if (priv->dma_params == NULL) |
| 432 | return -ENOMEM; | 432 | return -ENOMEM; |
diff --git a/sound/soc/rockchip/rk3399_gru_sound.c b/sound/soc/rockchip/rk3399_gru_sound.c index f184168f9a41..f2a51ae2b674 100644 --- a/sound/soc/rockchip/rk3399_gru_sound.c +++ b/sound/soc/rockchip/rk3399_gru_sound.c | |||
| @@ -462,7 +462,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev, | |||
| 462 | num_routes = 0; | 462 | num_routes = 0; |
| 463 | for (i = 0; i < ARRAY_SIZE(rockchip_routes); i++) | 463 | for (i = 0; i < ARRAY_SIZE(rockchip_routes); i++) |
| 464 | num_routes += rockchip_routes[i].num_routes; | 464 | num_routes += rockchip_routes[i].num_routes; |
| 465 | routes = devm_kzalloc(dev, num_routes * sizeof(*routes), | 465 | routes = devm_kcalloc(dev, num_routes, sizeof(*routes), |
| 466 | GFP_KERNEL); | 466 | GFP_KERNEL); |
| 467 | if (!routes) | 467 | if (!routes) |
| 468 | return -ENOMEM; | 468 | return -ENOMEM; |
diff --git a/sound/soc/sh/rcar/cmd.c b/sound/soc/sh/rcar/cmd.c index 4221937ae79b..5900fb535a2b 100644 --- a/sound/soc/sh/rcar/cmd.c +++ b/sound/soc/sh/rcar/cmd.c | |||
| @@ -155,7 +155,7 @@ int rsnd_cmd_probe(struct rsnd_priv *priv) | |||
| 155 | if (!nr) | 155 | if (!nr) |
| 156 | return 0; | 156 | return 0; |
| 157 | 157 | ||
| 158 | cmd = devm_kzalloc(dev, sizeof(*cmd) * nr, GFP_KERNEL); | 158 | cmd = devm_kcalloc(dev, nr, sizeof(*cmd), GFP_KERNEL); |
| 159 | if (!cmd) | 159 | if (!cmd) |
| 160 | return -ENOMEM; | 160 | return -ENOMEM; |
| 161 | 161 | ||
diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index af04d41a4274..f237002180c0 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c | |||
| @@ -1110,8 +1110,8 @@ static int rsnd_dai_probe(struct rsnd_priv *priv) | |||
| 1110 | if (!nr) | 1110 | if (!nr) |
| 1111 | return -EINVAL; | 1111 | return -EINVAL; |
| 1112 | 1112 | ||
| 1113 | rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL); | 1113 | rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL); |
| 1114 | rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL); | 1114 | rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL); |
| 1115 | if (!rdrv || !rdai) | 1115 | if (!rdrv || !rdai) |
| 1116 | return -ENOMEM; | 1116 | return -ENOMEM; |
| 1117 | 1117 | ||
diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index d201d551866d..83be7d3ae0a8 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c | |||
| @@ -378,7 +378,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv) | |||
| 378 | goto rsnd_ctu_probe_done; | 378 | goto rsnd_ctu_probe_done; |
| 379 | } | 379 | } |
| 380 | 380 | ||
| 381 | ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL); | 381 | ctu = devm_kcalloc(dev, nr, sizeof(*ctu), GFP_KERNEL); |
| 382 | if (!ctu) { | 382 | if (!ctu) { |
| 383 | ret = -ENOMEM; | 383 | ret = -ENOMEM; |
| 384 | goto rsnd_ctu_probe_done; | 384 | goto rsnd_ctu_probe_done; |
diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index dbe54f024d68..ca1780e0b830 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c | |||
| @@ -344,7 +344,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv) | |||
| 344 | goto rsnd_dvc_probe_done; | 344 | goto rsnd_dvc_probe_done; |
| 345 | } | 345 | } |
| 346 | 346 | ||
| 347 | dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL); | 347 | dvc = devm_kcalloc(dev, nr, sizeof(*dvc), GFP_KERNEL); |
| 348 | if (!dvc) { | 348 | if (!dvc) { |
| 349 | ret = -ENOMEM; | 349 | ret = -ENOMEM; |
| 350 | goto rsnd_dvc_probe_done; | 350 | goto rsnd_dvc_probe_done; |
diff --git a/sound/soc/sh/rcar/mix.c b/sound/soc/sh/rcar/mix.c index 7998380766f6..1881b2de9126 100644 --- a/sound/soc/sh/rcar/mix.c +++ b/sound/soc/sh/rcar/mix.c | |||
| @@ -294,7 +294,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv) | |||
| 294 | goto rsnd_mix_probe_done; | 294 | goto rsnd_mix_probe_done; |
| 295 | } | 295 | } |
| 296 | 296 | ||
| 297 | mix = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL); | 297 | mix = devm_kcalloc(dev, nr, sizeof(*mix), GFP_KERNEL); |
| 298 | if (!mix) { | 298 | if (!mix) { |
| 299 | ret = -ENOMEM; | 299 | ret = -ENOMEM; |
| 300 | goto rsnd_mix_probe_done; | 300 | goto rsnd_mix_probe_done; |
diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index a727e71587b6..6c72d1a81cf5 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c | |||
| @@ -575,7 +575,7 @@ int rsnd_src_probe(struct rsnd_priv *priv) | |||
| 575 | goto rsnd_src_probe_done; | 575 | goto rsnd_src_probe_done; |
| 576 | } | 576 | } |
| 577 | 577 | ||
| 578 | src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL); | 578 | src = devm_kcalloc(dev, nr, sizeof(*src), GFP_KERNEL); |
| 579 | if (!src) { | 579 | if (!src) { |
| 580 | ret = -ENOMEM; | 580 | ret = -ENOMEM; |
| 581 | goto rsnd_src_probe_done; | 581 | goto rsnd_src_probe_done; |
diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index 9538f76f8e20..6e1166ec24a0 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c | |||
| @@ -1116,7 +1116,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) | |||
| 1116 | goto rsnd_ssi_probe_done; | 1116 | goto rsnd_ssi_probe_done; |
| 1117 | } | 1117 | } |
| 1118 | 1118 | ||
| 1119 | ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL); | 1119 | ssi = devm_kcalloc(dev, nr, sizeof(*ssi), GFP_KERNEL); |
| 1120 | if (!ssi) { | 1120 | if (!ssi) { |
| 1121 | ret = -ENOMEM; | 1121 | ret = -ENOMEM; |
| 1122 | goto rsnd_ssi_probe_done; | 1122 | goto rsnd_ssi_probe_done; |
diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index 6ff8a36c2c82..47bdba9fc582 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c | |||
| @@ -258,7 +258,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv) | |||
| 258 | 258 | ||
| 259 | /* same number to SSI */ | 259 | /* same number to SSI */ |
| 260 | nr = priv->ssi_nr; | 260 | nr = priv->ssi_nr; |
| 261 | ssiu = devm_kzalloc(dev, sizeof(*ssiu) * nr, GFP_KERNEL); | 261 | ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL); |
| 262 | if (!ssiu) | 262 | if (!ssiu) |
| 263 | return -ENOMEM; | 263 | return -ENOMEM; |
| 264 | 264 | ||
diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 3d56f1fe5914..4663de3cf495 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c | |||
| @@ -373,8 +373,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( | |||
| 373 | if (!rtd->dai_link->ops) | 373 | if (!rtd->dai_link->ops) |
| 374 | rtd->dai_link->ops = &null_snd_soc_ops; | 374 | rtd->dai_link->ops = &null_snd_soc_ops; |
| 375 | 375 | ||
| 376 | rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) * | 376 | rtd->codec_dais = kcalloc(dai_link->num_codecs, |
| 377 | dai_link->num_codecs, | 377 | sizeof(struct snd_soc_dai *), |
| 378 | GFP_KERNEL); | 378 | GFP_KERNEL); |
| 379 | if (!rtd->codec_dais) { | 379 | if (!rtd->codec_dais) { |
| 380 | kfree(rtd); | 380 | kfree(rtd); |
| @@ -3354,7 +3354,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, | |||
| 3354 | return -EINVAL; | 3354 | return -EINVAL; |
| 3355 | } | 3355 | } |
| 3356 | 3356 | ||
| 3357 | routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes), | 3357 | routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes), |
| 3358 | GFP_KERNEL); | 3358 | GFP_KERNEL); |
| 3359 | if (!routes) { | 3359 | if (!routes) { |
| 3360 | dev_err(card->dev, | 3360 | dev_err(card->dev, |
| @@ -3678,8 +3678,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, | |||
| 3678 | dev_err(dev, "Bad phandle in 'sound-dai'\n"); | 3678 | dev_err(dev, "Bad phandle in 'sound-dai'\n"); |
| 3679 | return num_codecs; | 3679 | return num_codecs; |
| 3680 | } | 3680 | } |
| 3681 | component = devm_kzalloc(dev, | 3681 | component = devm_kcalloc(dev, |
| 3682 | sizeof *component * num_codecs, | 3682 | num_codecs, sizeof(*component), |
| 3683 | GFP_KERNEL); | 3683 | GFP_KERNEL); |
| 3684 | if (!component) | 3684 | if (!component) |
| 3685 | return -ENOMEM; | 3685 | return -ENOMEM; |
diff --git a/sound/soc/soc-dapm.c b/sound/soc/soc-dapm.c index 255cad43a972..229c12349803 100644 --- a/sound/soc/soc-dapm.c +++ b/sound/soc/soc-dapm.c | |||
| @@ -3055,7 +3055,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) | |||
| 3055 | continue; | 3055 | continue; |
| 3056 | 3056 | ||
| 3057 | if (w->num_kcontrols) { | 3057 | if (w->num_kcontrols) { |
| 3058 | w->kcontrols = kzalloc(w->num_kcontrols * | 3058 | w->kcontrols = kcalloc(w->num_kcontrols, |
| 3059 | sizeof(struct snd_kcontrol *), | 3059 | sizeof(struct snd_kcontrol *), |
| 3060 | GFP_KERNEL); | 3060 | GFP_KERNEL); |
| 3061 | if (!w->kcontrols) { | 3061 | if (!w->kcontrols) { |
diff --git a/sound/soc/soc-topology.c b/sound/soc/soc-topology.c index 3fd5d9c867b9..53f121a50c97 100644 --- a/sound/soc/soc-topology.c +++ b/sound/soc/soc-topology.c | |||
| @@ -885,7 +885,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se, | |||
| 885 | int i, ret; | 885 | int i, ret; |
| 886 | 886 | ||
| 887 | se->dobj.control.dtexts = | 887 | se->dobj.control.dtexts = |
| 888 | kzalloc(sizeof(char *) * ec->items, GFP_KERNEL); | 888 | kcalloc(ec->items, sizeof(char *), GFP_KERNEL); |
| 889 | if (se->dobj.control.dtexts == NULL) | 889 | if (se->dobj.control.dtexts == NULL) |
| 890 | return -ENOMEM; | 890 | return -ENOMEM; |
| 891 | 891 | ||
diff --git a/sound/soc/uniphier/aio-cpu.c b/sound/soc/uniphier/aio-cpu.c index 80daec17be25..2d9b7dde2ffa 100644 --- a/sound/soc/uniphier/aio-cpu.c +++ b/sound/soc/uniphier/aio-cpu.c | |||
| @@ -624,15 +624,17 @@ int uniphier_aio_probe(struct platform_device *pdev) | |||
| 624 | return PTR_ERR(chip->rst); | 624 | return PTR_ERR(chip->rst); |
| 625 | 625 | ||
| 626 | chip->num_aios = chip->chip_spec->num_dais; | 626 | chip->num_aios = chip->chip_spec->num_dais; |
| 627 | chip->aios = devm_kzalloc(dev, | 627 | chip->aios = devm_kcalloc(dev, |
| 628 | sizeof(struct uniphier_aio) * chip->num_aios, | 628 | chip->num_aios, sizeof(struct uniphier_aio), |
| 629 | GFP_KERNEL); | 629 | GFP_KERNEL); |
| 630 | if (!chip->aios) | 630 | if (!chip->aios) |
| 631 | return -ENOMEM; | 631 | return -ENOMEM; |
| 632 | 632 | ||
| 633 | chip->num_plls = chip->chip_spec->num_plls; | 633 | chip->num_plls = chip->chip_spec->num_plls; |
| 634 | chip->plls = devm_kzalloc(dev, sizeof(struct uniphier_aio_pll) * | 634 | chip->plls = devm_kcalloc(dev, |
| 635 | chip->num_plls, GFP_KERNEL); | 635 | chip->num_plls, |
| 636 | sizeof(struct uniphier_aio_pll), | ||
| 637 | GFP_KERNEL); | ||
| 636 | if (!chip->plls) | 638 | if (!chip->plls) |
| 637 | return -ENOMEM; | 639 | return -ENOMEM; |
| 638 | memcpy(chip->plls, chip->chip_spec->plls, | 640 | memcpy(chip->plls, chip->chip_spec->plls, |
diff --git a/sound/usb/6fire/pcm.c b/sound/usb/6fire/pcm.c index 224a6a5d1c0e..2dd2518a71d3 100644 --- a/sound/usb/6fire/pcm.c +++ b/sound/usb/6fire/pcm.c | |||
| @@ -591,12 +591,14 @@ static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt) | |||
| 591 | int i; | 591 | int i; |
| 592 | 592 | ||
| 593 | for (i = 0; i < PCM_N_URBS; i++) { | 593 | for (i = 0; i < PCM_N_URBS; i++) { |
| 594 | rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB | 594 | rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, |
| 595 | * PCM_MAX_PACKET_SIZE, GFP_KERNEL); | 595 | PCM_N_PACKETS_PER_URB, |
| 596 | GFP_KERNEL); | ||
| 596 | if (!rt->out_urbs[i].buffer) | 597 | if (!rt->out_urbs[i].buffer) |
| 597 | return -ENOMEM; | 598 | return -ENOMEM; |
| 598 | rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB | 599 | rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE, |
| 599 | * PCM_MAX_PACKET_SIZE, GFP_KERNEL); | 600 | PCM_N_PACKETS_PER_URB, |
| 601 | GFP_KERNEL); | ||
| 600 | if (!rt->in_urbs[i].buffer) | 602 | if (!rt->in_urbs[i].buffer) |
| 601 | return -ENOMEM; | 603 | return -ENOMEM; |
| 602 | } | 604 | } |
diff --git a/sound/usb/caiaq/audio.c b/sound/usb/caiaq/audio.c index fb1c1eac0b5e..f35d29f49ffe 100644 --- a/sound/usb/caiaq/audio.c +++ b/sound/usb/caiaq/audio.c | |||
| @@ -728,7 +728,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) | |||
| 728 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : | 728 | usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) : |
| 729 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); | 729 | usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE); |
| 730 | 730 | ||
| 731 | urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL); | 731 | urbs = kmalloc_array(N_URBS, sizeof(*urbs), GFP_KERNEL); |
| 732 | if (!urbs) { | 732 | if (!urbs) { |
| 733 | *ret = -ENOMEM; | 733 | *ret = -ENOMEM; |
| 734 | return NULL; | 734 | return NULL; |
| @@ -742,7 +742,8 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) | |||
| 742 | } | 742 | } |
| 743 | 743 | ||
| 744 | urbs[i]->transfer_buffer = | 744 | urbs[i]->transfer_buffer = |
| 745 | kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL); | 745 | kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB, |
| 746 | GFP_KERNEL); | ||
| 746 | if (!urbs[i]->transfer_buffer) { | 747 | if (!urbs[i]->transfer_buffer) { |
| 747 | *ret = -ENOMEM; | 748 | *ret = -ENOMEM; |
| 748 | return urbs; | 749 | return urbs; |
| @@ -857,7 +858,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) | |||
| 857 | &snd_usb_caiaq_ops); | 858 | &snd_usb_caiaq_ops); |
| 858 | 859 | ||
| 859 | cdev->data_cb_info = | 860 | cdev->data_cb_info = |
| 860 | kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS, | 861 | kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info), |
| 861 | GFP_KERNEL); | 862 | GFP_KERNEL); |
| 862 | 863 | ||
| 863 | if (!cdev->data_cb_info) | 864 | if (!cdev->data_cb_info) |
diff --git a/sound/usb/format.c b/sound/usb/format.c index 49e7ec6d2399..1f7a74a77ea3 100644 --- a/sound/usb/format.c +++ b/sound/usb/format.c | |||
| @@ -188,7 +188,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof | |||
| 188 | */ | 188 | */ |
| 189 | int r, idx; | 189 | int r, idx; |
| 190 | 190 | ||
| 191 | fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL); | 191 | fp->rate_table = kmalloc_array(nr_rates, sizeof(int), |
| 192 | GFP_KERNEL); | ||
| 192 | if (fp->rate_table == NULL) | 193 | if (fp->rate_table == NULL) |
| 193 | return -ENOMEM; | 194 | return -ENOMEM; |
| 194 | 195 | ||
| @@ -362,7 +363,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, | |||
| 362 | goto err_free; | 363 | goto err_free; |
| 363 | } | 364 | } |
| 364 | 365 | ||
| 365 | fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL); | 366 | fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL); |
| 366 | if (!fp->rate_table) { | 367 | if (!fp->rate_table) { |
| 367 | ret = -ENOMEM; | 368 | ret = -ENOMEM; |
| 368 | goto err_free; | 369 | goto err_free; |
diff --git a/sound/usb/line6/capture.c b/sound/usb/line6/capture.c index 947d6168f24a..d8a14d769f48 100644 --- a/sound/usb/line6/capture.c +++ b/sound/usb/line6/capture.c | |||
| @@ -264,8 +264,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) | |||
| 264 | struct usb_line6 *line6 = line6pcm->line6; | 264 | struct usb_line6 *line6 = line6pcm->line6; |
| 265 | int i; | 265 | int i; |
| 266 | 266 | ||
| 267 | line6pcm->in.urbs = kzalloc( | 267 | line6pcm->in.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *), |
| 268 | sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL); | 268 | GFP_KERNEL); |
| 269 | if (line6pcm->in.urbs == NULL) | 269 | if (line6pcm->in.urbs == NULL) |
| 270 | return -ENOMEM; | 270 | return -ENOMEM; |
| 271 | 271 | ||
diff --git a/sound/usb/line6/pcm.c b/sound/usb/line6/pcm.c index b3854f8c0c67..72c6f8e82a7e 100644 --- a/sound/usb/line6/pcm.c +++ b/sound/usb/line6/pcm.c | |||
| @@ -158,8 +158,10 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm, | |||
| 158 | 158 | ||
| 159 | /* Invoked multiple times in a row so allocate once only */ | 159 | /* Invoked multiple times in a row so allocate once only */ |
| 160 | if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) { | 160 | if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) { |
| 161 | pstr->buffer = kmalloc(line6pcm->line6->iso_buffers * | 161 | pstr->buffer = |
| 162 | LINE6_ISO_PACKETS * pkt_size, GFP_KERNEL); | 162 | kmalloc(array3_size(line6pcm->line6->iso_buffers, |
| 163 | LINE6_ISO_PACKETS, pkt_size), | ||
| 164 | GFP_KERNEL); | ||
| 163 | if (!pstr->buffer) | 165 | if (!pstr->buffer) |
| 164 | return -ENOMEM; | 166 | return -ENOMEM; |
| 165 | } | 167 | } |
diff --git a/sound/usb/line6/playback.c b/sound/usb/line6/playback.c index 819e9b2d1d6e..dec89d2beb57 100644 --- a/sound/usb/line6/playback.c +++ b/sound/usb/line6/playback.c | |||
| @@ -409,8 +409,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) | |||
| 409 | struct usb_line6 *line6 = line6pcm->line6; | 409 | struct usb_line6 *line6 = line6pcm->line6; |
| 410 | int i; | 410 | int i; |
| 411 | 411 | ||
| 412 | line6pcm->out.urbs = kzalloc( | 412 | line6pcm->out.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *), |
| 413 | sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL); | 413 | GFP_KERNEL); |
| 414 | if (line6pcm->out.urbs == NULL) | 414 | if (line6pcm->out.urbs == NULL) |
| 415 | return -ENOMEM; | 415 | return -ENOMEM; |
| 416 | 416 | ||
diff --git a/sound/usb/mixer.c b/sound/usb/mixer.c index 898afd3001ea..8c3568d8d03b 100644 --- a/sound/usb/mixer.c +++ b/sound/usb/mixer.c | |||
| @@ -2515,7 +2515,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, | |||
| 2515 | cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ? | 2515 | cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ? |
| 2516 | UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR; | 2516 | UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR; |
| 2517 | 2517 | ||
| 2518 | namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL); | 2518 | namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL); |
| 2519 | if (!namelist) { | 2519 | if (!namelist) { |
| 2520 | kfree(cval); | 2520 | kfree(cval); |
| 2521 | return -ENOMEM; | 2521 | return -ENOMEM; |
diff --git a/sound/usb/pcm.c b/sound/usb/pcm.c index 78d1cad08a0a..160f52c4871b 100644 --- a/sound/usb/pcm.c +++ b/sound/usb/pcm.c | |||
| @@ -1123,7 +1123,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, | |||
| 1123 | return 0; | 1123 | return 0; |
| 1124 | 1124 | ||
| 1125 | subs->rate_list.list = rate_list = | 1125 | subs->rate_list.list = rate_list = |
| 1126 | kmalloc(sizeof(int) * count, GFP_KERNEL); | 1126 | kmalloc_array(count, sizeof(int), GFP_KERNEL); |
| 1127 | if (!subs->rate_list.list) | 1127 | if (!subs->rate_list.list) |
| 1128 | return -ENOMEM; | 1128 | return -ENOMEM; |
| 1129 | subs->rate_list.count = count; | 1129 | subs->rate_list.count = count; |
diff --git a/sound/usb/usx2y/usbusx2y.c b/sound/usb/usx2y/usbusx2y.c index 0ddf29267d70..da4a5a541512 100644 --- a/sound/usb/usx2y/usbusx2y.c +++ b/sound/usb/usx2y/usbusx2y.c | |||
| @@ -266,7 +266,9 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y) | |||
| 266 | int err = 0, | 266 | int err = 0, |
| 267 | i; | 267 | i; |
| 268 | 268 | ||
| 269 | if (NULL == (usX2Y->AS04.buffer = kmalloc(URB_DataLen_AsyncSeq*URBS_AsyncSeq, GFP_KERNEL))) { | 269 | usX2Y->AS04.buffer = kmalloc_array(URBS_AsyncSeq, |
| 270 | URB_DataLen_AsyncSeq, GFP_KERNEL); | ||
| 271 | if (NULL == usX2Y->AS04.buffer) { | ||
| 270 | err = -ENOMEM; | 272 | err = -ENOMEM; |
| 271 | } else | 273 | } else |
| 272 | for (i = 0; i < URBS_AsyncSeq; ++i) { | 274 | for (i = 0; i < URBS_AsyncSeq; ++i) { |
diff --git a/sound/usb/usx2y/usbusx2yaudio.c b/sound/usb/usx2y/usbusx2yaudio.c index 345e439aa95b..2b833054e3b0 100644 --- a/sound/usb/usx2y/usbusx2yaudio.c +++ b/sound/usb/usx2y/usbusx2yaudio.c | |||
| @@ -436,7 +436,9 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) | |||
| 436 | } | 436 | } |
| 437 | if (!is_playback && !(*purb)->transfer_buffer) { | 437 | if (!is_playback && !(*purb)->transfer_buffer) { |
| 438 | /* allocate a capture buffer per urb */ | 438 | /* allocate a capture buffer per urb */ |
| 439 | (*purb)->transfer_buffer = kmalloc(subs->maxpacksize * nr_of_packs(), GFP_KERNEL); | 439 | (*purb)->transfer_buffer = |
| 440 | kmalloc_array(subs->maxpacksize, | ||
| 441 | nr_of_packs(), GFP_KERNEL); | ||
| 440 | if (NULL == (*purb)->transfer_buffer) { | 442 | if (NULL == (*purb)->transfer_buffer) { |
| 441 | usX2Y_urbs_release(subs); | 443 | usX2Y_urbs_release(subs); |
| 442 | return -ENOMEM; | 444 | return -ENOMEM; |
| @@ -662,7 +664,8 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) | |||
| 662 | err = -ENOMEM; | 664 | err = -ENOMEM; |
| 663 | goto cleanup; | 665 | goto cleanup; |
| 664 | } | 666 | } |
| 665 | usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL); | 667 | usbdata = kmalloc_array(NOOF_SETRATE_URBS, sizeof(int), |
| 668 | GFP_KERNEL); | ||
| 666 | if (NULL == usbdata) { | 669 | if (NULL == usbdata) { |
| 667 | err = -ENOMEM; | 670 | err = -ENOMEM; |
| 668 | goto cleanup; | 671 | goto cleanup; |
diff --git a/virt/kvm/arm/vgic/vgic-v4.c b/virt/kvm/arm/vgic/vgic-v4.c index bc4265154bac..1ed5f2286b8e 100644 --- a/virt/kvm/arm/vgic/vgic-v4.c +++ b/virt/kvm/arm/vgic/vgic-v4.c | |||
| @@ -126,7 +126,7 @@ int vgic_v4_init(struct kvm *kvm) | |||
| 126 | 126 | ||
| 127 | nr_vcpus = atomic_read(&kvm->online_vcpus); | 127 | nr_vcpus = atomic_read(&kvm->online_vcpus); |
| 128 | 128 | ||
| 129 | dist->its_vm.vpes = kzalloc(sizeof(*dist->its_vm.vpes) * nr_vcpus, | 129 | dist->its_vm.vpes = kcalloc(nr_vcpus, sizeof(*dist->its_vm.vpes), |
| 130 | GFP_KERNEL); | 130 | GFP_KERNEL); |
| 131 | if (!dist->its_vm.vpes) | 131 | if (!dist->its_vm.vpes) |
| 132 | return -ENOMEM; | 132 | return -ENOMEM; |
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c index aa7da1d8ece2..ada21f47f22b 100644 --- a/virt/kvm/kvm_main.c +++ b/virt/kvm/kvm_main.c | |||
| @@ -3076,7 +3076,8 @@ static long kvm_vm_ioctl(struct file *filp, | |||
| 3076 | goto out; | 3076 | goto out; |
| 3077 | if (routing.nr) { | 3077 | if (routing.nr) { |
| 3078 | r = -ENOMEM; | 3078 | r = -ENOMEM; |
| 3079 | entries = vmalloc(routing.nr * sizeof(*entries)); | 3079 | entries = vmalloc(array_size(sizeof(*entries), |
| 3080 | routing.nr)); | ||
| 3080 | if (!entries) | 3081 | if (!entries) |
| 3081 | goto out; | 3082 | goto out; |
| 3082 | r = -EFAULT; | 3083 | r = -EFAULT; |
