mirror of
				https://github.com/torvalds/linux.git
				synced 2025-11-04 10:40:15 +02:00 
			
		
		
		
	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:
		
							parent
							
								
									1c542f38ab
								
							
						
					
					
						commit
						6da2ec5605
					
				
					 377 changed files with 1014 additions and 748 deletions
				
			
		| 
						 | 
					@ -286,7 +286,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd,
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
 | 
						if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
 | 
				
			||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
	kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
 | 
						kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
 | 
				
			||||||
	if (!kbuf)
 | 
						if (!kbuf)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	fs = get_fs();
 | 
						fs = get_fs();
 | 
				
			||||||
| 
						 | 
					@ -324,7 +324,7 @@ asmlinkage long sys_oabi_semtimedop(int semid,
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
 | 
						if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
 | 
				
			||||||
		return -EFAULT;
 | 
							return -EFAULT;
 | 
				
			||||||
	sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL);
 | 
						sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
 | 
				
			||||||
	if (!sops)
 | 
						if (!sops)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	err = 0;
 | 
						err = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -20,7 +20,7 @@
 | 
				
			||||||
#include "mm.h"
 | 
					#include "mm.h"
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_ARM_LPAE
 | 
					#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)
 | 
					#define __pgd_free(pgd)	kfree(pgd)
 | 
				
			||||||
#else
 | 
					#else
 | 
				
			||||||
#define __pgd_alloc()	(pgd_t *)__get_free_pages(GFP_KERNEL, 2)
 | 
					#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)
 | 
					static int coverage_start(const union decode_item *table)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	coverage.base = kmalloc(MAX_COVERAGE_ENTRIES *
 | 
						coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
 | 
				
			||||||
				sizeof(struct coverage_entry), GFP_KERNEL);
 | 
									      sizeof(struct coverage_entry),
 | 
				
			||||||
 | 
									      GFP_KERNEL);
 | 
				
			||||||
	coverage.num_entries = 0;
 | 
						coverage.num_entries = 0;
 | 
				
			||||||
	coverage.nesting = 0;
 | 
						coverage.nesting = 0;
 | 
				
			||||||
	return table_iter(table, coverage_start_fn, &coverage);
 | 
						return table_iter(table, coverage_start_fn, &coverage);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -350,7 +350,8 @@ init_record_index_pools(void)
 | 
				
			||||||
	/* - 3 - */
 | 
						/* - 3 - */
 | 
				
			||||||
	slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
 | 
						slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
 | 
				
			||||||
	slidx_pool.buffer =
 | 
						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;
 | 
						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();
 | 
						int cpu = smp_processor_id();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!ia64_idtrs[cpu]) {
 | 
						if (!ia64_idtrs[cpu]) {
 | 
				
			||||||
		ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
 | 
							ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
 | 
				
			||||||
				sizeof (struct ia64_tr_entry), GFP_KERNEL);
 | 
											sizeof(struct ia64_tr_entry),
 | 
				
			||||||
 | 
											GFP_KERNEL);
 | 
				
			||||||
		if (!ia64_idtrs[cpu])
 | 
							if (!ia64_idtrs[cpu])
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						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)
 | 
						if (!sn_irq_lh)
 | 
				
			||||||
		panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
 | 
							panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -411,7 +411,7 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries)
 | 
				
			||||||
	 * and if we try that first we are likely to not waste larger
 | 
						 * and if we try that first we are likely to not waste larger
 | 
				
			||||||
	 * slabs of memory.
 | 
						 * slabs of memory.
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
 | 
						desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t),
 | 
				
			||||||
				       GFP_KERNEL|GFP_DMA);
 | 
									       GFP_KERNEL|GFP_DMA);
 | 
				
			||||||
	if (desc_base == 0)
 | 
						if (desc_base == 0)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new_blocks = max_blocks - info->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)
 | 
						if (block == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -156,7 +156,8 @@ static int hsta_msi_probe(struct platform_device *pdev)
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		goto out;
 | 
							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) {
 | 
						if (!ppc4xx_hsta_msi.irq_map) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out1;
 | 
							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)
 | 
						if (type == PCI_CAP_ID_MSIX)
 | 
				
			||||||
		pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n");
 | 
							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)
 | 
						if (!msi_data->msi_virqs)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1639,7 +1639,8 @@ void __init mpic_init(struct mpic *mpic)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
#ifdef CONFIG_PM
 | 
					#ifdef CONFIG_PM
 | 
				
			||||||
	/* allocate memory to save mpic state */
 | 
						/* allocate memory to save mpic state */
 | 
				
			||||||
	mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
 | 
						mpic->save_data = kmalloc_array(mpic->num_sources,
 | 
				
			||||||
 | 
									        sizeof(*mpic->save_data),
 | 
				
			||||||
				        GFP_KERNEL);
 | 
									        GFP_KERNEL);
 | 
				
			||||||
	BUG_ON(mpic->save_data == NULL);
 | 
						BUG_ON(mpic->save_data == NULL);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -49,7 +49,8 @@ static void *diag0c_store(unsigned int *count)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	get_online_cpus();
 | 
						get_online_cpus();
 | 
				
			||||||
	cpu_count = num_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)
 | 
						if (!cpu_vec)
 | 
				
			||||||
		goto fail_put_online_cpus;
 | 
							goto fail_put_online_cpus;
 | 
				
			||||||
	/* Note: Diag 0c needs 8 byte alignment and real storage */
 | 
						/* 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;
 | 
						debug_entry_t ***areas;
 | 
				
			||||||
	int i, j;
 | 
						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)
 | 
						if (!areas)
 | 
				
			||||||
		goto fail_malloc_areas;
 | 
							goto fail_malloc_areas;
 | 
				
			||||||
	for (i = 0; i < nr_areas; i++) {
 | 
						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])
 | 
							if (!areas[i])
 | 
				
			||||||
			goto fail_malloc_areas2;
 | 
								goto fail_malloc_areas2;
 | 
				
			||||||
		for (j = 0; j < pages_per_area; j++) {
 | 
							for (j = 0; j < pages_per_area; j++) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -527,7 +527,7 @@ static __init struct attribute **merge_attr(struct attribute **a,
 | 
				
			||||||
		j++;
 | 
							j++;
 | 
				
			||||||
	j++;
 | 
						j++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
 | 
						new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
 | 
				
			||||||
	if (!new)
 | 
						if (!new)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
	j = 0;
 | 
						j = 0;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -103,7 +103,7 @@ static int scode_set;
 | 
				
			||||||
static int
 | 
					static int
 | 
				
			||||||
dcss_set_subcodes(void)
 | 
					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;
 | 
						unsigned long rx, ry;
 | 
				
			||||||
	int rc;
 | 
						int rc;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -166,7 +166,8 @@ static int __init check_nmi_watchdog(void)
 | 
				
			||||||
	if (!atomic_read(&nmi_active))
 | 
						if (!atomic_read(&nmi_active))
 | 
				
			||||||
		return 0;
 | 
							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) {
 | 
						if (!prev_nmi_count) {
 | 
				
			||||||
		err = -ENOMEM;
 | 
							err = -ENOMEM;
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -575,7 +575,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
 | 
				
			||||||
			unsigned long *p = current_thread_info()->utraps;
 | 
								unsigned long *p = current_thread_info()->utraps;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
			current_thread_info()->utraps =
 | 
								current_thread_info()->utraps =
 | 
				
			||||||
				kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
 | 
									kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1,
 | 
				
			||||||
 | 
										      sizeof(long),
 | 
				
			||||||
					      GFP_KERNEL);
 | 
										      GFP_KERNEL);
 | 
				
			||||||
			if (!current_thread_info()->utraps) {
 | 
								if (!current_thread_info()->utraps) {
 | 
				
			||||||
				current_thread_info()->utraps = p;
 | 
									current_thread_info()->utraps = p;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
 | 
				
			||||||
	if (!bpf_jit_enable)
 | 
						if (!bpf_jit_enable)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
 | 
						addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
 | 
				
			||||||
	if (addrs == NULL)
 | 
						if (addrs == NULL)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1127,8 +1127,8 @@ static int __init ubd_init(void)
 | 
				
			||||||
			return -1;
 | 
								return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	irq_req_buffer = kmalloc(
 | 
						irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
 | 
				
			||||||
			sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
 | 
									       sizeof(struct io_thread_req *),
 | 
				
			||||||
				       GFP_KERNEL
 | 
									       GFP_KERNEL
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
	irq_remainder = 0;
 | 
						irq_remainder = 0;
 | 
				
			||||||
| 
						 | 
					@ -1137,8 +1137,8 @@ static int __init ubd_init(void)
 | 
				
			||||||
		printk(KERN_ERR "Failed to initialize ubd buffering\n");
 | 
							printk(KERN_ERR "Failed to initialize ubd buffering\n");
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	io_req_buffer = kmalloc(
 | 
						io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
 | 
				
			||||||
			sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
 | 
									      sizeof(struct io_thread_req *),
 | 
				
			||||||
				      GFP_KERNEL
 | 
									      GFP_KERNEL
 | 
				
			||||||
		);
 | 
							);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -527,13 +527,13 @@ static struct vector_queue *create_queue(
 | 
				
			||||||
	result->max_iov_frags = num_extra_frags;
 | 
						result->max_iov_frags = num_extra_frags;
 | 
				
			||||||
	for (i = 0; i < max_size; i++) {
 | 
						for (i = 0; i < max_size; i++) {
 | 
				
			||||||
		if (vp->header_size > 0)
 | 
							if (vp->header_size > 0)
 | 
				
			||||||
			iov = kmalloc(
 | 
								iov = kmalloc_array(3 + num_extra_frags,
 | 
				
			||||||
				sizeof(struct iovec) * (3 + num_extra_frags),
 | 
										    sizeof(struct iovec),
 | 
				
			||||||
					    GFP_KERNEL
 | 
										    GFP_KERNEL
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
		else
 | 
							else
 | 
				
			||||||
			iov = kmalloc(
 | 
								iov = kmalloc_array(2 + num_extra_frags,
 | 
				
			||||||
				sizeof(struct iovec) * (2 + num_extra_frags),
 | 
										    sizeof(struct iovec),
 | 
				
			||||||
					    GFP_KERNEL
 | 
										    GFP_KERNEL
 | 
				
			||||||
			);
 | 
								);
 | 
				
			||||||
		if (iov == NULL)
 | 
							if (iov == NULL)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -109,8 +109,9 @@ static int __init puv3_pm_init(void)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sleep_save = kmalloc(puv3_cpu_pm_fns->save_count
 | 
						sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count,
 | 
				
			||||||
				* sizeof(unsigned long), GFP_KERNEL);
 | 
									   sizeof(unsigned long),
 | 
				
			||||||
 | 
									   GFP_KERNEL);
 | 
				
			||||||
	if (!sleep_save) {
 | 
						if (!sleep_save) {
 | 
				
			||||||
		printk(KERN_ERR "failed to alloc memory for pm save\n");
 | 
							printk(KERN_ERR "failed to alloc memory for pm save\n");
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1637,7 +1637,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b)
 | 
				
			||||||
		j++;
 | 
							j++;
 | 
				
			||||||
	j++;
 | 
						j++;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
 | 
						new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
 | 
				
			||||||
	if (!new)
 | 
						if (!new)
 | 
				
			||||||
		return NULL;
 | 
							return NULL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -966,7 +966,7 @@ int __init hpet_enable(void)
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfg = hpet_readl(HPET_CFG);
 | 
						cfg = hpet_readl(HPET_CFG);
 | 
				
			||||||
	hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
 | 
						hpet_boot_cfg = kmalloc_array(last + 2, sizeof(*hpet_boot_cfg),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
	if (hpet_boot_cfg)
 | 
						if (hpet_boot_cfg)
 | 
				
			||||||
		*hpet_boot_cfg = cfg;
 | 
							*hpet_boot_cfg = cfg;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent)
 | 
				
			||||||
	if (ret)
 | 
						if (ret)
 | 
				
			||||||
		goto out_setup_data_kobj;
 | 
							goto out_setup_data_kobj;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL);
 | 
						kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL);
 | 
				
			||||||
	if (!kobjp) {
 | 
						if (!kobjp) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out_setup_data_kobj;
 | 
							goto out_setup_data_kobj;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1001,7 +1001,9 @@ static int svm_cpu_init(int cpu)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (svm_sev_enabled()) {
 | 
						if (svm_sev_enabled()) {
 | 
				
			||||||
		r = -ENOMEM;
 | 
							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)
 | 
							if (!sd->sev_vmcbs)
 | 
				
			||||||
			goto err_1;
 | 
								goto err_1;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1107,7 +1107,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 | 
				
			||||||
		extra_pass = true;
 | 
							extra_pass = true;
 | 
				
			||||||
		goto skip_init_addrs;
 | 
							goto skip_init_addrs;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
 | 
						addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
 | 
				
			||||||
	if (!addrs) {
 | 
						if (!addrs) {
 | 
				
			||||||
		prog = orig_prog;
 | 
							prog = orig_prog;
 | 
				
			||||||
		goto out_addrs;
 | 
							goto out_addrs;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2345,7 +2345,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog)
 | 
				
			||||||
		prog = tmp;
 | 
							prog = tmp;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
 | 
						addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
 | 
				
			||||||
	if (!addrs) {
 | 
						if (!addrs) {
 | 
				
			||||||
		prog = orig_prog;
 | 
							prog = orig_prog;
 | 
				
			||||||
		goto out;
 | 
							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())
 | 
						if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
 | 
				
			||||||
		timeout_us = calculate_destination_timeout();
 | 
							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;
 | 
						uvhub_descs = (struct uvhub_desc *)vp;
 | 
				
			||||||
	memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
 | 
						memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
 | 
				
			||||||
	uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
 | 
						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);
 | 
						BUG_ON(!state || !ldb);
 | 
				
			||||||
	ph = &ldb->ph;
 | 
						ph = &ldb->ph;
 | 
				
			||||||
	tb[0] = &ldb->toc;
 | 
						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]) {
 | 
						if (!tb[1]) {
 | 
				
			||||||
		ldm_crit("Out of memory.");
 | 
							ldm_crit("Out of memory.");
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -603,7 +603,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc,
 | 
				
			||||||
		goto out_nooutbuf;
 | 
							goto out_nooutbuf;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* avoid "the frame size is larger than 1024 bytes" compiler warning */
 | 
						/* 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)
 | 
						if (!sg)
 | 
				
			||||||
		goto out_nosg;
 | 
							goto out_nosg;
 | 
				
			||||||
	sgout = &sg[16];
 | 
						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
 | 
						 * in order to account for buggy BIOS which don't export the first two
 | 
				
			||||||
	 * special levels (see below)
 | 
						 * special levels (see below)
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) *
 | 
						br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL,
 | 
				
			||||||
	                     sizeof(*br->levels), GFP_KERNEL);
 | 
									   sizeof(*br->levels),
 | 
				
			||||||
 | 
									   GFP_KERNEL);
 | 
				
			||||||
	if (!br->levels) {
 | 
						if (!br->levels) {
 | 
				
			||||||
		result = -ENOMEM;
 | 
							result = -ENOMEM;
 | 
				
			||||||
		goto out_free;
 | 
							goto out_free;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -195,7 +195,8 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count)
 | 
				
			||||||
	struct ghes_arr ghes_arr;
 | 
						struct ghes_arr ghes_arr;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	ghes_arr.count = 0;
 | 
						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)
 | 
						if (!ghes_arr.ghes_devs)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -343,7 +343,8 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr->performance->state_count = pss->package.count;
 | 
						pr->performance->state_count = pss->package.count;
 | 
				
			||||||
	pr->performance->states =
 | 
						pr->performance->states =
 | 
				
			||||||
	    kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
 | 
						    kmalloc_array(pss->package.count,
 | 
				
			||||||
 | 
								  sizeof(struct acpi_processor_px),
 | 
				
			||||||
			  GFP_KERNEL);
 | 
								  GFP_KERNEL);
 | 
				
			||||||
	if (!pr->performance->states) {
 | 
						if (!pr->performance->states) {
 | 
				
			||||||
		result = -ENOMEM;
 | 
							result = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -534,7 +534,8 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	pr->throttling.state_count = tss->package.count;
 | 
						pr->throttling.state_count = tss->package.count;
 | 
				
			||||||
	pr->throttling.states_tss =
 | 
						pr->throttling.states_tss =
 | 
				
			||||||
	    kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
 | 
						    kmalloc_array(tss->package.count,
 | 
				
			||||||
 | 
								  sizeof(struct acpi_processor_tx_tss),
 | 
				
			||||||
			  GFP_KERNEL);
 | 
								  GFP_KERNEL);
 | 
				
			||||||
	if (!pr->throttling.states_tss) {
 | 
						if (!pr->throttling.states_tss) {
 | 
				
			||||||
		result = -ENOMEM;
 | 
							result = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1291,7 +1291,8 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id)
 | 
				
			||||||
		card->using_dma = 1;
 | 
							card->using_dma = 1;
 | 
				
			||||||
		if (1) { /* All known FPGA versions so far */
 | 
							if (1) { /* All known FPGA versions so far */
 | 
				
			||||||
			card->dma_alignment = 3;
 | 
								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) {
 | 
								if (!card->dma_bounce) {
 | 
				
			||||||
				dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
 | 
									dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
 | 
				
			||||||
				err = -ENOMEM;
 | 
									err = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -333,8 +333,8 @@ static int __init cfag12864b_init(void)
 | 
				
			||||||
		goto none;
 | 
							goto none;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cfag12864b_cache = kmalloc(sizeof(unsigned char) *
 | 
						cfag12864b_cache = kmalloc(CFAG12864B_SIZE,
 | 
				
			||||||
		CFAG12864B_SIZE, GFP_KERNEL);
 | 
									   GFP_KERNEL);
 | 
				
			||||||
	if (cfag12864b_cache == NULL) {
 | 
						if (cfag12864b_cache == NULL) {
 | 
				
			||||||
		printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 | 
							printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
 | 
				
			||||||
			"can't alloc cache buffer (%i bytes)\n",
 | 
								"can't alloc cache buffer (%i bytes)\n",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -5719,7 +5719,7 @@ static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller,
 | 
				
			||||||
      Controller->CombinedStatusBufferLength = NewStatusBufferLength;
 | 
					      Controller->CombinedStatusBufferLength = NewStatusBufferLength;
 | 
				
			||||||
      return true;
 | 
					      return true;
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  NewStatusBuffer = kmalloc(2 * Controller->CombinedStatusBufferLength,
 | 
					  NewStatusBuffer = kmalloc_array(2, Controller->CombinedStatusBufferLength,
 | 
				
			||||||
                                  GFP_ATOMIC);
 | 
					                                  GFP_ATOMIC);
 | 
				
			||||||
  if (NewStatusBuffer == NULL)
 | 
					  if (NewStatusBuffer == NULL)
 | 
				
			||||||
    {
 | 
					    {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -524,7 +524,8 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		__rq_for_each_bio(bio, rq)
 | 
							__rq_for_each_bio(bio, rq)
 | 
				
			||||||
			segments += bio_segments(bio);
 | 
								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)
 | 
							if (!bvec)
 | 
				
			||||||
			return -EIO;
 | 
								return -EIO;
 | 
				
			||||||
		cmd->bvec = bvec;
 | 
							cmd->bvec = bvec;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -197,7 +197,8 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
 | 
				
			||||||
		vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
 | 
							vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
 | 
				
			||||||
#endif
 | 
					#endif
 | 
				
			||||||
		z2ram_map = 
 | 
							z2ram_map = 
 | 
				
			||||||
			kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
 | 
								kmalloc_array(size / Z2RAM_CHUNKSIZE,
 | 
				
			||||||
 | 
					                                      sizeof(z2ram_map[0]),
 | 
				
			||||||
                                      GFP_KERNEL);
 | 
					                                      GFP_KERNEL);
 | 
				
			||||||
		if ( z2ram_map == NULL )
 | 
							if ( z2ram_map == NULL )
 | 
				
			||||||
		{
 | 
							{
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2132,7 +2132,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf,
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	nr = nframes;
 | 
						nr = nframes;
 | 
				
			||||||
	do {
 | 
						do {
 | 
				
			||||||
		cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
 | 
							cgc.buffer = kmalloc_array(nr, CD_FRAMESIZE_RAW, GFP_KERNEL);
 | 
				
			||||||
		if (cgc.buffer)
 | 
							if (cgc.buffer)
 | 
				
			||||||
			break;
 | 
								break;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user
 | 
				
			||||||
		if (ureserve.seg_count >= 16384)
 | 
							if (ureserve.seg_count >= 16384)
 | 
				
			||||||
			return -EINVAL;
 | 
								return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
 | 
							usegment = kmalloc_array(ureserve.seg_count,
 | 
				
			||||||
 | 
										 sizeof(*usegment),
 | 
				
			||||||
 | 
										 GFP_KERNEL);
 | 
				
			||||||
		if (!usegment)
 | 
							if (!usegment)
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
 | 
							ksegment = kmalloc_array(kreserve.seg_count,
 | 
				
			||||||
 | 
										 sizeof(*ksegment),
 | 
				
			||||||
 | 
										 GFP_KERNEL);
 | 
				
			||||||
		if (!ksegment) {
 | 
							if (!ksegment) {
 | 
				
			||||||
			kfree(usegment);
 | 
								kfree(usegment);
 | 
				
			||||||
			return -ENOMEM;
 | 
								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
 | 
						 * We'll work with an array of isoch_data's (one for each
 | 
				
			||||||
	 * device in dev_list) throughout this function.
 | 
						 * 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;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto get_out;
 | 
							goto get_out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -280,7 +280,7 @@ static int agp_sgi_init(void)
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
 | 
						sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
 | 
				
			||||||
					      sizeof(struct agp_bridge_data *),
 | 
										      sizeof(struct agp_bridge_data *),
 | 
				
			||||||
					      GFP_KERNEL);
 | 
										      GFP_KERNEL);
 | 
				
			||||||
	if (!sgi_tioca_agp_bridges)
 | 
						if (!sgi_tioca_agp_bridges)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge)
 | 
				
			||||||
	if (table == NULL)
 | 
						if (table == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							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)
 | 
						if (uninorth_priv.pages_arr == NULL)
 | 
				
			||||||
		goto enomem;
 | 
							goto enomem;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1891,12 +1891,13 @@ static int init_vqs(struct ports_device *portdev)
 | 
				
			||||||
	nr_ports = portdev->max_nr_ports;
 | 
						nr_ports = portdev->max_nr_ports;
 | 
				
			||||||
	nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
 | 
						nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
 | 
						vqs = kmalloc_array(nr_queues, sizeof(struct virtqueue *), GFP_KERNEL);
 | 
				
			||||||
	io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
 | 
						io_callbacks = kmalloc_array(nr_queues, sizeof(vq_callback_t *),
 | 
				
			||||||
	io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
 | 
					 | 
				
			||||||
	portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
 | 
					 | 
				
			||||||
				     GFP_KERNEL);
 | 
									     GFP_KERNEL);
 | 
				
			||||||
	portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
 | 
						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);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
	if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
 | 
						if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
 | 
				
			||||||
	    !portdev->out_vqs) {
 | 
						    !portdev->out_vqs) {
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -71,7 +71,7 @@ bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult);
 | 
						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)
 | 
						if (!table)
 | 
				
			||||||
		return ERR_PTR(-ENOMEM);
 | 
							return ERR_PTR(-ENOMEM);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -240,7 +240,7 @@ static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* generate the  IVs */
 | 
						/* 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)
 | 
						if (!ivs)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
	get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE);
 | 
						get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -970,7 +970,8 @@ static int stm32_hash_export(struct ahash_request *req, void *out)
 | 
				
			||||||
	while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY))
 | 
						while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY))
 | 
				
			||||||
		cpu_relax();
 | 
							cpu_relax();
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rctx->hw_context = kmalloc(sizeof(u32) * (3 + HASH_CSR_REGISTER_NUMBER),
 | 
						rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER,
 | 
				
			||||||
 | 
										 sizeof(u32),
 | 
				
			||||||
					 GFP_KERNEL);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	preg = rctx->hw_context;
 | 
						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 */
 | 
						/* Init the BDs, if needed */
 | 
				
			||||||
	if (bd_count) {
 | 
						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)
 | 
							if (!tsk->cookie)
 | 
				
			||||||
			goto error;
 | 
								goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -777,7 +777,7 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
 | 
				
			||||||
	struct dmaengine_unmap_data *unmap;
 | 
						struct dmaengine_unmap_data *unmap;
 | 
				
			||||||
	int err = 0;
 | 
						int err = 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
 | 
						src = kmalloc(PAGE_SIZE, GFP_KERNEL);
 | 
				
			||||||
	if (!src)
 | 
						if (!src)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -45,7 +45,7 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buffer->page_count = 0;
 | 
						buffer->page_count = 0;
 | 
				
			||||||
	buffer->page_count_mapped = 0;
 | 
						buffer->page_count_mapped = 0;
 | 
				
			||||||
	buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]),
 | 
						buffer->pages = kmalloc_array(page_count, sizeof(buffer->pages[0]),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
	if (buffer->pages == NULL)
 | 
						if (buffer->pages == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1121,7 +1121,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev)
 | 
				
			||||||
	max_receive = 1U << (dev->card->max_receive + 1);
 | 
						max_receive = 1U << (dev->card->max_receive + 1);
 | 
				
			||||||
	num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
 | 
						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) {
 | 
						if (!ptrptr) {
 | 
				
			||||||
		retval = -ENOMEM;
 | 
							retval = -ENOMEM;
 | 
				
			||||||
		goto failed;
 | 
							goto failed;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -407,7 +407,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
 | 
				
			||||||
		(*dump)[i++][1] = RREG32(addr);		\
 | 
							(*dump)[i++][1] = RREG32(addr);		\
 | 
				
			||||||
	} while (0)
 | 
						} 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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -504,7 +504,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 | 
				
			||||||
#undef HQD_N_REGS
 | 
					#undef HQD_N_REGS
 | 
				
			||||||
#define HQD_N_REGS (19+4)
 | 
					#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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -395,7 +395,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
 | 
				
			||||||
		(*dump)[i++][1] = RREG32(addr);		\
 | 
							(*dump)[i++][1] = RREG32(addr);		\
 | 
				
			||||||
	} while (0)
 | 
						} 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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -491,7 +491,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 | 
				
			||||||
#undef HQD_N_REGS
 | 
					#undef HQD_N_REGS
 | 
				
			||||||
#define HQD_N_REGS (19+4+2+3+7)
 | 
					#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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -504,7 +504,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd,
 | 
				
			||||||
		(*dump)[i++][1] = RREG32(addr);		\
 | 
							(*dump)[i++][1] = RREG32(addr);		\
 | 
				
			||||||
	} while (0)
 | 
						} 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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -606,7 +606,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd,
 | 
				
			||||||
#undef HQD_N_REGS
 | 
					#undef HQD_N_REGS
 | 
				
			||||||
#define HQD_N_REGS (19+6+7+10)
 | 
					#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)
 | 
						if (*dump == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							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[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
 | 
				
			||||||
		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)
 | 
							if (!new)
 | 
				
			||||||
			goto out;
 | 
								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))
 | 
						if (read_vbt_r10(addr, &vbt))
 | 
				
			||||||
		return -1;
 | 
							return -1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
 | 
						gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
 | 
				
			||||||
	if (!gct)
 | 
						if (!gct)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -65,12 +65,15 @@ nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu)
 | 
				
			||||||
		goto done;
 | 
							goto done;
 | 
				
			||||||
	mmu->mem = mems[ret].oclass;
 | 
						mmu->mem = mems[ret].oclass;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	mmu->heap = kmalloc(sizeof(*mmu->heap) * mmu->heap_nr, GFP_KERNEL);
 | 
						mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
 | 
				
			||||||
	mmu->type = kmalloc(sizeof(*mmu->type) * mmu->type_nr, GFP_KERNEL);
 | 
									  GFP_KERNEL);
 | 
				
			||||||
 | 
						mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
 | 
				
			||||||
 | 
									  GFP_KERNEL);
 | 
				
			||||||
	if (ret = -ENOMEM, !mmu->heap || !mmu->type)
 | 
						if (ret = -ENOMEM, !mmu->heap || !mmu->type)
 | 
				
			||||||
		goto done;
 | 
							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)
 | 
						if (!mmu->kind && mmu->kind_nr)
 | 
				
			||||||
		goto done;
 | 
							goto done;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,7 +138,8 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size,
 | 
				
			||||||
	vmm->limit = args->size;
 | 
						vmm->limit = args->size;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	vmm->page_nr = args->page_nr;
 | 
						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) {
 | 
						if (!vmm->page) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto done;
 | 
							goto done;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -73,7 +73,8 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iccsense->nr_entry = cnt;
 | 
						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)
 | 
						if (!iccsense->rail)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -171,7 +171,7 @@ gt215_link_train(struct gt215_ram *ram)
 | 
				
			||||||
		return -ENOSYS;
 | 
							return -ENOSYS;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* XXX: Multiple partitions? */
 | 
						/* XXX: Multiple partitions? */
 | 
				
			||||||
	result = kmalloc(64 * sizeof(u32), GFP_KERNEL);
 | 
						result = kmalloc_array(64, sizeof(u32), GFP_KERNEL);
 | 
				
			||||||
	if (!result)
 | 
						if (!result)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -940,8 +940,8 @@ int tiler_map_show(struct seq_file *s, void *arg)
 | 
				
			||||||
	h_adj = omap_dmm->container_height / ydiv;
 | 
						h_adj = omap_dmm->container_height / ydiv;
 | 
				
			||||||
	w_adj = omap_dmm->container_width / xdiv;
 | 
						w_adj = omap_dmm->container_width / xdiv;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
 | 
						map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
 | 
				
			||||||
	global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
 | 
						global_map = kmalloc_array(w_adj + 1, h_adj, GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!map || !global_map)
 | 
						if (!map || !global_map)
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,7 +244,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
 | 
				
			||||||
	 * DSS, GPU, etc. are not cache coherent:
 | 
						 * DSS, GPU, etc. are not cache coherent:
 | 
				
			||||||
	 */
 | 
						 */
 | 
				
			||||||
	if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
 | 
						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) {
 | 
							if (!addrs) {
 | 
				
			||||||
			ret = -ENOMEM;
 | 
								ret = -ENOMEM;
 | 
				
			||||||
			goto free_pages;
 | 
								goto free_pages;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -200,7 +200,7 @@ int qxl_device_init(struct qxl_device *qdev,
 | 
				
			||||||
		(~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
 | 
							(~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qdev->mem_slots =
 | 
						qdev->mem_slots =
 | 
				
			||||||
		kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
 | 
							kmalloc_array(qdev->n_mem_slots, sizeof(struct qxl_memslot),
 | 
				
			||||||
			      GFP_KERNEL);
 | 
								      GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	idr_init(&qdev->release_idr);
 | 
						idr_init(&qdev->release_idr);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -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 /
 | 
						dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
 | 
				
			||||||
	    (SAVAGE_DMA_PAGE_SIZE * 4);
 | 
						    (SAVAGE_DMA_PAGE_SIZE * 4);
 | 
				
			||||||
	dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
 | 
						dev_priv->dma_pages = kmalloc_array(dev_priv->nr_dma_pages,
 | 
				
			||||||
				      dev_priv->nr_dma_pages, GFP_KERNEL);
 | 
										    sizeof(drm_savage_dma_page_t),
 | 
				
			||||||
 | 
										    GFP_KERNEL);
 | 
				
			||||||
	if (dev_priv->dma_pages == NULL)
 | 
						if (dev_priv->dma_pages == NULL)
 | 
				
			||||||
		return -ENOMEM;
 | 
							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,
 | 
						DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
 | 
				
			||||||
		  epd->factored_stage_time);
 | 
							  epd->factored_stage_time);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buf = kmalloc(fb->width * fb->height, GFP_KERNEL);
 | 
						buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL);
 | 
				
			||||||
	if (!buf)
 | 
						if (!buf)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -348,7 +348,8 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free,
 | 
				
			||||||
	if (use_static)
 | 
						if (use_static)
 | 
				
			||||||
		pages_to_free = static_buf;
 | 
							pages_to_free = static_buf;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
 | 
							pages_to_free = kmalloc_array(npages_to_free,
 | 
				
			||||||
 | 
										      sizeof(struct page *),
 | 
				
			||||||
					      GFP_KERNEL);
 | 
										      GFP_KERNEL);
 | 
				
			||||||
	if (!pages_to_free) {
 | 
						if (!pages_to_free) {
 | 
				
			||||||
		pr_debug("Failed to allocate memory for pool free operation\n");
 | 
							pr_debug("Failed to allocate memory for pool free operation\n");
 | 
				
			||||||
| 
						 | 
					@ -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);
 | 
						unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* allocate array for page caching change */
 | 
						/* 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) {
 | 
						if (!caching_array) {
 | 
				
			||||||
		pr_debug("Unable to allocate table for new pages\n");
 | 
							pr_debug("Unable to allocate table for new pages\n");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -463,7 +463,8 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free,
 | 
				
			||||||
	if (use_static)
 | 
						if (use_static)
 | 
				
			||||||
		pages_to_free = static_buf;
 | 
							pages_to_free = static_buf;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
 | 
							pages_to_free = kmalloc_array(npages_to_free,
 | 
				
			||||||
 | 
										      sizeof(struct page *),
 | 
				
			||||||
					      GFP_KERNEL);
 | 
										      GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!pages_to_free) {
 | 
						if (!pages_to_free) {
 | 
				
			||||||
| 
						 | 
					@ -753,7 +754,8 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool,
 | 
				
			||||||
			(unsigned)(PAGE_SIZE/sizeof(struct page *)));
 | 
								(unsigned)(PAGE_SIZE/sizeof(struct page *)));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/* allocate array for page caching change */
 | 
						/* 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) {
 | 
						if (!caching_array) {
 | 
				
			||||||
		pr_debug("%s: Unable to allocate table for new pages\n",
 | 
							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) {
 | 
						if (vc4_state->dlist_count == vc4_state->dlist_size) {
 | 
				
			||||||
		u32 new_size = max(4u, vc4_state->dlist_count * 2);
 | 
							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)
 | 
							if (!new_dlist)
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type)
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (parser->device->maxcollection == parser->device->collection_size) {
 | 
						if (parser->device->maxcollection == parser->device->collection_size) {
 | 
				
			||||||
		collection = kmalloc(sizeof(struct hid_collection) *
 | 
							collection = kmalloc(
 | 
				
			||||||
				parser->device->collection_size * 2, GFP_KERNEL);
 | 
									array3_size(sizeof(struct hid_collection),
 | 
				
			||||||
 | 
										    parser->device->collection_size,
 | 
				
			||||||
 | 
										    2),
 | 
				
			||||||
 | 
									GFP_KERNEL);
 | 
				
			||||||
		if (collection == NULL) {
 | 
							if (collection == NULL) {
 | 
				
			||||||
			hid_err(parser->device, "failed to reallocate collection array\n");
 | 
								hid_err(parser->device, "failed to reallocate collection array\n");
 | 
				
			||||||
			return -ENOMEM;
 | 
								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 max = field->logical_maximum;
 | 
				
			||||||
	__s32 *value;
 | 
						__s32 *value;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
 | 
						value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
 | 
				
			||||||
	if (!value)
 | 
						if (!value)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -685,7 +685,7 @@ void hid_dump_report(struct hid_device *hid, int type, u8 *data,
 | 
				
			||||||
	char *buf;
 | 
						char *buf;
 | 
				
			||||||
	unsigned int i;
 | 
						unsigned int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
 | 
						buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (!buf)
 | 
						if (!buf)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -394,7 +394,8 @@ static int picolcd_set_par(struct fb_info *info)
 | 
				
			||||||
		return -EINVAL;
 | 
							return -EINVAL;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	o_fb   = fbdata->bitmap;
 | 
						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)
 | 
						if (!tmp_fb)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -218,7 +218,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	buf = kmalloc(count * sizeof(__u8), GFP_KERNEL);
 | 
						buf = kmalloc(count, GFP_KERNEL);
 | 
				
			||||||
	if (!buf) {
 | 
						if (!buf) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -244,7 +244,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client,
 | 
				
			||||||
	u8 __user **data_ptrs;
 | 
						u8 __user **data_ptrs;
 | 
				
			||||||
	int i, res;
 | 
						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) {
 | 
						if (data_ptrs == NULL) {
 | 
				
			||||||
		kfree(msgs);
 | 
							kfree(msgs);
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -985,7 +985,8 @@ static int hwif_init(ide_hwif_t *hwif)
 | 
				
			||||||
	if (!hwif->sg_max_nents)
 | 
						if (!hwif->sg_max_nents)
 | 
				
			||||||
		hwif->sg_max_nents = PRD_ENTRIES;
 | 
							hwif->sg_max_nents = PRD_ENTRIES;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
 | 
						hwif->sg_table = kmalloc_array(hwif->sg_max_nents,
 | 
				
			||||||
 | 
									       sizeof(struct scatterlist),
 | 
				
			||||||
				       GFP_KERNEL);
 | 
									       GFP_KERNEL);
 | 
				
			||||||
	if (!hwif->sg_table) {
 | 
						if (!hwif->sg_table) {
 | 
				
			||||||
		printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
 | 
							printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1855,7 +1855,7 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	rt = &id->route;
 | 
						rt = &id->route;
 | 
				
			||||||
	rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
 | 
						rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
 | 
				
			||||||
	rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
 | 
						rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec),
 | 
				
			||||||
				     GFP_KERNEL);
 | 
									     GFP_KERNEL);
 | 
				
			||||||
	if (!rt->path_rec)
 | 
						if (!rt->path_rec)
 | 
				
			||||||
		goto err;
 | 
							goto err;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -235,7 +235,8 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd             *pd,
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	if (params->cache) {
 | 
						if (params->cache) {
 | 
				
			||||||
		pool->cache_bucket =
 | 
							pool->cache_bucket =
 | 
				
			||||||
			kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
 | 
								kmalloc_array(IB_FMR_HASH_SIZE,
 | 
				
			||||||
 | 
									      sizeof(*pool->cache_bucket),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
		if (!pool->cache_bucket) {
 | 
							if (!pool->cache_bucket) {
 | 
				
			||||||
			ret = -ENOMEM;
 | 
								ret = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -92,7 +92,7 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num,
 | 
				
			||||||
		alloc->last = 0;
 | 
							alloc->last = 0;
 | 
				
			||||||
	alloc->max  = num;
 | 
						alloc->max  = num;
 | 
				
			||||||
	spin_lock_init(&alloc->lock);
 | 
						spin_lock_init(&alloc->lock);
 | 
				
			||||||
	alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
 | 
						alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
 | 
				
			||||||
				     GFP_KERNEL);
 | 
									     GFP_KERNEL);
 | 
				
			||||||
	if (!alloc->table)
 | 
						if (!alloc->table)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -302,7 +302,8 @@ static int mlx4_ib_add_gid(const union ib_gid *gid,
 | 
				
			||||||
		ctx->refcount++;
 | 
							ctx->refcount++;
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
	if (!ret && hw_update) {
 | 
						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) {
 | 
							if (!gids) {
 | 
				
			||||||
			ret = -ENOMEM;
 | 
								ret = -ENOMEM;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					@ -355,7 +356,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context)
 | 
				
			||||||
	if (!ret && hw_update) {
 | 
						if (!ret && hw_update) {
 | 
				
			||||||
		int i;
 | 
							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) {
 | 
							if (!gids) {
 | 
				
			||||||
			ret = -ENOMEM;
 | 
								ret = -ENOMEM;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
| 
						 | 
					@ -2872,7 +2874,7 @@ static void *mlx4_ib_add(struct mlx4_dev *dev)
 | 
				
			||||||
			goto err_counter;
 | 
								goto err_counter;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		ibdev->ib_uc_qpns_bitmap =
 | 
							ibdev->ib_uc_qpns_bitmap =
 | 
				
			||||||
			kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
 | 
								kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
 | 
				
			||||||
				      sizeof(long),
 | 
									      sizeof(long),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
		if (!ibdev->ib_uc_qpns_bitmap)
 | 
							if (!ibdev->ib_uc_qpns_bitmap)
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -573,7 +573,7 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp)
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qp->sqp_proxy_rcv =
 | 
						qp->sqp_proxy_rcv =
 | 
				
			||||||
		kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
 | 
							kmalloc_array(qp->rq.wqe_cnt, sizeof(struct mlx4_ib_buf),
 | 
				
			||||||
			      GFP_KERNEL);
 | 
								      GFP_KERNEL);
 | 
				
			||||||
	if (!qp->sqp_proxy_rcv)
 | 
						if (!qp->sqp_proxy_rcv)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -90,7 +90,7 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask,
 | 
				
			||||||
	alloc->max  = num;
 | 
						alloc->max  = num;
 | 
				
			||||||
	alloc->mask = mask;
 | 
						alloc->mask = mask;
 | 
				
			||||||
	spin_lock_init(&alloc->lock);
 | 
						spin_lock_init(&alloc->lock);
 | 
				
			||||||
	alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
 | 
						alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
 | 
				
			||||||
				     GFP_KERNEL);
 | 
									     GFP_KERNEL);
 | 
				
			||||||
	if (!alloc->table)
 | 
						if (!alloc->table)
 | 
				
			||||||
		return -ENOMEM;
 | 
							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 npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
 | 
				
			||||||
	int i;
 | 
						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)
 | 
						if (!array->page_list)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -220,7 +221,8 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
 | 
				
			||||||
			npages *= 2;
 | 
								npages *= 2;
 | 
				
			||||||
		}
 | 
							}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
 | 
							dma_list = kmalloc_array(npages, sizeof(*dma_list),
 | 
				
			||||||
 | 
										 GFP_KERNEL);
 | 
				
			||||||
		if (!dma_list)
 | 
							if (!dma_list)
 | 
				
			||||||
			goto err_free;
 | 
								goto err_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					@ -231,11 +233,13 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct,
 | 
				
			||||||
		npages     = (size + PAGE_SIZE - 1) / PAGE_SIZE;
 | 
							npages     = (size + PAGE_SIZE - 1) / PAGE_SIZE;
 | 
				
			||||||
		shift      = PAGE_SHIFT;
 | 
							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)
 | 
							if (!dma_list)
 | 
				
			||||||
			return -ENOMEM;
 | 
								return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		buf->page_list = kmalloc(npages * sizeof *buf->page_list,
 | 
							buf->page_list = kmalloc_array(npages,
 | 
				
			||||||
 | 
										       sizeof(*buf->page_list),
 | 
				
			||||||
					       GFP_KERNEL);
 | 
										       GFP_KERNEL);
 | 
				
			||||||
		if (!buf->page_list)
 | 
							if (!buf->page_list)
 | 
				
			||||||
			goto err_out;
 | 
								goto err_out;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -565,8 +565,8 @@ int mthca_cmd_use_events(struct mthca_dev *dev)
 | 
				
			||||||
{
 | 
					{
 | 
				
			||||||
	int i;
 | 
						int i;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dev->cmd.context = kmalloc(dev->cmd.max_cmds *
 | 
						dev->cmd.context = kmalloc_array(dev->cmd.max_cmds,
 | 
				
			||||||
				   sizeof (struct mthca_cmd_context),
 | 
										 sizeof(struct mthca_cmd_context),
 | 
				
			||||||
					 GFP_KERNEL);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
	if (!dev->cmd.context)
 | 
						if (!dev->cmd.context)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -479,7 +479,7 @@ static int mthca_create_eq(struct mthca_dev *dev,
 | 
				
			||||||
	eq->nent = roundup_pow_of_two(max(nent, 2));
 | 
						eq->nent = roundup_pow_of_two(max(nent, 2));
 | 
				
			||||||
	npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
 | 
						npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	eq->page_list = kmalloc(npages * sizeof *eq->page_list,
 | 
						eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
	if (!eq->page_list)
 | 
						if (!eq->page_list)
 | 
				
			||||||
		goto err_out;
 | 
							goto err_out;
 | 
				
			||||||
| 
						 | 
					@ -487,7 +487,7 @@ static int mthca_create_eq(struct mthca_dev *dev,
 | 
				
			||||||
	for (i = 0; i < npages; ++i)
 | 
						for (i = 0; i < npages; ++i)
 | 
				
			||||||
		eq->page_list[i].buf = NULL;
 | 
							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)
 | 
						if (!dma_list)
 | 
				
			||||||
		goto err_out_free;
 | 
							goto err_out_free;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -712,8 +712,8 @@ int mthca_init_db_tab(struct mthca_dev *dev)
 | 
				
			||||||
	dev->db_tab->max_group1 = 0;
 | 
						dev->db_tab->max_group1 = 0;
 | 
				
			||||||
	dev->db_tab->min_group2 = dev->db_tab->npages - 1;
 | 
						dev->db_tab->min_group2 = dev->db_tab->npages - 1;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	dev->db_tab->page = kmalloc(dev->db_tab->npages *
 | 
						dev->db_tab->page = kmalloc_array(dev->db_tab->npages,
 | 
				
			||||||
				    sizeof *dev->db_tab->page,
 | 
										  sizeof(*dev->db_tab->page),
 | 
				
			||||||
					  GFP_KERNEL);
 | 
										  GFP_KERNEL);
 | 
				
			||||||
	if (!dev->db_tab->page) {
 | 
						if (!dev->db_tab->page) {
 | 
				
			||||||
		kfree(dev->db_tab);
 | 
							kfree(dev->db_tab);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -153,7 +153,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i <= buddy->max_order; ++i) {
 | 
						for (i = 0; i <= buddy->max_order; ++i) {
 | 
				
			||||||
		s = BITS_TO_LONGS(1 << (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])
 | 
							if (!buddy->bits[i])
 | 
				
			||||||
			goto err_out_free;
 | 
								goto err_out_free;
 | 
				
			||||||
		bitmap_zero(buddy->bits[i],
 | 
							bitmap_zero(buddy->bits[i],
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1054,7 +1054,7 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev,
 | 
				
			||||||
	size = PAGE_ALIGN(qp->send_wqe_offset +
 | 
						size = PAGE_ALIGN(qp->send_wqe_offset +
 | 
				
			||||||
			  (qp->sq.max << qp->sq.wqe_shift));
 | 
								  (qp->sq.max << qp->sq.wqe_shift));
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
 | 
						qp->wrid = kmalloc_array(qp->rq.max + qp->sq.max, sizeof(u64),
 | 
				
			||||||
				 GFP_KERNEL);
 | 
									 GFP_KERNEL);
 | 
				
			||||||
	if (!qp->wrid)
 | 
						if (!qp->wrid)
 | 
				
			||||||
		goto err_out;
 | 
							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)
 | 
						if (pd->ibpd.uobject)
 | 
				
			||||||
		return 0;
 | 
							return 0;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
 | 
						srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL);
 | 
				
			||||||
	if (!srq->wrid)
 | 
						if (!srq->wrid)
 | 
				
			||||||
		return -ENOMEM;
 | 
							return -ENOMEM;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -904,7 +904,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev)
 | 
				
			||||||
		int i;
 | 
							int i;
 | 
				
			||||||
		struct netdev_hw_addr *ha;
 | 
							struct netdev_hw_addr *ha;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
		addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
 | 
							addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC);
 | 
				
			||||||
		if (!addrs) {
 | 
							if (!addrs) {
 | 
				
			||||||
			set_allmulti(nesdev, nic_active_bit);
 | 
								set_allmulti(nesdev, nic_active_bit);
 | 
				
			||||||
			goto unlock;
 | 
								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->bit_fields_len = (srq->rq.max_cnt / 32) +
 | 
				
			||||||
		    (srq->rq.max_cnt % 32 ? 1 : 0);
 | 
							    (srq->rq.max_cnt % 32 ? 1 : 0);
 | 
				
			||||||
		srq->idx_bit_fields =
 | 
							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)
 | 
							if (srq->idx_bit_fields == NULL)
 | 
				
			||||||
			goto arm_err;
 | 
								goto arm_err;
 | 
				
			||||||
		memset(srq->idx_bit_fields, 0xff,
 | 
							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;
 | 
							dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		dd->cspec->cntrnamelen = 1 + s - cntr6120names;
 | 
							dd->cspec->cntrnamelen = 1 + s - cntr6120names;
 | 
				
			||||||
	dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
 | 
						dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
 | 
				
			||||||
		* sizeof(u64), GFP_KERNEL);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0, s = (char *)portcntr6120names; s; i++)
 | 
						for (i = 0, s = (char *)portcntr6120names; s; i++)
 | 
				
			||||||
		s = strchr(s + 1, '\n');
 | 
							s = strchr(s + 1, '\n');
 | 
				
			||||||
	dd->cspec->nportcntrs = i - 1;
 | 
						dd->cspec->nportcntrs = i - 1;
 | 
				
			||||||
	dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1;
 | 
						dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1;
 | 
				
			||||||
	dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
 | 
						dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
 | 
				
			||||||
		* sizeof(u64), GFP_KERNEL);
 | 
										     sizeof(u64),
 | 
				
			||||||
 | 
										     GFP_KERNEL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
 | 
					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;
 | 
							dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		dd->cspec->cntrnamelen = 1 + s - cntr7220names;
 | 
							dd->cspec->cntrnamelen = 1 + s - cntr7220names;
 | 
				
			||||||
	dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
 | 
						dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
 | 
				
			||||||
		* sizeof(u64), GFP_KERNEL);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0, s = (char *)portcntr7220names; s; i++)
 | 
						for (i = 0, s = (char *)portcntr7220names; s; i++)
 | 
				
			||||||
		s = strchr(s + 1, '\n');
 | 
							s = strchr(s + 1, '\n');
 | 
				
			||||||
	dd->cspec->nportcntrs = i - 1;
 | 
						dd->cspec->nportcntrs = i - 1;
 | 
				
			||||||
	dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1;
 | 
						dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1;
 | 
				
			||||||
	dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
 | 
						dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
 | 
				
			||||||
		* sizeof(u64), GFP_KERNEL);
 | 
										     sizeof(u64),
 | 
				
			||||||
 | 
										     GFP_KERNEL);
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
 | 
					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) {
 | 
						if (msix_entries) {
 | 
				
			||||||
		/* can be up to 512 bytes, too big for stack */
 | 
							/* can be up to 512 bytes, too big for stack */
 | 
				
			||||||
		msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries *
 | 
							msix_vecsave = kmalloc_array(2 * dd->cspec->num_msix_entries,
 | 
				
			||||||
			sizeof(u64), GFP_KERNEL);
 | 
										     sizeof(u64),
 | 
				
			||||||
 | 
										     GFP_KERNEL);
 | 
				
			||||||
	}
 | 
						}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	/*
 | 
						/*
 | 
				
			||||||
| 
						 | 
					@ -5009,16 +5010,17 @@ static void init_7322_cntrnames(struct qib_devdata *dd)
 | 
				
			||||||
		dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1;
 | 
							dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1;
 | 
				
			||||||
	else
 | 
						else
 | 
				
			||||||
		dd->cspec->cntrnamelen = 1 + s - cntr7322names;
 | 
							dd->cspec->cntrnamelen = 1 + s - cntr7322names;
 | 
				
			||||||
	dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
 | 
						dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
 | 
				
			||||||
		* sizeof(u64), GFP_KERNEL);
 | 
										 GFP_KERNEL);
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0, s = (char *)portcntr7322names; s; i++)
 | 
						for (i = 0, s = (char *)portcntr7322names; s; i++)
 | 
				
			||||||
		s = strchr(s + 1, '\n');
 | 
							s = strchr(s + 1, '\n');
 | 
				
			||||||
	dd->cspec->nportcntrs = i - 1;
 | 
						dd->cspec->nportcntrs = i - 1;
 | 
				
			||||||
	dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1;
 | 
						dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1;
 | 
				
			||||||
	for (i = 0; i < dd->num_pports; ++i) {
 | 
						for (i = 0; i < dd->num_pports; ++i) {
 | 
				
			||||||
		dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs
 | 
							dd->pport[i].cpspec->portcntrs =
 | 
				
			||||||
			* sizeof(u64), GFP_KERNEL);
 | 
								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 +
 | 
						sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
 | 
				
			||||||
		NUM_VL15_BUFS + BITS_PER_LONG - 1;
 | 
							NUM_VL15_BUFS + BITS_PER_LONG - 1;
 | 
				
			||||||
	sbufcnt /= BITS_PER_LONG;
 | 
						sbufcnt /= BITS_PER_LONG;
 | 
				
			||||||
	dd->cspec->sendchkenable = kmalloc(sbufcnt *
 | 
						dd->cspec->sendchkenable =
 | 
				
			||||||
		sizeof(*dd->cspec->sendchkenable), GFP_KERNEL);
 | 
							kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable),
 | 
				
			||||||
	dd->cspec->sendgrhchk = kmalloc(sbufcnt *
 | 
								      GFP_KERNEL);
 | 
				
			||||||
		sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL);
 | 
						dd->cspec->sendgrhchk =
 | 
				
			||||||
	dd->cspec->sendibchk = kmalloc(sbufcnt *
 | 
							kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk),
 | 
				
			||||||
		sizeof(*dd->cspec->sendibchk), GFP_KERNEL);
 | 
								      GFP_KERNEL);
 | 
				
			||||||
 | 
						dd->cspec->sendibchk =
 | 
				
			||||||
 | 
							kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk),
 | 
				
			||||||
 | 
								      GFP_KERNEL);
 | 
				
			||||||
	if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
 | 
						if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
 | 
				
			||||||
		!dd->cspec->sendibchk) {
 | 
							!dd->cspec->sendibchk) {
 | 
				
			||||||
		ret = -ENOMEM;
 | 
							ret = -ENOMEM;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -258,8 +258,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn,
 | 
				
			||||||
		goto alloc_login_buf_fail;
 | 
							goto alloc_login_buf_fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	iser_conn->num_rx_descs = session->cmds_max;
 | 
						iser_conn->num_rx_descs = session->cmds_max;
 | 
				
			||||||
	iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
 | 
						iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
 | 
				
			||||||
				sizeof(struct iser_rx_desc), GFP_KERNEL);
 | 
										    sizeof(struct iser_rx_desc),
 | 
				
			||||||
 | 
										    GFP_KERNEL);
 | 
				
			||||||
	if (!iser_conn->rx_descs)
 | 
						if (!iser_conn->rx_descs)
 | 
				
			||||||
		goto rx_desc_alloc_fail;
 | 
							goto rx_desc_alloc_fail;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -1035,7 +1035,7 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	for (i = 0; i < target->req_ring_size; ++i) {
 | 
						for (i = 0; i < target->req_ring_size; ++i) {
 | 
				
			||||||
		req = &ch->req_ring[i];
 | 
							req = &ch->req_ring[i];
 | 
				
			||||||
		mr_list = kmalloc(target->mr_per_cmd * sizeof(void *),
 | 
							mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
 | 
				
			||||||
					GFP_KERNEL);
 | 
										GFP_KERNEL);
 | 
				
			||||||
		if (!mr_list)
 | 
							if (!mr_list)
 | 
				
			||||||
			goto out;
 | 
								goto out;
 | 
				
			||||||
| 
						 | 
					@ -1043,8 +1043,9 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch)
 | 
				
			||||||
			req->fr_list = mr_list;
 | 
								req->fr_list = mr_list;
 | 
				
			||||||
		} else {
 | 
							} else {
 | 
				
			||||||
			req->fmr_list = mr_list;
 | 
								req->fmr_list = mr_list;
 | 
				
			||||||
			req->map_page = kmalloc(srp_dev->max_pages_per_mr *
 | 
								req->map_page = kmalloc_array(srp_dev->max_pages_per_mr,
 | 
				
			||||||
						sizeof(void *), GFP_KERNEL);
 | 
											      sizeof(void *),
 | 
				
			||||||
 | 
											      GFP_KERNEL);
 | 
				
			||||||
			if (!req->map_page)
 | 
								if (!req->map_page)
 | 
				
			||||||
				goto out;
 | 
									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)
 | 
						WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
 | 
				
			||||||
		&& ioctx_size != sizeof(struct srpt_send_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)
 | 
						if (!ring)
 | 
				
			||||||
		goto out;
 | 
							goto out;
 | 
				
			||||||
	for (i = 0; i < ring_size; ++i) {
 | 
						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 */
 | 
						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) {
 | 
						if (!buf) {
 | 
				
			||||||
		printk(KERN_INFO "joydump: no memory for testing\n");
 | 
							printk(KERN_INFO "joydump: no memory for testing\n");
 | 
				
			||||||
		goto jd_end;
 | 
							goto jd_end;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -3567,7 +3567,7 @@ static void __init acpi_table_parse_srat_its(void)
 | 
				
			||||||
	if (count <= 0)
 | 
						if (count <= 0)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
	its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
 | 
						its_srat_maps = kmalloc_array(count, sizeof(struct its_srat_map),
 | 
				
			||||||
				      GFP_KERNEL);
 | 
									      GFP_KERNEL);
 | 
				
			||||||
	if (!its_srat_maps) {
 | 
						if (!its_srat_maps) {
 | 
				
			||||||
		pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
 | 
							pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -2268,7 +2268,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp)
 | 
				
			||||||
	strcpy(card->name, id);
 | 
						strcpy(card->name, id);
 | 
				
			||||||
	card->contrnr = contr;
 | 
						card->contrnr = contr;
 | 
				
			||||||
	card->nbchan = profp->nbchannel;
 | 
						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) {
 | 
						if (!card->bchans) {
 | 
				
			||||||
		printk(KERN_WARNING
 | 
							printk(KERN_WARNING
 | 
				
			||||||
		       "capidrv: (%s) Could not allocate bchan-structs.\n", id);
 | 
							       "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;
 | 
							return;
 | 
				
			||||||
	if (l > 64)
 | 
						if (l > 64)
 | 
				
			||||||
		l = 64; /* arbitrary limit */
 | 
							l = 64; /* arbitrary limit */
 | 
				
			||||||
	dbgline = kmalloc(3 * l, GFP_ATOMIC);
 | 
						dbgline = kmalloc_array(3, l, GFP_ATOMIC);
 | 
				
			||||||
	if (!dbgline)
 | 
						if (!dbgline)
 | 
				
			||||||
		return;
 | 
							return;
 | 
				
			||||||
	for (i = 0; i < l; i++) {
 | 
						for (i = 0; i < l; i++) {
 | 
				
			||||||
| 
						 | 
					@ -272,7 +272,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag,
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		if (l > 64)
 | 
							if (l > 64)
 | 
				
			||||||
			l = 64; /* arbitrary limit */
 | 
								l = 64; /* arbitrary limit */
 | 
				
			||||||
		dbgline = kmalloc(3 * l, GFP_ATOMIC);
 | 
							dbgline = kmalloc_array(3, l, GFP_ATOMIC);
 | 
				
			||||||
		if (!dbgline)
 | 
							if (!dbgline)
 | 
				
			||||||
			return;
 | 
								return;
 | 
				
			||||||
		data += CAPIMSG_LEN(data);
 | 
							data += CAPIMSG_LEN(data);
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -710,7 +710,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels,
 | 
				
			||||||
	cs->mode = M_UNKNOWN;
 | 
						cs->mode = M_UNKNOWN;
 | 
				
			||||||
	cs->mstate = MS_UNINITIALIZED;
 | 
						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);
 | 
						cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
 | 
				
			||||||
	if (!cs->bcs || !cs->inbuf) {
 | 
						if (!cs->bcs || !cs->inbuf) {
 | 
				
			||||||
		pr_err("out of memory\n");
 | 
							pr_err("out of memory\n");
 | 
				
			||||||
| 
						 | 
					@ -1089,7 +1089,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors,
 | 
				
			||||||
	drv->owner = owner;
 | 
						drv->owner = owner;
 | 
				
			||||||
	INIT_LIST_HEAD(&drv->list);
 | 
						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)
 | 
						if (!drv->cs)
 | 
				
			||||||
		goto error;
 | 
							goto error;
 | 
				
			||||||
 | 
					
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
Some files were not shown because too many files have changed in this diff Show more
		Loading…
	
		Reference in a new issue