treewide: kmalloc() -> kmalloc_array()
The kmalloc() function has a 2-factor argument form, kmalloc_array(). This patch replaces cases of: kmalloc(a * b, gfp) with: kmalloc_array(a * b, gfp) as well as handling cases of: kmalloc(a * b * c, gfp) with: kmalloc(array3_size(a, b, c), gfp) as it's slightly less ugly than: kmalloc_array(array_size(a, b), c, gfp) This does, however, attempt to ignore constant size factors like: kmalloc(4 * 1024, gfp) though any constants defined via macros get caught up in the conversion. Any factors with a sizeof() of "unsigned char", "char", and "u8" were dropped, since they're redundant. The tools/ directory was manually excluded, since it has its own implementation of kmalloc(). The Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( kmalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | kmalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( kmalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | kmalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | kmalloc( - sizeof(char) * (COUNT) + COUNT , ...) | kmalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | kmalloc( - sizeof(u8) * COUNT + COUNT , ...) | kmalloc( - sizeof(__u8) * COUNT + COUNT , ...) | kmalloc( - sizeof(char) * COUNT + COUNT , ...) | kmalloc( - sizeof(unsigned char) * COUNT + COUNT , ...) ) // 2-factor product with sizeof(type/expression) and identifier or constant. @@ type TYPE; expression THING; identifier COUNT_ID; constant COUNT_CONST; @@ ( - kmalloc + kmalloc_array ( - sizeof(TYPE) * (COUNT_ID) + COUNT_ID, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(TYPE) * COUNT_ID + COUNT_ID, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(TYPE) * (COUNT_CONST) + COUNT_CONST, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(TYPE) * COUNT_CONST + COUNT_CONST, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * (COUNT_ID) + COUNT_ID, sizeof(THING) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * COUNT_ID + COUNT_ID, sizeof(THING) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * (COUNT_CONST) + COUNT_CONST, sizeof(THING) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * COUNT_CONST + COUNT_CONST, sizeof(THING) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ - kmalloc + kmalloc_array ( - SIZE * COUNT + COUNT, SIZE , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( kmalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kmalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kmalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kmalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | kmalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kmalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kmalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | kmalloc( - sizeof(THING) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) ) // 3-factor product with 2 sizeof(variable), with redundant parens removed. @@ expression THING1, THING2; identifier COUNT; type TYPE1, TYPE2; @@ ( kmalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kmalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | kmalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kmalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | kmalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | kmalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) ) // 3-factor product, only identifiers, with redundant parens removed. @@ identifier STRIDE, SIZE, COUNT; @@ ( kmalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | kmalloc( - COUNT * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) ) // Any remaining multi-factor products, first at least 3-factor products, // when they're not all constants... @@ expression E1, E2, E3; constant C1, C2, C3; @@ ( kmalloc(C1 * C2 * C3, ...) | kmalloc( - (E1) * E2 * E3 + array3_size(E1, E2, E3) , ...) | kmalloc( - (E1) * (E2) * E3 + array3_size(E1, E2, E3) , ...) | kmalloc( - (E1) * (E2) * (E3) + array3_size(E1, E2, E3) , ...) | kmalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants, // keeping sizeof() as the second factor argument. @@ expression THING, E1, E2; type TYPE; constant C1, C2, C3; @@ ( kmalloc(sizeof(THING) * C2, ...) | kmalloc(sizeof(TYPE) * C2, ...) | kmalloc(C1 * C2 * C3, ...) | kmalloc(C1 * C2, ...) | - kmalloc + kmalloc_array ( - sizeof(TYPE) * (E2) + E2, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(TYPE) * E2 + E2, sizeof(TYPE) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * (E2) + E2, sizeof(THING) , ...) | - kmalloc + kmalloc_array ( - sizeof(THING) * E2 + E2, sizeof(THING) , ...) | - kmalloc + kmalloc_array ( - (E1) * E2 + E1, E2 , ...) | - kmalloc + kmalloc_array ( - (E1) * (E2) + E1, E2 , ...) | - kmalloc + kmalloc_array ( - E1 * E2 + E1, E2 , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
This commit is contained in:
Родитель
1c542f38ab
Коммит
6da2ec5605
|
@ -286,7 +286,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,
|
|||
return -EINVAL;
|
||||
if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
|
||||
return -EFAULT;
|
||||
kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
|
||||
kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
|
||||
if (!kbuf)
|
||||
return -ENOMEM;
|
||||
fs = get_fs();
|
||||
|
@ -324,7 +324,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
|
|||
return -EINVAL;
|
||||
if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
|
||||
return -EFAULT;
|
||||
sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL);
|
||||
sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
|
||||
if (!sops)
|
||||
return -ENOMEM;
|
||||
err = 0;
|
||||
|
|
|
@ -20,7 +20,7 @@
|
|||
#include "mm.h"
|
||||
|
||||
#ifdef CONFIG_ARM_LPAE
|
||||
#define __pgd_alloc() kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL)
|
||||
#define __pgd_alloc() kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL)
|
||||
#define __pgd_free(pgd) kfree(pgd)
|
||||
#else
|
||||
#define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL, 2)
|
||||
|
|
|
@ -766,8 +766,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args)
|
|||
|
||||
static int coverage_start(const union decode_item *table)
|
||||
{
|
||||
coverage.base = kmalloc(MAX_COVERAGE_ENTRIES *
|
||||
sizeof(struct coverage_entry), GFP_KERNEL);
|
||||
coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
|
||||
sizeof(struct coverage_entry),
|
||||
GFP_KERNEL);
|
||||
coverage.num_entries = 0;
|
||||
coverage.nesting = 0;
|
||||
return table_iter(table, coverage_start_fn, &coverage);
|
||||
|
|
|
@ -350,7 +350,8 @@ init_record_index_pools(void)
|
|||
/* - 3 - */
|
||||
slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
|
||||
slidx_pool.buffer =
|
||||
kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
|
||||
kmalloc_array(slidx_pool.max_idx, sizeof(slidx_list_t),
|
||||
GFP_KERNEL);
|
||||
|
||||
return slidx_pool.buffer ? 0 : -ENOMEM;
|
||||
}
|
||||
|
|
|
@ -430,8 +430,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size)
|
|||
int cpu = smp_processor_id();
|
||||
|
||||
if (!ia64_idtrs[cpu]) {
|
||||
ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
|
||||
sizeof (struct ia64_tr_entry), GFP_KERNEL);
|
||||
ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
|
||||
sizeof(struct ia64_tr_entry),
|
||||
GFP_KERNEL);
|
||||
if (!ia64_idtrs[cpu])
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
|
|
@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void)
|
|||
{
|
||||
int i;
|
||||
|
||||
sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL);
|
||||
sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(struct list_head *),
|
||||
GFP_KERNEL);
|
||||
if (!sn_irq_lh)
|
||||
panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
|
||||
|
||||
|
|
|
@ -411,8 +411,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
|
|||
* and if we try that first we are likely to not waste larger
|
||||
* slabs of memory.
|
||||
*/
|
||||
desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
|
||||
GFP_KERNEL|GFP_DMA);
|
||||
desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t),
|
||||
GFP_KERNEL|GFP_DMA);
|
||||
if (desc_base == 0)
|
||||
return 0;
|
||||
|
||||
|
|
|
@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks)
|
|||
|
||||
new_blocks = max_blocks - info->max_blocks;
|
||||
|
||||
block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC);
|
||||
block = kmalloc_array(max_blocks, sizeof(rh_block_t), GFP_ATOMIC);
|
||||
if (block == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -156,7 +156,8 @@ static int hsta_msi_probe(struct platform_device *pdev)
|
|||
if (ret)
|
||||
goto out;
|
||||
|
||||
ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL);
|
||||
ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count, sizeof(int),
|
||||
GFP_KERNEL);
|
||||
if (!ppc4xx_hsta_msi.irq_map) {
|
||||
ret = -ENOMEM;
|
||||
goto out1;
|
||||
|
|
|
@ -89,7 +89,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
|
|||
if (type == PCI_CAP_ID_MSIX)
|
||||
pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n");
|
||||
|
||||
msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int), GFP_KERNEL);
|
||||
msi_data->msi_virqs = kmalloc_array(msi_irqs, sizeof(int), GFP_KERNEL);
|
||||
if (!msi_data->msi_virqs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -1639,8 +1639,9 @@ void __init mpic_init(struct mpic *mpic)
|
|||
|
||||
#ifdef CONFIG_PM
|
||||
/* allocate memory to save mpic state */
|
||||
mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
|
||||
GFP_KERNEL);
|
||||
mpic->save_data = kmalloc_array(mpic->num_sources,
|
||||
sizeof(*mpic->save_data),
|
||||
GFP_KERNEL);
|
||||
BUG_ON(mpic->save_data == NULL);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -49,7 +49,8 @@ static void *diag0c_store(unsigned int *count)
|
|||
|
||||
get_online_cpus();
|
||||
cpu_count = num_online_cpus();
|
||||
cpu_vec = kmalloc(sizeof(*cpu_vec) * num_possible_cpus(), GFP_KERNEL);
|
||||
cpu_vec = kmalloc_array(num_possible_cpus(), sizeof(*cpu_vec),
|
||||
GFP_KERNEL);
|
||||
if (!cpu_vec)
|
||||
goto fail_put_online_cpus;
|
||||
/* Note: Diag 0c needs 8 byte alignment and real storage */
|
||||
|
|
|
@ -194,11 +194,13 @@ static debug_entry_t ***debug_areas_alloc(int pages_per_area, int nr_areas)
|
|||
debug_entry_t ***areas;
|
||||
int i, j;
|
||||
|
||||
areas = kmalloc(nr_areas * sizeof(debug_entry_t **), GFP_KERNEL);
|
||||
areas = kmalloc_array(nr_areas, sizeof(debug_entry_t **), GFP_KERNEL);
|
||||
if (!areas)
|
||||
goto fail_malloc_areas;
|
||||
for (i = 0; i < nr_areas; i++) {
|
||||
areas[i] = kmalloc(pages_per_area * sizeof(debug_entry_t *), GFP_KERNEL);
|
||||
areas[i] = kmalloc_array(pages_per_area,
|
||||
sizeof(debug_entry_t *),
|
||||
GFP_KERNEL);
|
||||
if (!areas[i])
|
||||
goto fail_malloc_areas2;
|
||||
for (j = 0; j < pages_per_area; j++) {
|
||||
|
|
|
@ -527,7 +527,7 @@ static __init struct attribute **merge_attr(struct attribute **a,
|
|||
j++;
|
||||
j++;
|
||||
|
||||
new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
|
||||
new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
|
||||
if (!new)
|
||||
return NULL;
|
||||
j = 0;
|
||||
|
|
|
@ -103,7 +103,7 @@ static int scode_set;
|
|||
static int
|
||||
dcss_set_subcodes(void)
|
||||
{
|
||||
char *name = kmalloc(8 * sizeof(char), GFP_KERNEL | GFP_DMA);
|
||||
char *name = kmalloc(8, GFP_KERNEL | GFP_DMA);
|
||||
unsigned long rx, ry;
|
||||
int rc;
|
||||
|
||||
|
|
|
@ -166,7 +166,8 @@ static int __init check_nmi_watchdog(void)
|
|||
if (!atomic_read(&nmi_active))
|
||||
return 0;
|
||||
|
||||
prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(unsigned int), GFP_KERNEL);
|
||||
prev_nmi_count = kmalloc_array(nr_cpu_ids, sizeof(unsigned int),
|
||||
GFP_KERNEL);
|
||||
if (!prev_nmi_count) {
|
||||
err = -ENOMEM;
|
||||
goto error;
|
||||
|
|
|
@ -575,8 +575,9 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
|
|||
unsigned long *p = current_thread_info()->utraps;
|
||||
|
||||
current_thread_info()->utraps =
|
||||
kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1,
|
||||
sizeof(long),
|
||||
GFP_KERNEL);
|
||||
if (!current_thread_info()->utraps) {
|
||||
current_thread_info()->utraps = p;
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
|
|||
if (!bpf_jit_enable)
|
||||
return;
|
||||
|
||||
addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
|
||||
addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
|
||||
if (addrs == NULL)
|
||||
return;
|
||||
|
||||
|
|
|
@ -1127,9 +1127,9 @@ static int __init ubd_init(void)
|
|||
return -1;
|
||||
}
|
||||
|
||||
irq_req_buffer = kmalloc(
|
||||
sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
|
||||
GFP_KERNEL
|
||||
irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
|
||||
sizeof(struct io_thread_req *),
|
||||
GFP_KERNEL
|
||||
);
|
||||
irq_remainder = 0;
|
||||
|
||||
|
@ -1137,9 +1137,9 @@ static int __init ubd_init(void)
|
|||
printk(KERN_ERR "Failed to initialize ubd buffering\n");
|
||||
return -1;
|
||||
}
|
||||
io_req_buffer = kmalloc(
|
||||
sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
|
||||
GFP_KERNEL
|
||||
io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
|
||||
sizeof(struct io_thread_req *),
|
||||
GFP_KERNEL
|
||||
);
|
||||
|
||||
io_remainder = 0;
|
||||
|
|
|
@ -527,14 +527,14 @@ static struct vector_queue *create_queue(
|
|||
result->max_iov_frags = num_extra_frags;
|
||||
for (i = 0; i < max_size; i++) {
|
||||
if (vp->header_size > 0)
|
||||
iov = kmalloc(
|
||||
sizeof(struct iovec) * (3 + num_extra_frags),
|
||||
GFP_KERNEL
|
||||
iov = kmalloc_array(3 + num_extra_frags,
|
||||
sizeof(struct iovec),
|
||||
GFP_KERNEL
|
||||
);
|
||||
else
|
||||
iov = kmalloc(
|
||||
sizeof(struct iovec) * (2 + num_extra_frags),
|
||||
GFP_KERNEL
|
||||
iov = kmalloc_array(2 + num_extra_frags,
|
||||
sizeof(struct iovec),
|
||||
GFP_KERNEL
|
||||
);
|
||||
if (iov == NULL)
|
||||
goto out_fail;
|
||||
|
|
|
@ -109,8 +109,9 @@ static int __init puv3_pm_init(void)
|
|||
return -EINVAL;
|
||||
}
|
||||
|
||||
sleep_save = kmalloc(puv3_cpu_pm_fns->save_count
|
||||
* sizeof(unsigned long), GFP_KERNEL);
|
||||
sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count,
|
||||
sizeof(unsigned long),
|
||||
GFP_KERNEL);
|
||||
if (!sleep_save) {
|
||||
printk(KERN_ERR "failed to alloc memory for pm save\n");
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -1637,7 +1637,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b)
|
|||
j++;
|
||||
j++;
|
||||
|
||||
new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
|
||||
new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
|
||||
if (!new)
|
||||
return NULL;
|
||||
|
||||
|
|
|
@ -966,8 +966,8 @@ int __init hpet_enable(void)
|
|||
#endif
|
||||
|
||||
cfg = hpet_readl(HPET_CFG);
|
||||
hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
|
||||
GFP_KERNEL);
|
||||
hpet_boot_cfg = kmalloc_array(last + 2, sizeof(*hpet_boot_cfg),
|
||||
GFP_KERNEL);
|
||||
if (hpet_boot_cfg)
|
||||
*hpet_boot_cfg = cfg;
|
||||
else
|
||||
|
|
|
@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
|
|||
if (ret)
|
||||
goto out_setup_data_kobj;
|
||||
|
||||
kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL);
|
||||
kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL);
|
||||
if (!kobjp) {
|
||||
ret = -ENOMEM;
|
||||
goto out_setup_data_kobj;
|
||||
|
|
|
@ -1001,7 +1001,9 @@ static int svm_cpu_init(int cpu)
|
|||
|
||||
if (svm_sev_enabled()) {
|
||||
r = -ENOMEM;
|
||||
sd->sev_vmcbs = kmalloc((max_sev_asid + 1) * sizeof(void *), GFP_KERNEL);
|
||||
sd->sev_vmcbs = kmalloc_array(max_sev_asid + 1,
|
||||
sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!sd->sev_vmcbs)
|
||||
goto err_1;
|
||||
}
|
||||
|
|
|
@ -1107,7 +1107,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
|
|||
extra_pass = true;
|
||||
goto skip_init_addrs;
|
||||
}
|
||||
addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
|
||||
addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
|
||||
if (!addrs) {
|
||||
prog = orig_prog;
|
||||
goto out_addrs;
|
||||
|
|
|
@ -2345,7 +2345,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
|
|||
prog = tmp;
|
||||
}
|
||||
|
||||
addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
|
||||
addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
|
||||
if (!addrs) {
|
||||
prog = orig_prog;
|
||||
goto out;
|
||||
|
|
|
@ -2142,7 +2142,7 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode)
|
|||
if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
|
||||
timeout_us = calculate_destination_timeout();
|
||||
|
||||
vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
|
||||
vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL);
|
||||
uvhub_descs = (struct uvhub_desc *)vp;
|
||||
memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
|
||||
uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
|
||||
|
|
|
@ -378,7 +378,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state,
|
|||
BUG_ON(!state || !ldb);
|
||||
ph = &ldb->ph;
|
||||
tb[0] = &ldb->toc;
|
||||
tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
|
||||
tb[1] = kmalloc_array(3, sizeof(*tb[1]), GFP_KERNEL);
|
||||
if (!tb[1]) {
|
||||
ldm_crit("Out of memory.");
|
||||
goto err;
|
||||
|
|
|
@ -603,7 +603,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
|
|||
goto out_nooutbuf;
|
||||
|
||||
/* avoid "the frame size is larger than 1024 bytes" compiler warning */
|
||||
sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 4 : 2), GFP_KERNEL);
|
||||
sg = kmalloc(array3_size(sizeof(*sg), 8, (diff_dst ? 4 : 2)),
|
||||
GFP_KERNEL);
|
||||
if (!sg)
|
||||
goto out_nosg;
|
||||
sgout = &sg[16];
|
||||
|
|
|
@ -832,8 +832,9 @@ int acpi_video_get_levels(struct acpi_device *device,
|
|||
* in order to account for buggy BIOS which don't export the first two
|
||||
* special levels (see below)
|
||||
*/
|
||||
br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) *
|
||||
sizeof(*br->levels), GFP_KERNEL);
|
||||
br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL,
|
||||
sizeof(*br->levels),
|
||||
GFP_KERNEL);
|
||||
if (!br->levels) {
|
||||
result = -ENOMEM;
|
||||
goto out_free;
|
||||
|
|
|
@ -195,7 +195,8 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
|
|||
struct ghes_arr ghes_arr;
|
||||
|
||||
ghes_arr.count = 0;
|
||||
ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL);
|
||||
ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!ghes_arr.ghes_devs)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -343,8 +343,9 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
|
|||
|
||||
pr->performance->state_count = pss->package.count;
|
||||
pr->performance->states =
|
||||
kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(pss->package.count,
|
||||
sizeof(struct acpi_processor_px),
|
||||
GFP_KERNEL);
|
||||
if (!pr->performance->states) {
|
||||
result = -ENOMEM;
|
||||
goto end;
|
||||
|
|
|
@ -534,8 +534,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
|
|||
|
||||
pr->throttling.state_count = tss->package.count;
|
||||
pr->throttling.states_tss =
|
||||
kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(tss->package.count,
|
||||
sizeof(struct acpi_processor_tx_tss),
|
||||
GFP_KERNEL);
|
||||
if (!pr->throttling.states_tss) {
|
||||
result = -ENOMEM;
|
||||
goto end;
|
||||
|
|
|
@ -1291,7 +1291,8 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
|
|||
card->using_dma = 1;
|
||||
if (1) { /* All known FPGA versions so far */
|
||||
card->dma_alignment = 3;
|
||||
card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL);
|
||||
card->dma_bounce = kmalloc_array(card->nr_ports,
|
||||
BUF_SIZE, GFP_KERNEL);
|
||||
if (!card->dma_bounce) {
|
||||
dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
|
||||
err = -ENOMEM;
|
||||
|
|
|
@ -333,8 +333,8 @@ static int __init cfag12864b_init(void)
|
|||
goto none;
|
||||
}
|
||||
|
||||
cfag12864b_cache = kmalloc(sizeof(unsigned char) *
|
||||
CFAG12864B_SIZE, GFP_KERNEL);
|
||||
cfag12864b_cache = kmalloc(CFAG12864B_SIZE,
|
||||
GFP_KERNEL);
|
||||
if (cfag12864b_cache == NULL) {
|
||||
printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
|
||||
"can't alloc cache buffer (%i bytes)\n",
|
||||
|
|
|
@ -5719,8 +5719,8 @@ static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
|
|||
Controller->CombinedStatusBufferLength = NewStatusBufferLength;
|
||||
return true;
|
||||
}
|
||||
NewStatusBuffer = kmalloc(2 * Controller->CombinedStatusBufferLength,
|
||||
GFP_ATOMIC);
|
||||
NewStatusBuffer = kmalloc_array(2, Controller->CombinedStatusBufferLength,
|
||||
GFP_ATOMIC);
|
||||
if (NewStatusBuffer == NULL)
|
||||
{
|
||||
DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
|
||||
|
|
|
@ -524,7 +524,8 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
|
|||
|
||||
__rq_for_each_bio(bio, rq)
|
||||
segments += bio_segments(bio);
|
||||
bvec = kmalloc(sizeof(struct bio_vec) * segments, GFP_NOIO);
|
||||
bvec = kmalloc_array(segments, sizeof(struct bio_vec),
|
||||
GFP_NOIO);
|
||||
if (!bvec)
|
||||
return -EIO;
|
||||
cmd->bvec = bvec;
|
||||
|
|
|
@ -197,8 +197,9 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
|
|||
vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
|
||||
#endif
|
||||
z2ram_map =
|
||||
kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(size / Z2RAM_CHUNKSIZE,
|
||||
sizeof(z2ram_map[0]),
|
||||
GFP_KERNEL);
|
||||
if ( z2ram_map == NULL )
|
||||
{
|
||||
printk( KERN_ERR DEVICE_NAME
|
||||
|
|
|
@ -2132,7 +2132,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
|
|||
*/
|
||||
nr = nframes;
|
||||
do {
|
||||
cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
|
||||
cgc.buffer = kmalloc_array(nr, CD_FRAMESIZE_RAW, GFP_KERNEL);
|
||||
if (cgc.buffer)
|
||||
break;
|
||||
|
||||
|
|
|
@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
|
|||
if (ureserve.seg_count >= 16384)
|
||||
return -EINVAL;
|
||||
|
||||
usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
|
||||
usegment = kmalloc_array(ureserve.seg_count,
|
||||
sizeof(*usegment),
|
||||
GFP_KERNEL);
|
||||
if (!usegment)
|
||||
return -ENOMEM;
|
||||
|
||||
ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
|
||||
ksegment = kmalloc_array(kreserve.seg_count,
|
||||
sizeof(*ksegment),
|
||||
GFP_KERNEL);
|
||||
if (!ksegment) {
|
||||
kfree(usegment);
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -93,7 +93,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge,
|
|||
* We'll work with an array of isoch_data's (one for each
|
||||
* device in dev_list) throughout this function.
|
||||
*/
|
||||
if ((master = kmalloc(ndevs * sizeof(*master), GFP_KERNEL)) == NULL) {
|
||||
master = kmalloc_array(ndevs, sizeof(*master), GFP_KERNEL);
|
||||
if (master == NULL) {
|
||||
ret = -ENOMEM;
|
||||
goto get_out;
|
||||
}
|
||||
|
|
|
@ -280,9 +280,9 @@ static int agp_sgi_init(void)
|
|||
else
|
||||
return 0;
|
||||
|
||||
sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
|
||||
sizeof(struct agp_bridge_data *),
|
||||
GFP_KERNEL);
|
||||
sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
|
||||
sizeof(struct agp_bridge_data *),
|
||||
GFP_KERNEL);
|
||||
if (!sgi_tioca_agp_bridges)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
|
|||
if (table == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL);
|
||||
uninorth_priv.pages_arr = kmalloc_array(1 << page_order,
|
||||
sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
if (uninorth_priv.pages_arr == NULL)
|
||||
goto enomem;
|
||||
|
||||
|
|
|
@ -1891,13 +1891,14 @@ static int init_vqs(struct ports_device *portdev)
|
|||
nr_ports = portdev->max_nr_ports;
|
||||
nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
|
||||
|
||||
vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
|
||||
io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
|
||||
io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
|
||||
portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
|
||||
GFP_KERNEL);
|
||||
portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
|
||||
GFP_KERNEL);
|
||||
vqs = kmalloc_array(nr_queues, sizeof(struct virtqueue *), GFP_KERNEL);
|
||||
io_callbacks = kmalloc_array(nr_queues, sizeof(vq_callback_t *),
|
||||
GFP_KERNEL);
|
||||
io_names = kmalloc_array(nr_queues, sizeof(char *), GFP_KERNEL);
|
||||
portdev->in_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
|
||||
GFP_KERNEL);
|
||||
portdev->out_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
|
||||
GFP_KERNEL);
|
||||
if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
|
||||
!portdev->out_vqs) {
|
||||
err = -ENOMEM;
|
||||
|
|
|
@ -71,7 +71,7 @@ bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy)
|
|||
|
||||
cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult);
|
||||
|
||||
table = kmalloc((priv->max_freqs + 1) * sizeof(*table), GFP_KERNEL);
|
||||
table = kmalloc_array(priv->max_freqs + 1, sizeof(*table), GFP_KERNEL);
|
||||
if (!table)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
|
|
|
@ -240,7 +240,7 @@ static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb)
|
|||
}
|
||||
|
||||
/* generate the IVs */
|
||||
ivs = kmalloc(number_of_ivs * CIPHER_BLOCK_SIZE, GFP_ATOMIC);
|
||||
ivs = kmalloc_array(CIPHER_BLOCK_SIZE, number_of_ivs, GFP_ATOMIC);
|
||||
if (!ivs)
|
||||
return -ENOMEM;
|
||||
get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE);
|
||||
|
|
|
@ -970,8 +970,9 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
|
|||
while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY))
|
||||
cpu_relax();
|
||||
|
||||
rctx->hw_context = kmalloc(sizeof(u32) * (3 + HASH_CSR_REGISTER_NUMBER),
|
||||
GFP_KERNEL);
|
||||
rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER,
|
||||
sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
|
||||
preg = rctx->hw_context;
|
||||
|
||||
|
|
|
@ -87,7 +87,8 @@ bcom_task_alloc(int bd_count, int bd_size, int priv_size)
|
|||
|
||||
/* Init the BDs, if needed */
|
||||
if (bd_count) {
|
||||
tsk->cookie = kmalloc(sizeof(void*) * bd_count, GFP_KERNEL);
|
||||
tsk->cookie = kmalloc_array(bd_count, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!tsk->cookie)
|
||||
goto error;
|
||||
|
||||
|
|
|
@ -777,7 +777,7 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
|
|||
struct dmaengine_unmap_data *unmap;
|
||||
int err = 0;
|
||||
|
||||
src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
|
||||
src = kmalloc(PAGE_SIZE, GFP_KERNEL);
|
||||
if (!src)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -45,8 +45,8 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count)
|
|||
|
||||
buffer->page_count = 0;
|
||||
buffer->page_count_mapped = 0;
|
||||
buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]),
|
||||
GFP_KERNEL);
|
||||
buffer->pages = kmalloc_array(page_count, sizeof(buffer->pages[0]),
|
||||
GFP_KERNEL);
|
||||
if (buffer->pages == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -1121,7 +1121,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
|
|||
max_receive = 1U << (dev->card->max_receive + 1);
|
||||
num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
|
||||
|
||||
ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
|
||||
ptrptr = kmalloc_array(num_packets, sizeof(void *), GFP_KERNEL);
|
||||
if (!ptrptr) {
|
||||
retval = -ENOMEM;
|
||||
goto failed;
|
||||
|
|
|
@ -407,7 +407,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
|
|||
(*dump)[i++][1] = RREG32(addr); \
|
||||
} while (0)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -504,7 +504,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
|
|||
#undef HQD_N_REGS
|
||||
#define HQD_N_REGS (19+4)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -395,7 +395,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
|
|||
(*dump)[i++][1] = RREG32(addr); \
|
||||
} while (0)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -491,7 +491,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
|
|||
#undef HQD_N_REGS
|
||||
#define HQD_N_REGS (19+4+2+3+7)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -504,7 +504,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
|
|||
(*dump)[i++][1] = RREG32(addr); \
|
||||
} while (0)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -606,7 +606,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
|
|||
#undef HQD_N_REGS
|
||||
#define HQD_N_REGS (19+6+7+10)
|
||||
|
||||
*dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
|
||||
*dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
|
||||
if (*dump == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -1633,7 +1633,8 @@ struct edid *drm_do_get_edid(struct drm_connector *connector,
|
|||
edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
|
||||
edid[0x7e] = valid_extensions;
|
||||
|
||||
new = kmalloc((valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
|
||||
new = kmalloc_array(valid_extensions + 1, EDID_LENGTH,
|
||||
GFP_KERNEL);
|
||||
if (!new)
|
||||
goto out;
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr)
|
|||
if (read_vbt_r10(addr, &vbt))
|
||||
return -1;
|
||||
|
||||
gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
|
||||
gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
|
||||
if (!gct)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -65,12 +65,15 @@ nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu)
|
|||
goto done;
|
||||
mmu->mem = mems[ret].oclass;
|
||||
|
||||
mmu->heap = kmalloc(sizeof(*mmu->heap) * mmu->heap_nr, GFP_KERNEL);
|
||||
mmu->type = kmalloc(sizeof(*mmu->type) * mmu->type_nr, GFP_KERNEL);
|
||||
mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
|
||||
GFP_KERNEL);
|
||||
mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
|
||||
GFP_KERNEL);
|
||||
if (ret = -ENOMEM, !mmu->heap || !mmu->type)
|
||||
goto done;
|
||||
|
||||
mmu->kind = kmalloc(sizeof(*mmu->kind) * mmu->kind_nr, GFP_KERNEL);
|
||||
mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
|
||||
GFP_KERNEL);
|
||||
if (!mmu->kind && mmu->kind_nr)
|
||||
goto done;
|
||||
|
||||
|
|
|
@ -138,7 +138,8 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size,
|
|||
vmm->limit = args->size;
|
||||
|
||||
vmm->page_nr = args->page_nr;
|
||||
vmm->page = kmalloc(sizeof(*vmm->page) * vmm->page_nr, GFP_KERNEL);
|
||||
vmm->page = kmalloc_array(vmm->page_nr, sizeof(*vmm->page),
|
||||
GFP_KERNEL);
|
||||
if (!vmm->page) {
|
||||
ret = -ENOMEM;
|
||||
goto done;
|
||||
|
|
|
@ -73,7 +73,8 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense)
|
|||
}
|
||||
|
||||
iccsense->nr_entry = cnt;
|
||||
iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL);
|
||||
iccsense->rail = kmalloc_array(cnt, sizeof(struct pwr_rail_t),
|
||||
GFP_KERNEL);
|
||||
if (!iccsense->rail)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -171,7 +171,7 @@ gt215_link_train(struct gt215_ram *ram)
|
|||
return -ENOSYS;
|
||||
|
||||
/* XXX: Multiple partitions? */
|
||||
result = kmalloc(64 * sizeof(u32), GFP_KERNEL);
|
||||
result = kmalloc_array(64, sizeof(u32), GFP_KERNEL);
|
||||
if (!result)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -940,8 +940,8 @@ int tiler_map_show(struct seq_file *s, void *arg)
|
|||
h_adj = omap_dmm->container_height / ydiv;
|
||||
w_adj = omap_dmm->container_width / xdiv;
|
||||
|
||||
map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
|
||||
global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
|
||||
map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
|
||||
global_map = kmalloc_array(w_adj + 1, h_adj, GFP_KERNEL);
|
||||
|
||||
if (!map || !global_map)
|
||||
goto error;
|
||||
|
|
|
@ -244,7 +244,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
|
|||
* DSS, GPU, etc. are not cache coherent:
|
||||
*/
|
||||
if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
|
||||
addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL);
|
||||
addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL);
|
||||
if (!addrs) {
|
||||
ret = -ENOMEM;
|
||||
goto free_pages;
|
||||
|
|
|
@ -200,8 +200,8 @@ int qxl_device_init(struct qxl_device *qdev,
|
|||
(~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
|
||||
|
||||
qdev->mem_slots =
|
||||
kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(qdev->n_mem_slots, sizeof(struct qxl_memslot),
|
||||
GFP_KERNEL);
|
||||
|
||||
idr_init(&qdev->release_idr);
|
||||
spin_lock_init(&qdev->release_idr_lock);
|
||||
|
|
|
@ -298,8 +298,9 @@ static int savage_dma_init(drm_savage_private_t * dev_priv)
|
|||
|
||||
dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
|
||||
(SAVAGE_DMA_PAGE_SIZE * 4);
|
||||
dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
|
||||
dev_priv->nr_dma_pages, GFP_KERNEL);
|
||||
dev_priv->dma_pages = kmalloc_array(dev_priv->nr_dma_pages,
|
||||
sizeof(drm_savage_dma_page_t),
|
||||
GFP_KERNEL);
|
||||
if (dev_priv->dma_pages == NULL)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -548,7 +548,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb,
|
|||
DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
|
||||
epd->factored_stage_time);
|
||||
|
||||
buf = kmalloc(fb->width * fb->height, GFP_KERNEL);
|
||||
buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL);
|
||||
if (!buf)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -348,8 +348,9 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
|
|||
if (use_static)
|
||||
pages_to_free = static_buf;
|
||||
else
|
||||
pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
pages_to_free = kmalloc_array(npages_to_free,
|
||||
sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
if (!pages_to_free) {
|
||||
pr_debug("Failed to allocate memory for pool free operation\n");
|
||||
return 0;
|
||||
|
@ -547,7 +548,8 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags,
|
|||
unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC);
|
||||
|
||||
/* allocate array for page caching change */
|
||||
caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
|
||||
caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!caching_array) {
|
||||
pr_debug("Unable to allocate table for new pages\n");
|
||||
|
|
|
@ -463,8 +463,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
|
|||
if (use_static)
|
||||
pages_to_free = static_buf;
|
||||
else
|
||||
pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
pages_to_free = kmalloc_array(npages_to_free,
|
||||
sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!pages_to_free) {
|
||||
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,
|
|||
(unsigned)(PAGE_SIZE/sizeof(struct page *)));
|
||||
|
||||
/* allocate array for page caching change */
|
||||
caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
|
||||
caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
|
||||
GFP_KERNEL);
|
||||
|
||||
if (!caching_array) {
|
||||
pr_debug("%s: Unable to allocate table for new pages\n",
|
||||
|
|
|
@ -209,7 +209,7 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val)
|
|||
{
|
||||
if (vc4_state->dlist_count == vc4_state->dlist_size) {
|
||||
u32 new_size = max(4u, vc4_state->dlist_count * 2);
|
||||
u32 *new_dlist = kmalloc(new_size * 4, GFP_KERNEL);
|
||||
u32 *new_dlist = kmalloc_array(new_size, 4, GFP_KERNEL);
|
||||
|
||||
if (!new_dlist)
|
||||
return;
|
||||
|
|
|
@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type)
|
|||
}
|
||||
|
||||
if (parser->device->maxcollection == parser->device->collection_size) {
|
||||
collection = kmalloc(sizeof(struct hid_collection) *
|
||||
parser->device->collection_size * 2, GFP_KERNEL);
|
||||
collection = kmalloc(
|
||||
array3_size(sizeof(struct hid_collection),
|
||||
parser->device->collection_size,
|
||||
2),
|
||||
GFP_KERNEL);
|
||||
if (collection == NULL) {
|
||||
hid_err(parser->device, "failed to reallocate collection array\n");
|
||||
return -ENOMEM;
|
||||
|
@ -1278,7 +1281,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field,
|
|||
__s32 max = field->logical_maximum;
|
||||
__s32 *value;
|
||||
|
||||
value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
|
||||
value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
|
||||
if (!value)
|
||||
return;
|
||||
|
||||
|
|
|
@ -685,7 +685,7 @@ void hid_dump_report(struct hid_device *hid, int type, u8 *data,
|
|||
char *buf;
|
||||
unsigned int i;
|
||||
|
||||
buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
|
||||
buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
|
||||
|
||||
if (!buf)
|
||||
return;
|
||||
|
|
|
@ -394,7 +394,8 @@ static int picolcd_set_par(struct fb_info *info)
|
|||
return -EINVAL;
|
||||
|
||||
o_fb = fbdata->bitmap;
|
||||
tmp_fb = kmalloc(PICOLCDFB_SIZE*info->var.bits_per_pixel, GFP_KERNEL);
|
||||
tmp_fb = kmalloc_array(PICOLCDFB_SIZE, info->var.bits_per_pixel,
|
||||
GFP_KERNEL);
|
||||
if (!tmp_fb)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -218,7 +218,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
|
|||
goto out;
|
||||
}
|
||||
|
||||
buf = kmalloc(count * sizeof(__u8), GFP_KERNEL);
|
||||
buf = kmalloc(count, GFP_KERNEL);
|
||||
if (!buf) {
|
||||
ret = -ENOMEM;
|
||||
goto out;
|
||||
|
|
|
@ -244,7 +244,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
|
|||
u8 __user **data_ptrs;
|
||||
int i, res;
|
||||
|
||||
data_ptrs = kmalloc(nmsgs * sizeof(u8 __user *), GFP_KERNEL);
|
||||
data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL);
|
||||
if (data_ptrs == NULL) {
|
||||
kfree(msgs);
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -985,8 +985,9 @@ static int hwif_init(ide_hwif_t *hwif)
|
|||
if (!hwif->sg_max_nents)
|
||||
hwif->sg_max_nents = PRD_ENTRIES;
|
||||
|
||||
hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
|
||||
GFP_KERNEL);
|
||||
hwif->sg_table = kmalloc_array(hwif->sg_max_nents,
|
||||
sizeof(struct scatterlist),
|
||||
GFP_KERNEL);
|
||||
if (!hwif->sg_table) {
|
||||
printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
|
||||
goto out;
|
||||
|
|
|
@ -1855,8 +1855,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
|
|||
|
||||
rt = &id->route;
|
||||
rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
|
||||
rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
|
||||
GFP_KERNEL);
|
||||
rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec),
|
||||
GFP_KERNEL);
|
||||
if (!rt->path_rec)
|
||||
goto err;
|
||||
|
||||
|
|
|
@ -235,8 +235,9 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd,
|
|||
|
||||
if (params->cache) {
|
||||
pool->cache_bucket =
|
||||
kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(IB_FMR_HASH_SIZE,
|
||||
sizeof(*pool->cache_bucket),
|
||||
GFP_KERNEL);
|
||||
if (!pool->cache_bucket) {
|
||||
ret = -ENOMEM;
|
||||
goto out_free_pool;
|
||||
|
|
|
@ -92,8 +92,8 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
|
|||
alloc->last = 0;
|
||||
alloc->max = num;
|
||||
spin_lock_init(&alloc->lock);
|
||||
alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
|
||||
GFP_KERNEL);
|
||||
alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
|
||||
GFP_KERNEL);
|
||||
if (!alloc->table)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -302,7 +302,8 @@ static int mlx4_ib_add_gid(const union ib_gid *gid,
|
|||
ctx->refcount++;
|
||||
}
|
||||
if (!ret && hw_update) {
|
||||
gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
|
||||
gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
|
||||
GFP_ATOMIC);
|
||||
if (!gids) {
|
||||
ret = -ENOMEM;
|
||||
} else {
|
||||
|
@ -355,7 +356,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
|
|||
if (!ret && hw_update) {
|
||||
int i;
|
||||
|
||||
gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
|
||||
gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
|
||||
GFP_ATOMIC);
|
||||
if (!gids) {
|
||||
ret = -ENOMEM;
|
||||
} else {
|
||||
|
@ -2872,9 +2874,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
|
|||
goto err_counter;
|
||||
|
||||
ibdev->ib_uc_qpns_bitmap =
|
||||
kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
|
||||
sizeof(long),
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
|
||||
sizeof(long),
|
||||
GFP_KERNEL);
|
||||
if (!ibdev->ib_uc_qpns_bitmap)
|
||||
goto err_steer_qp_release;
|
||||
|
||||
|
|
|
@ -573,8 +573,8 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
|
|||
int i;
|
||||
|
||||
qp->sqp_proxy_rcv =
|
||||
kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
|
||||
GFP_KERNEL);
|
||||
kmalloc_array(qp->rq.wqe_cnt, sizeof(struct mlx4_ib_buf),
|
||||
GFP_KERNEL);
|
||||
if (!qp->sqp_proxy_rcv)
|
||||
return -ENOMEM;
|
||||
for (i = 0; i < qp->rq.wqe_cnt; i++) {
|
||||
|
|
|
@ -90,8 +90,8 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
|
|||
alloc->max = num;
|
||||
alloc->mask = mask;
|
||||
spin_lock_init(&alloc->lock);
|
||||
alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
|
||||
GFP_KERNEL);
|
||||
alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
|
||||
GFP_KERNEL);
|
||||
if (!alloc->table)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -162,7 +162,8 @@ int mthca_array_init(struct mthca_array *array, int nent)
|
|||
int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
int i;
|
||||
|
||||
array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL);
|
||||
array->page_list = kmalloc_array(npage, sizeof(*array->page_list),
|
||||
GFP_KERNEL);
|
||||
if (!array->page_list)
|
||||
return -ENOMEM;
|
||||
|
||||
|
@ -220,7 +221,8 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
|
|||
npages *= 2;
|
||||
}
|
||||
|
||||
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
|
||||
dma_list = kmalloc_array(npages, sizeof(*dma_list),
|
||||
GFP_KERNEL);
|
||||
if (!dma_list)
|
||||
goto err_free;
|
||||
|
||||
|
@ -231,12 +233,14 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
|
|||
npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
|
||||
shift = PAGE_SHIFT;
|
||||
|
||||
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
|
||||
dma_list = kmalloc_array(npages, sizeof(*dma_list),
|
||||
GFP_KERNEL);
|
||||
if (!dma_list)
|
||||
return -ENOMEM;
|
||||
|
||||
buf->page_list = kmalloc(npages * sizeof *buf->page_list,
|
||||
GFP_KERNEL);
|
||||
buf->page_list = kmalloc_array(npages,
|
||||
sizeof(*buf->page_list),
|
||||
GFP_KERNEL);
|
||||
if (!buf->page_list)
|
||||
goto err_out;
|
||||
|
||||
|
|
|
@ -565,9 +565,9 @@ int mthca_cmd_use_events(struct mthca_dev *dev)
|
|||
{
|
||||
int i;
|
||||
|
||||
dev->cmd.context = kmalloc(dev->cmd.max_cmds *
|
||||
sizeof (struct mthca_cmd_context),
|
||||
GFP_KERNEL);
|
||||
dev->cmd.context = kmalloc_array(dev->cmd.max_cmds,
|
||||
sizeof(struct mthca_cmd_context),
|
||||
GFP_KERNEL);
|
||||
if (!dev->cmd.context)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -479,15 +479,15 @@ static int mthca_create_eq(struct mthca_dev *dev,
|
|||
eq->nent = roundup_pow_of_two(max(nent, 2));
|
||||
npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
|
||||
|
||||
eq->page_list = kmalloc(npages * sizeof *eq->page_list,
|
||||
GFP_KERNEL);
|
||||
eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
|
||||
GFP_KERNEL);
|
||||
if (!eq->page_list)
|
||||
goto err_out;
|
||||
|
||||
for (i = 0; i < npages; ++i)
|
||||
eq->page_list[i].buf = NULL;
|
||||
|
||||
dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
|
||||
dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL);
|
||||
if (!dma_list)
|
||||
goto err_out_free;
|
||||
|
||||
|
|
|
@ -712,9 +712,9 @@ int mthca_init_db_tab(struct mthca_dev *dev)
|
|||
dev->db_tab->max_group1 = 0;
|
||||
dev->db_tab->min_group2 = dev->db_tab->npages - 1;
|
||||
|
||||
dev->db_tab->page = kmalloc(dev->db_tab->npages *
|
||||
sizeof *dev->db_tab->page,
|
||||
GFP_KERNEL);
|
||||
dev->db_tab->page = kmalloc_array(dev->db_tab->npages,
|
||||
sizeof(*dev->db_tab->page),
|
||||
GFP_KERNEL);
|
||||
if (!dev->db_tab->page) {
|
||||
kfree(dev->db_tab);
|
||||
return -ENOMEM;
|
||||
|
|
|
@ -153,7 +153,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
|
|||
|
||||
for (i = 0; i <= buddy->max_order; ++i) {
|
||||
s = BITS_TO_LONGS(1 << (buddy->max_order - i));
|
||||
buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
|
||||
buddy->bits[i] = kmalloc_array(s, sizeof(long), GFP_KERNEL);
|
||||
if (!buddy->bits[i])
|
||||
goto err_out_free;
|
||||
bitmap_zero(buddy->bits[i],
|
||||
|
|
|
@ -1054,8 +1054,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
|
|||
size = PAGE_ALIGN(qp->send_wqe_offset +
|
||||
(qp->sq.max << qp->sq.wqe_shift));
|
||||
|
||||
qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
|
||||
GFP_KERNEL);
|
||||
qp->wrid = kmalloc_array(qp->rq.max + qp->sq.max, sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
if (!qp->wrid)
|
||||
goto err_out;
|
||||
|
||||
|
|
|
@ -155,7 +155,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd,
|
|||
if (pd->ibpd.uobject)
|
||||
return 0;
|
||||
|
||||
srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
|
||||
srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL);
|
||||
if (!srq->wrid)
|
||||
return -ENOMEM;
|
||||
|
||||
|
|
|
@ -904,7 +904,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
|
|||
int i;
|
||||
struct netdev_hw_addr *ha;
|
||||
|
||||
addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
|
||||
addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC);
|
||||
if (!addrs) {
|
||||
set_allmulti(nesdev, nic_active_bit);
|
||||
goto unlock;
|
||||
|
|
|
@ -1873,7 +1873,8 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,
|
|||
srq->bit_fields_len = (srq->rq.max_cnt / 32) +
|
||||
(srq->rq.max_cnt % 32 ? 1 : 0);
|
||||
srq->idx_bit_fields =
|
||||
kmalloc(srq->bit_fields_len * sizeof(u32), GFP_KERNEL);
|
||||
kmalloc_array(srq->bit_fields_len, sizeof(u32),
|
||||
GFP_KERNEL);
|
||||
if (srq->idx_bit_fields == NULL)
|
||||
goto arm_err;
|
||||
memset(srq->idx_bit_fields, 0xff,
|
||||
|
|
|
@ -2496,15 +2496,16 @@ static void init_6120_cntrnames(struct qib_devdata *dd)
|
|||
dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1;
|
||||
else
|
||||
dd->cspec->cntrnamelen = 1 + s - cntr6120names;
|
||||
dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
|
||||
for (i = 0, s = (char *)portcntr6120names; s; i++)
|
||||
s = strchr(s + 1, '\n');
|
||||
dd->cspec->nportcntrs = i - 1;
|
||||
dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1;
|
||||
dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
|
||||
sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
}
|
||||
|
||||
static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
|
||||
|
|
|
@ -3147,15 +3147,16 @@ static void init_7220_cntrnames(struct qib_devdata *dd)
|
|||
dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1;
|
||||
else
|
||||
dd->cspec->cntrnamelen = 1 + s - cntr7220names;
|
||||
dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
|
||||
for (i = 0, s = (char *)portcntr7220names; s; i++)
|
||||
s = strchr(s + 1, '\n');
|
||||
dd->cspec->nportcntrs = i - 1;
|
||||
dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1;
|
||||
dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
|
||||
sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
}
|
||||
|
||||
static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
|
||||
|
|
|
@ -3648,8 +3648,9 @@ static int qib_do_7322_reset(struct qib_devdata *dd)
|
|||
|
||||
if (msix_entries) {
|
||||
/* can be up to 512 bytes, too big for stack */
|
||||
msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries *
|
||||
sizeof(u64), GFP_KERNEL);
|
||||
msix_vecsave = kmalloc_array(2 * dd->cspec->num_msix_entries,
|
||||
sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
}
|
||||
|
||||
/*
|
||||
|
@ -5009,16 +5010,17 @@ static void init_7322_cntrnames(struct qib_devdata *dd)
|
|||
dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1;
|
||||
else
|
||||
dd->cspec->cntrnamelen = 1 + s - cntr7322names;
|
||||
dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
|
||||
for (i = 0, s = (char *)portcntr7322names; s; i++)
|
||||
s = strchr(s + 1, '\n');
|
||||
dd->cspec->nportcntrs = i - 1;
|
||||
dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1;
|
||||
for (i = 0; i < dd->num_pports; ++i) {
|
||||
dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs
|
||||
* sizeof(u64), GFP_KERNEL);
|
||||
dd->pport[i].cpspec->portcntrs =
|
||||
kmalloc_array(dd->cspec->nportcntrs, sizeof(u64),
|
||||
GFP_KERNEL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -6412,12 +6414,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd)
|
|||
sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
|
||||
NUM_VL15_BUFS + BITS_PER_LONG - 1;
|
||||
sbufcnt /= BITS_PER_LONG;
|
||||
dd->cspec->sendchkenable = kmalloc(sbufcnt *
|
||||
sizeof(*dd->cspec->sendchkenable), GFP_KERNEL);
|
||||
dd->cspec->sendgrhchk = kmalloc(sbufcnt *
|
||||
sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL);
|
||||
dd->cspec->sendibchk = kmalloc(sbufcnt *
|
||||
sizeof(*dd->cspec->sendibchk), GFP_KERNEL);
|
||||
dd->cspec->sendchkenable =
|
||||
kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable),
|
||||
GFP_KERNEL);
|
||||
dd->cspec->sendgrhchk =
|
||||
kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk),
|
||||
GFP_KERNEL);
|
||||
dd->cspec->sendibchk =
|
||||
kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk),
|
||||
GFP_KERNEL);
|
||||
if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
|
||||
!dd->cspec->sendibchk) {
|
||||
ret = -ENOMEM;
|
||||
|
|
|
@ -258,8 +258,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
|
|||
goto alloc_login_buf_fail;
|
||||
|
||||
iser_conn->num_rx_descs = session->cmds_max;
|
||||
iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
|
||||
sizeof(struct iser_rx_desc), GFP_KERNEL);
|
||||
iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
|
||||
sizeof(struct iser_rx_desc),
|
||||
GFP_KERNEL);
|
||||
if (!iser_conn->rx_descs)
|
||||
goto rx_desc_alloc_fail;
|
||||
|
||||
|
|
|
@ -1035,16 +1035,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
|
|||
|
||||
for (i = 0; i < target->req_ring_size; ++i) {
|
||||
req = &ch->req_ring[i];
|
||||
mr_list = kmalloc(target->mr_per_cmd * sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!mr_list)
|
||||
goto out;
|
||||
if (srp_dev->use_fast_reg) {
|
||||
req->fr_list = mr_list;
|
||||
} else {
|
||||
req->fmr_list = mr_list;
|
||||
req->map_page = kmalloc(srp_dev->max_pages_per_mr *
|
||||
sizeof(void *), GFP_KERNEL);
|
||||
req->map_page = kmalloc_array(srp_dev->max_pages_per_mr,
|
||||
sizeof(void *),
|
||||
GFP_KERNEL);
|
||||
if (!req->map_page)
|
||||
goto out;
|
||||
}
|
||||
|
|
|
@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev,
|
|||
WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
|
||||
&& ioctx_size != sizeof(struct srpt_send_ioctx));
|
||||
|
||||
ring = kmalloc(ring_size * sizeof(ring[0]), GFP_KERNEL);
|
||||
ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
|
||||
if (!ring)
|
||||
goto out;
|
||||
for (i = 0; i < ring_size; ++i) {
|
||||
|
|
|
@ -80,7 +80,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr
|
|||
|
||||
timeout = gameport_time(gameport, 10000); /* 10 ms */
|
||||
|
||||
buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
|
||||
buf = kmalloc_array(BUF_SIZE, sizeof(struct joydump), GFP_KERNEL);
|
||||
if (!buf) {
|
||||
printk(KERN_INFO "joydump: no memory for testing\n");
|
||||
goto jd_end;
|
||||
|
|
|
@ -3567,8 +3567,8 @@ static void __init acpi_table_parse_srat_its(void)
|
|||
if (count <= 0)
|
||||
return;
|
||||
|
||||
its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
|
||||
GFP_KERNEL);
|
||||
its_srat_maps = kmalloc_array(count, sizeof(struct its_srat_map),
|
||||
GFP_KERNEL);
|
||||
if (!its_srat_maps) {
|
||||
pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
|
||||
return;
|
||||
|
|
|
@ -2268,7 +2268,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
|
|||
strcpy(card->name, id);
|
||||
card->contrnr = contr;
|
||||
card->nbchan = profp->nbchannel;
|
||||
card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC);
|
||||
card->bchans = kmalloc_array(card->nbchan, sizeof(capidrv_bchan),
|
||||
GFP_ATOMIC);
|
||||
if (!card->bchans) {
|
||||
printk(KERN_WARNING
|
||||
"capidrv: (%s) Could not allocate bchan-structs.\n", id);
|
||||
|
|
|
@ -252,7 +252,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
|
|||
return;
|
||||
if (l > 64)
|
||||
l = 64; /* arbitrary limit */
|
||||
dbgline = kmalloc(3 * l, GFP_ATOMIC);
|
||||
dbgline = kmalloc_array(3, l, GFP_ATOMIC);
|
||||
if (!dbgline)
|
||||
return;
|
||||
for (i = 0; i < l; i++) {
|
||||
|
@ -272,7 +272,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
|
|||
return;
|
||||
if (l > 64)
|
||||
l = 64; /* arbitrary limit */
|
||||
dbgline = kmalloc(3 * l, GFP_ATOMIC);
|
||||
dbgline = kmalloc_array(3, l, GFP_ATOMIC);
|
||||
if (!dbgline)
|
||||
return;
|
||||
data += CAPIMSG_LEN(data);
|
||||
|
|
|
@ -710,7 +710,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
|
|||
cs->mode = M_UNKNOWN;
|
||||
cs->mstate = MS_UNINITIALIZED;
|
||||
|
||||
cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
|
||||
cs->bcs = kmalloc_array(channels, sizeof(struct bc_state), GFP_KERNEL);
|
||||
cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
|
||||
if (!cs->bcs || !cs->inbuf) {
|
||||
pr_err("out of memory\n");
|
||||
|
@ -1089,7 +1089,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
|
|||
drv->owner = owner;
|
||||
INIT_LIST_HEAD(&drv->list);
|
||||
|
||||
drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
|
||||
drv->cs = kmalloc_array(minors, sizeof(*drv->cs), GFP_KERNEL);
|
||||
if (!drv->cs)
|
||||
goto error;
|
||||
|
||||
|
|
Некоторые файлы не были показаны из-за слишком большого количества измененных файлов Показать больше
Загрузка…
Ссылка в новой задаче