summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKees Cook <keescook@chromium.org>2018-06-12 17:27:11 -0400
committerKees Cook <keescook@chromium.org>2018-06-12 19:19:22 -0400
commit42bc47b35320e0e587a88e437e18f80f9c5bcbb2 (patch)
tree95c9f023d6f31176ea867c6bb13d85a1963c6d18
parenta86854d0c599b3202307abceb68feee4d7061578 (diff)
treewide: Use array_size() in vmalloc()
The vmalloc() function has no 2-factor argument form, so multiplication factors need to be wrapped in array_size(). This patch replaces cases of: vmalloc(a * b) with: vmalloc(array_size(a, b)) as well as handling cases of: vmalloc(a * b * c) with: vmalloc(array3_size(a, b, c)) This does, however, attempt to ignore constant size factors like: vmalloc(4 * 1024) 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 Coccinelle script used for this was: // Fix redundant parens around sizeof(). @@ type TYPE; expression THING, E; @@ ( vmalloc( - (sizeof(TYPE)) * E + sizeof(TYPE) * E , ...) | vmalloc( - (sizeof(THING)) * E + sizeof(THING) * E , ...) ) // Drop single-byte sizes and redundant parens. @@ expression COUNT; typedef u8; typedef __u8; @@ ( vmalloc( - sizeof(u8) * (COUNT) + COUNT , ...) | vmalloc( - sizeof(__u8) * (COUNT) + COUNT , ...) | vmalloc( - sizeof(char) * (COUNT) + COUNT , ...) | vmalloc( - sizeof(unsigned char) * (COUNT) + COUNT , ...) | vmalloc( - sizeof(u8) * COUNT + COUNT , ...) | vmalloc( - sizeof(__u8) * COUNT + COUNT , ...) | vmalloc( - sizeof(char) * COUNT + COUNT , ...) | vmalloc( - 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; @@ ( vmalloc( - sizeof(TYPE) * (COUNT_ID) + array_size(COUNT_ID, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * COUNT_ID + array_size(COUNT_ID, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * (COUNT_CONST) + array_size(COUNT_CONST, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * COUNT_CONST + array_size(COUNT_CONST, sizeof(TYPE)) , ...) | vmalloc( - sizeof(THING) * (COUNT_ID) + array_size(COUNT_ID, sizeof(THING)) , ...) | vmalloc( - sizeof(THING) * COUNT_ID + array_size(COUNT_ID, sizeof(THING)) , ...) | vmalloc( - sizeof(THING) * (COUNT_CONST) + array_size(COUNT_CONST, sizeof(THING)) , ...) | vmalloc( - sizeof(THING) * COUNT_CONST + array_size(COUNT_CONST, sizeof(THING)) , ...) ) // 2-factor product, only identifiers. @@ identifier SIZE, COUNT; @@ vmalloc( - SIZE * COUNT + array_size(COUNT, SIZE) , ...) // 3-factor product with 1 sizeof(type) or sizeof(expression), with // redundant parens removed. @@ expression THING; identifier STRIDE, COUNT; type TYPE; @@ ( vmalloc( - sizeof(TYPE) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vmalloc( - sizeof(TYPE) * COUNT * STRIDE + array3_size(COUNT, STRIDE, sizeof(TYPE)) , ...) | vmalloc( - sizeof(THING) * (COUNT) * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vmalloc( - sizeof(THING) * (COUNT) * STRIDE + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vmalloc( - sizeof(THING) * COUNT * (STRIDE) + array3_size(COUNT, STRIDE, sizeof(THING)) , ...) | vmalloc( - 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; @@ ( vmalloc( - sizeof(TYPE1) * sizeof(TYPE2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | vmalloc( - sizeof(TYPE1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2)) , ...) | vmalloc( - sizeof(THING1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | vmalloc( - sizeof(THING1) * sizeof(THING2) * (COUNT) + array3_size(COUNT, sizeof(THING1), sizeof(THING2)) , ...) | vmalloc( - sizeof(TYPE1) * sizeof(THING2) * COUNT + array3_size(COUNT, sizeof(TYPE1), sizeof(THING2)) , ...) | vmalloc( - 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; @@ ( vmalloc( - (COUNT) * STRIDE * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - COUNT * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - COUNT * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - (COUNT) * (STRIDE) * SIZE + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - COUNT * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - (COUNT) * STRIDE * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - (COUNT) * (STRIDE) * (SIZE) + array3_size(COUNT, STRIDE, SIZE) , ...) | vmalloc( - 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; @@ ( vmalloc(C1 * C2 * C3, ...) | vmalloc( - E1 * E2 * E3 + array3_size(E1, E2, E3) , ...) ) // And then all remaining 2 factors products when they're not all constants. @@ expression E1, E2; constant C1, C2; @@ ( vmalloc(C1 * C2, ...) | vmalloc( - E1 * E2 + array_size(E1, E2) , ...) ) Signed-off-by: Kees Cook <keescook@chromium.org>
-rw-r--r--arch/powerpc/kernel/rtasd.c3
-rw-r--r--arch/powerpc/kvm/book3s_64_mmu_hv.c2
-rw-r--r--arch/s390/hypfs/hypfs_diag.c2
-rw-r--r--arch/s390/kernel/module.c4
-rw-r--r--arch/s390/kernel/sthyi.c2
-rw-r--r--arch/s390/kvm/gaccess.c2
-rw-r--r--arch/s390/kvm/kvm-s390.c2
-rw-r--r--arch/x86/kvm/cpuid.c5
-rw-r--r--drivers/base/firmware_loader/fallback.c2
-rw-r--r--drivers/dma/ipu/ipu_idmac.c3
-rw-r--r--drivers/gpu/drm/drm_memory.c2
-rw-r--r--drivers/gpu/drm/nouveau/nv84_fence.c2
-rw-r--r--drivers/gpu/drm/qxl/qxl_fb.c2
-rw-r--r--drivers/gpu/drm/radeon/radeon_gart.c4
-rw-r--r--drivers/gpu/drm/selftests/test-drm_mm.c2
-rw-r--r--drivers/iommu/tegra-gart.c2
-rw-r--r--drivers/isdn/i4l/isdn_bsdcomp.c5
-rw-r--r--drivers/lightnvm/pblk-gc.c2
-rw-r--r--drivers/md/bcache/sysfs.c3
-rw-r--r--drivers/md/dm-cache-policy-smq.c2
-rw-r--r--drivers/md/dm-region-hash.c2
-rw-r--r--drivers/md/dm-switch.c3
-rw-r--r--drivers/md/dm-thin.c4
-rw-r--r--drivers/media/dvb-core/dmxdev.c3
-rw-r--r--drivers/media/dvb-core/dvb_demux.c6
-rw-r--r--drivers/media/pci/meye/meye.c2
-rw-r--r--drivers/media/pci/pt1/pt1.c2
-rw-r--r--drivers/media/pci/ttpci/av7110_ipack.c2
-rw-r--r--drivers/media/platform/soc_camera/soc_camera.c3
-rw-r--r--drivers/media/v4l2-core/videobuf-dma-sg.c2
-rw-r--r--drivers/mtd/ftl.c2
-rw-r--r--drivers/mtd/mtdoops.c6
-rw-r--r--drivers/mtd/mtdswap.c4
-rw-r--r--drivers/mtd/nand/raw/nandsim.c2
-rw-r--r--drivers/mtd/rfd_ftl.c3
-rw-r--r--drivers/net/ethernet/cavium/liquidio/request_manager.c5
-rw-r--r--drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/igb/igb_ethtool.c8
-rw-r--r--drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c2
-rw-r--r--drivers/net/ethernet/intel/ixgbevf/ethtool.c8
-rw-r--r--drivers/net/ethernet/netronome/nfp/flower/metadata.c3
-rw-r--r--drivers/net/ppp/bsd_comp.c4
-rw-r--r--drivers/net/wireless/ath/ath5k/debug.c2
-rw-r--r--drivers/net/wireless/marvell/mwifiex/cfg80211.c4
-rw-r--r--drivers/oprofile/event_buffer.c2
-rw-r--r--drivers/rapidio/devices/rio_mport_cdev.c2
-rw-r--r--drivers/scsi/fnic/fnic_debugfs.c7
-rw-r--r--drivers/scsi/fnic/fnic_trace.c15
-rw-r--r--drivers/scsi/ipr.c6
-rw-r--r--drivers/scsi/osst.c2
-rw-r--r--drivers/scsi/scsi_debug.c3
-rw-r--r--drivers/staging/android/ion/ion_heap.c3
-rw-r--r--drivers/staging/greybus/camera.c5
-rw-r--r--drivers/staging/media/zoran/zoran_driver.c3
-rw-r--r--drivers/staging/rts5208/ms.c2
-rw-r--r--drivers/staging/rts5208/rtsx_chip.c2
-rw-r--r--drivers/usb/misc/sisusbvga/sisusb_con.c2
-rw-r--r--drivers/video/fbdev/xen-fbfront.c2
-rw-r--r--fs/binfmt_elf.c2
-rw-r--r--fs/cifs/misc.c4
-rw-r--r--fs/dlm/lockspace.c2
-rw-r--r--fs/reiserfs/bitmap.c2
-rw-r--r--fs/ubifs/lpt.c9
-rw-r--r--kernel/cgroup/cgroup-v1.c2
-rw-r--r--kernel/power/swap.c6
-rw-r--r--kernel/rcu/rcutorture.c5
-rw-r--r--kernel/trace/tracing_map.c2
-rw-r--r--mm/percpu-stats.c2
-rw-r--r--net/bridge/netfilter/ebtables.c11
-rw-r--r--net/netfilter/ipvs/ip_vs_conn.c3
-rw-r--r--sound/core/seq/seq_memory.c3
-rw-r--r--sound/pci/cs46xx/dsp_spos.c5
-rw-r--r--sound/pci/emu10k1/emu10k1_main.c9
-rw-r--r--sound/pci/emu10k1/emufx.c2
-rw-r--r--sound/pci/emu10k1/p16v.c2
-rw-r--r--sound/pci/maestro3.c5
-rw-r--r--sound/pci/trident/trident_main.c4
-rw-r--r--virt/kvm/kvm_main.c3
78 files changed, 160 insertions, 116 deletions
diff --git a/arch/powerpc/kernel/rtasd.c b/arch/powerpc/kernel/rtasd.c
index f915db93cd42..44d66c33d59d 100644
--- a/arch/powerpc/kernel/rtasd.c
+++ b/arch/powerpc/kernel/rtasd.c
@@ -559,7 +559,8 @@ static int __init rtas_event_scan_init(void)
559 rtas_error_log_max = rtas_get_error_log_max(); 559 rtas_error_log_max = rtas_get_error_log_max();
560 rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int); 560 rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
561 561
562 rtas_log_buf = vmalloc(rtas_error_log_buffer_max*LOG_NUMBER); 562 rtas_log_buf = vmalloc(array_size(LOG_NUMBER,
563 rtas_error_log_buffer_max));
563 if (!rtas_log_buf) { 564 if (!rtas_log_buf) {
564 printk(KERN_ERR "rtasd: no memory\n"); 565 printk(KERN_ERR "rtasd: no memory\n");
565 return -ENOMEM; 566 return -ENOMEM;
diff --git a/arch/powerpc/kvm/book3s_64_mmu_hv.c b/arch/powerpc/kvm/book3s_64_mmu_hv.c
index a670fa5fbe50..1b3fcafc685e 100644
--- a/arch/powerpc/kvm/book3s_64_mmu_hv.c
+++ b/arch/powerpc/kvm/book3s_64_mmu_hv.c
@@ -108,7 +108,7 @@ int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order)
108 npte = 1ul << (order - 4); 108 npte = 1ul << (order - 4);
109 109
110 /* Allocate reverse map array */ 110 /* Allocate reverse map array */
111 rev = vmalloc(sizeof(struct revmap_entry) * npte); 111 rev = vmalloc(array_size(npte, sizeof(struct revmap_entry)));
112 if (!rev) { 112 if (!rev) {
113 if (cma) 113 if (cma)
114 kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT)); 114 kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT));
diff --git a/arch/s390/hypfs/hypfs_diag.c b/arch/s390/hypfs/hypfs_diag.c
index be8cc53204b5..a2945b289a29 100644
--- a/arch/s390/hypfs/hypfs_diag.c
+++ b/arch/s390/hypfs/hypfs_diag.c
@@ -239,7 +239,7 @@ static void *page_align_ptr(void *ptr)
239static void *diag204_alloc_vbuf(int pages) 239static void *diag204_alloc_vbuf(int pages)
240{ 240{
241 /* The buffer has to be page aligned! */ 241 /* The buffer has to be page aligned! */
242 diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1)); 242 diag204_buf_vmalloc = vmalloc(array_size(PAGE_SIZE, (pages + 1)));
243 if (!diag204_buf_vmalloc) 243 if (!diag204_buf_vmalloc)
244 return ERR_PTR(-ENOMEM); 244 return ERR_PTR(-ENOMEM);
245 diag204_buf = page_align_ptr(diag204_buf_vmalloc); 245 diag204_buf = page_align_ptr(diag204_buf_vmalloc);
diff --git a/arch/s390/kernel/module.c b/arch/s390/kernel/module.c
index 0dc8ac8548ee..d298d3cb46d0 100644
--- a/arch/s390/kernel/module.c
+++ b/arch/s390/kernel/module.c
@@ -123,8 +123,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs,
123 123
124 /* Allocate one syminfo structure per symbol. */ 124 /* Allocate one syminfo structure per symbol. */
125 me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym); 125 me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym);
126 me->arch.syminfo = vmalloc(me->arch.nsyms * 126 me->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo),
127 sizeof(struct mod_arch_syminfo)); 127 me->arch.nsyms));
128 if (!me->arch.syminfo) 128 if (!me->arch.syminfo)
129 return -ENOMEM; 129 return -ENOMEM;
130 symbols = (void *) hdr + symtab->sh_offset; 130 symbols = (void *) hdr + symtab->sh_offset;
diff --git a/arch/s390/kernel/sthyi.c b/arch/s390/kernel/sthyi.c
index 80b862e9c53c..0859cde36f75 100644
--- a/arch/s390/kernel/sthyi.c
+++ b/arch/s390/kernel/sthyi.c
@@ -315,7 +315,7 @@ static void fill_diag(struct sthyi_sctns *sctns)
315 if (pages <= 0) 315 if (pages <= 0)
316 return; 316 return;
317 317
318 diag204_buf = vmalloc(PAGE_SIZE * pages); 318 diag204_buf = vmalloc(array_size(pages, PAGE_SIZE));
319 if (!diag204_buf) 319 if (!diag204_buf)
320 return; 320 return;
321 321
diff --git a/arch/s390/kvm/gaccess.c b/arch/s390/kvm/gaccess.c
index 8e2b8647ee12..07d30ffcfa41 100644
--- a/arch/s390/kvm/gaccess.c
+++ b/arch/s390/kvm/gaccess.c
@@ -847,7 +847,7 @@ int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data,
847 nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1; 847 nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1;
848 pages = pages_array; 848 pages = pages_array;
849 if (nr_pages > ARRAY_SIZE(pages_array)) 849 if (nr_pages > ARRAY_SIZE(pages_array))
850 pages = vmalloc(nr_pages * sizeof(unsigned long)); 850 pages = vmalloc(array_size(nr_pages, sizeof(unsigned long)));
851 if (!pages) 851 if (!pages)
852 return -ENOMEM; 852 return -ENOMEM;
853 need_ipte_lock = psw_bits(*psw).dat && !asce.r; 853 need_ipte_lock = psw_bits(*psw).dat && !asce.r;
diff --git a/arch/s390/kvm/kvm-s390.c b/arch/s390/kvm/kvm-s390.c
index 64c986243018..3f6625c64341 100644
--- a/arch/s390/kvm/kvm-s390.c
+++ b/arch/s390/kvm/kvm-s390.c
@@ -1725,7 +1725,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm,
1725 if (args->count == 0) 1725 if (args->count == 0)
1726 return 0; 1726 return 0;
1727 1727
1728 bits = vmalloc(sizeof(*bits) * args->count); 1728 bits = vmalloc(array_size(sizeof(*bits), args->count));
1729 if (!bits) 1729 if (!bits)
1730 return -ENOMEM; 1730 return -ENOMEM;
1731 1731
diff --git a/arch/x86/kvm/cpuid.c b/arch/x86/kvm/cpuid.c
index f4f30d0c25c4..66fc27b92c59 100644
--- a/arch/x86/kvm/cpuid.c
+++ b/arch/x86/kvm/cpuid.c
@@ -203,8 +203,9 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu,
203 goto out; 203 goto out;
204 r = -ENOMEM; 204 r = -ENOMEM;
205 if (cpuid->nent) { 205 if (cpuid->nent) {
206 cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry) * 206 cpuid_entries =
207 cpuid->nent); 207 vmalloc(array_size(sizeof(struct kvm_cpuid_entry),
208 cpuid->nent));
208 if (!cpuid_entries) 209 if (!cpuid_entries)
209 goto out; 210 goto out;
210 r = -EFAULT; 211 r = -EFAULT;
diff --git a/drivers/base/firmware_loader/fallback.c b/drivers/base/firmware_loader/fallback.c
index b676a99c469c..7f732744f0d3 100644
--- a/drivers/base/firmware_loader/fallback.c
+++ b/drivers/base/firmware_loader/fallback.c
@@ -403,7 +403,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size)
403 fw_priv->page_array_size * 2); 403 fw_priv->page_array_size * 2);
404 struct page **new_pages; 404 struct page **new_pages;
405 405
406 new_pages = vmalloc(new_array_size * sizeof(void *)); 406 new_pages = vmalloc(array_size(new_array_size, sizeof(void *)));
407 if (!new_pages) { 407 if (!new_pages) {
408 fw_load_abort(fw_sysfs); 408 fw_load_abort(fw_sysfs);
409 return -ENOMEM; 409 return -ENOMEM;
diff --git a/drivers/dma/ipu/ipu_idmac.c b/drivers/dma/ipu/ipu_idmac.c
index ed76044ce4b9..bbff52be4f0f 100644
--- a/drivers/dma/ipu/ipu_idmac.c
+++ b/drivers/dma/ipu/ipu_idmac.c
@@ -910,7 +910,8 @@ out:
910/* Called with ichan->chan_mutex held */ 910/* Called with ichan->chan_mutex held */
911static int idmac_desc_alloc(struct idmac_channel *ichan, int n) 911static int idmac_desc_alloc(struct idmac_channel *ichan, int n)
912{ 912{
913 struct idmac_tx_desc *desc = vmalloc(n * sizeof(struct idmac_tx_desc)); 913 struct idmac_tx_desc *desc =
914 vmalloc(array_size(n, sizeof(struct idmac_tx_desc)));
914 struct idmac *idmac = to_idmac(ichan->dma_chan.device); 915 struct idmac *idmac = to_idmac(ichan->dma_chan.device);
915 916
916 if (!desc) 917 if (!desc)
diff --git a/drivers/gpu/drm/drm_memory.c b/drivers/gpu/drm/drm_memory.c
index 3c54044214db..d69e4fc1ee77 100644
--- a/drivers/gpu/drm/drm_memory.c
+++ b/drivers/gpu/drm/drm_memory.c
@@ -80,7 +80,7 @@ static void *agp_remap(unsigned long offset, unsigned long size,
80 * page-table instead (that's probably faster anyhow...). 80 * page-table instead (that's probably faster anyhow...).
81 */ 81 */
82 /* note: use vmalloc() because num_pages could be large... */ 82 /* note: use vmalloc() because num_pages could be large... */
83 page_map = vmalloc(num_pages * sizeof(struct page *)); 83 page_map = vmalloc(array_size(num_pages, sizeof(struct page *)));
84 if (!page_map) 84 if (!page_map)
85 return NULL; 85 return NULL;
86 86
diff --git a/drivers/gpu/drm/nouveau/nv84_fence.c b/drivers/gpu/drm/nouveau/nv84_fence.c
index 090664899247..e721bb2163a0 100644
--- a/drivers/gpu/drm/nouveau/nv84_fence.c
+++ b/drivers/gpu/drm/nouveau/nv84_fence.c
@@ -141,7 +141,7 @@ nv84_fence_suspend(struct nouveau_drm *drm)
141 struct nv84_fence_priv *priv = drm->fence; 141 struct nv84_fence_priv *priv = drm->fence;
142 int i; 142 int i;
143 143
144 priv->suspend = vmalloc(drm->chan.nr * sizeof(u32)); 144 priv->suspend = vmalloc(array_size(sizeof(u32), drm->chan.nr));
145 if (priv->suspend) { 145 if (priv->suspend) {
146 for (i = 0; i < drm->chan.nr; i++) 146 for (i = 0; i < drm->chan.nr; i++)
147 priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4); 147 priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4);
diff --git a/drivers/gpu/drm/qxl/qxl_fb.c b/drivers/gpu/drm/qxl/qxl_fb.c
index 9a6752606079..ca465c0d49fa 100644
--- a/drivers/gpu/drm/qxl/qxl_fb.c
+++ b/drivers/gpu/drm/qxl/qxl_fb.c
@@ -241,7 +241,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev,
241 DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width, 241 DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width,
242 mode_cmd.height, mode_cmd.pitches[0]); 242 mode_cmd.height, mode_cmd.pitches[0]);
243 243
244 shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height); 244 shadow = vmalloc(array_size(mode_cmd.pitches[0], mode_cmd.height));
245 /* TODO: what's the usual response to memory allocation errors? */ 245 /* TODO: what's the usual response to memory allocation errors? */
246 BUG_ON(!shadow); 246 BUG_ON(!shadow);
247 DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n", 247 DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n",
diff --git a/drivers/gpu/drm/radeon/radeon_gart.c b/drivers/gpu/drm/radeon/radeon_gart.c
index 0b3ec35515f3..66149eaba78c 100644
--- a/drivers/gpu/drm/radeon/radeon_gart.c
+++ b/drivers/gpu/drm/radeon/radeon_gart.c
@@ -352,8 +352,8 @@ int radeon_gart_init(struct radeon_device *rdev)
352 radeon_gart_fini(rdev); 352 radeon_gart_fini(rdev);
353 return -ENOMEM; 353 return -ENOMEM;
354 } 354 }
355 rdev->gart.pages_entry = vmalloc(sizeof(uint64_t) * 355 rdev->gart.pages_entry = vmalloc(array_size(sizeof(uint64_t),
356 rdev->gart.num_gpu_pages); 356 rdev->gart.num_gpu_pages));
357 if (rdev->gart.pages_entry == NULL) { 357 if (rdev->gart.pages_entry == NULL) {
358 radeon_gart_fini(rdev); 358 radeon_gart_fini(rdev);
359 return -ENOMEM; 359 return -ENOMEM;
diff --git a/drivers/gpu/drm/selftests/test-drm_mm.c b/drivers/gpu/drm/selftests/test-drm_mm.c
index ab6c6c9c5b5c..7027a6739845 100644
--- a/drivers/gpu/drm/selftests/test-drm_mm.c
+++ b/drivers/gpu/drm/selftests/test-drm_mm.c
@@ -579,7 +579,7 @@ static int __igt_insert(unsigned int count, u64 size, bool replace)
579 DRM_MM_BUG_ON(!size); 579 DRM_MM_BUG_ON(!size);
580 580
581 ret = -ENOMEM; 581 ret = -ENOMEM;
582 nodes = vmalloc(count * sizeof(*nodes)); 582 nodes = vmalloc(array_size(count, sizeof(*nodes)));
583 if (!nodes) 583 if (!nodes)
584 goto err; 584 goto err;
585 585
diff --git a/drivers/iommu/tegra-gart.c b/drivers/iommu/tegra-gart.c
index 89ec24c6952c..a004f6da35f2 100644
--- a/drivers/iommu/tegra-gart.c
+++ b/drivers/iommu/tegra-gart.c
@@ -465,7 +465,7 @@ static int tegra_gart_probe(struct platform_device *pdev)
465 gart->iovmm_base = (dma_addr_t)res_remap->start; 465 gart->iovmm_base = (dma_addr_t)res_remap->start;
466 gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT); 466 gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT);
467 467
468 gart->savedata = vmalloc(sizeof(u32) * gart->page_count); 468 gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
469 if (!gart->savedata) { 469 if (!gart->savedata) {
470 dev_err(dev, "failed to allocate context save area\n"); 470 dev_err(dev, "failed to allocate context save area\n");
471 return -ENOMEM; 471 return -ENOMEM;
diff --git a/drivers/isdn/i4l/isdn_bsdcomp.c b/drivers/isdn/i4l/isdn_bsdcomp.c
index 99012c047751..7f28b967ed19 100644
--- a/drivers/isdn/i4l/isdn_bsdcomp.c
+++ b/drivers/isdn/i4l/isdn_bsdcomp.c
@@ -340,7 +340,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
340 * Allocate space for the dictionary. This may be more than one page in 340 * Allocate space for the dictionary. This may be more than one page in
341 * length. 341 * length.
342 */ 342 */
343 db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); 343 db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
344 if (!db->dict) { 344 if (!db->dict) {
345 bsd_free(db); 345 bsd_free(db);
346 return NULL; 346 return NULL;
@@ -353,7 +353,8 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data)
353 if (!decomp) 353 if (!decomp)
354 db->lens = NULL; 354 db->lens = NULL;
355 else { 355 else {
356 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); 356 db->lens = vmalloc(array_size(sizeof(db->lens[0]),
357 maxmaxcode + 1));
357 if (!db->lens) { 358 if (!db->lens) {
358 bsd_free(db); 359 bsd_free(db);
359 return (NULL); 360 return (NULL);
diff --git a/drivers/lightnvm/pblk-gc.c b/drivers/lightnvm/pblk-gc.c
index 6a4883e40cc0..080469d90b40 100644
--- a/drivers/lightnvm/pblk-gc.c
+++ b/drivers/lightnvm/pblk-gc.c
@@ -88,7 +88,7 @@ static void pblk_gc_line_ws(struct work_struct *work)
88 88
89 up(&gc->gc_sem); 89 up(&gc->gc_sem);
90 90
91 gc_rq->data = vmalloc(gc_rq->nr_secs * geo->csecs); 91 gc_rq->data = vmalloc(array_size(gc_rq->nr_secs, geo->csecs));
92 if (!gc_rq->data) { 92 if (!gc_rq->data) {
93 pr_err("pblk: could not GC line:%d (%d/%d)\n", 93 pr_err("pblk: could not GC line:%d (%d/%d)\n",
94 line->id, *line->vsc, gc_rq->nr_secs); 94 line->id, *line->vsc, gc_rq->nr_secs);
diff --git a/drivers/md/bcache/sysfs.c b/drivers/md/bcache/sysfs.c
index 8ccbc8f3b3af..225b15aa0340 100644
--- a/drivers/md/bcache/sysfs.c
+++ b/drivers/md/bcache/sysfs.c
@@ -881,7 +881,8 @@ SHOW(__bch_cache)
881 uint16_t q[31], *p, *cached; 881 uint16_t q[31], *p, *cached;
882 ssize_t ret; 882 ssize_t ret;
883 883
884 cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t)); 884 cached = p = vmalloc(array_size(sizeof(uint16_t),
885 ca->sb.nbuckets));
885 if (!p) 886 if (!p)
886 return -ENOMEM; 887 return -ENOMEM;
887 888
diff --git a/drivers/md/dm-cache-policy-smq.c b/drivers/md/dm-cache-policy-smq.c
index 4ab23d0075f6..4d69b6f4129e 100644
--- a/drivers/md/dm-cache-policy-smq.c
+++ b/drivers/md/dm-cache-policy-smq.c
@@ -588,7 +588,7 @@ static int h_init(struct smq_hash_table *ht, struct entry_space *es, unsigned nr
588 nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u)); 588 nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u));
589 ht->hash_bits = __ffs(nr_buckets); 589 ht->hash_bits = __ffs(nr_buckets);
590 590
591 ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets); 591 ht->buckets = vmalloc(array_size(nr_buckets, sizeof(*ht->buckets)));
592 if (!ht->buckets) 592 if (!ht->buckets)
593 return -ENOMEM; 593 return -ENOMEM;
594 594
diff --git a/drivers/md/dm-region-hash.c b/drivers/md/dm-region-hash.c
index abf3521b80a8..bc7795095dd9 100644
--- a/drivers/md/dm-region-hash.c
+++ b/drivers/md/dm-region-hash.c
@@ -202,7 +202,7 @@ struct dm_region_hash *dm_region_hash_create(
202 rh->shift = RH_HASH_SHIFT; 202 rh->shift = RH_HASH_SHIFT;
203 rh->prime = RH_HASH_MULT; 203 rh->prime = RH_HASH_MULT;
204 204
205 rh->buckets = vmalloc(nr_buckets * sizeof(*rh->buckets)); 205 rh->buckets = vmalloc(array_size(nr_buckets, sizeof(*rh->buckets)));
206 if (!rh->buckets) { 206 if (!rh->buckets) {
207 DMERR("unable to allocate region hash bucket memory"); 207 DMERR("unable to allocate region hash bucket memory");
208 kfree(rh); 208 kfree(rh);
diff --git a/drivers/md/dm-switch.c b/drivers/md/dm-switch.c
index 7924a6a33ddc..fae35caf3672 100644
--- a/drivers/md/dm-switch.c
+++ b/drivers/md/dm-switch.c
@@ -114,7 +114,8 @@ static int alloc_region_table(struct dm_target *ti, unsigned nr_paths)
114 return -EINVAL; 114 return -EINVAL;
115 } 115 }
116 116
117 sctx->region_table = vmalloc(nr_slots * sizeof(region_table_slot_t)); 117 sctx->region_table = vmalloc(array_size(nr_slots,
118 sizeof(region_table_slot_t)));
118 if (!sctx->region_table) { 119 if (!sctx->region_table) {
119 ti->error = "Cannot allocate region table"; 120 ti->error = "Cannot allocate region table";
120 return -ENOMEM; 121 return -ENOMEM;
diff --git a/drivers/md/dm-thin.c b/drivers/md/dm-thin.c
index 5772756c63c1..a91332557bc8 100644
--- a/drivers/md/dm-thin.c
+++ b/drivers/md/dm-thin.c
@@ -2939,7 +2939,9 @@ static struct pool *pool_create(struct mapped_device *pool_md,
2939 goto bad_mapping_pool; 2939 goto bad_mapping_pool;
2940 } 2940 }
2941 2941
2942 pool->cell_sort_array = vmalloc(sizeof(*pool->cell_sort_array) * CELL_SORT_ARRAY_SIZE); 2942 pool->cell_sort_array =
2943 vmalloc(array_size(CELL_SORT_ARRAY_SIZE,
2944 sizeof(*pool->cell_sort_array)));
2943 if (!pool->cell_sort_array) { 2945 if (!pool->cell_sort_array) {
2944 *error = "Error allocating cell sort array"; 2946 *error = "Error allocating cell sort array";
2945 err_p = ERR_PTR(-ENOMEM); 2947 err_p = ERR_PTR(-ENOMEM);
diff --git a/drivers/media/dvb-core/dmxdev.c b/drivers/media/dvb-core/dmxdev.c
index cb078d688c70..d548f98c7a67 100644
--- a/drivers/media/dvb-core/dmxdev.c
+++ b/drivers/media/dvb-core/dmxdev.c
@@ -1417,7 +1417,8 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter)
1417 if (dmxdev->demux->open(dmxdev->demux) < 0) 1417 if (dmxdev->demux->open(dmxdev->demux) < 0)
1418 return -EUSERS; 1418 return -EUSERS;
1419 1419
1420 dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter)); 1420 dmxdev->filter = vmalloc(array_size(sizeof(struct dmxdev_filter),
1421 dmxdev->filternum));
1421 if (!dmxdev->filter) 1422 if (!dmxdev->filter)
1422 return -ENOMEM; 1423 return -ENOMEM;
1423 1424
diff --git a/drivers/media/dvb-core/dvb_demux.c b/drivers/media/dvb-core/dvb_demux.c
index f45091246bdc..39a2c6ccf31d 100644
--- a/drivers/media/dvb-core/dvb_demux.c
+++ b/drivers/media/dvb-core/dvb_demux.c
@@ -1247,12 +1247,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux)
1247 1247
1248 dvbdemux->cnt_storage = NULL; 1248 dvbdemux->cnt_storage = NULL;
1249 dvbdemux->users = 0; 1249 dvbdemux->users = 0;
1250 dvbdemux->filter = vmalloc(dvbdemux->filternum * sizeof(struct dvb_demux_filter)); 1250 dvbdemux->filter = vmalloc(array_size(sizeof(struct dvb_demux_filter),
1251 dvbdemux->filternum));
1251 1252
1252 if (!dvbdemux->filter) 1253 if (!dvbdemux->filter)
1253 return -ENOMEM; 1254 return -ENOMEM;
1254 1255
1255 dvbdemux->feed = vmalloc(dvbdemux->feednum * sizeof(struct dvb_demux_feed)); 1256 dvbdemux->feed = vmalloc(array_size(sizeof(struct dvb_demux_feed),
1257 dvbdemux->feednum));
1256 if (!dvbdemux->feed) { 1258 if (!dvbdemux->feed) {
1257 vfree(dvbdemux->filter); 1259 vfree(dvbdemux->filter);
1258 dvbdemux->filter = NULL; 1260 dvbdemux->filter = NULL;
diff --git a/drivers/media/pci/meye/meye.c b/drivers/media/pci/meye/meye.c
index dedcdb573427..8001d3e9134e 100644
--- a/drivers/media/pci/meye/meye.c
+++ b/drivers/media/pci/meye/meye.c
@@ -1625,7 +1625,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent)
1625 ret = -ENOMEM; 1625 ret = -ENOMEM;
1626 meye.mchip_dev = pcidev; 1626 meye.mchip_dev = pcidev;
1627 1627
1628 meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE); 1628 meye.grab_temp = vmalloc(array_size(PAGE_SIZE, MCHIP_NB_PAGES_MJPEG));
1629 if (!meye.grab_temp) 1629 if (!meye.grab_temp)
1630 goto outvmalloc; 1630 goto outvmalloc;
1631 1631
diff --git a/drivers/media/pci/pt1/pt1.c b/drivers/media/pci/pt1/pt1.c
index 5708f69622cc..fda969a85684 100644
--- a/drivers/media/pci/pt1/pt1.c
+++ b/drivers/media/pci/pt1/pt1.c
@@ -615,7 +615,7 @@ static int pt1_init_tables(struct pt1 *pt1)
615 if (!pt1_nr_tables) 615 if (!pt1_nr_tables)
616 return 0; 616 return 0;
617 617
618 tables = vmalloc(sizeof(struct pt1_table) * pt1_nr_tables); 618 tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table)));
619 if (tables == NULL) 619 if (tables == NULL)
620 return -ENOMEM; 620 return -ENOMEM;
621 621
diff --git a/drivers/media/pci/ttpci/av7110_ipack.c b/drivers/media/pci/ttpci/av7110_ipack.c
index 5aff26574fe1..ec528fae7333 100644
--- a/drivers/media/pci/ttpci/av7110_ipack.c
+++ b/drivers/media/pci/ttpci/av7110_ipack.c
@@ -24,7 +24,7 @@ void av7110_ipack_reset(struct ipack *p)
24int av7110_ipack_init(struct ipack *p, int size, 24int av7110_ipack_init(struct ipack *p, int size,
25 void (*func)(u8 *buf, int size, void *priv)) 25 void (*func)(u8 *buf, int size, void *priv))
26{ 26{
27 if (!(p->buf = vmalloc(size*sizeof(u8)))) { 27 if (!(p->buf = vmalloc(size))) {
28 printk(KERN_WARNING "Couldn't allocate memory for ipack\n"); 28 printk(KERN_WARNING "Couldn't allocate memory for ipack\n");
29 return -ENOMEM; 29 return -ENOMEM;
30 } 30 }
diff --git a/drivers/media/platform/soc_camera/soc_camera.c b/drivers/media/platform/soc_camera/soc_camera.c
index 69f0d8e80bd8..66d613629167 100644
--- a/drivers/media/platform/soc_camera/soc_camera.c
+++ b/drivers/media/platform/soc_camera/soc_camera.c
@@ -481,7 +481,8 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd)
481 return -ENXIO; 481 return -ENXIO;
482 482
483 icd->user_formats = 483 icd->user_formats =
484 vmalloc(fmts * sizeof(struct soc_camera_format_xlate)); 484 vmalloc(array_size(fmts,
485 sizeof(struct soc_camera_format_xlate)));
485 if (!icd->user_formats) 486 if (!icd->user_formats)
486 return -ENOMEM; 487 return -ENOMEM;
487 488
diff --git a/drivers/media/v4l2-core/videobuf-dma-sg.c b/drivers/media/v4l2-core/videobuf-dma-sg.c
index 78155f596f74..314abde9a922 100644
--- a/drivers/media/v4l2-core/videobuf-dma-sg.c
+++ b/drivers/media/v4l2-core/videobuf-dma-sg.c
@@ -100,7 +100,7 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages,
100 100
101 if (NULL == pages[0]) 101 if (NULL == pages[0])
102 return NULL; 102 return NULL;
103 sglist = vmalloc(nr_pages * sizeof(*sglist)); 103 sglist = vmalloc(array_size(nr_pages, sizeof(*sglist)));
104 if (NULL == sglist) 104 if (NULL == sglist)
105 return NULL; 105 return NULL;
106 sg_init_table(sglist, nr_pages); 106 sg_init_table(sglist, nr_pages);
diff --git a/drivers/mtd/ftl.c b/drivers/mtd/ftl.c
index 1f8063c6aed1..2578f27914ef 100644
--- a/drivers/mtd/ftl.c
+++ b/drivers/mtd/ftl.c
@@ -263,7 +263,7 @@ static int build_maps(partition_t *part)
263 263
264 /* Set up virtual page map */ 264 /* Set up virtual page map */
265 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize; 265 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize;
266 part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t)); 266 part->VirtualBlockMap = vmalloc(array_size(blocks, sizeof(uint32_t)));
267 if (!part->VirtualBlockMap) 267 if (!part->VirtualBlockMap)
268 goto out_XferInfo; 268 goto out_XferInfo;
269 269
diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c
index 9f25111fd559..e078fc41aa61 100644
--- a/drivers/mtd/mtdoops.c
+++ b/drivers/mtd/mtdoops.c
@@ -330,8 +330,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd)
330 } 330 }
331 331
332 /* oops_page_used is a bit field */ 332 /* oops_page_used is a bit field */
333 cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages, 333 cxt->oops_page_used =
334 BITS_PER_LONG) * sizeof(unsigned long)); 334 vmalloc(array_size(sizeof(unsigned long),
335 DIV_ROUND_UP(mtdoops_pages,
336 BITS_PER_LONG)));
335 if (!cxt->oops_page_used) { 337 if (!cxt->oops_page_used) {
336 printk(KERN_ERR "mtdoops: could not allocate page array\n"); 338 printk(KERN_ERR "mtdoops: could not allocate page array\n");
337 return; 339 return;
diff --git a/drivers/mtd/mtdswap.c b/drivers/mtd/mtdswap.c
index 6593879595e3..d9dcb2d051b4 100644
--- a/drivers/mtd/mtdswap.c
+++ b/drivers/mtd/mtdswap.c
@@ -1317,11 +1317,11 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks,
1317 for (i = 0; i < MTDSWAP_TREE_CNT; i++) 1317 for (i = 0; i < MTDSWAP_TREE_CNT; i++)
1318 d->trees[i].root = RB_ROOT; 1318 d->trees[i].root = RB_ROOT;
1319 1319
1320 d->page_data = vmalloc(sizeof(int)*pages); 1320 d->page_data = vmalloc(array_size(pages, sizeof(int)));
1321 if (!d->page_data) 1321 if (!d->page_data)
1322 goto page_data_fail; 1322 goto page_data_fail;
1323 1323
1324 d->revmap = vmalloc(sizeof(int)*blocks); 1324 d->revmap = vmalloc(array_size(blocks, sizeof(int)));
1325 if (!d->revmap) 1325 if (!d->revmap)
1326 goto revmap_fail; 1326 goto revmap_fail;
1327 1327
diff --git a/drivers/mtd/nand/raw/nandsim.c b/drivers/mtd/nand/raw/nandsim.c
index e027c6f9d327..9dc29d4389f7 100644
--- a/drivers/mtd/nand/raw/nandsim.c
+++ b/drivers/mtd/nand/raw/nandsim.c
@@ -582,7 +582,7 @@ static int __init alloc_device(struct nandsim *ns)
582 return 0; 582 return 0;
583 } 583 }
584 584
585 ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem)); 585 ns->pages = vmalloc(array_size(sizeof(union ns_mem), ns->geom.pgnum));
586 if (!ns->pages) { 586 if (!ns->pages) {
587 NS_ERR("alloc_device: unable to allocate page array\n"); 587 NS_ERR("alloc_device: unable to allocate page array\n");
588 return -ENOMEM; 588 return -ENOMEM;
diff --git a/drivers/mtd/rfd_ftl.c b/drivers/mtd/rfd_ftl.c
index df27f24ce0fa..94720f2ca9a8 100644
--- a/drivers/mtd/rfd_ftl.c
+++ b/drivers/mtd/rfd_ftl.c
@@ -189,7 +189,8 @@ static int scan_header(struct partition *part)
189 if (!part->blocks) 189 if (!part->blocks)
190 goto err; 190 goto err;
191 191
192 part->sector_map = vmalloc(part->sector_count * sizeof(u_long)); 192 part->sector_map = vmalloc(array_size(sizeof(u_long),
193 part->sector_count));
193 if (!part->sector_map) { 194 if (!part->sector_map) {
194 printk(KERN_ERR PREFIX "'%s': unable to allocate memory for " 195 printk(KERN_ERR PREFIX "'%s': unable to allocate memory for "
195 "sector map", part->mbd.mtd->name); 196 "sector map", part->mbd.mtd->name);
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index b1270355b0b1..1f2e75da28f8 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -98,8 +98,9 @@ int octeon_init_instr_queue(struct octeon_device *oct,
98 iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs), 98 iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs),
99 numa_node); 99 numa_node);
100 if (!iq->request_list) 100 if (!iq->request_list)
101 iq->request_list = vmalloc(sizeof(*iq->request_list) * 101 iq->request_list =
102 num_descs); 102 vmalloc(array_size(num_descs,
103 sizeof(*iq->request_list)));
103 if (!iq->request_list) { 104 if (!iq->request_list) {
104 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); 105 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma);
105 dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", 106 dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n",
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
index 7657daa27298..4895dd83dd08 100644
--- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
+++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c
@@ -558,7 +558,7 @@ static int fm10k_set_ringparam(struct net_device *netdev,
558 558
559 /* allocate temporary buffer to store rings in */ 559 /* allocate temporary buffer to store rings in */
560 i = max_t(int, interface->num_tx_queues, interface->num_rx_queues); 560 i = max_t(int, interface->num_tx_queues, interface->num_rx_queues);
561 temp_ring = vmalloc(i * sizeof(struct fm10k_ring)); 561 temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring)));
562 562
563 if (!temp_ring) { 563 if (!temp_ring) {
564 err = -ENOMEM; 564 err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c
index 0edd3cdd84b0..f92f7918112d 100644
--- a/drivers/net/ethernet/intel/igb/igb_ethtool.c
+++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c
@@ -902,11 +902,11 @@ static int igb_set_ringparam(struct net_device *netdev,
902 } 902 }
903 903
904 if (adapter->num_tx_queues > adapter->num_rx_queues) 904 if (adapter->num_tx_queues > adapter->num_rx_queues)
905 temp_ring = vmalloc(adapter->num_tx_queues * 905 temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
906 sizeof(struct igb_ring)); 906 adapter->num_tx_queues));
907 else 907 else
908 temp_ring = vmalloc(adapter->num_rx_queues * 908 temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
909 sizeof(struct igb_ring)); 909 adapter->num_rx_queues));
910 910
911 if (!temp_ring) { 911 if (!temp_ring) {
912 err = -ENOMEM; 912 err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
index be2636ea945b..bd1ba88ec1d5 100644
--- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c
@@ -1063,7 +1063,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev,
1063 /* allocate temporary buffer to store rings in */ 1063 /* allocate temporary buffer to store rings in */
1064 i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues, 1064 i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
1065 adapter->num_rx_queues); 1065 adapter->num_rx_queues);
1066 temp_ring = vmalloc(i * sizeof(struct ixgbe_ring)); 1066 temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
1067 1067
1068 if (!temp_ring) { 1068 if (!temp_ring) {
1069 err = -ENOMEM; 1069 err = -ENOMEM;
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
index e7813d76527c..631c91046f39 100644
--- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c
+++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c
@@ -282,8 +282,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
282 } 282 }
283 283
284 if (new_tx_count != adapter->tx_ring_count) { 284 if (new_tx_count != adapter->tx_ring_count) {
285 tx_ring = vmalloc((adapter->num_tx_queues + 285 tx_ring = vmalloc(array_size(sizeof(*tx_ring),
286 adapter->num_xdp_queues) * sizeof(*tx_ring)); 286 adapter->num_tx_queues +
287 adapter->num_xdp_queues));
287 if (!tx_ring) { 288 if (!tx_ring) {
288 err = -ENOMEM; 289 err = -ENOMEM;
289 goto clear_reset; 290 goto clear_reset;
@@ -327,7 +328,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev,
327 } 328 }
328 329
329 if (new_rx_count != adapter->rx_ring_count) { 330 if (new_rx_count != adapter->rx_ring_count) {
330 rx_ring = vmalloc(adapter->num_rx_queues * sizeof(*rx_ring)); 331 rx_ring = vmalloc(array_size(sizeof(*rx_ring),
332 adapter->num_rx_queues));
331 if (!rx_ring) { 333 if (!rx_ring) {
332 err = -ENOMEM; 334 err = -ENOMEM;
333 goto clear_reset; 335 goto clear_reset;
diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c
index 21668aa435e8..93fb809f50d1 100644
--- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c
+++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c
@@ -417,7 +417,8 @@ int nfp_flower_metadata_init(struct nfp_app *app)
417 417
418 /* Init ring buffer and unallocated stats_ids. */ 418 /* Init ring buffer and unallocated stats_ids. */
419 priv->stats_ids.free_list.buf = 419 priv->stats_ids.free_list.buf =
420 vmalloc(NFP_FL_STATS_ENTRY_RS * NFP_FL_STATS_ELEM_RS); 420 vmalloc(array_size(NFP_FL_STATS_ELEM_RS,
421 NFP_FL_STATS_ENTRY_RS));
421 if (!priv->stats_ids.free_list.buf) 422 if (!priv->stats_ids.free_list.buf)
422 goto err_free_last_used; 423 goto err_free_last_used;
423 424
diff --git a/drivers/net/ppp/bsd_comp.c b/drivers/net/ppp/bsd_comp.c
index a9b759add187..61fedb23d3cf 100644
--- a/drivers/net/ppp/bsd_comp.c
+++ b/drivers/net/ppp/bsd_comp.c
@@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
406 * Allocate space for the dictionary. This may be more than one page in 406 * Allocate space for the dictionary. This may be more than one page in
407 * length. 407 * length.
408 */ 408 */
409 db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); 409 db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
410 if (!db->dict) 410 if (!db->dict)
411 { 411 {
412 bsd_free (db); 412 bsd_free (db);
@@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp)
425 */ 425 */
426 else 426 else
427 { 427 {
428 db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); 428 db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1)));
429 if (!db->lens) 429 if (!db->lens)
430 { 430 {
431 bsd_free (db); 431 bsd_free (db);
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c
index 3513bbec4639..e01faf641288 100644
--- a/drivers/net/wireless/ath/ath5k/debug.c
+++ b/drivers/net/wireless/ath/ath5k/debug.c
@@ -931,7 +931,7 @@ static int open_file_eeprom(struct inode *inode, struct file *file)
931 931
932 /* Create buffer and read in eeprom */ 932 /* Create buffer and read in eeprom */
933 933
934 buf = vmalloc(eesize * 2); 934 buf = vmalloc(array_size(eesize, 2));
935 if (!buf) { 935 if (!buf) {
936 ret = -ENOMEM; 936 ret = -ENOMEM;
937 goto err; 937 goto err;
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
index a67e2d66ac9d..4b5ae9098504 100644
--- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c
+++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c
@@ -4242,8 +4242,8 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter)
4242 * additional active scan request for hidden SSIDs on passive channels. 4242 * additional active scan request for hidden SSIDs on passive channels.
4243 */ 4243 */
4244 adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); 4244 adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a);
4245 adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) * 4245 adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats),
4246 adapter->num_in_chan_stats); 4246 adapter->num_in_chan_stats));
4247 4247
4248 if (!adapter->chan_stats) 4248 if (!adapter->chan_stats)
4249 return -ENOMEM; 4249 return -ENOMEM;
diff --git a/drivers/oprofile/event_buffer.c b/drivers/oprofile/event_buffer.c
index 32888f2bd1a9..12ea4a4ad607 100644
--- a/drivers/oprofile/event_buffer.c
+++ b/drivers/oprofile/event_buffer.c
@@ -91,7 +91,7 @@ int alloc_event_buffer(void)
91 return -EINVAL; 91 return -EINVAL;
92 92
93 buffer_pos = 0; 93 buffer_pos = 0;
94 event_buffer = vmalloc(sizeof(unsigned long) * buffer_size); 94 event_buffer = vmalloc(array_size(buffer_size, sizeof(unsigned long)));
95 if (!event_buffer) 95 if (!event_buffer)
96 return -ENOMEM; 96 return -ENOMEM;
97 97
diff --git a/drivers/rapidio/devices/rio_mport_cdev.c b/drivers/rapidio/devices/rio_mport_cdev.c
index 0434ab7b6497..a8cb8d2f2abb 100644
--- a/drivers/rapidio/devices/rio_mport_cdev.c
+++ b/drivers/rapidio/devices/rio_mport_cdev.c
@@ -975,7 +975,7 @@ static int rio_mport_transfer_ioctl(struct file *filp, void __user *arg)
975 priv->md->properties.transfer_mode) == 0) 975 priv->md->properties.transfer_mode) == 0)
976 return -ENODEV; 976 return -ENODEV;
977 977
978 transfer = vmalloc(transaction.count * sizeof(*transfer)); 978 transfer = vmalloc(array_size(sizeof(*transfer), transaction.count));
979 if (!transfer) 979 if (!transfer)
980 return -ENOMEM; 980 return -ENOMEM;
981 981
diff --git a/drivers/scsi/fnic/fnic_debugfs.c b/drivers/scsi/fnic/fnic_debugfs.c
index 6d3e1cb4fea6..139fffa3658a 100644
--- a/drivers/scsi/fnic/fnic_debugfs.c
+++ b/drivers/scsi/fnic/fnic_debugfs.c
@@ -233,8 +233,8 @@ static int fnic_trace_debugfs_open(struct inode *inode,
233 return -ENOMEM; 233 return -ENOMEM;
234 234
235 if (*rdata_ptr == fc_trc_flag->fnic_trace) { 235 if (*rdata_ptr == fc_trc_flag->fnic_trace) {
236 fnic_dbg_prt->buffer = vmalloc(3 * 236 fnic_dbg_prt->buffer = vmalloc(array3_size(3, trace_max_pages,
237 (trace_max_pages * PAGE_SIZE)); 237 PAGE_SIZE));
238 if (!fnic_dbg_prt->buffer) { 238 if (!fnic_dbg_prt->buffer) {
239 kfree(fnic_dbg_prt); 239 kfree(fnic_dbg_prt);
240 return -ENOMEM; 240 return -ENOMEM;
@@ -244,7 +244,8 @@ static int fnic_trace_debugfs_open(struct inode *inode,
244 fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt); 244 fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt);
245 } else { 245 } else {
246 fnic_dbg_prt->buffer = 246 fnic_dbg_prt->buffer =
247 vmalloc(3 * (fnic_fc_trace_max_pages * PAGE_SIZE)); 247 vmalloc(array3_size(3, fnic_fc_trace_max_pages,
248 PAGE_SIZE));
248 if (!fnic_dbg_prt->buffer) { 249 if (!fnic_dbg_prt->buffer) {
249 kfree(fnic_dbg_prt); 250 kfree(fnic_dbg_prt);
250 return -ENOMEM; 251 return -ENOMEM;
diff --git a/drivers/scsi/fnic/fnic_trace.c b/drivers/scsi/fnic/fnic_trace.c
index 98597b59c12a..8271785bdb93 100644
--- a/drivers/scsi/fnic/fnic_trace.c
+++ b/drivers/scsi/fnic/fnic_trace.c
@@ -477,8 +477,9 @@ int fnic_trace_buf_init(void)
477 } 477 }
478 memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE)); 478 memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
479 479
480 fnic_trace_entries.page_offset = vmalloc(fnic_max_trace_entries * 480 fnic_trace_entries.page_offset =
481 sizeof(unsigned long)); 481 vmalloc(array_size(fnic_max_trace_entries,
482 sizeof(unsigned long)));
482 if (!fnic_trace_entries.page_offset) { 483 if (!fnic_trace_entries.page_offset) {
483 printk(KERN_ERR PFX "Failed to allocate memory for" 484 printk(KERN_ERR PFX "Failed to allocate memory for"
484 " page_offset\n"); 485 " page_offset\n");
@@ -555,8 +556,9 @@ int fnic_fc_trace_init(void)
555 556
556 fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/ 557 fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
557 FC_TRC_SIZE_BYTES; 558 FC_TRC_SIZE_BYTES;
558 fnic_fc_ctlr_trace_buf_p = (unsigned long)vmalloc( 559 fnic_fc_ctlr_trace_buf_p =
559 fnic_fc_trace_max_pages * PAGE_SIZE); 560 (unsigned long)vmalloc(array_size(PAGE_SIZE,
561 fnic_fc_trace_max_pages));
560 if (!fnic_fc_ctlr_trace_buf_p) { 562 if (!fnic_fc_ctlr_trace_buf_p) {
561 pr_err("fnic: Failed to allocate memory for " 563 pr_err("fnic: Failed to allocate memory for "
562 "FC Control Trace Buf\n"); 564 "FC Control Trace Buf\n");
@@ -568,8 +570,9 @@ int fnic_fc_trace_init(void)
568 fnic_fc_trace_max_pages * PAGE_SIZE); 570 fnic_fc_trace_max_pages * PAGE_SIZE);
569 571
570 /* Allocate memory for page offset */ 572 /* Allocate memory for page offset */
571 fc_trace_entries.page_offset = vmalloc(fc_trace_max_entries * 573 fc_trace_entries.page_offset =
572 sizeof(unsigned long)); 574 vmalloc(array_size(fc_trace_max_entries,
575 sizeof(unsigned long)));
573 if (!fc_trace_entries.page_offset) { 576 if (!fc_trace_entries.page_offset) {
574 pr_err("fnic:Failed to allocate memory for page_offset\n"); 577 pr_err("fnic:Failed to allocate memory for page_offset\n");
575 if (fnic_fc_ctlr_trace_buf_p) { 578 if (fnic_fc_ctlr_trace_buf_p) {
diff --git a/drivers/scsi/ipr.c b/drivers/scsi/ipr.c
index e63785d5df32..0a9b8b387bd2 100644
--- a/drivers/scsi/ipr.c
+++ b/drivers/scsi/ipr.c
@@ -4331,9 +4331,11 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg)
4331 } 4331 }
4332 4332
4333 if (ioa_cfg->sis64) 4333 if (ioa_cfg->sis64)
4334 ioa_data = vmalloc(IPR_FMT3_MAX_NUM_DUMP_PAGES * sizeof(__be32 *)); 4334 ioa_data = vmalloc(array_size(IPR_FMT3_MAX_NUM_DUMP_PAGES,
4335 sizeof(__be32 *)));
4335 else 4336 else
4336 ioa_data = vmalloc(IPR_FMT2_MAX_NUM_DUMP_PAGES * sizeof(__be32 *)); 4337 ioa_data = vmalloc(array_size(IPR_FMT2_MAX_NUM_DUMP_PAGES,
4338 sizeof(__be32 *)));
4337 4339
4338 if (!ioa_data) { 4340 if (!ioa_data) {
4339 ipr_err("Dump memory allocation failed\n"); 4341 ipr_err("Dump memory allocation failed\n");
diff --git a/drivers/scsi/osst.c b/drivers/scsi/osst.c
index 928ee4e89813..7a1a1edde35d 100644
--- a/drivers/scsi/osst.c
+++ b/drivers/scsi/osst.c
@@ -1488,7 +1488,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst
1488 int dbg = debugging; 1488 int dbg = debugging;
1489#endif 1489#endif
1490 1490
1491 if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL) 1491 if ((buffer = vmalloc(array_size((nframes + 1), OS_DATA_SIZE))) == NULL)
1492 return (-EIO); 1492 return (-EIO);
1493 1493
1494 printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n", 1494 printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
diff --git a/drivers/scsi/scsi_debug.c b/drivers/scsi/scsi_debug.c
index 798a6afa4cbf..24d7496cd9e2 100644
--- a/drivers/scsi/scsi_debug.c
+++ b/drivers/scsi/scsi_debug.c
@@ -5439,7 +5439,8 @@ static int __init scsi_debug_init(void)
5439 } 5439 }
5440 5440
5441 map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1; 5441 map_size = lba_to_map_index(sdebug_store_sectors - 1) + 1;
5442 map_storep = vmalloc(BITS_TO_LONGS(map_size) * sizeof(long)); 5442 map_storep = vmalloc(array_size(sizeof(long),
5443 BITS_TO_LONGS(map_size)));
5443 5444
5444 pr_info("%lu provisioning blocks\n", map_size); 5445 pr_info("%lu provisioning blocks\n", map_size);
5445 5446
diff --git a/drivers/staging/android/ion/ion_heap.c b/drivers/staging/android/ion/ion_heap.c
index 772dad65396e..e8c440329708 100644
--- a/drivers/staging/android/ion/ion_heap.c
+++ b/drivers/staging/android/ion/ion_heap.c
@@ -25,7 +25,8 @@ void *ion_heap_map_kernel(struct ion_heap *heap,
25 pgprot_t pgprot; 25 pgprot_t pgprot;
26 struct sg_table *table = buffer->sg_table; 26 struct sg_table *table = buffer->sg_table;
27 int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE; 27 int npages = PAGE_ALIGN(buffer->size) / PAGE_SIZE;
28 struct page **pages = vmalloc(sizeof(struct page *) * npages); 28 struct page **pages = vmalloc(array_size(npages,
29 sizeof(struct page *)));
29 struct page **tmp = pages; 30 struct page **tmp = pages;
30 31
31 if (!pages) 32 if (!pages)
diff --git a/drivers/staging/greybus/camera.c b/drivers/staging/greybus/camera.c
index 341f729a9779..6dded10f4155 100644
--- a/drivers/staging/greybus/camera.c
+++ b/drivers/staging/greybus/camera.c
@@ -1175,8 +1175,9 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam)
1175 1175
1176 gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get()); 1176 gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get());
1177 1177
1178 gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) * 1178 gcam->debugfs.buffers =
1179 GB_CAMERA_DEBUGFS_BUFFER_MAX); 1179 vmalloc(array_size(GB_CAMERA_DEBUGFS_BUFFER_MAX,
1180 sizeof(*gcam->debugfs.buffers)));
1180 if (!gcam->debugfs.buffers) 1181 if (!gcam->debugfs.buffers)
1181 return -ENOMEM; 1182 return -ENOMEM;
1182 1183
diff --git a/drivers/staging/media/zoran/zoran_driver.c b/drivers/staging/media/zoran/zoran_driver.c
index 906c3549e2ba..d7842224fff6 100644
--- a/drivers/staging/media/zoran/zoran_driver.c
+++ b/drivers/staging/media/zoran/zoran_driver.c
@@ -1220,7 +1220,8 @@ static int setup_window(struct zoran_fh *fh,
1220 } 1220 }
1221 } else if (clipcount) { 1221 } else if (clipcount) {
1222 /* write our own bitmap from the clips */ 1222 /* write our own bitmap from the clips */
1223 vcp = vmalloc(sizeof(struct v4l2_clip) * (clipcount + 4)); 1223 vcp = vmalloc(array_size(sizeof(struct v4l2_clip),
1224 clipcount + 4));
1224 if (vcp == NULL) { 1225 if (vcp == NULL) {
1225 dprintk(1, 1226 dprintk(1,
1226 KERN_ERR 1227 KERN_ERR
diff --git a/drivers/staging/rts5208/ms.c b/drivers/staging/rts5208/ms.c
index 821256b95e22..b89ef15e3c20 100644
--- a/drivers/staging/rts5208/ms.c
+++ b/drivers/staging/rts5208/ms.c
@@ -2618,7 +2618,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no)
2618 segment = &ms_card->segment[seg_no]; 2618 segment = &ms_card->segment[seg_no];
2619 2619
2620 if (!segment->l2p_table) { 2620 if (!segment->l2p_table) {
2621 segment->l2p_table = vmalloc(table_size * 2); 2621 segment->l2p_table = vmalloc(array_size(table_size, 2));
2622 if (!segment->l2p_table) { 2622 if (!segment->l2p_table) {
2623 rtsx_trace(chip); 2623 rtsx_trace(chip);
2624 goto BUILD_FAIL; 2624 goto BUILD_FAIL;
diff --git a/drivers/staging/rts5208/rtsx_chip.c b/drivers/staging/rts5208/rtsx_chip.c
index 4ad472dd9daf..f8f9579cc679 100644
--- a/drivers/staging/rts5208/rtsx_chip.c
+++ b/drivers/staging/rts5208/rtsx_chip.c
@@ -1721,7 +1721,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf,
1721 1721
1722 dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len); 1722 dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
1723 1723
1724 data = vmalloc(dw_len * 4); 1724 data = vmalloc(array_size(dw_len, 4));
1725 if (!data) { 1725 if (!data) {
1726 rtsx_trace(chip); 1726 rtsx_trace(chip);
1727 return STATUS_NOMEM; 1727 return STATUS_NOMEM;
diff --git a/drivers/usb/misc/sisusbvga/sisusb_con.c b/drivers/usb/misc/sisusbvga/sisusb_con.c
index a0d6e0af957c..c4f017e1d17a 100644
--- a/drivers/usb/misc/sisusbvga/sisusb_con.c
+++ b/drivers/usb/misc/sisusbvga/sisusb_con.c
@@ -1243,7 +1243,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font,
1243 } 1243 }
1244 1244
1245 if (!sisusb->font_backup) 1245 if (!sisusb->font_backup)
1246 sisusb->font_backup = vmalloc(charcount * 32); 1246 sisusb->font_backup = vmalloc(array_size(charcount, 32));
1247 1247
1248 if (sisusb->font_backup) { 1248 if (sisusb->font_backup) {
1249 memcpy(sisusb->font_backup, font->data, charcount * 32); 1249 memcpy(sisusb->font_backup, font->data, charcount * 32);
diff --git a/drivers/video/fbdev/xen-fbfront.c b/drivers/video/fbdev/xen-fbfront.c
index 46f63960fa9e..6a4bbc9e1fb0 100644
--- a/drivers/video/fbdev/xen-fbfront.c
+++ b/drivers/video/fbdev/xen-fbfront.c
@@ -412,7 +412,7 @@ static int xenfb_probe(struct xenbus_device *dev,
412 412
413 info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT; 413 info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
414 414
415 info->gfns = vmalloc(sizeof(unsigned long) * info->nr_pages); 415 info->gfns = vmalloc(array_size(sizeof(unsigned long), info->nr_pages));
416 if (!info->gfns) 416 if (!info->gfns)
417 goto error_nomem; 417 goto error_nomem;
418 418
diff --git a/fs/binfmt_elf.c b/fs/binfmt_elf.c
index bf5ee6f741cd..070b6184642d 100644
--- a/fs/binfmt_elf.c
+++ b/fs/binfmt_elf.c
@@ -2294,7 +2294,7 @@ static int elf_core_dump(struct coredump_params *cprm)
2294 2294
2295 if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz)) 2295 if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz))
2296 goto end_coredump; 2296 goto end_coredump;
2297 vma_filesz = vmalloc((segs - 1) * sizeof(*vma_filesz)); 2297 vma_filesz = vmalloc(array_size(sizeof(*vma_filesz), (segs - 1)));
2298 if (!vma_filesz) 2298 if (!vma_filesz)
2299 goto end_coredump; 2299 goto end_coredump;
2300 2300
diff --git a/fs/cifs/misc.c b/fs/cifs/misc.c
index f90d4ad6624c..af29ade195c0 100644
--- a/fs/cifs/misc.c
+++ b/fs/cifs/misc.c
@@ -789,7 +789,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
789 GFP_KERNEL); 789 GFP_KERNEL);
790 790
791 if (!bv) { 791 if (!bv) {
792 bv = vmalloc(max_pages * sizeof(struct bio_vec)); 792 bv = vmalloc(array_size(max_pages, sizeof(struct bio_vec)));
793 if (!bv) 793 if (!bv)
794 return -ENOMEM; 794 return -ENOMEM;
795 } 795 }
@@ -799,7 +799,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw)
799 GFP_KERNEL); 799 GFP_KERNEL);
800 800
801 if (!pages) { 801 if (!pages) {
802 pages = vmalloc(max_pages * sizeof(struct page *)); 802 pages = vmalloc(array_size(max_pages, sizeof(struct page *)));
803 if (!pages) { 803 if (!pages) {
804 kvfree(bv); 804 kvfree(bv);
805 return -ENOMEM; 805 return -ENOMEM;
diff --git a/fs/dlm/lockspace.c b/fs/dlm/lockspace.c
index 78a7c855b06b..5ba94be006ee 100644
--- a/fs/dlm/lockspace.c
+++ b/fs/dlm/lockspace.c
@@ -517,7 +517,7 @@ static int new_lockspace(const char *name, const char *cluster,
517 size = dlm_config.ci_rsbtbl_size; 517 size = dlm_config.ci_rsbtbl_size;
518 ls->ls_rsbtbl_size = size; 518 ls->ls_rsbtbl_size = size;
519 519
520 ls->ls_rsbtbl = vmalloc(sizeof(struct dlm_rsbtable) * size); 520 ls->ls_rsbtbl = vmalloc(array_size(size, sizeof(struct dlm_rsbtable)));
521 if (!ls->ls_rsbtbl) 521 if (!ls->ls_rsbtbl)
522 goto out_lsfree; 522 goto out_lsfree;
523 for (i = 0; i < size; i++) { 523 for (i = 0; i < size; i++) {
diff --git a/fs/reiserfs/bitmap.c b/fs/reiserfs/bitmap.c
index edc8ef78b63f..bf708ac287b4 100644
--- a/fs/reiserfs/bitmap.c
+++ b/fs/reiserfs/bitmap.c
@@ -1456,7 +1456,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb)
1456 struct reiserfs_bitmap_info *bitmap; 1456 struct reiserfs_bitmap_info *bitmap;
1457 unsigned int bmap_nr = reiserfs_bmap_count(sb); 1457 unsigned int bmap_nr = reiserfs_bmap_count(sb);
1458 1458
1459 bitmap = vmalloc(sizeof(*bitmap) * bmap_nr); 1459 bitmap = vmalloc(array_size(bmap_nr, sizeof(*bitmap)));
1460 if (bitmap == NULL) 1460 if (bitmap == NULL)
1461 return -ENOMEM; 1461 return -ENOMEM;
1462 1462
diff --git a/fs/ubifs/lpt.c b/fs/ubifs/lpt.c
index d4e45adddf1e..8e99dad18880 100644
--- a/fs/ubifs/lpt.c
+++ b/fs/ubifs/lpt.c
@@ -632,7 +632,8 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first,
632 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL); 632 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
633 nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL); 633 nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
634 buf = vmalloc(c->leb_size); 634 buf = vmalloc(c->leb_size);
635 ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); 635 ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
636 c->lpt_lebs));
636 if (!pnode || !nnode || !buf || !ltab || !lsave) { 637 if (!pnode || !nnode || !buf || !ltab || !lsave) {
637 err = -ENOMEM; 638 err = -ENOMEM;
638 goto out; 639 goto out;
@@ -1626,7 +1627,8 @@ static int lpt_init_rd(struct ubifs_info *c)
1626{ 1627{
1627 int err, i; 1628 int err, i;
1628 1629
1629 c->ltab = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); 1630 c->ltab = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
1631 c->lpt_lebs));
1630 if (!c->ltab) 1632 if (!c->ltab)
1631 return -ENOMEM; 1633 return -ENOMEM;
1632 1634
@@ -1690,7 +1692,8 @@ static int lpt_init_wr(struct ubifs_info *c)
1690{ 1692{
1691 int err, i; 1693 int err, i;
1692 1694
1693 c->ltab_cmt = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs); 1695 c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
1696 c->lpt_lebs));
1694 if (!c->ltab_cmt) 1697 if (!c->ltab_cmt)
1695 return -ENOMEM; 1698 return -ENOMEM;
1696 1699
diff --git a/kernel/cgroup/cgroup-v1.c b/kernel/cgroup/cgroup-v1.c
index 9b3f9b04f817..8b4f0768efd6 100644
--- a/kernel/cgroup/cgroup-v1.c
+++ b/kernel/cgroup/cgroup-v1.c
@@ -195,7 +195,7 @@ struct cgroup_pidlist {
195static void *pidlist_allocate(int count) 195static void *pidlist_allocate(int count)
196{ 196{
197 if (PIDLIST_TOO_LARGE(count)) 197 if (PIDLIST_TOO_LARGE(count))
198 return vmalloc(count * sizeof(pid_t)); 198 return vmalloc(array_size(count, sizeof(pid_t)));
199 else 199 else
200 return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL); 200 return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
201} 201}
diff --git a/kernel/power/swap.c b/kernel/power/swap.c
index 1efcb5b0c3ed..c2bcf97d24c8 100644
--- a/kernel/power/swap.c
+++ b/kernel/power/swap.c
@@ -698,7 +698,7 @@ static int save_image_lzo(struct swap_map_handle *handle,
698 goto out_clean; 698 goto out_clean;
699 } 699 }
700 700
701 data = vmalloc(sizeof(*data) * nr_threads); 701 data = vmalloc(array_size(nr_threads, sizeof(*data)));
702 if (!data) { 702 if (!data) {
703 pr_err("Failed to allocate LZO data\n"); 703 pr_err("Failed to allocate LZO data\n");
704 ret = -ENOMEM; 704 ret = -ENOMEM;
@@ -1183,14 +1183,14 @@ static int load_image_lzo(struct swap_map_handle *handle,
1183 nr_threads = num_online_cpus() - 1; 1183 nr_threads = num_online_cpus() - 1;
1184 nr_threads = clamp_val(nr_threads, 1, LZO_THREADS); 1184 nr_threads = clamp_val(nr_threads, 1, LZO_THREADS);
1185 1185
1186 page = vmalloc(sizeof(*page) * LZO_MAX_RD_PAGES); 1186 page = vmalloc(array_size(LZO_MAX_RD_PAGES, sizeof(*page)));
1187 if (!page) { 1187 if (!page) {
1188 pr_err("Failed to allocate LZO page\n"); 1188 pr_err("Failed to allocate LZO page\n");
1189 ret = -ENOMEM; 1189 ret = -ENOMEM;
1190 goto out_clean; 1190 goto out_clean;
1191 } 1191 }
1192 1192
1193 data = vmalloc(sizeof(*data) * nr_threads); 1193 data = vmalloc(array_size(nr_threads, sizeof(*data)));
1194 if (!data) { 1194 if (!data) {
1195 pr_err("Failed to allocate LZO data\n"); 1195 pr_err("Failed to allocate LZO data\n");
1196 ret = -ENOMEM; 1196 ret = -ENOMEM;
diff --git a/kernel/rcu/rcutorture.c b/kernel/rcu/rcutorture.c
index e628fcfd1bde..42fcb7f05fac 100644
--- a/kernel/rcu/rcutorture.c
+++ b/kernel/rcu/rcutorture.c
@@ -831,8 +831,9 @@ rcu_torture_cbflood(void *arg)
831 cbflood_intra_holdoff > 0 && 831 cbflood_intra_holdoff > 0 &&
832 cur_ops->call && 832 cur_ops->call &&
833 cur_ops->cb_barrier) { 833 cur_ops->cb_barrier) {
834 rhp = vmalloc(sizeof(*rhp) * 834 rhp = vmalloc(array3_size(cbflood_n_burst,
835 cbflood_n_burst * cbflood_n_per_burst); 835 cbflood_n_per_burst,
836 sizeof(*rhp)));
836 err = !rhp; 837 err = !rhp;
837 } 838 }
838 if (err) { 839 if (err) {
diff --git a/kernel/trace/tracing_map.c b/kernel/trace/tracing_map.c
index 5cadb1b8b5fe..752d8042bad4 100644
--- a/kernel/trace/tracing_map.c
+++ b/kernel/trace/tracing_map.c
@@ -1075,7 +1075,7 @@ int tracing_map_sort_entries(struct tracing_map *map,
1075 struct tracing_map_sort_entry *sort_entry, **entries; 1075 struct tracing_map_sort_entry *sort_entry, **entries;
1076 int i, n_entries, ret; 1076 int i, n_entries, ret;
1077 1077
1078 entries = vmalloc(map->max_elts * sizeof(sort_entry)); 1078 entries = vmalloc(array_size(sizeof(sort_entry), map->max_elts));
1079 if (!entries) 1079 if (!entries)
1080 return -ENOMEM; 1080 return -ENOMEM;
1081 1081
diff --git a/mm/percpu-stats.c b/mm/percpu-stats.c
index 063ff60ecd90..b5fdd43b60c9 100644
--- a/mm/percpu-stats.c
+++ b/mm/percpu-stats.c
@@ -144,7 +144,7 @@ alloc_buffer:
144 spin_unlock_irq(&pcpu_lock); 144 spin_unlock_irq(&pcpu_lock);
145 145
146 /* there can be at most this many free and allocated fragments */ 146 /* there can be at most this many free and allocated fragments */
147 buffer = vmalloc((2 * max_nr_alloc + 1) * sizeof(int)); 147 buffer = vmalloc(array_size(sizeof(int), (2 * max_nr_alloc + 1)));
148 if (!buffer) 148 if (!buffer)
149 return -ENOMEM; 149 return -ENOMEM;
150 150
diff --git a/net/bridge/netfilter/ebtables.c b/net/bridge/netfilter/ebtables.c
index 28f68a2ec911..684b66bfa199 100644
--- a/net/bridge/netfilter/ebtables.c
+++ b/net/bridge/netfilter/ebtables.c
@@ -903,12 +903,13 @@ static int translate_table(struct net *net, const char *name,
903 * if an error occurs 903 * if an error occurs
904 */ 904 */
905 newinfo->chainstack = 905 newinfo->chainstack =
906 vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack))); 906 vmalloc(array_size(nr_cpu_ids,
907 sizeof(*(newinfo->chainstack))));
907 if (!newinfo->chainstack) 908 if (!newinfo->chainstack)
908 return -ENOMEM; 909 return -ENOMEM;
909 for_each_possible_cpu(i) { 910 for_each_possible_cpu(i) {
910 newinfo->chainstack[i] = 911 newinfo->chainstack[i] =
911 vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0]))); 912 vmalloc(array_size(udc_cnt, sizeof(*(newinfo->chainstack[0]))));
912 if (!newinfo->chainstack[i]) { 913 if (!newinfo->chainstack[i]) {
913 while (i) 914 while (i)
914 vfree(newinfo->chainstack[--i]); 915 vfree(newinfo->chainstack[--i]);
@@ -918,7 +919,7 @@ static int translate_table(struct net *net, const char *name,
918 } 919 }
919 } 920 }
920 921
921 cl_s = vmalloc(udc_cnt * sizeof(*cl_s)); 922 cl_s = vmalloc(array_size(udc_cnt, sizeof(*cl_s)));
922 if (!cl_s) 923 if (!cl_s)
923 return -ENOMEM; 924 return -ENOMEM;
924 i = 0; /* the i'th udc */ 925 i = 0; /* the i'th udc */
@@ -1293,7 +1294,7 @@ static int do_update_counters(struct net *net, const char *name,
1293 if (num_counters == 0) 1294 if (num_counters == 0)
1294 return -EINVAL; 1295 return -EINVAL;
1295 1296
1296 tmp = vmalloc(num_counters * sizeof(*tmp)); 1297 tmp = vmalloc(array_size(num_counters, sizeof(*tmp)));
1297 if (!tmp) 1298 if (!tmp)
1298 return -ENOMEM; 1299 return -ENOMEM;
1299 1300
@@ -1434,7 +1435,7 @@ static int copy_counters_to_user(struct ebt_table *t,
1434 return -EINVAL; 1435 return -EINVAL;
1435 } 1436 }
1436 1437
1437 counterstmp = vmalloc(nentries * sizeof(*counterstmp)); 1438 counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp)));
1438 if (!counterstmp) 1439 if (!counterstmp)
1439 return -ENOMEM; 1440 return -ENOMEM;
1440 1441
diff --git a/net/netfilter/ipvs/ip_vs_conn.c b/net/netfilter/ipvs/ip_vs_conn.c
index 61c3a389da89..99e0aa350dc5 100644
--- a/net/netfilter/ipvs/ip_vs_conn.c
+++ b/net/netfilter/ipvs/ip_vs_conn.c
@@ -1380,7 +1380,8 @@ int __init ip_vs_conn_init(void)
1380 /* 1380 /*
1381 * Allocate the connection hash table and initialize its list heads 1381 * Allocate the connection hash table and initialize its list heads
1382 */ 1382 */
1383 ip_vs_conn_tab = vmalloc(ip_vs_conn_tab_size * sizeof(*ip_vs_conn_tab)); 1383 ip_vs_conn_tab = vmalloc(array_size(ip_vs_conn_tab_size,
1384 sizeof(*ip_vs_conn_tab)));
1384 if (!ip_vs_conn_tab) 1385 if (!ip_vs_conn_tab)
1385 return -ENOMEM; 1386 return -ENOMEM;
1386 1387
diff --git a/sound/core/seq/seq_memory.c b/sound/core/seq/seq_memory.c
index ab1112e90f88..a4c8543176b2 100644
--- a/sound/core/seq/seq_memory.c
+++ b/sound/core/seq/seq_memory.c
@@ -389,7 +389,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool)
389 if (snd_BUG_ON(!pool)) 389 if (snd_BUG_ON(!pool))
390 return -EINVAL; 390 return -EINVAL;
391 391
392 cellptr = vmalloc(sizeof(struct snd_seq_event_cell) * pool->size); 392 cellptr = vmalloc(array_size(sizeof(struct snd_seq_event_cell),
393 pool->size));
393 if (!cellptr) 394 if (!cellptr)
394 return -ENOMEM; 395 return -ENOMEM;
395 396
diff --git a/sound/pci/cs46xx/dsp_spos.c b/sound/pci/cs46xx/dsp_spos.c
index 99d5a02f9169..598d140bb7cb 100644
--- a/sound/pci/cs46xx/dsp_spos.c
+++ b/sound/pci/cs46xx/dsp_spos.c
@@ -240,8 +240,9 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip)
240 return NULL; 240 return NULL;
241 241
242 /* better to use vmalloc for this big table */ 242 /* better to use vmalloc for this big table */
243 ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) * 243 ins->symbol_table.symbols =
244 DSP_MAX_SYMBOLS); 244 vmalloc(array_size(DSP_MAX_SYMBOLS,
245 sizeof(struct dsp_symbol_entry)));
245 ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL); 246 ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL);
246 ins->modules = kmalloc_array(DSP_MAX_MODULES, 247 ins->modules = kmalloc_array(DSP_MAX_MODULES,
247 sizeof(struct dsp_module_desc), 248 sizeof(struct dsp_module_desc),
diff --git a/sound/pci/emu10k1/emu10k1_main.c b/sound/pci/emu10k1/emu10k1_main.c
index 18267de3a269..61f85ff91cd9 100644
--- a/sound/pci/emu10k1/emu10k1_main.c
+++ b/sound/pci/emu10k1/emu10k1_main.c
@@ -1941,9 +1941,10 @@ int snd_emu10k1_create(struct snd_card *card,
1941 (unsigned long)emu->ptb_pages.addr, 1941 (unsigned long)emu->ptb_pages.addr,
1942 (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes)); 1942 (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
1943 1943
1944 emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *)); 1944 emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
1945 emu->page_addr_table = vmalloc(emu->max_cache_pages * 1945 emu->max_cache_pages));
1946 sizeof(unsigned long)); 1946 emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
1947 emu->max_cache_pages));
1947 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) { 1948 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {
1948 err = -ENOMEM; 1949 err = -ENOMEM;
1949 goto error; 1950 goto error;
@@ -2099,7 +2100,7 @@ static int alloc_pm_buffer(struct snd_emu10k1 *emu)
2099 size = ARRAY_SIZE(saved_regs); 2100 size = ARRAY_SIZE(saved_regs);
2100 if (emu->audigy) 2101 if (emu->audigy)
2101 size += ARRAY_SIZE(saved_regs_audigy); 2102 size += ARRAY_SIZE(saved_regs_audigy);
2102 emu->saved_ptr = vmalloc(4 * NUM_G * size); 2103 emu->saved_ptr = vmalloc(array3_size(4, NUM_G, size));
2103 if (!emu->saved_ptr) 2104 if (!emu->saved_ptr)
2104 return -ENOMEM; 2105 return -ENOMEM;
2105 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0) 2106 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
diff --git a/sound/pci/emu10k1/emufx.c b/sound/pci/emu10k1/emufx.c
index af1085d946ec..de2ecbe95d6c 100644
--- a/sound/pci/emu10k1/emufx.c
+++ b/sound/pci/emu10k1/emufx.c
@@ -2692,7 +2692,7 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu)
2692 if (! emu->tram_val_saved || ! emu->tram_addr_saved) 2692 if (! emu->tram_val_saved || ! emu->tram_addr_saved)
2693 return -ENOMEM; 2693 return -ENOMEM;
2694 len = emu->audigy ? 2 * 1024 : 2 * 512; 2694 len = emu->audigy ? 2 * 1024 : 2 * 512;
2695 emu->saved_icode = vmalloc(len * 4); 2695 emu->saved_icode = vmalloc(array_size(len, 4));
2696 if (! emu->saved_icode) 2696 if (! emu->saved_icode)
2697 return -ENOMEM; 2697 return -ENOMEM;
2698 return 0; 2698 return 0;
diff --git a/sound/pci/emu10k1/p16v.c b/sound/pci/emu10k1/p16v.c
index a30da78a95b7..4948b95f6665 100644
--- a/sound/pci/emu10k1/p16v.c
+++ b/sound/pci/emu10k1/p16v.c
@@ -874,7 +874,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu)
874 874
875int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu) 875int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu)
876{ 876{
877 emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80); 877 emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
878 if (! emu->p16v_saved) 878 if (! emu->p16v_saved)
879 return -ENOMEM; 879 return -ENOMEM;
880 return 0; 880 return 0;
diff --git a/sound/pci/maestro3.c b/sound/pci/maestro3.c
index 8f20dec97843..224e942f556d 100644
--- a/sound/pci/maestro3.c
+++ b/sound/pci/maestro3.c
@@ -2657,7 +2657,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci,
2657 chip->irq = pci->irq; 2657 chip->irq = pci->irq;
2658 2658
2659#ifdef CONFIG_PM_SLEEP 2659#ifdef CONFIG_PM_SLEEP
2660 chip->suspend_mem = vmalloc(sizeof(u16) * (REV_B_CODE_MEMORY_LENGTH + REV_B_DATA_MEMORY_LENGTH)); 2660 chip->suspend_mem =
2661 vmalloc(array_size(sizeof(u16),
2662 REV_B_CODE_MEMORY_LENGTH +
2663 REV_B_DATA_MEMORY_LENGTH));
2661 if (chip->suspend_mem == NULL) 2664 if (chip->suspend_mem == NULL)
2662 dev_warn(card->dev, "can't allocate apm buffer\n"); 2665 dev_warn(card->dev, "can't allocate apm buffer\n");
2663#endif 2666#endif
diff --git a/sound/pci/trident/trident_main.c b/sound/pci/trident/trident_main.c
index eabd84d9ffee..49c64fae3466 100644
--- a/sound/pci/trident/trident_main.c
+++ b/sound/pci/trident/trident_main.c
@@ -3362,7 +3362,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident)
3362 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4); 3362 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
3363 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4); 3363 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
3364 /* allocate shadow TLB page table (virtual addresses) */ 3364 /* allocate shadow TLB page table (virtual addresses) */
3365 trident->tlb.shadow_entries = vmalloc(SNDRV_TRIDENT_MAX_PAGES*sizeof(unsigned long)); 3365 trident->tlb.shadow_entries =
3366 vmalloc(array_size(SNDRV_TRIDENT_MAX_PAGES,
3367 sizeof(unsigned long)));
3366 if (!trident->tlb.shadow_entries) 3368 if (!trident->tlb.shadow_entries)
3367 return -ENOMEM; 3369 return -ENOMEM;
3368 3370
diff --git a/virt/kvm/kvm_main.c b/virt/kvm/kvm_main.c
index c7b2e927f699..828ec2ca9b31 100644
--- a/virt/kvm/kvm_main.c
+++ b/virt/kvm/kvm_main.c
@@ -3059,7 +3059,8 @@ static long kvm_vm_ioctl(struct file *filp,
3059 goto out; 3059 goto out;
3060 if (routing.nr) { 3060 if (routing.nr) {
3061 r = -ENOMEM; 3061 r = -ENOMEM;
3062 entries = vmalloc(routing.nr * sizeof(*entries)); 3062 entries = vmalloc(array_size(sizeof(*entries),
3063 routing.nr));
3063 if (!entries) 3064 if (!entries)
3064 goto out; 3065 goto out;
3065 r = -EFAULT; 3066 r = -EFAULT;