History

Merge tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux

Pull more overflow updates from Kees Cook: "The rest of the overflow changes for v4.18-rc1. This includes the explicit overflow fixes from Silvio, further struct_size() conversions from Matthew, and a bug fix from Dan. But the bulk of it is the treewide conversions to use either the 2-factor argument allocators (e.g. kmalloc(a * b, ...) into kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a * b) into vmalloc(array_size(a, b)). Coccinelle was fighting me on several fronts, so I've done a bunch of manual whitespace updates in the patches as well. Summary: - Error path bug fix for overflow tests (Dan) - Additional struct_size() conversions (Matthew, Kees) - Explicitly reported overflow fixes (Silvio, Kees) - Add missing kvcalloc() function (Kees) - Treewide conversions of allocators to use either 2-factor argument variant when available, or array_size() and array3_size() as needed (Kees)" * tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits) treewide: Use array_size in f2fs_kvzalloc() treewide: Use array_size() in f2fs_kzalloc() treewide: Use array_size() in f2fs_kmalloc() treewide: Use array_size() in sock_kmalloc() treewide: Use array_size() in kvzalloc_node() treewide: Use array_size() in vzalloc_node() treewide: Use array_size() in vzalloc() treewide: Use array_size() in vmalloc() treewide: devm_kzalloc() -> devm_kcalloc() treewide: devm_kmalloc() -> devm_kmalloc_array() treewide: kvzalloc() -> kvcalloc() treewide: kvmalloc() -> kvmalloc_array() treewide: kzalloc_node() -> kcalloc_node() treewide: kzalloc() -> kcalloc() treewide: kmalloc() -> kmalloc_array() mm: Introduce kvcalloc() video: uvesafb: Fix integer overflow in allocation UBIFS: Fix potential integer overflow in allocation leds: Use struct_size() in allocation Convert intel uncore to struct_size ...

Linus Torvalds committed 8 years ago

Commit b08fc522 parents 4597fcf 9d2a7891201 files · +3586 −2796Browse files

Unified · Split

1201 files
  1. arch/arm/kernel/sys_oabi-compat.c +2 −2
  2. arch/arm/mach-footbridge/dc21285.c +1 −1
  3. arch/arm/mach-ixp4xx/common-pci.c +1 −1
  4. arch/arm/mach-omap1/mcbsp.c +1 −1
  5. arch/arm/mach-omap2/hsmmc.c +1 −1
  6. arch/arm/mach-omap2/omap_device.c +2 −2
  7. arch/arm/mach-omap2/prm_common.c +5 −4
  8. arch/arm/mach-vexpress/spc.c +1 −1
  9. arch/arm/mm/dma-mapping.c +2 −2
  10. arch/arm/mm/pgd.c +1 −1
  11. arch/arm/probes/kprobes/test-core.c +3 −2
  12. arch/arm64/kernel/armv8_deprecated.c +2 −2
  13. arch/arm64/mm/context.c +1 −1
  14. arch/ia64/kernel/mca_drv.c +2 −1
  15. arch/ia64/kernel/topology.c +3 −3
  16. arch/ia64/mm/tlb.c +3 −2
  17. arch/ia64/sn/kernel/io_common.c +1 −1
  18. arch/ia64/sn/kernel/irq.c +2 −1
  19. arch/ia64/sn/pci/pcibr/pcibr_provider.c +1 −1
  20. arch/mips/alchemy/common/clock.c +1 −1
  21. arch/mips/alchemy/common/dbdma.c +3 −3
  22. arch/mips/alchemy/common/platform.c +2 −2
  23. arch/mips/alchemy/devboards/platform.c +2 −2
  24. arch/mips/bmips/dma.c +1 −1
  25. arch/mips/txx9/rbtx4939/setup.c +1 −1
  26. arch/powerpc/kernel/rtasd.c +2 −1
  27. arch/powerpc/kernel/vdso.c +2 −2
  28. arch/powerpc/kvm/book3s_64_mmu_hv.c +1 −1
  29. arch/powerpc/kvm/book3s_hv.c +1 −1
  30. arch/powerpc/lib/rheap.c +1 −1
  31. arch/powerpc/mm/mmu_context_iommu.c +1 −1
  32. arch/powerpc/mm/numa.c +1 −1
  33. arch/powerpc/net/bpf_jit_comp.c +1 −1
  34. arch/powerpc/net/bpf_jit_comp64.c +1 −1
  35. arch/powerpc/oprofile/cell/spu_profiler.c +2 −2
  36. arch/powerpc/platforms/4xx/hsta_msi.c +2 −1
  37. arch/powerpc/platforms/4xx/msi.c +1 −1
  38. arch/powerpc/platforms/4xx/pci.c +1 −1
  39. arch/powerpc/platforms/powernv/opal-sysparam.c +4 −4
  40. arch/powerpc/sysdev/mpic.c +5 −4
  41. arch/powerpc/sysdev/xive/native.c +1 −1
  42. arch/s390/appldata/appldata_base.c +1 −1
  43. arch/s390/hypfs/hypfs_diag.c +1 −1
  44. arch/s390/hypfs/hypfs_diag0c.c +2 −1
  45. arch/s390/kernel/debug.c +4 −2
  46. arch/s390/kernel/module.c +2 −2
  47. arch/s390/kernel/perf_cpum_cf_events.c +1 −1
  48. arch/s390/kernel/sthyi.c +1 −1
  49. arch/s390/kernel/vdso.c +2 −2
  50. arch/s390/kvm/gaccess.c +1 −1
  51. arch/s390/kvm/kvm-s390.c +1 −1
  52. arch/s390/mm/extmem.c +1 −1
  53. arch/sh/drivers/dma/dmabrg.c +1 −1
  54. arch/sh/drivers/pci/pcie-sh7786.c +1 −1
  55. arch/sparc/kernel/nmi.c +2 −1
  56. arch/sparc/kernel/sys_sparc_64.c +5 −3
  57. arch/sparc/net/bpf_jit_comp_32.c +1 −1
  58. arch/um/drivers/ubd_kern.c +6 −6
  59. arch/um/drivers/vector_kern.c +6 −6
  60. arch/unicore32/kernel/pm.c +3 −2
  61. arch/x86/events/amd/iommu.c +1 −1
  62. arch/x86/events/core.c +1 −1
  63. arch/x86/events/intel/uncore.c +11 −10
  64. arch/x86/kernel/cpu/mcheck/mce.c +1 −1
  65. arch/x86/kernel/cpu/mcheck/mce_amd.c +1 −1
  66. arch/x86/kernel/cpu/mtrr/if.c +1 −1
  67. arch/x86/kernel/hpet.c +3 −3
  68. arch/x86/kernel/ksysfs.c +1 −1
  69. arch/x86/kvm/cpuid.c +5 −3
  70. arch/x86/kvm/page_track.c +3 −2
  71. arch/x86/kvm/svm.c +3 −1
  72. arch/x86/kvm/x86.c +3 −2
  73. arch/x86/net/bpf_jit_comp.c +1 −1
  74. arch/x86/net/bpf_jit_comp32.c +1 −1
  75. arch/x86/pci/xen.c +1 −1
  76. arch/x86/platform/uv/tlb_uv.c +1 −1
  77. arch/x86/platform/uv/uv_time.c +1 −1
  78. block/bio.c +2 −1
  79. block/blk-mq.c +8 −8
  80. block/blk-tag.c +2 −2
  81. block/blk-zoned.c +2 −2
  82. block/partitions/check.c +1 −1
  83. block/partitions/ldm.c +1 −1
  84. crypto/algif_aead.c +2 −2
  85. crypto/algif_skcipher.c +2 −1
  86. crypto/testmgr.c +2 −1
  87. drivers/acpi/acpi_platform.c +1 −1
  88. drivers/acpi/acpi_video.c +3 −2
  89. drivers/acpi/apei/erst.c +2 −1
  90. drivers/acpi/apei/hest.c +2 −1
  91. drivers/acpi/fan.c +2 −2
  92. drivers/acpi/nfit/core.c +4 −3
  93. drivers/acpi/processor_perflib.c +3 −2
  94. drivers/acpi/processor_throttling.c +3 −2
  95. drivers/acpi/sysfs.c +3 −3
  96. drivers/android/binder_alloc.c +2 −2
  97. drivers/ata/libata-core.c +1 −1
  98. drivers/ata/libata-pmp.c +1 −1
  99. drivers/ata/sata_mv.c +4 −4
  100. drivers/atm/fore200e.c +2 −1
  101. drivers/atm/iphase.c +1 −1
  102. drivers/atm/solos-pci.c +2 −1
  103. drivers/auxdisplay/cfag12864b.c +2 −2
  104. drivers/base/firmware_loader/fallback.c +1 −1
  105. drivers/block/DAC960.c +2 −2
  106. drivers/block/drbd/drbd_main.c +2 −1
  107. drivers/block/loop.c +2 −1
  108. drivers/block/null_blk.c +5 −4
  109. drivers/block/ps3vram.c +3 −2
  110. drivers/block/rsxx/core.c +2 −1
  111. drivers/block/rsxx/dma.c +1 −1
  112. drivers/block/xen-blkback/xenbus.c +2 −1
  113. drivers/block/xen-blkfront.c +14 −9
  114. drivers/block/z2ram.c +3 −2
  115. drivers/block/zram/zram_drv.c +1 −1
  116. drivers/bus/fsl-mc/fsl-mc-allocator.c +3 −3
  117. drivers/cdrom/cdrom.c +1 −1
  118. drivers/char/agp/amd-k7-agp.c +2 −1
  119. drivers/char/agp/ati-agp.c +2 −1
  120. drivers/char/agp/compat_ioctl.c +6 −2
  121. drivers/char/agp/isoch.c +2 −1
  122. drivers/char/agp/sgi-agp.c +3 −3
  123. drivers/char/agp/sworks-agp.c +1 −1
  124. drivers/char/agp/uninorth-agp.c +3 −1
  125. drivers/char/ipmi/ipmi_ssif.c +2 −1
  126. drivers/char/raw.c +2 −1
  127. drivers/char/tpm/tpm2-cmd.c +1 −1
  128. drivers/char/virtio_console.c +9 −9
  129. drivers/clk/bcm/clk-bcm2835.c +2 −2
  130. drivers/clk/renesas/clk-r8a7740.c +1 −1
  131. drivers/clk/renesas/clk-r8a7779.c +1 −1
  132. drivers/clk/renesas/clk-rcar-gen2.c +1 −1
  133. drivers/clk/renesas/clk-rz.c +1 −1
  134. drivers/clk/st/clkgen-fsyn.c +1 −1
  135. drivers/clk/st/clkgen-pll.c +1 −1
  136. drivers/clk/sunxi/clk-usb.c +1 −1
  137. drivers/clk/tegra/clk.c +4 −3
  138. drivers/clk/ti/adpll.c +4 −2
  139. drivers/clk/ti/apll.c +1 −1
  140. drivers/clk/ti/divider.c +2 −2
  141. drivers/clk/ti/dpll.c +1 −1
  142. drivers/clocksource/sh_cmt.c +1 −1
  143. drivers/clocksource/sh_mtu2.c +1 −1
  144. drivers/clocksource/sh_tmu.c +1 −1
  145. drivers/cpufreq/acpi-cpufreq.c +2 −2
  146. drivers/cpufreq/arm_big_little.c +1 −1
  147. drivers/cpufreq/bmips-cpufreq.c +1 −1
  148. drivers/cpufreq/brcmstb-avs-cpufreq.c +1 −1
  149. drivers/cpufreq/cppc_cpufreq.c +2 −1
  150. drivers/cpufreq/ia64-acpi-cpufreq.c +2 −2
  151. drivers/cpufreq/imx6q-cpufreq.c +2 −1
  152. drivers/cpufreq/intel_pstate.c +1 −1
  153. drivers/cpufreq/longhaul.c +2 −2
  154. drivers/cpufreq/pxa3xx-cpufreq.c +1 −1
  155. drivers/cpufreq/s3c24xx-cpufreq.c +1 −1
  156. drivers/cpufreq/sfi-cpufreq.c +2 −2
  157. drivers/cpufreq/spear-cpufreq.c +1 −1
  158. drivers/crypto/amcc/crypto4xx_core.c +4 −4
  159. drivers/crypto/cavium/nitrox/nitrox_isr.c +1 −1
  160. drivers/crypto/chelsio/chtls/chtls_io.c +1 −1
  161. drivers/crypto/inside-secure/safexcel_hash.c +1 −1
  162. drivers/crypto/marvell/cesa.c +1 −1
  163. drivers/crypto/marvell/hash.c +1 −1
  164. drivers/crypto/n2_core.c +2 −2
  165. drivers/crypto/qat/qat_common/adf_isr.c +1 −1
  166. drivers/crypto/qat/qat_common/qat_uclo.c +3 −2
  167. drivers/crypto/stm32/stm32-hash.c +3 −2
  168. drivers/crypto/talitos.c +8 −5
  169. drivers/crypto/virtio/virtio_crypto_algs.c +1 −1
  170. drivers/devfreq/devfreq.c +8 −7
  171. drivers/devfreq/event/exynos-ppmu.c +1 −1
  172. drivers/dma/bestcomm/bestcomm.c +2 −1
  173. drivers/dma/ioat/init.c +2 −2
  174. drivers/dma/ipu/ipu_idmac.c +2 −1
  175. drivers/dma/k3dma.c +4 −4
  176. drivers/dma/mic_x100_dma.c +2 −1
  177. drivers/dma/mv_xor.c +2 −2
  178. drivers/dma/mv_xor_v2.c +3 −2
  179. drivers/dma/pl330.c +2 −2
  180. drivers/dma/s3c24xx-dma.c +3 −3
  181. drivers/dma/sh/shdma-base.c +3 −2
  182. drivers/dma/xilinx/zynqmp_dma.c +1 −1
  183. drivers/dma/zx_dma.c +4 −4
  184. drivers/edac/amd64_edac.c +1 −1
  185. drivers/edac/i7core_edac.c +1 −1
  186. drivers/extcon/extcon.c +14 −10
  187. drivers/firewire/core-iso.c +2 −2
  188. drivers/firewire/net.c +1 −1
  189. drivers/firmware/arm_scpi.c +1 −1
  190. drivers/firmware/dell_rbu.c +1 −1
  191. drivers/firmware/efi/capsule.c +1 −1
  192. drivers/firmware/efi/runtime-map.c +1 −1
  193. drivers/firmware/ti_sci.c +3 −3
  194. drivers/fmc/fmc-sdb.c +2 −2
  195. drivers/gpio/gpio-adnp.c +1 −1
  196. drivers/gpio/gpio-aspeed.c +2 −2
  197. drivers/gpio/gpio-bcm-kona.c +4 −3
  198. drivers/gpio/gpio-davinci.c +2 −2
  199. drivers/gpio/gpio-htc-egpio.c +2 −2
  200. drivers/gpio/gpio-ml-ioh.c +1 −1
  201. drivers/gpio/gpio-thunderx.c +5 −4
  202. drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c +3 −3
  203. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c +2 −2
  204. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c +2 −2
  205. drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c +2 −2
  206. drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c +1 −1
  207. drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c +2 −1
  208. drivers/gpu/drm/amd/amdgpu/amdgpu_test.c +1 −1
  209. drivers/gpu/drm/amd/amdgpu/atom.c +1 −1
  210. drivers/gpu/drm/amd/amdgpu/ci_dpm.c +6 −3
  211. drivers/gpu/drm/amd/amdgpu/kv_dpm.c +3 −2
  212. drivers/gpu/drm/amd/amdgpu/si_dpm.c +6 −3
  213. drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c +1 −1
  214. drivers/gpu/drm/amd/display/dc/basics/logger.c +1 −1
  215. drivers/gpu/drm/amd/display/dc/basics/vector.c +2 −2
  216. drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c +4 −2
  217. drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c +2 −1
  218. drivers/gpu/drm/amd/display/modules/color/color_gamma.c +27 −20
  219. drivers/gpu/drm/amd/display/modules/freesync/freesync.c +2 −1
  220. drivers/gpu/drm/amd/display/modules/stats/stats.c +5 −7
  221. drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c +1 −1
  222. drivers/gpu/drm/drm_edid.c +2 −1
  223. drivers/gpu/drm/drm_hashtab.c +1 −1
  224. drivers/gpu/drm/drm_memory.c +1 −1
  225. drivers/gpu/drm/exynos/exynos_drm_dsi.c +2 −2
  226. drivers/gpu/drm/exynos/exynos_drm_fimc.c +2 −1
  227. drivers/gpu/drm/exynos/exynos_drm_gsc.c +3 −2
  228. drivers/gpu/drm/exynos/exynos_hdmi.c +1 −1
  229. drivers/gpu/drm/gma500/mid_bios.c +1 −1
  230. drivers/gpu/drm/i915/gvt/gtt.c +3 −2
  231. drivers/gpu/drm/i915/gvt/mmio.c +1 −1
  232. drivers/gpu/drm/i915/gvt/vgpu.c +1 −1
  233. drivers/gpu/drm/i915/intel_hdcp.c +1 −1
  234. drivers/gpu/drm/i915/selftests/intel_uncore.c +1 −1
  235. drivers/gpu/drm/msm/hdmi/hdmi.c +16 −8
  236. drivers/gpu/drm/msm/hdmi/hdmi_phy.c +2 −2
  237. drivers/gpu/drm/nouveau/nv84_fence.c +1 −1
  238. drivers/gpu/drm/nouveau/nvif/fifo.c +2 −2
  239. drivers/gpu/drm/nouveau/nvif/mmu.c +6 −3
  240. drivers/gpu/drm/nouveau/nvif/object.c +1 −1
  241. drivers/gpu/drm/nouveau/nvif/vmm.c +2 −1
  242. drivers/gpu/drm/nouveau/nvkm/core/event.c +2 −1
  243. drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c +1 −1
  244. drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c +2 −1
  245. drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c +1 −1
  246. drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c +2 −2
  247. drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c +1 −1
  248. drivers/gpu/drm/omapdrm/omap_dmm_tiler.c +2 −2
  249. drivers/gpu/drm/omapdrm/omap_gem.c +2 −2
  250. drivers/gpu/drm/qxl/qxl_fb.c +1 −1
  251. drivers/gpu/drm/qxl/qxl_kms.c +2 −2
  252. drivers/gpu/drm/radeon/atom.c +1 −1
  253. drivers/gpu/drm/radeon/btc_dpm.c +3 −1
  254. drivers/gpu/drm/radeon/ci_dpm.c +6 −3
  255. drivers/gpu/drm/radeon/kv_dpm.c +3 −2
  256. drivers/gpu/drm/radeon/ni_dpm.c +6 −3
  257. drivers/gpu/drm/radeon/r600_dpm.c +1 −1
  258. drivers/gpu/drm/radeon/radeon_atombios.c +24 −15
  259. drivers/gpu/drm/radeon/radeon_combios.c +6 −3
  260. drivers/gpu/drm/radeon/radeon_gart.c +4 −3
  261. drivers/gpu/drm/radeon/radeon_test.c +1 −1
  262. drivers/gpu/drm/radeon/rs780_dpm.c +3 −2
  263. drivers/gpu/drm/radeon/rv6xx_dpm.c +3 −2
  264. drivers/gpu/drm/radeon/rv770_dpm.c +3 −2
  265. drivers/gpu/drm/radeon/si_dpm.c +6 −3
  266. drivers/gpu/drm/radeon/sumo_dpm.c +3 −2
  267. drivers/gpu/drm/radeon/trinity_dpm.c +3 −2
  268. drivers/gpu/drm/savage/savage_bci.c +3 −2
  269. drivers/gpu/drm/selftests/test-drm_mm.c +12 −12
  270. drivers/gpu/drm/tinydrm/repaper.c +1 −1
  271. drivers/gpu/drm/ttm/ttm_page_alloc.c +5 −3
  272. drivers/gpu/drm/ttm/ttm_page_alloc_dma.c +5 −3
  273. drivers/gpu/drm/vc4/vc4_plane.c +1 −1
  274. drivers/gpu/drm/via/via_dmablit.c +1 −1
  275. drivers/hid/hid-core.c +6 −3
  276. drivers/hid/hid-debug.c +3 −3
  277. drivers/hid/hid-picolcd_fb.c +2 −1
  278. drivers/hid/hid-sensor-hub.c +2 −1
  279. drivers/hid/hidraw.c +1 −1
  280. drivers/hid/intel-ish-hid/ishtp-hid-client.c +2 −2
  281. drivers/hid/wacom_sys.c +2 −2
  282. drivers/hv/hv.c +1 −1
  283. drivers/hv/ring_buffer.c +1 −1
  284. drivers/hwmon/acpi_power_meter.c +4 −3
  285. drivers/hwmon/aspeed-pwm-tacho.c +1 −1
  286. drivers/hwmon/coretemp.c +1 −1
  287. drivers/hwmon/gpio-fan.c +4 −4
  288. drivers/hwmon/i5k_amb.c +3 −2
  289. drivers/hwmon/ibmpex.c +1 −1
  290. drivers/hwmon/ibmpowernv.c +5 −4
  291. drivers/hwmon/iio_hwmon.c +2 −2
  292. drivers/hwmon/nct6683.c +2 −2
  293. drivers/hwmon/nct6775.c +2 −2
  294. drivers/hwmon/pmbus/pmbus_core.c +2 −2
  295. drivers/hwmon/pmbus/ucd9000.c +2 −2
  296. drivers/hwmon/pwm-fan.c +1 −1
  297. drivers/hwtracing/coresight/coresight-etb10.c +2 −2
  298. drivers/hwtracing/coresight/of_coresight.c +6 −3
  299. drivers/i2c/busses/i2c-amd756-s4882.c +2 −2
  300. drivers/i2c/busses/i2c-nforce2-s4985.c +2 −2
  301. drivers/i2c/busses/i2c-nforce2.c +1 −1
  302. drivers/i2c/busses/i2c-qup.c +4 −4
  303. drivers/i2c/i2c-dev.c +1 −1
  304. drivers/i2c/i2c-stub.c +3 −2
  305. drivers/i2c/muxes/i2c-mux-gpio.c +5 −4
  306. drivers/i2c/muxes/i2c-mux-reg.c +2 −2
  307. drivers/ide/hpt366.c +1 −1
  308. drivers/ide/ide-probe.c +3 −2
  309. drivers/ide/it821x.c +1 −1
  310. drivers/iio/adc/at91_adc.c +4 −3
  311. drivers/iio/adc/max1027.c +2 −2
  312. drivers/iio/adc/max1363.c +4 −2
  313. drivers/iio/adc/twl6030-gpadc.c +4 −3
  314. drivers/iio/dac/ad5592r-base.c +3 −2
  315. drivers/iio/imu/adis_buffer.c +1 −1
  316. drivers/iio/inkern.c +1 −1
  317. drivers/iio/multiplexer/iio-mux.c +4 −3
  318. drivers/infiniband/core/cache.c +3 −2
  319. drivers/infiniband/core/cma.c +2 −2
  320. drivers/infiniband/core/device.c +2 −2
  321. drivers/infiniband/core/fmr_pool.c +3 −2
  322. drivers/infiniband/core/iwpm_util.c +6 −4
  323. drivers/infiniband/core/umem_odp.c +10 −6
  324. drivers/infiniband/core/uverbs_cmd.c +2 −2
  325. drivers/infiniband/hw/cxgb3/cxio_hal.c +2 −2
  326. drivers/infiniband/hw/cxgb4/device.c +4 −3
  327. drivers/infiniband/hw/cxgb4/id_table.c +2 −2
  328. drivers/infiniband/hw/cxgb4/qp.c +4 −4
  329. drivers/infiniband/hw/hfi1/sdma.c +2 −1
  330. drivers/infiniband/hw/hns/hns_roce_hw_v2.c +1 −1
  331. drivers/infiniband/hw/hns/hns_roce_mr.c +1 −1
  332. drivers/infiniband/hw/mlx4/mad.c +2 −1
  333. drivers/infiniband/hw/mlx4/main.c +7 −5
  334. drivers/infiniband/hw/mlx4/qp.c +2 −2
  335. drivers/infiniband/hw/mlx5/srq.c +2 −2
  336. drivers/infiniband/hw/mthca/mthca_allocator.c +11 −7
  337. drivers/infiniband/hw/mthca/mthca_cmd.c +3 −3
  338. drivers/infiniband/hw/mthca/mthca_eq.c +3 −3
  339. drivers/infiniband/hw/mthca/mthca_memfree.c +3 −3
  340. drivers/infiniband/hw/mthca/mthca_mr.c +2 −2
  341. drivers/infiniband/hw/mthca/mthca_profile.c +1 −1
  342. drivers/infiniband/hw/mthca/mthca_qp.c +2 −2
  343. drivers/infiniband/hw/mthca/mthca_srq.c +1 −1
  344. drivers/infiniband/hw/nes/nes_mgt.c +2 −1
  345. drivers/infiniband/hw/nes/nes_nic.c +1 −1
  346. drivers/infiniband/hw/nes/nes_verbs.c +3 −2
  347. drivers/infiniband/hw/ocrdma/ocrdma_hw.c +1 −1
  348. drivers/infiniband/hw/ocrdma/ocrdma_main.c +6 −5
  349. drivers/infiniband/hw/ocrdma/ocrdma_verbs.c +8 −7
  350. drivers/infiniband/hw/qedr/main.c +2 −2
  351. drivers/infiniband/hw/qedr/verbs.c +2 −2
  352. drivers/infiniband/hw/qib/qib_iba6120.c +5 −4
  353. drivers/infiniband/hw/qib/qib_iba7220.c +5 −4
  354. drivers/infiniband/hw/qib/qib_iba7322.c +20 −14
  355. drivers/infiniband/hw/qib/qib_init.c +8 −6
  356. drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c +1 −1
  357. drivers/infiniband/hw/usnic/usnic_vnic.c +1 −1
  358. drivers/infiniband/sw/rdmavt/qp.c +5 −6
  359. drivers/infiniband/ulp/ipoib/ipoib_cm.c +5 −3
  360. drivers/infiniband/ulp/ipoib/ipoib_main.c +6 −4
  361. drivers/infiniband/ulp/iser/iser_initiator.c +3 −2
  362. drivers/infiniband/ulp/isert/ib_isert.c +3 −2
  363. drivers/infiniband/ulp/srp/ib_srp.c +5 −4
  364. drivers/infiniband/ulp/srpt/ib_srpt.c +1 −1
  365. drivers/input/joystick/joydump.c +1 −1
  366. drivers/input/keyboard/clps711x-keypad.c +2 −2
  367. drivers/input/keyboard/matrix_keypad.c +3 −3
  368. drivers/input/keyboard/omap4-keypad.c +2 −1
  369. drivers/input/keyboard/samsung-keypad.c +1 −1
  370. drivers/input/matrix-keymap.c +2 −2
  371. drivers/input/misc/rotary_encoder.c +2 −2
  372. drivers/input/rmi4/rmi_driver.c +5 −4
  373. drivers/input/rmi4/rmi_f11.c +8 −7
  374. drivers/input/rmi4/rmi_f12.c +8 −7
  375. drivers/input/rmi4/rmi_f54.c +1 −1
  376. drivers/input/rmi4/rmi_spi.c +5 −4
  377. drivers/iommu/arm-smmu.c +1 −1
  378. drivers/iommu/dmar.c +1 −1
  379. drivers/iommu/intel-iommu.c +2 −2
  380. drivers/iommu/omap-iommu.c +1 −1
  381. drivers/iommu/rockchip-iommu.c +1 −1
  382. drivers/iommu/tegra-gart.c +1 −1
  383. drivers/ipack/carriers/tpci200.c +2 −2
  384. drivers/irqchip/irq-alpine-msi.c +2 −1
  385. drivers/irqchip/irq-gic-v2m.c +1 −1
  386. drivers/irqchip/irq-gic-v3-its.c +10 −9
  387. drivers/irqchip/irq-gic-v3.c +3 −2
  388. drivers/irqchip/irq-imgpdc.c +1 −1
  389. drivers/irqchip/irq-mvebu-gicp.c +4 −4
  390. drivers/irqchip/irq-partition-percpu.c +1 −1
  391. drivers/irqchip/irq-s3c24xx.c +1 −1
  392. drivers/isdn/capi/capi.c +1 −1
  393. drivers/isdn/capi/capidrv.c +2 −1
  394. drivers/isdn/gigaset/capi.c +3 −3
  395. drivers/isdn/gigaset/common.c +2 −2
  396. drivers/isdn/gigaset/i4l.c +1 −1
  397. drivers/isdn/hardware/avm/b1.c +1 −1
  398. drivers/isdn/hisax/fsm.c +3 −1
  399. drivers/isdn/hisax/hfc_2bds0.c +1 −1
  400. drivers/isdn/hisax/hfc_2bs0.c +2 −1
  401. drivers/isdn/hisax/netjet.c +8 −4
  402. drivers/isdn/i4l/isdn_bsdcomp.c +3 −2
  403. drivers/isdn/i4l/isdn_common.c +6 −4
  404. drivers/isdn/mISDN/fsm.c +4 −2
  405. drivers/leds/leds-adp5520.c +1 −1
  406. drivers/leds/leds-apu.c +2 −2
  407. drivers/leds/leds-cr0014114.c +1 −2
  408. drivers/leds/leds-da9052.c +2 −2
  409. drivers/leds/leds-lp5521.c +2 −2
  410. drivers/leds/leds-lp5523.c +2 −2
  411. drivers/leds/leds-lp5562.c +2 −2
  412. drivers/leds/leds-lp55xx-common.c +1 −1
  413. drivers/leds/leds-lp8501.c +2 −2
  414. drivers/leds/leds-lt3593.c +2 −2
  415. drivers/leds/leds-mc13783.c +2 −2
  416. drivers/leds/leds-mlxcpld.c +4 −2
  417. drivers/leds/leds-netxbig.c +8 −8
  418. drivers/leds/leds-ns2.c +4 −3
  419. drivers/leds/leds-pca955x.c +4 −4
  420. drivers/leds/leds-pca963x.c +3 −3
  421. drivers/leds/leds-tca6507.c +2 −2
  422. drivers/lightnvm/pblk-gc.c +1 −1
  423. drivers/lightnvm/pblk-init.c +4 −4
  424. drivers/lightnvm/pblk-recovery.c +1 −1
  425. drivers/mailbox/hi6220-mailbox.c +4 −4
  426. drivers/mailbox/mailbox-sti.c +2 −2
  427. drivers/mailbox/omap-mailbox.c +5 −5
  428. drivers/mailbox/pcc.c +2 −1
  429. drivers/mailbox/ti-msgmgr.c +2 −2
  430. drivers/md/bcache/super.c +6 −5
  431. drivers/md/bcache/sysfs.c +2 −1
  432. drivers/md/dm-cache-policy-smq.c +2 −2
  433. drivers/md/dm-crypt.c +3 −2
  434. drivers/md/dm-integrity.c +13 −5
  435. drivers/md/dm-region-hash.c +1 −1
  436. drivers/md/dm-snap.c +5 −4
  437. drivers/md/dm-stats.c +3 −1
  438. drivers/md/dm-switch.c +2 −1
  439. drivers/md/dm-table.c +1 −1
  440. drivers/md/dm-thin.c +3 −1
  441. drivers/md/dm-verity-target.c +3 −2
  442. drivers/md/md-bitmap.c +3 −3
  443. drivers/md/md-cluster.c +3 −3
  444. drivers/md/md-multipath.c +2 −1
  445. drivers/md/raid0.c +6 −4
  446. drivers/md/raid1.c +7 −6
  447. drivers/md/raid10.c +7 −8
  448. drivers/md/raid5.c +8 −7
  449. drivers/media/common/v4l2-tpg/v4l2-tpg-core.c +10 −5
  450. drivers/media/dvb-core/dmxdev.c +2 −1
  451. drivers/media/dvb-core/dvb_demux.c +4 −2
  452. drivers/media/dvb-frontends/dib7000p.c +2 −2
  453. drivers/media/dvb-frontends/dib8000.c +2 −2
  454. drivers/media/dvb-frontends/dib9000.c +2 −2
  455. drivers/media/i2c/s5k5baf.c +1 −1
  456. drivers/media/pci/bt8xx/bttv-risc.c +2 −1
  457. drivers/media/pci/cx23885/cx23885-alsa.c +1 −1
  458. drivers/media/pci/cx25821/cx25821-alsa.c +1 −1
  459. drivers/media/pci/cx88/cx88-alsa.c +1 −1
  460. drivers/media/pci/ivtv/ivtvfb.c +1 −1
  461. drivers/media/pci/meye/meye.c +1 −1
  462. drivers/media/pci/pt1/pt1.c +1 −1
  463. drivers/media/pci/saa7134/saa7134-alsa.c +1 −1
  464. drivers/media/pci/ttpci/av7110_ipack.c +1 −1
  465. drivers/media/platform/am437x/am437x-vpfe.c +4 −2
  466. drivers/media/platform/davinci/vpif_capture.c +6 −4
  467. drivers/media/platform/qcom/camss-8x16/camss-csid.c +5 −3
  468. drivers/media/platform/qcom/camss-8x16/camss-csiphy.c +7 −4
  469. drivers/media/platform/qcom/camss-8x16/camss-ispif.c +6 −3
  470. drivers/media/platform/qcom/camss-8x16/camss-vfe.c +5 −3
  471. drivers/media/platform/qcom/camss-8x16/camss.c +2 −1
  472. drivers/media/platform/soc_camera/soc_camera.c +2 −1
  473. drivers/media/platform/vivid/vivid-core.c +5 −4
  474. drivers/media/platform/vsp1/vsp1_entity.c +2 −1
  475. drivers/media/platform/xilinx/xilinx-vipp.c +1 −1
  476. drivers/media/usb/au0828/au0828-video.c +3 −3
  477. drivers/media/usb/cpia2/cpia2_usb.c +2 −1
  478. drivers/media/usb/cx231xx/cx231xx-audio.c +1 −1
  479. drivers/media/usb/cx231xx/cx231xx-core.c +4 −4
  480. drivers/media/usb/cx231xx/cx231xx-vbi.c +2 −2
  481. drivers/media/usb/go7007/go7007-fw.c +1 −1
  482. drivers/media/usb/go7007/go7007-usb.c +2 −1
  483. drivers/media/usb/gspca/t613.c +1 −1
  484. drivers/media/usb/pvrusb2/pvrusb2-hdw.c +1 −1
  485. drivers/media/usb/pvrusb2/pvrusb2-std.c +1 −1
  486. drivers/media/usb/stk1160/stk1160-core.c +3 −2
  487. drivers/media/usb/stk1160/stk1160-video.c +3 −3
  488. drivers/media/usb/stkwebcam/stk-webcam.c +3 −2
  489. drivers/media/usb/tm6000/tm6000-video.c +8 −5
  490. drivers/media/usb/usbtv/usbtv-video.c +1 −1
  491. drivers/media/usb/usbvision/usbvision-video.c +2 −1
  492. drivers/media/usb/uvc/uvc_video.c +2 −2
  493. drivers/media/v4l2-core/v4l2-event.c +1 −2
  494. drivers/media/v4l2-core/v4l2-flash-led-class.c +4 −3
  495. drivers/media/v4l2-core/videobuf-dma-sg.c +4 −3
  496. drivers/memory/of_memory.c +2 −2
  497. drivers/memstick/core/ms_block.c +4 −2
  498. drivers/message/fusion/mptlan.c +4 −3
  499. drivers/mfd/ab8500-debugfs.c +6 −6
  500. drivers/mfd/cros_ec_dev.c +4 −3
  501. drivers/mfd/htc-i2cpld.c +3 −1
  502. drivers/mfd/mfd-core.c +1 −1
  503. drivers/mfd/motorola-cpcap.c +3 −3
  504. drivers/mfd/sprd-sc27xx-spi.c +3 −2
  505. drivers/mfd/timberdale.c +2 −2
  506. drivers/mfd/twl-core.c +3 −2
  507. drivers/mfd/wm8994-core.c +4 −3
  508. drivers/misc/altera-stapl/altera.c +3 −3
  509. drivers/misc/cxl/guest.c +1 −1
  510. drivers/misc/cxl/of.c +1 −1
  511. drivers/misc/eeprom/idt_89hpesx.c +1 −1
  512. drivers/misc/genwqe/card_ddcb.c +5 −4
  513. drivers/misc/sgi-xp/xpc_main.c +5 −3
  514. drivers/misc/sgi-xp/xpc_partition.c +1 −1
  515. drivers/misc/sgi-xp/xpnet.c +3 −2
  516. drivers/misc/sram.c +3 −3
  517. drivers/misc/vmw_vmci/vmci_queue_pair.c +4 −2
  518. drivers/mmc/host/sdhci-omap.c +4 −2
  519. drivers/mtd/ar7part.c +1 −1
  520. drivers/mtd/bcm47xxpart.c +1 −1
  521. drivers/mtd/chips/cfi_cmdset_0001.c +6 −3
  522. drivers/mtd/chips/cfi_cmdset_0002.c +4 −3
  523. drivers/mtd/chips/cfi_cmdset_0020.c +3 −2
  524. drivers/mtd/devices/docg3.c +2 −2
  525. drivers/mtd/ftl.c +8 −7
  526. drivers/mtd/inftlmount.c +4 −2
  527. drivers/mtd/lpddr/lpddr_cmds.c +1 −1
  528. drivers/mtd/maps/physmap_of_core.c +2 −2
  529. drivers/mtd/maps/vmu-flash.c +4 −4
  530. drivers/mtd/mtdconcat.c +3 −2
  531. drivers/mtd/mtdoops.c +4 −2
  532. drivers/mtd/mtdswap.c +3 −3
  533. drivers/mtd/nand/onenand/onenand_base.c +4 −2
  534. drivers/mtd/nand/raw/nand_bch.c +1 −1
  535. drivers/mtd/nand/raw/nandsim.c +4 −3
  536. drivers/mtd/nand/raw/qcom_nandc.c +2 −2
  537. drivers/mtd/nand/raw/s3c2410.c +1 −1
  538. drivers/mtd/nftlmount.c +5 −2
  539. drivers/mtd/ofpart.c +2 −2
  540. drivers/mtd/parsers/parser_trx.c +1 −1
  541. drivers/mtd/parsers/sharpslpart.c +3 −2
  542. drivers/mtd/rfd_ftl.c +2 −1
  543. drivers/mtd/sm_ftl.c +3 −3
  544. drivers/mtd/ssfdc.c +3 −2
  545. drivers/mtd/tests/pagetest.c +1 −1
  546. drivers/mtd/tests/stresstest.c +1 −1
  547. drivers/mtd/ubi/eba.c +8 −6
  548. drivers/mtd/ubi/wl.c +1 −1
  549. drivers/net/bonding/bond_main.c +1 −1
  550. drivers/net/can/grcan.c +2 −2
  551. drivers/net/can/slcan.c +1 −1
  552. drivers/net/dsa/b53/b53_common.c +4 −4
  553. drivers/net/ethernet/amazon/ena/ena_ethtool.c +4 −4
  554. drivers/net/ethernet/amd/lance.c +4 −4
  555. drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c +2 −2
  556. drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c +2 −2
  557. drivers/net/ethernet/atheros/atlx/atl2.c +2 −2
  558. drivers/net/ethernet/broadcom/bcm63xx_enet.c +2 −2
  559. drivers/net/ethernet/broadcom/bnx2.c +5 −4
  560. drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +7 −6
  561. drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +2 −2
  562. drivers/net/ethernet/broadcom/cnic.c +5 −5
  563. drivers/net/ethernet/broadcom/tg3.c +3 −2
  564. drivers/net/ethernet/brocade/bna/bnad.c +2 −2
  565. drivers/net/ethernet/calxeda/xgmac.c +2 −2
  566. drivers/net/ethernet/cavium/liquidio/octeon_droq.c +4 −5
  567. drivers/net/ethernet/cavium/liquidio/request_manager.c +3 −2
  568. drivers/net/ethernet/cavium/thunder/nicvf_queues.c +2 −2
  569. drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +1 −1
  570. drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +1 −1
  571. drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +5 −5
  572. drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +2 −1
  573. drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +2 −2
  574. drivers/net/ethernet/chelsio/cxgb4/sge.c +1 −1
  575. drivers/net/ethernet/cortina/gemini.c +2 −2
  576. drivers/net/ethernet/ethoc.c +2 −1
  577. drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +1 −1
  578. drivers/net/ethernet/freescale/ucc_geth.c +6 −6
  579. drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +2 −2
  580. drivers/net/ethernet/hisilicon/hns/hns_enet.c +2 −1
  581. drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +4 −2
  582. drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c +3 −2
  583. drivers/net/ethernet/ibm/ibmveth.c +1 −1
  584. drivers/net/ethernet/intel/e1000/e1000_ethtool.c +2 −2
  585. drivers/net/ethernet/intel/e1000e/ethtool.c +2 −2
  586. drivers/net/ethernet/intel/e1000e/netdev.c +1 −1
  587. drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +1 −1
  588. drivers/net/ethernet/intel/igb/igb_ethtool.c +8 −8
  589. drivers/net/ethernet/intel/igb/igb_main.c +4 −3
  590. drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +3 −2
  591. drivers/net/ethernet/intel/ixgb/ixgb_main.c +3 −2
  592. drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +2 −2
  593. drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +2 −2
  594. drivers/net/ethernet/intel/ixgbevf/ethtool.c +5 −3
  595. drivers/net/ethernet/jme.c +6 −4
  596. drivers/net/ethernet/mellanox/mlx4/alloc.c +2 −2
  597. drivers/net/ethernet/mellanox/mlx4/cmd.c +12 −9
  598. drivers/net/ethernet/mellanox/mlx4/en_netdev.c +12 −8
  599. drivers/net/ethernet/mellanox/mlx4/eq.c +3 −2
  600. drivers/net/ethernet/mellanox/mlx4/icm.c +1 −1
  601. drivers/net/ethernet/mellanox/mlx4/main.c +3 −2
  602. drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +14 −12
  603. drivers/net/ethernet/mellanox/mlx5/core/en_main.c +8 −8
  604. drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c +6 −4
  605. drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +1 −1
  606. drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +3 −2
  607. drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +2 −1
  608. drivers/net/ethernet/micrel/ksz884x.c +1 −1
  609. drivers/net/ethernet/moxa/moxart_ether.c +4 −4
  610. drivers/net/ethernet/neterion/vxge/vxge-config.c +11 −10
  611. drivers/net/ethernet/neterion/vxge/vxge-main.c +2 −2
  612. drivers/net/ethernet/netronome/nfp/abm/main.c +1 −1
  613. drivers/net/ethernet/netronome/nfp/flower/metadata.c +2 −1
  614. drivers/net/ethernet/ni/nixge.c +2 −3
  615. drivers/net/ethernet/nvidia/forcedeth.c +4 −2
  616. drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +1 −1
  617. drivers/net/ethernet/pasemi/pasemi_mac.c +6 −4
  618. drivers/net/ethernet/qlogic/qed/qed_debug.c +3 −2
  619. drivers/net/ethernet/qlogic/qed/qed_dev.c +8 −8
  620. drivers/net/ethernet/qlogic/qed/qed_init_ops.c +2 −2
  621. drivers/net/ethernet/qlogic/qed/qed_l2.c +2 −2
  622. drivers/net/ethernet/qlogic/qed/qed_mcp.c +3 −3
  623. drivers/net/ethernet/qlogic/qede/qede_filter.c +3 −2
  624. drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +3 −2
  625. drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +9 −6
  626. drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +4 −4
  627. drivers/net/ethernet/qlogic/qlge/qlge_main.c +2 −1
  628. drivers/net/ethernet/sfc/ef10.c +2 −1
  629. drivers/net/ethernet/sfc/falcon/farch.c +2 −1
  630. drivers/net/ethernet/sfc/farch.c +2 −1
  631. drivers/net/ethernet/socionext/netsec.c +1 −1
  632. drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +2 −2
  633. drivers/net/ethernet/ti/cpsw.c +5 −4
  634. drivers/net/ethernet/ti/netcp_ethss.c +12 −12
  635. drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +3 −2
  636. drivers/net/gtp.c +4 −2
  637. drivers/net/hippi/rrunner.c +1 −1
  638. drivers/net/phy/dp83640.c +3 −2
  639. drivers/net/phy/phy_led_triggers.c +3 −3
  640. drivers/net/ppp/bsd_comp.c +2 −2
  641. drivers/net/ppp/pptp.c +1 −1
  642. drivers/net/slip/slip.c +1 −1
  643. drivers/net/team/team.c +3 −2
  644. drivers/net/usb/asix_common.c +4 −4
  645. drivers/net/usb/ax88179_178a.c +2 −2
  646. drivers/net/usb/smsc95xx.c +1 −1
  647. drivers/net/usb/usbnet.c +2 −2
  648. drivers/net/virtio_net.c +6 −6
  649. drivers/net/wan/fsl_ucc_hdlc.c +4 −2
  650. drivers/net/wireless/ath/ath10k/htt_rx.c +1 −1
  651. drivers/net/wireless/ath/ath10k/wmi-tlv.c +1 −1
  652. drivers/net/wireless/ath/ath5k/debug.c +1 −1
  653. drivers/net/wireless/ath/ath5k/phy.c +2 −1
  654. drivers/net/wireless/ath/ath6kl/cfg80211.c +1 −1
  655. drivers/net/wireless/ath/ath9k/ar9003_paprd.c +1 −1
  656. drivers/net/wireless/ath/ath9k/hw.c +2 −2
  657. drivers/net/wireless/ath/carl9170/main.c +4 −3
  658. drivers/net/wireless/broadcom/b43/phy_n.c +1 −1
  659. drivers/net/wireless/broadcom/b43legacy/main.c +2 −2
  660. drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +3 −2
  661. drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +1 −1
  662. drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +4 −3
  663. drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c +4 −4
  664. drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +3 −2
  665. drivers/net/wireless/cisco/airo.c +1 −1
  666. drivers/net/wireless/intel/ipw2x00/ipw2100.c +6 −5
  667. drivers/net/wireless/intel/ipw2x00/ipw2200.c +5 −5
  668. drivers/net/wireless/intel/iwlegacy/common.c +7 −6
  669. drivers/net/wireless/intel/iwlwifi/mvm/scan.c +1 −1
  670. drivers/net/wireless/intersil/hostap/hostap_info.c +3 −2
  671. drivers/net/wireless/intersil/hostap/hostap_ioctl.c +2 −2
  672. drivers/net/wireless/intersil/p54/eeprom.c +7 −5
  673. drivers/net/wireless/intersil/prism54/oid_mgt.c +1 −1
  674. drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +2 −2
  675. drivers/net/wireless/marvell/mwifiex/cfg80211.c +2 −2
  676. drivers/net/wireless/marvell/mwifiex/sdio.c +5 −4
  677. drivers/net/wireless/mediatek/mt76/mac80211.c +1 −1
  678. drivers/net/wireless/quantenna/qtnfmac/commands.c +1 −1
  679. drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +1 −1
  680. drivers/net/wireless/realtek/rtlwifi/efuse.c +2 −2
  681. drivers/net/wireless/realtek/rtlwifi/usb.c +1 −1
  682. drivers/net/wireless/st/cw1200/queue.c +5 −5
  683. drivers/net/wireless/st/cw1200/scan.c +3 −3
  684. drivers/net/wireless/zydas/zd1211rw/zd_mac.c +2 −1
  685. drivers/net/xen-netback/xenbus.c +2 −2
  686. drivers/nfc/fdp/i2c.c +2 −2
  687. drivers/ntb/hw/amd/ntb_hw_amd.c +2 −2
  688. drivers/ntb/hw/intel/ntb_hw_gen1.c +2 −2
  689. drivers/ntb/ntb_transport.c +2 −2
  690. drivers/nvmem/rockchip-efuse.c +4 −2
  691. drivers/nvmem/sunxi_sid.c +1 −1
  692. drivers/of/platform.c +1 −1
  693. drivers/of/unittest.c +1 −1
  694. drivers/opp/ti-opp-supply.c +2 −2
  695. drivers/oprofile/event_buffer.c +1 −1
  696. drivers/pci/controller/dwc/pci-dra7xx.c +2 −2
  697. drivers/pci/controller/dwc/pcie-designware-ep.c +5 −3
  698. drivers/pci/controller/pcie-cadence-ep.c +2 −1
  699. drivers/pci/controller/pcie-rockchip-ep.c +1 −1
  700. drivers/pci/msi.c +2 −2
  701. drivers/pci/pci-sysfs.c +1 −1
  702. drivers/pcmcia/cistpl.c +2 −2
  703. drivers/pcmcia/pd6729.c +1 −1
  704. drivers/pinctrl/bcm/pinctrl-bcm2835.c +2 −2
  705. drivers/pinctrl/berlin/berlin.c +6 −4
  706. drivers/pinctrl/freescale/pinctrl-imx.c +11 −7
  707. drivers/pinctrl/freescale/pinctrl-imx1-core.c +12 −11
  708. drivers/pinctrl/freescale/pinctrl-mxs.c +12 −8
  709. drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +13 −8
  710. drivers/pinctrl/mvebu/pinctrl-armada-xp.c +2 −2
  711. drivers/pinctrl/mvebu/pinctrl-mvebu.c +10 −6
  712. drivers/pinctrl/pinctrl-at91-pio4.c +23 −16
  713. drivers/pinctrl/pinctrl-at91.c +22 −12
  714. drivers/pinctrl/pinctrl-axp209.c +4 −3
  715. drivers/pinctrl/pinctrl-digicolor.c +3 −2
  716. drivers/pinctrl/pinctrl-ingenic.c +2 −2
  717. drivers/pinctrl/pinctrl-lantiq.c +2 −1
  718. drivers/pinctrl/pinctrl-lpc18xx.c +3 −2
  719. drivers/pinctrl/pinctrl-ocelot.c +2 −1
  720. drivers/pinctrl/pinctrl-rockchip.c +14 −10
  721. drivers/pinctrl/pinctrl-single.c +14 −12
  722. drivers/pinctrl/pinctrl-st.c +16 −15
  723. drivers/pinctrl/pinctrl-xway.c +2 −2
  724. drivers/pinctrl/samsung/pinctrl-exynos.c +3 −2
  725. drivers/pinctrl/samsung/pinctrl-samsung.c +10 −7
  726. drivers/pinctrl/sh-pfc/core.c +3 −3
  727. drivers/pinctrl/sh-pfc/gpio.c +4 −3
  728. drivers/pinctrl/sh-pfc/pinctrl.c +4 −4
  729. drivers/pinctrl/sirf/pinctrl-sirf.c +1 −1
  730. drivers/pinctrl/spear/pinctrl-plgpio.c +2 −2
  731. drivers/pinctrl/spear/pinctrl-spear.c +1 −1
  732. drivers/pinctrl/sprd/pinctrl-sprd.c +11 −8
  733. drivers/pinctrl/sunxi/pinctrl-sunxi.c +12 −10
  734. drivers/pinctrl/tegra/pinctrl-tegra.c +3 −3
  735. drivers/pinctrl/ti/pinctrl-ti-iodelay.c +3 −3
  736. drivers/pinctrl/vt8500/pinctrl-wmt.c +1 −1
  737. drivers/pinctrl/zte/pinctrl-zx.c +3 −3
  738. drivers/platform/mellanox/mlxreg-hotplug.c +2 −1
  739. drivers/platform/x86/alienware-wmi.c +3 −3
  740. drivers/platform/x86/intel_ips.c +6 −6
  741. drivers/platform/x86/panasonic-laptop.c +1 −1
  742. drivers/platform/x86/thinkpad_acpi.c +1 −1
  743. drivers/power/supply/charger-manager.c +17 −12
  744. drivers/power/supply/power_supply_core.c +2 −2
  745. drivers/power/supply/wm97xx_battery.c +1 −1
  746. drivers/power/supply/z2_battery.c +1 −1
  747. drivers/powercap/powercap_sys.c +5 −4
  748. drivers/pwm/pwm-lp3943.c +1 −1
  749. drivers/rapidio/devices/rio_mport_cdev.c +1 −1
  750. drivers/rapidio/rio-scan.c +3 −3
  751. drivers/regulator/act8865-regulator.c +4 −3
  752. drivers/regulator/as3711-regulator.c +4 −2
  753. drivers/regulator/bcm590xx-regulator.c +4 −2
  754. drivers/regulator/da9063-regulator.c +2 −2
  755. drivers/regulator/gpio-regulator.c +5 −5
  756. drivers/regulator/max1586.c +4 −2
  757. drivers/regulator/max8660.c +4 −2
  758. drivers/regulator/max8997-regulator.c +3 −2
  759. drivers/regulator/max8998.c +3 −2
  760. drivers/regulator/mc13xxx-regulator-core.c +1 −1
  761. drivers/regulator/pbias-regulator.c +3 −2
  762. drivers/regulator/rc5t583-regulator.c +4 −2
  763. drivers/regulator/s2mps11.c +3 −3
  764. drivers/regulator/s5m8767.c +6 −4
  765. drivers/regulator/ti-abb-regulator.c +2 −2
  766. drivers/regulator/tps65090-regulator.c +6 −4
  767. drivers/regulator/tps65217-regulator.c +3 −2
  768. drivers/regulator/tps65218-regulator.c +3 −2
  769. drivers/regulator/tps65910-regulator.c +12 −6
  770. drivers/regulator/tps80031-regulator.c +2 −2
  771. drivers/reset/reset-ti-syscon.c +2 −1
  772. drivers/s390/block/dasd_eer.c +2 −2
  773. drivers/s390/block/dcssblk.c +3 −3
  774. drivers/s390/char/keyboard.c +1 −1
  775. drivers/s390/char/sclp_sd.c +1 −1
  776. drivers/s390/char/tty3270.c +2 −1
  777. drivers/s390/char/vmur.c +1 −1
  778. drivers/s390/char/zcore.c +1 −1
  779. drivers/s390/cio/qdio_setup.c +1 −1
  780. drivers/s390/cio/qdio_thinint.c +3 −2
  781. drivers/s390/crypto/pkey_api.c +4 −4
  782. drivers/s390/net/ctcm_main.c +1 −1
  783. drivers/s390/net/qeth_core_main.c +15 −12
  784. drivers/scsi/BusLogic.c +1 −1
  785. drivers/scsi/aacraid/aachba.c +1 −1
  786. drivers/scsi/aacraid/linit.c +3 −1
  787. drivers/scsi/aha1542.c +2 −1
  788. drivers/scsi/aic7xxx/aic79xx_core.c +2 −1
  789. drivers/scsi/aic7xxx/aic7xxx_core.c +2 −2
  790. drivers/scsi/aic94xx/aic94xx_hwi.c +7 −5
  791. drivers/scsi/aic94xx/aic94xx_init.c +1 −1
  792. drivers/scsi/arm/queue.c +1 −1
  793. drivers/scsi/be2iscsi/be_main.c +30 −24
  794. drivers/scsi/bfa/bfad_attr.c +1 −1
  795. drivers/scsi/bfa/bfad_bsg.c +3 −2
  796. drivers/scsi/bnx2fc/bnx2fc_fcoe.c +1 −1
  797. drivers/scsi/bnx2fc/bnx2fc_io.c +4 −4
  798. drivers/scsi/csiostor/csio_wr.c +2 −2
  799. drivers/scsi/esas2r/esas2r_init.c +6 −5
  800. drivers/scsi/fcoe/fcoe_ctlr.c +2 −2
  801. drivers/scsi/fnic/fnic_debugfs.c +4 −3
  802. drivers/scsi/fnic/fnic_trace.c +9 −6
  803. drivers/scsi/hpsa.c +19 −17
  804. drivers/scsi/ipr.c +10 −6
  805. drivers/scsi/isci/init.c +4 −4
  806. drivers/scsi/libiscsi.c +1 −1
  807. drivers/scsi/libsas/sas_expander.c +1 −1
  808. drivers/scsi/lpfc/lpfc_init.c +4 −3
  809. drivers/scsi/lpfc/lpfc_mem.c +3 −2
  810. drivers/scsi/lpfc/lpfc_sli.c +22 −28
  811. drivers/scsi/lpfc/lpfc_vport.c +1 −1
  812. drivers/scsi/mac53c94.c +3 −2
  813. drivers/scsi/megaraid.c +2 −1
  814. drivers/scsi/megaraid/megaraid_mm.c +6 −4
  815. drivers/scsi/megaraid/megaraid_sas_base.c +4 −4
  816. drivers/scsi/megaraid/megaraid_sas_fusion.c +7 −5
  817. drivers/scsi/osst.c +5 −3
  818. drivers/scsi/pm8001/pm8001_ctl.c +1 −1
  819. drivers/scsi/pmcraid.c +3 −2
  820. drivers/scsi/qedi/qedi_main.c +1 −1
  821. drivers/scsi/qla2xxx/qla_init.c +6 −4
  822. drivers/scsi/qla2xxx/qla_isr.c +3 −2
  823. drivers/scsi/qla2xxx/qla_nx.c +1 −1
  824. drivers/scsi/qla2xxx/qla_os.c +8 −6
  825. drivers/scsi/qla2xxx/qla_target.c +6 −4
  826. drivers/scsi/qla2xxx/tcm_qla2xxx.c +3 −1
  827. drivers/scsi/qla4xxx/ql4_nx.c +1 −1
  828. drivers/scsi/scsi_debug.c +3 −2
  829. drivers/scsi/sd_zbc.c +1 −1
  830. drivers/scsi/ses.c +1 −1
  831. drivers/scsi/sg.c +1 −1
  832. drivers/scsi/smartpqi/smartpqi_init.c +6 −4
  833. drivers/scsi/st.c +3 −2
  834. drivers/scsi/ufs/ufshcd-pltfrm.c +2 −2
  835. drivers/scsi/ufs/ufshcd.c +2 −2
  836. drivers/scsi/virtio_scsi.c +4 −3
  837. drivers/sh/clk/cpg.c +1 −1
  838. drivers/sh/intc/core.c +5 −5
  839. drivers/sh/maple/maple.c +1 −1
  840. drivers/slimbus/qcom-ctrl.c +1 −1
  841. drivers/soc/bcm/raspberrypi-power.c +4 −2
  842. drivers/soc/fsl/qbman/qman.c +3 −2
  843. drivers/soc/mediatek/mtk-scpsys.c +4 −4
  844. drivers/soc/ti/knav_qmss_acc.c +3 −3
  845. drivers/spi/spi-davinci.c +4 −3
  846. drivers/spi/spi-ep93xx.c +2 −2
  847. drivers/spi/spi-gpio.c +3 −2
  848. drivers/spi/spi-imx.c +3 −2
  849. drivers/spi/spi-oc-tiny.c +2 −2
  850. drivers/spi/spi-pl022.c +1 −1
  851. drivers/spi/spi.c +1 −1
  852. drivers/staging/android/ion/ion_heap.c +2 −1
  853. drivers/staging/greybus/audio_topology.c +1 −1
  854. drivers/staging/greybus/camera.c +3 −2
  855. drivers/staging/media/imx/imx-media-dev.c +3 −3
  856. drivers/staging/media/zoran/zoran_driver.c +3 −2
  857. drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c +17 −9
  858. drivers/staging/rtl8188eu/core/rtw_mlme.c +1 −1
  859. drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c +3 −2
  860. drivers/staging/rtl8192u/r8192U_core.c +2 −2
  861. drivers/staging/rtl8723bs/core/rtw_mlme.c +1 −1
  862. drivers/staging/rtlwifi/efuse.c +2 −2
  863. drivers/staging/rts5208/ms.c +1 −1
  864. drivers/staging/rts5208/rtsx_chip.c +3 −3
  865. drivers/staging/unisys/visorhba/visorhba_main.c +1 −1
  866. drivers/target/target_core_transport.c +2 −2
  867. drivers/target/target_core_user.c +3 −2
  868. drivers/thermal/int340x_thermal/acpi_thermal_rel.c +2 −2
  869. drivers/thermal/int340x_thermal/int340x_thermal_zone.c +4 −3
  870. drivers/thermal/of-thermal.c +2 −2
  871. drivers/thermal/tegra/soctherm.c +4 −4
  872. drivers/thermal/thermal-generic-adc.c +3 −2
  873. drivers/thermal/x86_pkg_temp_thermal.c +2 −1
  874. drivers/tty/ehv_bytechan.c +1 −1
  875. drivers/tty/goldfish.c +3 −2
  876. drivers/tty/hvc/hvc_iucv.c +1 −1
  877. drivers/tty/hvc/hvcs.c +2 −1
  878. drivers/tty/isicom.c +1 −1
  879. drivers/tty/serial/atmel_serial.c +3 −2
  880. drivers/tty/serial/pch_uart.c +1 −1
  881. drivers/tty/serial/rp2.c +1 −1
  882. drivers/tty/serial/serial_core.c +1 −1
  883. drivers/tty/serial/sunsab.c +3 −2
  884. drivers/tty/vt/consolemap.c +4 −3
  885. drivers/tty/vt/keyboard.c +2 −2
  886. drivers/tty/vt/selection.c +2 −1
  887. drivers/uio/uio_pruss.c +1 −1
  888. drivers/usb/core/devio.c +4 −3
  889. drivers/usb/core/hub.c +1 −1
  890. drivers/usb/core/message.c +3 −3
  891. drivers/usb/dwc2/hcd.c +6 −5
  892. drivers/usb/gadget/udc/atmel_usba_udc.c +1 −1
  893. drivers/usb/gadget/udc/bdc/bdc_ep.c +3 −3
  894. drivers/usb/gadget/udc/fsl_udc_core.c +1 −1
  895. drivers/usb/gadget/udc/renesas_usb3.c +2 −1
  896. drivers/usb/host/ehci-sched.c +3 −2
  897. drivers/usb/host/fhci-tds.c +1 −1
  898. drivers/usb/host/imx21-hcd.c +2 −2
  899. drivers/usb/host/ohci-dbg.c +1 −1
  900. drivers/usb/host/xhci-mem.c +2 −2
  901. drivers/usb/misc/ldusb.c +7 −2
  902. drivers/usb/misc/sisusbvga/sisusb_con.c +1 −1
  903. drivers/usb/mon/mon_bin.c +2 −1
  904. drivers/usb/renesas_usbhs/mod_gadget.c +1 −1
  905. drivers/usb/renesas_usbhs/pipe.c +2 −1
  906. drivers/usb/serial/iuu_phoenix.c +2 −2
  907. drivers/usb/storage/alauda.c +1 −1
  908. drivers/usb/storage/ene_ub6250.c +12 −4
  909. drivers/usb/storage/sddr09.c +2 −2
  910. drivers/usb/storage/sddr55.c +3 −3
  911. drivers/usb/wusbcore/wa-rpipe.c +2 −1
  912. drivers/uwb/est.c +1 −1
  913. drivers/uwb/i1480/dfu/usb.c +1 −1
  914. drivers/vhost/net.c +5 −3
  915. drivers/vhost/scsi.c +10 −7
  916. drivers/vhost/test.c +1 −1
  917. drivers/vhost/vhost.c +9 −5
  918. drivers/vhost/vringh.c +1 −1
  919. drivers/video/backlight/adp8860_bl.c +1 −1
  920. drivers/video/backlight/adp8870_bl.c +1 −1
  921. drivers/video/backlight/lp855x_bl.c +1 −1
  922. drivers/video/console/sticore.c +1 −1
  923. drivers/video/fbdev/au1100fb.c +1 −1
  924. drivers/video/fbdev/broadsheetfb.c +1 −1
  925. drivers/video/fbdev/core/bitblit.c +2 −2
  926. drivers/video/fbdev/core/fbcon.c +2 −1
  927. drivers/video/fbdev/core/fbcon_ccw.c +4 −3
  928. drivers/video/fbdev/core/fbcon_cw.c +4 −3
  929. drivers/video/fbdev/core/fbcon_rotate.c +1 −1
  930. drivers/video/fbdev/core/fbcon_ud.c +2 −2
  931. drivers/video/fbdev/core/fbmem.c +4 −3
  932. drivers/video/fbdev/core/fbmon.c +5 −4
  933. drivers/video/fbdev/imxfb.c +1 −1
  934. drivers/video/fbdev/mb862xx/mb862xxfb_accel.c +1 −1
  935. drivers/video/fbdev/mmp/fb/mmpfb.c +2 −2
  936. drivers/video/fbdev/mxsfb.c +1 −1
  937. drivers/video/fbdev/nvidia/nvidia.c +1 −1
  938. drivers/video/fbdev/omap2/omapfb/dss/manager.c +2 −2
  939. drivers/video/fbdev/omap2/omapfb/dss/overlay.c +2 −2
  940. drivers/video/fbdev/omap2/omapfb/vrfb.c +2 −2
  941. drivers/video/fbdev/pvr2fb.c +1 −1
  942. drivers/video/fbdev/riva/fbdev.c +1 −1
  943. drivers/video/fbdev/uvesafb.c +6 −4
  944. drivers/video/fbdev/via/viafbdev.c +2 −1
  945. drivers/video/fbdev/w100fb.c +2 −1
  946. drivers/video/fbdev/xen-fbfront.c +1 −1
  947. drivers/video/of_display_timing.c +3 −2
  948. drivers/virt/fsl_hypervisor.c +1 −1
  949. drivers/virt/vboxguest/vboxguest_core.c +4 −3
  950. drivers/virtio/virtio_pci_common.c +4 −3
  951. drivers/virtio/virtio_ring.c +1 −1
  952. drivers/xen/arm-device.c +3 −3
  953. drivers/xen/evtchn.c +1 −1
  954. drivers/xen/grant-table.c +4 −3
  955. drivers/xen/xen-pciback/pciback_ops.c +1 −1
  956. fs/9p/fid.c +1 −1
  957. fs/adfs/super.c +1 −1
  958. fs/afs/cmservice.c +4 −3
  959. fs/binfmt_elf.c +2 −2
  960. fs/binfmt_elf_fdpic.c +2 −1
  961. fs/block_dev.c +2 −1
  962. fs/btrfs/check-integrity.c +2 −2
  963. fs/ceph/addr.c +6 −5
  964. fs/ceph/mds_client.c +3 −2
  965. fs/cifs/asn1.c +1 −1
  966. fs/cifs/cifsacl.c +2 −2
  967. fs/cifs/cifssmb.c +1 −1
  968. fs/cifs/file.c +1 −1
  969. fs/cifs/inode.c +1 −1
  970. fs/cifs/misc.c +2 −2
  971. fs/cifs/smb2pdu.c +3 −3
  972. fs/cifs/transport.c +4 −4
  973. fs/dlm/lockspace.c +1 −1
  974. fs/exofs/inode.c +2 −2
  975. fs/ext2/super.c +3 −1
  976. fs/ext4/extents.c +4 −4
  977. fs/ext4/resize.c +6 −4
  978. fs/ext4/super.c +3 −3
  979. fs/f2fs/checkpoint.c +2 −1
  980. fs/f2fs/file.c +4 −2
  981. fs/f2fs/node.c +8 −4
  982. fs/f2fs/segment.c +10 −5
  983. fs/f2fs/super.c +13 −7
  984. fs/fat/namei_vfat.c +1 −1
  985. fs/fuse/dev.c +10 −5
  986. fs/gfs2/dir.c +3 −3
  987. fs/gfs2/glock.c +2 −1
  988. fs/gfs2/quota.c +1 −1
  989. fs/gfs2/rgrp.c +3 −2
  990. fs/gfs2/super.c +1 −1
  991. fs/hpfs/dnode.c +2 −1
  992. fs/hpfs/map.c +1 −1
  993. fs/jbd2/revoke.c +1 −1
  994. fs/jffs2/acl.c +2 −1
  995. fs/jffs2/acl.h +1 −0
  996. fs/jffs2/wbuf.c +1 −1
  997. fs/jfs/jfs_dmap.c +1 −1
  998. fs/jfs/jfs_dtree.c +5 −4
  999. fs/jfs/jfs_unicode.c +1 −1
  1000. fs/mbcache.c +3 −2
  1001. fs/namei.c +2 −2
  1002. fs/nfs/flexfilelayout/flexfilelayout.c +1 −1
  1003. fs/nfs/flexfilelayout/flexfilelayoutdev.c +2 −1
  1004. fs/nfsd/export.c +3 −2
  1005. fs/nfsd/nfs4recover.c +3 −2
  1006. fs/nfsd/nfs4state.c +12 −8
  1007. fs/nfsd/nfscache.c +2 −1
  1008. fs/ntfs/compress.c +1 −1
  1009. fs/ocfs2/cluster/tcp.c +1 −1
  1010. fs/ocfs2/dlm/dlmdomain.c +1 −1
  1011. fs/ocfs2/journal.c +1 −1
  1012. fs/ocfs2/sysfile.c +5 −4
  1013. fs/overlayfs/namei.c +1 −1
  1014. fs/proc/base.c +2 −1
  1015. fs/proc/proc_sysctl.c +1 −1
  1016. fs/proc/task_mmu.c +1 −1
  1017. fs/read_write.c +2 −2
  1018. fs/reiserfs/bitmap.c +1 −1
  1019. fs/reiserfs/inode.c +2 −1
  1020. fs/reiserfs/journal.c +8 −5
  1021. fs/reiserfs/resize.c +2 −1
  1022. fs/select.c +1 −1
  1023. fs/splice.c +4 −3
  1024. fs/ubifs/journal.c +3 −2
  1025. fs/ubifs/lpt.c +15 −10
  1026. fs/ubifs/super.c +2 −1
  1027. fs/ubifs/tnc.c +3 −2
  1028. fs/ubifs/tnc_commit.c +3 −2
  1029. fs/udf/super.c +4 −3
  1030. fs/ufs/super.c +3 −1
  1031. include/linux/mm.h +5 −0
  1032. include/rdma/ib_verbs.h +1 −4
  1033. ipc/sem.c +1 −1
  1034. kernel/bpf/btf.c +4 −4
  1035. kernel/bpf/lpm_trie.c +3 −2
  1036. kernel/bpf/verifier.c +6 −4
  1037. kernel/cgroup/cgroup-v1.c +2 −2
  1038. kernel/cgroup/cpuset.c +3 −2
  1039. kernel/debug/kdb/kdb_main.c +8 −5
  1040. kernel/events/ring_buffer.c +2 −1
  1041. kernel/events/uprobes.c +2 −1
  1042. kernel/fail_function.c +1 −1
  1043. kernel/kexec_file.c +1 −1
  1044. kernel/locking/locktorture.c +10 −4
  1045. kernel/power/swap.c +3 −3
  1046. kernel/rcu/rcutorture.c +3 −2
  1047. kernel/relay.c +2 −1
  1048. kernel/sched/fair.c +2 −2
  1049. kernel/sched/rt.c +2 −2
  1050. kernel/sched/topology.c +1 −1
  1051. kernel/sysctl.c +2 −1
  1052. kernel/trace/ftrace.c +15 −13
  1053. kernel/trace/trace.c +7 −5
  1054. kernel/trace/trace_events_filter.c +3 −3
  1055. kernel/trace/tracing_map.c +1 −1
  1056. kernel/user_namespace.c +3 −2
  1057. kernel/workqueue.c +1 −1
  1058. lib/argv_split.c +1 −1
  1059. lib/interval_tree_test.c +3 −2
  1060. lib/kfifo.c +1 −1
  1061. lib/lru_cache.c +1 −1
  1062. lib/mpi/mpiutil.c +2 −2
  1063. lib/rbtree_test.c +1 −1
  1064. lib/reed_solomon/reed_solomon.c +3 −3
  1065. lib/sbitmap.c +1 −1
  1066. lib/scatterlist.c +2 −1
  1067. lib/test_firmware.c +6 −4
  1068. lib/test_kmod.c +3 −2
  1069. lib/test_overflow.c +1 −1
  1070. lib/test_rhashtable.c +8 −5
  1071. mm/gup_benchmark.c +1 −1
  1072. mm/huge_memory.c +2 −2
  1073. mm/hugetlb.c +2 −1
  1074. mm/percpu-stats.c +1 −1
  1075. mm/slab.c +2 −1
  1076. mm/slub.c +11 −8
  1077. mm/swap_slots.c +2 −2
  1078. mm/swap_state.c +1 −1
  1079. mm/swapfile.c +3 −2
  1080. net/9p/protocol.c +6 −5
  1081. net/9p/trans_virtio.c +2 −1
  1082. net/atm/mpc.c +1 −1
  1083. net/bluetooth/hci_core.c +1 −1
  1084. net/bluetooth/l2cap_core.c +1 −1
  1085. net/bridge/br_multicast.c +1 −1
  1086. net/bridge/netfilter/ebtables.c +6 −5
  1087. net/can/bcm.c +8 −5
  1088. net/ceph/osdmap.c +3 −2
  1089. net/ceph/pagevec.c +2 −2
  1090. net/core/dev.c +1 −1
  1091. net/core/ethtool.c +6 −6
  1092. net/core/pktgen.c +2 −1
  1093. net/dcb/dcbnl.c +2 −1
  1094. net/dccp/ccids/ccid2.c +2 −1
  1095. net/ieee802154/nl-phy.c +1 −1
  1096. net/ipv4/fib_frontend.c +1 −1
  1097. net/ipv4/route.c +3 −2
  1098. net/ipv6/icmp.c +1 −1
  1099. net/ipv6/ila/ila_xlat.c +2 −1
  1100. net/mac80211/chan.c +1 −1
  1101. net/mac80211/main.c +1 −1
  1102. net/mac80211/rc80211_minstrel.c +2 −2
  1103. net/mac80211/rc80211_minstrel_ht.c +2 −2
  1104. net/mac80211/scan.c +1 −1
  1105. net/mac80211/util.c +3 −2
  1106. net/netfilter/ipvs/ip_vs_conn.c +2 −1
  1107. net/netfilter/nf_conntrack_proto.c +2 −1
  1108. net/netfilter/nf_nat_core.c +3 −2
  1109. net/netfilter/nf_tables_api.c +3 −3
  1110. net/netfilter/nfnetlink_cthelper.c +3 −2
  1111. net/netfilter/x_tables.c +1 −1
  1112. net/netlink/genetlink.c +6 −4
  1113. net/netrom/af_netrom.c +1 −1
  1114. net/openvswitch/datapath.c +3 −2
  1115. net/openvswitch/vport.c +1 −1
  1116. net/packet/af_packet.c +1 −1
  1117. net/rds/ib.c +2 −1
  1118. net/rds/ib_cm.c +4 −2
  1119. net/rds/info.c +1 −1
  1120. net/rose/af_rose.c +2 −1
  1121. net/rxrpc/rxkad.c +1 −1
  1122. net/sched/sch_fq_codel.c +4 −3
  1123. net/sched/sch_hhf.c +5 −4
  1124. net/sctp/auth.c +3 −2
  1125. net/sctp/protocol.c +1 −1
  1126. net/smc/smc_wr.c +3 −3
  1127. net/sunrpc/auth_gss/auth_gss.c +2 −1
  1128. net/sunrpc/auth_gss/gss_rpc_upcall.c +1 −1
  1129. net/sunrpc/cache.c +1 −1
  1130. net/tipc/netlink_compat.c +3 −2
  1131. net/wireless/nl80211.c +2 −2
  1132. security/apparmor/policy_unpack.c +1 −1
  1133. security/keys/trusted.c +1 −1
  1134. security/selinux/ss/services.c +1 −1
  1135. sound/core/pcm_compat.c +1 −1
  1136. sound/core/pcm_native.c +2 −2
  1137. sound/core/seq/seq_memory.c +2 −1
  1138. sound/core/seq/seq_midi_emul.c +1 −1
  1139. sound/firewire/fireface/ff-protocol-ff400.c +1 −1
  1140. sound/firewire/packets-buffer.c +1 −1
  1141. sound/oss/dmasound/dmasound_core.c +1 −1
  1142. sound/pci/cs46xx/cs46xx_lib.c +4 −3
  1143. sound/pci/cs46xx/dsp_spos.c +6 −3
  1144. sound/pci/ctxfi/ctatc.c +9 −9
  1145. sound/pci/ctxfi/ctdaio.c +2 −1
  1146. sound/pci/ctxfi/ctmixer.c +3 −2
  1147. sound/pci/ctxfi/ctsrc.c +1 −1
  1148. sound/pci/emu10k1/emu10k1_main.c +5 −4
  1149. sound/pci/emu10k1/emufx.c +4 −4
  1150. sound/pci/emu10k1/p16v.c +1 −1
  1151. sound/pci/hda/hda_codec.c +2 −2
  1152. sound/pci/hda/hda_proc.c +3 −2
  1153. sound/pci/hda/patch_ca0132.c +3 −1
  1154. sound/pci/maestro3.c +4 −1
  1155. sound/pci/trident/trident_main.c +3 −1
  1156. sound/pci/via82xx.c +3 −1
  1157. sound/pci/via82xx_modem.c +3 −1
  1158. sound/pci/ymfpci/ymfpci_main.c +2 −2
  1159. sound/soc/au1x/dbdma2.c +2 −2
  1160. sound/soc/codecs/hdmi-codec.c +1 −1
  1161. sound/soc/codecs/rt5645.c +3 −2
  1162. sound/soc/codecs/wm8904.c +3 −2
  1163. sound/soc/codecs/wm8958-dsp2.c +12 −8
  1164. sound/soc/codecs/wm8994.c +2 −2
  1165. sound/soc/codecs/wm_adsp.c +1 −1
  1166. sound/soc/davinci/davinci-mcasp.c +8 −6
  1167. sound/soc/generic/audio-graph-card.c +2 −2
  1168. sound/soc/generic/audio-graph-scu-card.c +2 −2
  1169. sound/soc/generic/simple-card.c +4 −4
  1170. sound/soc/generic/simple-scu-card.c +2 −2
  1171. sound/soc/img/img-i2s-in.c +2 −2
  1172. sound/soc/img/img-i2s-out.c +2 −2
  1173. sound/soc/intel/common/sst-ipc.c +2 −2
  1174. sound/soc/intel/skylake/skl-topology.c +12 −8
  1175. sound/soc/mediatek/mt2701/mt2701-afe-pcm.c +2 −1
  1176. sound/soc/pxa/mmp-sspa.c +2 −2
  1177. sound/soc/rockchip/rk3399_gru_sound.c +1 −1
  1178. sound/soc/sh/rcar/cmd.c +1 −1
  1179. sound/soc/sh/rcar/core.c +2 −2
  1180. sound/soc/sh/rcar/ctu.c +1 −1
  1181. sound/soc/sh/rcar/dvc.c +1 −1
  1182. sound/soc/sh/rcar/mix.c +1 −1
  1183. sound/soc/sh/rcar/src.c +1 −1
  1184. sound/soc/sh/rcar/ssi.c +1 −1
  1185. sound/soc/sh/rcar/ssiu.c +1 −1
  1186. sound/soc/soc-core.c +5 −5
  1187. sound/soc/soc-dapm.c +1 −1
  1188. sound/soc/soc-topology.c +1 −1
  1189. sound/soc/uniphier/aio-cpu.c +6 −4
  1190. sound/usb/6fire/pcm.c +6 −4
  1191. sound/usb/caiaq/audio.c +4 −3
  1192. sound/usb/format.c +3 −2
  1193. sound/usb/line6/capture.c +2 −2
  1194. sound/usb/line6/pcm.c +4 −2
  1195. sound/usb/line6/playback.c +2 −2
  1196. sound/usb/mixer.c +1 −1
  1197. sound/usb/pcm.c +1 −1
  1198. sound/usb/usx2y/usbusx2y.c +3 −1
  1199. sound/usb/usx2y/usbusx2yaudio.c +5 −2
  1200. virt/kvm/arm/vgic/vgic-v4.c +1 −1
  1201. virt/kvm/kvm_main.c +2 −1
arch/arm/kernel/sys_oabi-compat.c+2−2
@@ -286,7 +286,7 @@ asmlinkage long sys_oabi_epoll_wait(int epfd, · 285 unmodified lines
286286 return -EINVAL;
287287 if (!access_ok(VERIFY_WRITE, events, sizeof(*events) * maxevents))
288288 return -EFAULT;
289− kbuf = kmalloc(sizeof(*kbuf) * maxevents, GFP_KERNEL);
289+ kbuf = kmalloc_array(maxevents, sizeof(*kbuf), GFP_KERNEL);
290290 if (!kbuf)
291291 return -ENOMEM;
292292 fs = get_fs();
@@ -324,7 +324,7 @@ asmlinkage long sys_oabi_semtimedop(int semid, · 31 unmodified lines
324324 return -EINVAL;
325325 if (!access_ok(VERIFY_READ, tsops, sizeof(*tsops) * nsops))
326326 return -EFAULT;
327− sops = kmalloc(sizeof(*sops) * nsops, GFP_KERNEL);
327+ sops = kmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
328328 if (!sops)
329329 return -ENOMEM;
330330 err = 0;
arch/arm/mach-footbridge/dc21285.c+1−1
@@ -252,7 +252,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys) · 251 unmodified lines
252252 if (nr || !footbridge_cfn_mode())
253253 return 0;
254254
255− res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
255+ res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
256256 if (!res) {
257257 printk("out of memory for root bus resources");
258258 return 0;
arch/arm/mach-ixp4xx/common-pci.c+1−1
@@ -421,7 +421,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys) · 420 unmodified lines
421421 if (nr >= 1)
422422 return 0;
423423
424− res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
424+ res = kcalloc(2, sizeof(*res), GFP_KERNEL);
425425 if (res == NULL) {
426426 /*
427427 * If we're out of memory this early, something is wrong,
arch/arm/mach-omap1/mcbsp.c+1−1
@@ -389,7 +389,7 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count, · 388 unmodified lines
389389 {
390390 int i;
391391
392− omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
392+ omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *),
393393 GFP_KERNEL);
394394 if (!omap_mcbsp_devices) {
395395 printk(KERN_ERR "Could not register McBSP devices\n");
arch/arm/mach-omap2/hsmmc.c+1−1
@@ -34,7 +34,7 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c, · 33 unmodified lines
3434 {
3535 char *hc_name;
3636
37− hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
37+ hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL);
3838 if (!hc_name) {
3939 kfree(hc_name);
4040 return -ENOMEM;
arch/arm/mach-omap2/omap_device.c+2−2
@@ -162,7 +162,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev) · 161 unmodified lines
162162 !omap_hwmod_parse_module_range(NULL, node, &res))
163163 return -ENODEV;
164164
165− hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
165+ hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL);
166166 if (!hwmods) {
167167 ret = -ENOMEM;
168168 goto odbfd_exit;
@@ -413,7 +413,7 @@ omap_device_copy_resources(struct omap_hwmod *oh, · 244 unmodified lines
413413 goto error;
414414 }
415415
416− res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
416+ res = kcalloc(2, sizeof(*res), GFP_KERNEL);
417417 if (!res)
418418 return -ENOMEM;
419419
arch/arm/mach-omap2/prm_common.c+5−4
@@ -285,10 +285,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup) · 284 unmodified lines
285285
286286 prcm_irq_setup = irq_setup;
287287
288− prcm_irq_chips = kzalloc(sizeof(void *) * nr_regs, GFP_KERNEL);
289− prcm_irq_setup->saved_mask = kzalloc(sizeof(u32) * nr_regs, GFP_KERNEL);
290− prcm_irq_setup->priority_mask = kzalloc(sizeof(u32) * nr_regs,
291− GFP_KERNEL);
288+ prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL);
289+ prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32),
290+ GFP_KERNEL);
291+ prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32),
292+ GFP_KERNEL);
292293
293294 if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
294295 !prcm_irq_setup->priority_mask)
arch/arm/mach-vexpress/spc.c+1−1
@@ -403,7 +403,7 @@ static int ve_spc_populate_opps(uint32_t cluster) · 402 unmodified lines
403403 uint32_t data = 0, off, ret, idx;
404404 struct ve_spc_opp *opps;
405405
406− opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
406+ opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL);
407407 if (!opps)
408408 return -ENOMEM;
409409
arch/arm/mm/dma-mapping.c+2−2
@@ -2162,8 +2162,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size) · 2161 unmodified lines
21622162 goto err;
21632163
21642164 mapping->bitmap_size = bitmap_size;
2165− mapping->bitmaps = kzalloc(extensions * sizeof(unsigned long *),
2166− GFP_KERNEL);
2165+ mapping->bitmaps = kcalloc(extensions, sizeof(unsigned long *),
2166+ GFP_KERNEL);
21672167 if (!mapping->bitmaps)
21682168 goto err2;
21692169
arch/arm/mm/pgd.c+1−1
@@ -20,7 +20,7 @@ · 19 unmodified lines
2020 #include "mm.h"
2121
2222 #ifdef CONFIG_ARM_LPAE
23−#define __pgd_alloc() kmalloc(PTRS_PER_PGD * sizeof(pgd_t), GFP_KERNEL)
23+#define __pgd_alloc() kmalloc_array(PTRS_PER_PGD, sizeof(pgd_t), GFP_KERNEL)
2424 #define __pgd_free(pgd) kfree(pgd)
2525 #else
2626 #define __pgd_alloc() (pgd_t *)__get_free_pages(GFP_KERNEL, 2)
arch/arm/probes/kprobes/test-core.c+3−2
@@ -766,8 +766,9 @@ static int coverage_start_fn(const struct decode_header *h, void *args) · 765 unmodified lines
766766
767767 static int coverage_start(const union decode_item *table)
768768 {
769− coverage.base = kmalloc(MAX_COVERAGE_ENTRIES *
770− sizeof(struct coverage_entry), GFP_KERNEL);
769+ coverage.base = kmalloc_array(MAX_COVERAGE_ENTRIES,
770+ sizeof(struct coverage_entry),
771+ GFP_KERNEL);
771772 coverage.num_entries = 0;
772773 coverage.nesting = 0;
773774 return table_iter(table, coverage_start_fn, &coverage);
arch/arm64/kernel/armv8_deprecated.c+2−2
@@ -234,8 +234,8 @@ static void __init register_insn_emulation_sysctl(void) · 233 unmodified lines
234234 struct insn_emulation *insn;
235235 struct ctl_table *insns_sysctl, *sysctl;
236236
237− insns_sysctl = kzalloc(sizeof(*sysctl) * (nr_insn_emulated + 1),
238− GFP_KERNEL);
237+ insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
238+ GFP_KERNEL);
239239
240240 raw_spin_lock_irqsave(&insn_emulation_lock, flags);
241241 list_for_each_entry(insn, &insn_emulation, node) {
arch/arm64/mm/context.c+1−1
@@ -263,7 +263,7 @@ static int asids_init(void) · 262 unmodified lines
263263 */
264264 WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus());
265265 atomic64_set(&asid_generation, ASID_FIRST_VERSION);
266− asid_map = kzalloc(BITS_TO_LONGS(NUM_USER_ASIDS) * sizeof(*asid_map),
266+ asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map),
267267 GFP_KERNEL);
268268 if (!asid_map)
269269 panic("Failed to allocate bitmap for %lu ASIDs\n",
arch/ia64/kernel/mca_drv.c+2−1
@@ -350,7 +350,8 @@ init_record_index_pools(void) · 349 unmodified lines
350350 /* - 3 - */
351351 slidx_pool.max_idx = (rec_max_size/sect_min_size) * 2 + 1;
352352 slidx_pool.buffer =
353− kmalloc(slidx_pool.max_idx * sizeof(slidx_list_t), GFP_KERNEL);
353+ kmalloc_array(slidx_pool.max_idx, sizeof(slidx_list_t),
354+ GFP_KERNEL);
354355
355356 return slidx_pool.buffer ? 0 : -ENOMEM;
356357 }
arch/ia64/kernel/topology.c+3−3
@@ -85,7 +85,7 @@ static int __init topology_init(void) · 84 unmodified lines
8585 }
8686 #endif
8787
88− sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
88+ sysfs_cpus = kcalloc(NR_CPUS, sizeof(struct ia64_cpu), GFP_KERNEL);
8989 if (!sysfs_cpus)
9090 panic("kzalloc in topology_init failed - NR_CPUS too big?");
9191
@@ -319,8 +319,8 @@ static int cpu_cache_sysfs_init(unsigned int cpu) · 227 unmodified lines
319319 return -1;
320320 }
321321
322− this_cache=kzalloc(sizeof(struct cache_info)*unique_caches,
323− GFP_KERNEL);
322+ this_cache=kcalloc(unique_caches, sizeof(struct cache_info),
323+ GFP_KERNEL);
324324 if (this_cache == NULL)
325325 return -ENOMEM;
326326
arch/ia64/mm/tlb.c+3−2
@@ -430,8 +430,9 @@ int ia64_itr_entry(u64 target_mask, u64 va, u64 pte, u64 log_size) · 429 unmodified lines
430430 int cpu = smp_processor_id();
431431
432432 if (!ia64_idtrs[cpu]) {
433− ia64_idtrs[cpu] = kmalloc(2 * IA64_TR_ALLOC_MAX *
434− sizeof (struct ia64_tr_entry), GFP_KERNEL);
433+ ia64_idtrs[cpu] = kmalloc_array(2 * IA64_TR_ALLOC_MAX,
434+ sizeof(struct ia64_tr_entry),
435+ GFP_KERNEL);
435436 if (!ia64_idtrs[cpu])
436437 return -ENOMEM;
437438 }
arch/ia64/sn/kernel/io_common.c+1−1
@@ -132,7 +132,7 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device, · 131 unmodified lines
132132 printk_once(KERN_WARNING
133133 "PROM version < 4.50 -- implementing old PROM flush WAR\n");
134134
135− war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
135+ war_list = kcalloc(DEV_PER_WIDGET, sizeof(*war_list), GFP_KERNEL);
136136 BUG_ON(!war_list);
137137
138138 SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
arch/ia64/sn/kernel/irq.c+2−1
@@ -474,7 +474,8 @@ void __init sn_irq_lh_init(void) · 473 unmodified lines
474474 {
475475 int i;
476476
477− sn_irq_lh = kmalloc(sizeof(struct list_head *) * NR_IRQS, GFP_KERNEL);
477+ sn_irq_lh = kmalloc_array(NR_IRQS, sizeof(struct list_head *),
478+ GFP_KERNEL);
478479 if (!sn_irq_lh)
479480 panic("SN PCI INIT: Failed to allocate memory for PCI init\n");
480481
arch/ia64/sn/pci/pcibr/pcibr_provider.c+1−1
@@ -184,7 +184,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont · 183 unmodified lines
184184 /* Setup the PMU ATE map */
185185 soft->pbi_int_ate_resource.lowest_free_index = 0;
186186 soft->pbi_int_ate_resource.ate =
187− kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL);
187+ kcalloc(soft->pbi_int_ate_size, sizeof(u64), GFP_KERNEL);
188188
189189 if (!soft->pbi_int_ate_resource.ate) {
190190 kfree(soft);
arch/mips/alchemy/common/clock.c+1−1
@@ -985,7 +985,7 @@ static int __init alchemy_clk_setup_imux(int ctype) · 984 unmodified lines
985985 return -ENODEV;
986986 }
987987
988− a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL);
988+ a = kcalloc(6, sizeof(*a), GFP_KERNEL);
989989 if (!a)
990990 return -ENOMEM;
991991
arch/mips/alchemy/common/dbdma.c+3−3
@@ -411,8 +411,8 @@ u32 au1xxx_dbdma_ring_alloc(u32 chanid, int entries) · 410 unmodified lines
411411 * and if we try that first we are likely to not waste larger
412412 * slabs of memory.
413413 */
414− desc_base = (u32)kmalloc(entries * sizeof(au1x_ddma_desc_t),
415− GFP_KERNEL|GFP_DMA);
414+ desc_base = (u32)kmalloc_array(entries, sizeof(au1x_ddma_desc_t),
415+ GFP_KERNEL|GFP_DMA);
416416 if (desc_base == 0)
417417 return 0;
418418
@@ -1050,7 +1050,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable) · 631 unmodified lines
10501050 {
10511051 int ret;
10521052
1053− dbdev_tab = kzalloc(sizeof(dbdev_tab_t) * DBDEV_TAB_SIZE, GFP_KERNEL);
1053+ dbdev_tab = kcalloc(DBDEV_TAB_SIZE, sizeof(dbdev_tab_t), GFP_KERNEL);
10541054 if (!dbdev_tab)
10551055 return -ENOMEM;
10561056
arch/mips/alchemy/common/platform.c+2−2
@@ -115,7 +115,7 @@ static void __init alchemy_setup_uarts(int ctype) · 114 unmodified lines
115115 uartclk = clk_get_rate(clk);
116116 clk_put(clk);
117117
118− ports = kzalloc(s * (c + 1), GFP_KERNEL);
118+ ports = kcalloc(s, (c + 1), GFP_KERNEL);
119119 if (!ports) {
120120 printk(KERN_INFO "Alchemy: no memory for UART data\n");
121121 return;
@@ -198,7 +198,7 @@ static unsigned long alchemy_ehci_data[][2] __initdata = { · 76 unmodified lines
198198
199199 static int __init _new_usbres(struct resource **r, struct platform_device **d)
200200 {
201− *r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
201+ *r = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
202202 if (!*r)
203203 return -ENOMEM;
204204 *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
arch/mips/alchemy/devboards/platform.c+2−2
@@ -103,7 +103,7 @@ int __init db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start, · 102 unmodified lines
103103 if (stschg_irq)
104104 cnt++;
105105
106− sr = kzalloc(sizeof(struct resource) * cnt, GFP_KERNEL);
106+ sr = kcalloc(cnt, sizeof(struct resource), GFP_KERNEL);
107107 if (!sr)
108108 return -ENOMEM;
109109
@@ -178,7 +178,7 @@ int __init db1x_register_norflash(unsigned long size, int width, · 68 unmodified lines
178178 return -EINVAL;
179179
180180 ret = -ENOMEM;
181− parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
181+ parts = kcalloc(5, sizeof(struct mtd_partition), GFP_KERNEL);
182182 if (!parts)
183183 goto out;
184184
arch/mips/bmips/dma.c+1−1
@@ -94,7 +94,7 @@ static int __init bmips_init_dma_ranges(void) · 93 unmodified lines
9494 goto out_bad;
9595
9696 /* add a dummy (zero) entry at the end as a sentinel */
97− bmips_dma_ranges = kzalloc(sizeof(struct bmips_dma_range) * (len + 1),
97+ bmips_dma_ranges = kcalloc(len + 1, sizeof(struct bmips_dma_range),
9898 GFP_KERNEL);
9999 if (!bmips_dma_ranges)
100100 goto out_bad;
arch/mips/txx9/rbtx4939/setup.c+1−1
@@ -219,7 +219,7 @@ static int __init rbtx4939_led_probe(struct platform_device *pdev) · 218 unmodified lines
219219 "nand-disk",
220220 };
221221
222− leds_data = kzalloc(sizeof(*leds_data) * RBTX4939_MAX_7SEGLEDS,
222+ leds_data = kcalloc(RBTX4939_MAX_7SEGLEDS, sizeof(*leds_data),
223223 GFP_KERNEL);
224224 if (!leds_data)
225225 return -ENOMEM;
arch/powerpc/kernel/rtasd.c+2−1
@@ -559,7 +559,8 @@ static int __init rtas_event_scan_init(void) · 558 unmodified lines
559559 rtas_error_log_max = rtas_get_error_log_max();
560560 rtas_error_log_buffer_max = rtas_error_log_max + sizeof(int);
561561
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));
563564 if (!rtas_log_buf) {
564565 printk(KERN_ERR "rtasd: no memory\n");
565566 return -ENOMEM;
arch/powerpc/kernel/vdso.c+2−2
@@ -791,7 +791,7 @@ static int __init vdso_init(void) · 790 unmodified lines
791791
792792 #ifdef CONFIG_VDSO32
793793 /* Make sure pages are in the correct state */
794− vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),
794+ vdso32_pagelist = kcalloc(vdso32_pages + 2, sizeof(struct page *),
795795 GFP_KERNEL);
796796 BUG_ON(vdso32_pagelist == NULL);
797797 for (i = 0; i < vdso32_pages; i++) {
@@ -805,7 +805,7 @@ static int __init vdso_init(void) · 7 unmodified lines
805805 #endif
806806
807807 #ifdef CONFIG_PPC64
808− vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),
808+ vdso64_pagelist = kcalloc(vdso64_pages + 2, sizeof(struct page *),
809809 GFP_KERNEL);
810810 BUG_ON(vdso64_pagelist == NULL);
811811 for (i = 0; i < vdso64_pages; i++) {
arch/powerpc/kvm/book3s_64_mmu_hv.c+1−1
@@ -108,7 +108,7 @@ int kvmppc_allocate_hpt(struct kvm_hpt_info *info, u32 order) · 107 unmodified lines
108108 npte = 1ul << (order - 4);
109109
110110 /* Allocate reverse map array */
111− rev = vmalloc(sizeof(struct revmap_entry) * npte);
111+ rev = vmalloc(array_size(npte, sizeof(struct revmap_entry)));
112112 if (!rev) {
113113 if (cma)
114114 kvm_free_hpt_cma(page, 1 << (order - PAGE_SHIFT));
arch/powerpc/kvm/book3s_hv.c+1−1
@@ -3548,7 +3548,7 @@ static void kvmppc_core_free_memslot_hv(struct kvm_memory_slot *free, · 3547 unmodified lines
35483548 static int kvmppc_core_create_memslot_hv(struct kvm_memory_slot *slot,
35493549 unsigned long npages)
35503550 {
3551− slot->arch.rmap = vzalloc(npages * sizeof(*slot->arch.rmap));
3551+ slot->arch.rmap = vzalloc(array_size(npages, sizeof(*slot->arch.rmap)));
35523552 if (!slot->arch.rmap)
35533553 return -ENOMEM;
35543554
arch/powerpc/lib/rheap.c+1−1
@@ -54,7 +54,7 @@ static int grow(rh_info_t * info, int max_blocks) · 53 unmodified lines
5454
5555 new_blocks = max_blocks - info->max_blocks;
5656
57− block = kmalloc(sizeof(rh_block_t) * max_blocks, GFP_ATOMIC);
57+ block = kmalloc_array(max_blocks, sizeof(rh_block_t), GFP_ATOMIC);
5858 if (block == NULL)
5959 return -ENOMEM;
6060
arch/powerpc/mm/mmu_context_iommu.c+1−1
@@ -159,7 +159,7 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries, · 158 unmodified lines
159159 goto unlock_exit;
160160 }
161161
162− mem->hpas = vzalloc(entries * sizeof(mem->hpas[0]));
162+ mem->hpas = vzalloc(array_size(entries, sizeof(mem->hpas[0])));
163163 if (!mem->hpas) {
164164 kfree(mem);
165165 ret = -ENOMEM;
arch/powerpc/mm/numa.c+1−1
@@ -1316,7 +1316,7 @@ int numa_update_cpu_topology(bool cpus_locked) · 1315 unmodified lines
13161316 if (!weight)
13171317 return 0;
13181318
1319− updates = kzalloc(weight * (sizeof(*updates)), GFP_KERNEL);
1319+ updates = kcalloc(weight, sizeof(*updates), GFP_KERNEL);
13201320 if (!updates)
13211321 return 0;
13221322
arch/powerpc/net/bpf_jit_comp.c+1−1
@@ -566,7 +566,7 @@ void bpf_jit_compile(struct bpf_prog *fp) · 565 unmodified lines
566566 if (!bpf_jit_enable)
567567 return;
568568
569− addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
569+ addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
570570 if (addrs == NULL)
571571 return;
572572
arch/powerpc/net/bpf_jit_comp64.c+1−1
@@ -949,7 +949,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp) · 948 unmodified lines
949949 goto skip_init_ctx;
950950 }
951951
952− addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
952+ addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
953953 if (addrs == NULL) {
954954 fp = org_fp;
955955 goto out_addrs;
arch/powerpc/oprofile/cell/spu_profiler.c+2−2
@@ -210,8 +210,8 @@ int start_spu_profiling_cycles(unsigned int cycles_reset) · 209 unmodified lines
210210 timer.function = profile_spus;
211211
212212 /* Allocate arrays for collecting SPU PC samples */
213− samples = kzalloc(SPUS_PER_NODE *
214− TRACE_ARRAY_SIZE * sizeof(u32), GFP_KERNEL);
213+ samples = kcalloc(SPUS_PER_NODE * TRACE_ARRAY_SIZE, sizeof(u32),
214+ GFP_KERNEL);
215215
216216 if (!samples)
217217 return -ENOMEM;
arch/powerpc/platforms/4xx/hsta_msi.c+2−1
@@ -156,7 +156,8 @@ static int hsta_msi_probe(struct platform_device *pdev) · 155 unmodified lines
156156 if (ret)
157157 goto out;
158158
159− ppc4xx_hsta_msi.irq_map = kmalloc(sizeof(int) * irq_count, GFP_KERNEL);
159+ ppc4xx_hsta_msi.irq_map = kmalloc_array(irq_count, sizeof(int),
160+ GFP_KERNEL);
160161 if (!ppc4xx_hsta_msi.irq_map) {
161162 ret = -ENOMEM;
162163 goto out1;
arch/powerpc/platforms/4xx/msi.c+1−1
@@ -89,7 +89,7 @@ static int ppc4xx_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) · 88 unmodified lines
8989 if (type == PCI_CAP_ID_MSIX)
9090 pr_debug("ppc4xx msi: MSI-X untested, trying anyway.\n");
9191
92− msi_data->msi_virqs = kmalloc((msi_irqs) * sizeof(int), GFP_KERNEL);
92+ msi_data->msi_virqs = kmalloc_array(msi_irqs, sizeof(int), GFP_KERNEL);
9393 if (!msi_data->msi_virqs)
9494 return -ENOMEM;
9595
arch/powerpc/platforms/4xx/pci.c+1−1
@@ -1449,7 +1449,7 @@ static int __init ppc4xx_pciex_check_core_init(struct device_node *np) · 1448 unmodified lines
14491449 count = ppc4xx_pciex_hwops->core_init(np);
14501450 if (count > 0) {
14511451 ppc4xx_pciex_ports =
1452− kzalloc(count * sizeof(struct ppc4xx_pciex_port),
1452+ kcalloc(count, sizeof(struct ppc4xx_pciex_port),
14531453 GFP_KERNEL);
14541454 if (ppc4xx_pciex_ports) {
14551455 ppc4xx_pciex_port_count = count;
arch/powerpc/platforms/powernv/opal-sysparam.c+4−4
@@ -198,21 +198,21 @@ void __init opal_sys_param_init(void) · 197 unmodified lines
198198 goto out_param_buf;
199199 }
200200
201− id = kzalloc(sizeof(*id) * count, GFP_KERNEL);
201+ id = kcalloc(count, sizeof(*id), GFP_KERNEL);
202202 if (!id) {
203203 pr_err("SYSPARAM: Failed to allocate memory to read parameter "
204204 "id\n");
205205 goto out_param_buf;
206206 }
207207
208− size = kzalloc(sizeof(*size) * count, GFP_KERNEL);
208+ size = kcalloc(count, sizeof(*size), GFP_KERNEL);
209209 if (!size) {
210210 pr_err("SYSPARAM: Failed to allocate memory to read parameter "
211211 "size\n");
212212 goto out_free_id;
213213 }
214214
215− perm = kzalloc(sizeof(*perm) * count, GFP_KERNEL);
215+ perm = kcalloc(count, sizeof(*perm), GFP_KERNEL);
216216 if (!perm) {
217217 pr_err("SYSPARAM: Failed to allocate memory to read supported "
218218 "action on the parameter");
@@ -235,7 +235,7 @@ void __init opal_sys_param_init(void) · 16 unmodified lines
235235 goto out_free_perm;
236236 }
237237
238− attr = kzalloc(sizeof(*attr) * count, GFP_KERNEL);
238+ attr = kcalloc(count, sizeof(*attr), GFP_KERNEL);
239239 if (!attr) {
240240 pr_err("SYSPARAM: Failed to allocate memory for parameter "
241241 "attributes\n");
arch/powerpc/sysdev/mpic.c+5−4
@@ -544,7 +544,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic) · 543 unmodified lines
544544 printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
545545
546546 /* Allocate fixups array */
547− mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL);
547+ mpic->fixups = kcalloc(128, sizeof(*mpic->fixups), GFP_KERNEL);
548548 BUG_ON(mpic->fixups == NULL);
549549
550550 /* Init spinlock */
@@ -1324,7 +1324,7 @@ struct mpic * __init mpic_alloc(struct device_node *node, · 773 unmodified lines
13241324 if (psrc) {
13251325 /* Allocate a bitmap with one bit per interrupt */
13261326 unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
1327− mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL);
1327+ mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL);
13281328 BUG_ON(mpic->protected == NULL);
13291329 for (i = 0; i < psize/sizeof(u32); i++) {
13301330 if (psrc[i] > intvec_top)
@@ -1639,8 +1639,9 @@ void __init mpic_init(struct mpic *mpic) · 308 unmodified lines
16391639
16401640 #ifdef CONFIG_PM
16411641 /* allocate memory to save mpic state */
1642− mpic->save_data = kmalloc(mpic->num_sources * sizeof(*mpic->save_data),
1643− GFP_KERNEL);
1642+ mpic->save_data = kmalloc_array(mpic->num_sources,
1643+ sizeof(*mpic->save_data),
1644+ GFP_KERNEL);
16441645 BUG_ON(mpic->save_data == NULL);
16451646 #endif
16461647
arch/powerpc/sysdev/xive/native.c+1−1
@@ -489,7 +489,7 @@ static bool xive_parse_provisioning(struct device_node *np) · 488 unmodified lines
489489 if (rc == 0)
490490 return true;
491491
492− xive_provision_chips = kzalloc(4 * xive_provision_chip_count,
492+ xive_provision_chips = kcalloc(4, xive_provision_chip_count,
493493 GFP_KERNEL);
494494 if (WARN_ON(!xive_provision_chips))
495495 return false;
arch/s390/appldata/appldata_base.c+1−1
@@ -391,7 +391,7 @@ int appldata_register_ops(struct appldata_ops *ops) · 390 unmodified lines
391391 if (ops->size > APPLDATA_MAX_REC_SIZE)
392392 return -EINVAL;
393393
394− ops->ctl_table = kzalloc(4 * sizeof(struct ctl_table), GFP_KERNEL);
394+ ops->ctl_table = kcalloc(4, sizeof(struct ctl_table), GFP_KERNEL);
395395 if (!ops->ctl_table)
396396 return -ENOMEM;
397397
arch/s390/hypfs/hypfs_diag.c+1−1
@@ -239,7 +239,7 @@ static void *page_align_ptr(void *ptr) · 238 unmodified lines
239239 static void *diag204_alloc_vbuf(int pages)
240240 {
241241 /* 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)));
243243 if (!diag204_buf_vmalloc)
244244 return ERR_PTR(-ENOMEM);
245245 diag204_buf = page_align_ptr(diag204_buf_vmalloc);
arch/s390/hypfs/hypfs_diag0c.c+2−1
@@ -49,7 +49,8 @@ static void *diag0c_store(unsigned int *count) · 48 unmodified lines
4949
5050 get_online_cpus();
5151 cpu_count = num_online_cpus();
52− cpu_vec = kmalloc(sizeof(*cpu_vec) * num_possible_cpus(), GFP_KERNEL);
52+ cpu_vec = kmalloc_array(num_possible_cpus(), sizeof(*cpu_vec),
53+ GFP_KERNEL);
5354 if (!cpu_vec)
5455 goto fail_put_online_cpus;
5556 /* Note: Diag 0c needs 8 byte alignment and real storage */
arch/s390/kernel/debug.c+4−2
@@ -194,11 +194,13 @@ static debug_entry_t ***debug_areas_alloc(int pages_per_area, int nr_areas) · 193 unmodified lines
194194 debug_entry_t ***areas;
195195 int i, j;
196196
197− areas = kmalloc(nr_areas * sizeof(debug_entry_t **), GFP_KERNEL);
197+ areas = kmalloc_array(nr_areas, sizeof(debug_entry_t **), GFP_KERNEL);
198198 if (!areas)
199199 goto fail_malloc_areas;
200200 for (i = 0; i < nr_areas; i++) {
201− areas[i] = kmalloc(pages_per_area * sizeof(debug_entry_t *), GFP_KERNEL);
201+ areas[i] = kmalloc_array(pages_per_area,
202+ sizeof(debug_entry_t *),
203+ GFP_KERNEL);
202204 if (!areas[i])
203205 goto fail_malloc_areas2;
204206 for (j = 0; j < pages_per_area; j++) {
arch/s390/kernel/module.c+2−2
@@ -123,8 +123,8 @@ int module_frob_arch_sections(Elf_Ehdr *hdr, Elf_Shdr *sechdrs, · 122 unmodified lines
123123
124124 /* Allocate one syminfo structure per symbol. */
125125 me->arch.nsyms = symtab->sh_size / sizeof(Elf_Sym);
126− me->arch.syminfo = vmalloc(me->arch.nsyms *
127− sizeof(struct mod_arch_syminfo));
126+ me->arch.syminfo = vmalloc(array_size(sizeof(struct mod_arch_syminfo),
127+ me->arch.nsyms));
128128 if (!me->arch.syminfo)
129129 return -ENOMEM;
130130 symbols = (void *) hdr + symtab->sh_offset;
arch/s390/kernel/perf_cpum_cf_events.c+1−1
@@ -527,7 +527,7 @@ static __init struct attribute **merge_attr(struct attribute **a, · 526 unmodified lines
527527 j++;
528528 j++;
529529
530− new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
530+ new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
531531 if (!new)
532532 return NULL;
533533 j = 0;
arch/s390/kernel/sthyi.c+1−1
@@ -315,7 +315,7 @@ static void fill_diag(struct sthyi_sctns *sctns) · 314 unmodified lines
315315 if (pages <= 0)
316316 return;
317317
318− diag204_buf = vmalloc(PAGE_SIZE * pages);
318+ diag204_buf = vmalloc(array_size(pages, PAGE_SIZE));
319319 if (!diag204_buf)
320320 return;
321321
arch/s390/kernel/vdso.c+2−2
@@ -285,7 +285,7 @@ static int __init vdso_init(void) · 284 unmodified lines
285285 + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
286286
287287 /* Make sure pages are in the correct state */
288− vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 1),
288+ vdso32_pagelist = kcalloc(vdso32_pages + 1, sizeof(struct page *),
289289 GFP_KERNEL);
290290 BUG_ON(vdso32_pagelist == NULL);
291291 for (i = 0; i < vdso32_pages - 1; i++) {
@@ -303,7 +303,7 @@ static int __init vdso_init(void) · 11 unmodified lines
303303 + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
304304
305305 /* Make sure pages are in the correct state */
306− vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 1),
306+ vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *),
307307 GFP_KERNEL);
308308 BUG_ON(vdso64_pagelist == NULL);
309309 for (i = 0; i < vdso64_pages - 1; i++) {
arch/s390/kvm/gaccess.c+1−1
@@ -847,7 +847,7 @@ int access_guest(struct kvm_vcpu *vcpu, unsigned long ga, u8 ar, void *data, · 846 unmodified lines
847847 nr_pages = (((ga & ~PAGE_MASK) + len - 1) >> PAGE_SHIFT) + 1;
848848 pages = pages_array;
849849 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)));
851851 if (!pages)
852852 return -ENOMEM;
853853 need_ipte_lock = psw_bits(*psw).dat && !asce.r;
arch/s390/kvm/kvm-s390.c+1−1
@@ -1729,7 +1729,7 @@ static int kvm_s390_set_cmma_bits(struct kvm *kvm, · 1728 unmodified lines
17291729 if (args->count == 0)
17301730 return 0;
17311731
1732− bits = vmalloc(sizeof(*bits) * args->count);
1732+ bits = vmalloc(array_size(sizeof(*bits), args->count));
17331733 if (!bits)
17341734 return -ENOMEM;
17351735
arch/s390/mm/extmem.c+1−1
@@ -103,7 +103,7 @@ static int scode_set; · 102 unmodified lines
103103 static int
104104 dcss_set_subcodes(void)
105105 {
106− char *name = kmalloc(8 * sizeof(char), GFP_KERNEL | GFP_DMA);
106+ char *name = kmalloc(8, GFP_KERNEL | GFP_DMA);
107107 unsigned long rx, ry;
108108 int rc;
109109
arch/sh/drivers/dma/dmabrg.c+1−1
@@ -154,7 +154,7 @@ static int __init dmabrg_init(void) · 153 unmodified lines
154154 unsigned long or;
155155 int ret;
156156
157− dmabrg_handlers = kzalloc(10 * sizeof(struct dmabrg_handler),
157+ dmabrg_handlers = kcalloc(10, sizeof(struct dmabrg_handler),
158158 GFP_KERNEL);
159159 if (!dmabrg_handlers)
160160 return -ENOMEM;
arch/sh/drivers/pci/pcie-sh7786.c+1−1
@@ -561,7 +561,7 @@ static int __init sh7786_pcie_init(void) · 560 unmodified lines
561561 if (unlikely(nr_ports == 0))
562562 return -ENODEV;
563563
564− sh7786_pcie_ports = kzalloc(nr_ports * sizeof(struct sh7786_pcie_port),
564+ sh7786_pcie_ports = kcalloc(nr_ports, sizeof(struct sh7786_pcie_port),
565565 GFP_KERNEL);
566566 if (unlikely(!sh7786_pcie_ports))
567567 return -ENOMEM;
arch/sparc/kernel/nmi.c+2−1
@@ -166,7 +166,8 @@ static int __init check_nmi_watchdog(void) · 165 unmodified lines
166166 if (!atomic_read(&nmi_active))
167167 return 0;
168168
169− prev_nmi_count = kmalloc(nr_cpu_ids * sizeof(unsigned int), GFP_KERNEL);
169+ prev_nmi_count = kmalloc_array(nr_cpu_ids, sizeof(unsigned int),
170+ GFP_KERNEL);
170171 if (!prev_nmi_count) {
171172 err = -ENOMEM;
172173 goto error;
arch/sparc/kernel/sys_sparc_64.c+5−3
@@ -565,7 +565,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, · 564 unmodified lines
565565 }
566566 if (!current_thread_info()->utraps) {
567567 current_thread_info()->utraps =
568− kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
568+ kcalloc(UT_TRAP_INSTRUCTION_31 + 1, sizeof(long),
569+ GFP_KERNEL);
569570 if (!current_thread_info()->utraps)
570571 return -ENOMEM;
571572 current_thread_info()->utraps[0] = 1;
@@ -575,8 +576,9 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type, · 3 unmodified lines
575576 unsigned long *p = current_thread_info()->utraps;
576577
577578 current_thread_info()->utraps =
578− kmalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long),
579− GFP_KERNEL);
579+ kmalloc_array(UT_TRAP_INSTRUCTION_31 + 1,
580+ sizeof(long),
581+ GFP_KERNEL);
580582 if (!current_thread_info()->utraps) {
581583 current_thread_info()->utraps = p;
582584 return -ENOMEM;
arch/sparc/net/bpf_jit_comp_32.c+1−1
@@ -335,7 +335,7 @@ void bpf_jit_compile(struct bpf_prog *fp) · 334 unmodified lines
335335 if (!bpf_jit_enable)
336336 return;
337337
338− addrs = kmalloc(flen * sizeof(*addrs), GFP_KERNEL);
338+ addrs = kmalloc_array(flen, sizeof(*addrs), GFP_KERNEL);
339339 if (addrs == NULL)
340340 return;
341341
arch/um/drivers/ubd_kern.c+6−6
@@ -1127,9 +1127,9 @@ static int __init ubd_init(void) · 1126 unmodified lines
11271127 return -1;
11281128 }
11291129
1130− irq_req_buffer = kmalloc(
1131− sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
1132− GFP_KERNEL
1130+ irq_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
1131+ sizeof(struct io_thread_req *),
1132+ GFP_KERNEL
11331133 );
11341134 irq_remainder = 0;
11351135
@@ -1137,9 +1137,9 @@ static int __init ubd_init(void) · 1 unmodified line
11371137 printk(KERN_ERR "Failed to initialize ubd buffering\n");
11381138 return -1;
11391139 }
1140− io_req_buffer = kmalloc(
1141− sizeof(struct io_thread_req *) * UBD_REQ_BUFFER_SIZE,
1142− GFP_KERNEL
1140+ io_req_buffer = kmalloc_array(UBD_REQ_BUFFER_SIZE,
1141+ sizeof(struct io_thread_req *),
1142+ GFP_KERNEL
11431143 );
11441144
11451145 io_remainder = 0;
arch/um/drivers/vector_kern.c+6−6
@@ -527,14 +527,14 @@ static struct vector_queue *create_queue( · 526 unmodified lines
527527 result->max_iov_frags = num_extra_frags;
528528 for (i = 0; i < max_size; i++) {
529529 if (vp->header_size > 0)
530− iov = kmalloc(
531− sizeof(struct iovec) * (3 + num_extra_frags),
532− GFP_KERNEL
530+ iov = kmalloc_array(3 + num_extra_frags,
531+ sizeof(struct iovec),
532+ GFP_KERNEL
533533 );
534534 else
535− iov = kmalloc(
536− sizeof(struct iovec) * (2 + num_extra_frags),
537− GFP_KERNEL
535+ iov = kmalloc_array(2 + num_extra_frags,
536+ sizeof(struct iovec),
537+ GFP_KERNEL
538538 );
539539 if (iov == NULL)
540540 goto out_fail;
arch/unicore32/kernel/pm.c+3−2
@@ -109,8 +109,9 @@ static int __init puv3_pm_init(void) · 108 unmodified lines
109109 return -EINVAL;
110110 }
111111
112− sleep_save = kmalloc(puv3_cpu_pm_fns->save_count
113− * sizeof(unsigned long), GFP_KERNEL);
112+ sleep_save = kmalloc_array(puv3_cpu_pm_fns->save_count,
113+ sizeof(unsigned long),
114+ GFP_KERNEL);
114115 if (!sleep_save) {
115116 printk(KERN_ERR "failed to alloc memory for pm save\n");
116117 return -ENOMEM;
arch/x86/events/amd/iommu.c+1−1
@@ -387,7 +387,7 @@ static __init int _init_events_attrs(void) · 386 unmodified lines
387387 while (amd_iommu_v2_event_descs[i].attr.attr.name)
388388 i++;
389389
390− attrs = kzalloc(sizeof(struct attribute **) * (i + 1), GFP_KERNEL);
390+ attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL);
391391 if (!attrs)
392392 return -ENOMEM;
393393
arch/x86/events/core.c+1−1
@@ -1637,7 +1637,7 @@ __init struct attribute **merge_attr(struct attribute **a, struct attribute **b) · 1636 unmodified lines
16371637 j++;
16381638 j++;
16391639
1640− new = kmalloc(sizeof(struct attribute *) * j, GFP_KERNEL);
1640+ new = kmalloc_array(j, sizeof(struct attribute *), GFP_KERNEL);
16411641 if (!new)
16421642 return NULL;
16431643
arch/x86/events/intel/uncore.c+11−10
@@ -865,12 +865,10 @@ static void uncore_types_exit(struct intel_uncore_type **types) · 864 unmodified lines
865865 static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
866866 {
867867 struct intel_uncore_pmu *pmus;
868− struct attribute_group *attr_group;
869− struct attribute **attrs;
870868 size_t size;
871869 int i, j;
872870
873− pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL);
871+ pmus = kcalloc(type->num_boxes, sizeof(*pmus), GFP_KERNEL);
874872 if (!pmus)
875873 return -ENOMEM;
876874
@@ -891,21 +889,24 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid) · 14 unmodified lines
891889 0, type->num_counters, 0, 0);
892890
893891 if (type->event_descs) {
892+ struct {
893+ struct attribute_group group;
894+ struct attribute *attrs[];
895+ } *attr_group;
894896 for (i = 0; type->event_descs[i].attr.attr.name; i++);
895897
896− attr_group = kzalloc(sizeof(struct attribute *) * (i + 1) +
897− sizeof(*attr_group), GFP_KERNEL);
898+ attr_group = kzalloc(struct_size(attr_group, attrs, i + 1),
899+ GFP_KERNEL);
898900 if (!attr_group)
899901 goto err;
900902
901− attrs = (struct attribute **)(attr_group + 1);
902− attr_group->name = "events";
903− attr_group->attrs = attrs;
903+ attr_group->group.name = "events";
904+ attr_group->group.attrs = attr_group->attrs;
904905
905906 for (j = 0; j < i; j++)
906− attrs[j] = &type->event_descs[j].attr.attr;
907+ attr_group->attrs[j] = &type->event_descs[j].attr.attr;
907908
908− type->events_group = attr_group;
909+ type->events_group = &attr_group->group;
909910 }
910911
911912 type->pmu_group = &uncore_pmu_attr_group;
arch/x86/kernel/cpu/mcheck/mce.c+1−1
@@ -1457,7 +1457,7 @@ static int __mcheck_cpu_mce_banks_init(void) · 1456 unmodified lines
14571457 int i;
14581458 u8 num_banks = mca_cfg.banks;
14591459
1460− mce_banks = kzalloc(num_banks * sizeof(struct mce_bank), GFP_KERNEL);
1460+ mce_banks = kcalloc(num_banks, sizeof(struct mce_bank), GFP_KERNEL);
14611461 if (!mce_banks)
14621462 return -ENOMEM;
14631463
arch/x86/kernel/cpu/mcheck/mce_amd.c+1−1
@@ -1384,7 +1384,7 @@ int mce_threshold_create_device(unsigned int cpu) · 1383 unmodified lines
13841384 if (bp)
13851385 return 0;
13861386
1387− bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks,
1387+ bp = kcalloc(mca_cfg.banks, sizeof(struct threshold_bank *),
13881388 GFP_KERNEL);
13891389 if (!bp)
13901390 return -ENOMEM;
arch/x86/kernel/cpu/mtrr/if.c+1−1
@@ -43,7 +43,7 @@ mtrr_file_add(unsigned long base, unsigned long size, · 42 unmodified lines
4343
4444 max = num_var_ranges;
4545 if (fcount == NULL) {
46− fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL);
46+ fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL);
4747 if (!fcount)
4848 return -ENOMEM;
4949 FILE_FCOUNT(file) = fcount;
arch/x86/kernel/hpet.c+3−3
@@ -610,7 +610,7 @@ static void hpet_msi_capability_lookup(unsigned int start_timer) · 609 unmodified lines
610610 if (!hpet_domain)
611611 return;
612612
613− hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL);
613+ hpet_devs = kcalloc(num_timers, sizeof(struct hpet_dev), GFP_KERNEL);
614614 if (!hpet_devs)
615615 return;
616616
@@ -966,8 +966,8 @@ int __init hpet_enable(void) · 349 unmodified lines
966966 #endif
967967
968968 cfg = hpet_readl(HPET_CFG);
969− hpet_boot_cfg = kmalloc((last + 2) * sizeof(*hpet_boot_cfg),
970− GFP_KERNEL);
969+ hpet_boot_cfg = kmalloc_array(last + 2, sizeof(*hpet_boot_cfg),
970+ GFP_KERNEL);
971971 if (hpet_boot_cfg)
972972 *hpet_boot_cfg = cfg;
973973 else
arch/x86/kernel/ksysfs.c+1−1
@@ -283,7 +283,7 @@ static int __init create_setup_data_nodes(struct kobject *parent) · 282 unmodified lines
283283 if (ret)
284284 goto out_setup_data_kobj;
285285
286− kobjp = kmalloc(sizeof(*kobjp) * nr, GFP_KERNEL);
286+ kobjp = kmalloc_array(nr, sizeof(*kobjp), GFP_KERNEL);
287287 if (!kobjp) {
288288 ret = -ENOMEM;
289289 goto out_setup_data_kobj;
arch/x86/kvm/cpuid.c+5−3
@@ -203,8 +203,9 @@ int kvm_vcpu_ioctl_set_cpuid(struct kvm_vcpu *vcpu, · 202 unmodified lines
203203 goto out;
204204 r = -ENOMEM;
205205 if (cpuid->nent) {
206− cpuid_entries = vmalloc(sizeof(struct kvm_cpuid_entry) *
207− cpuid->nent);
206+ cpuid_entries =
207+ vmalloc(array_size(sizeof(struct kvm_cpuid_entry),
208+ cpuid->nent));
208209 if (!cpuid_entries)
209210 goto out;
210211 r = -EFAULT;
@@ -785,7 +786,8 @@ int kvm_dev_ioctl_get_cpuid(struct kvm_cpuid2 *cpuid, · 574 unmodified lines
785786 return -EINVAL;
786787
787788 r = -ENOMEM;
788− cpuid_entries = vzalloc(sizeof(struct kvm_cpuid_entry2) * cpuid->nent);
789+ cpuid_entries = vzalloc(array_size(sizeof(struct kvm_cpuid_entry2),
790+ cpuid->nent));
789791 if (!cpuid_entries)
790792 goto out;
791793
arch/x86/kvm/page_track.c+3−2
@@ -40,8 +40,9 @@ int kvm_page_track_create_memslot(struct kvm_memory_slot *slot, · 39 unmodified lines
4040 int i;
4141
4242 for (i = 0; i < KVM_PAGE_TRACK_MAX; i++) {
43− slot->arch.gfn_track[i] = kvzalloc(npages *
44− sizeof(*slot->arch.gfn_track[i]), GFP_KERNEL);
43+ slot->arch.gfn_track[i] =
44+ kvcalloc(npages, sizeof(*slot->arch.gfn_track[i]),
45+ GFP_KERNEL);
4546 if (!slot->arch.gfn_track[i])
4647 goto track_free;
4748 }
arch/x86/kvm/svm.c+3−1
@@ -1001,7 +1001,9 @@ static int svm_cpu_init(int cpu) · 1000 unmodified lines
10011001
10021002 if (svm_sev_enabled()) {
10031003 r = -ENOMEM;
1004− sd->sev_vmcbs = kmalloc((max_sev_asid + 1) * sizeof(void *), GFP_KERNEL);
1004+ sd->sev_vmcbs = kmalloc_array(max_sev_asid + 1,
1005+ sizeof(void *),
1006+ GFP_KERNEL);
10051007 if (!sd->sev_vmcbs)
10061008 goto err_1;
10071009 }
arch/x86/kvm/x86.c+3−2
@@ -8900,13 +8900,14 @@ int kvm_arch_create_memslot(struct kvm *kvm, struct kvm_memory_slot *slot, · 8899 unmodified lines
89008900 slot->base_gfn, level) + 1;
89018901
89028902 slot->arch.rmap[i] =
8903− kvzalloc(lpages * sizeof(*slot->arch.rmap[i]), GFP_KERNEL);
8903+ kvcalloc(lpages, sizeof(*slot->arch.rmap[i]),
8904+ GFP_KERNEL);
89048905 if (!slot->arch.rmap[i])
89058906 goto out_free;
89068907 if (i == 0)
89078908 continue;
89088909
8909− linfo = kvzalloc(lpages * sizeof(*linfo), GFP_KERNEL);
8910+ linfo = kvcalloc(lpages, sizeof(*linfo), GFP_KERNEL);
89108911 if (!linfo)
89118912 goto out_free;
89128913
arch/x86/net/bpf_jit_comp.c+1−1
@@ -1107,7 +1107,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) · 1106 unmodified lines
11071107 extra_pass = true;
11081108 goto skip_init_addrs;
11091109 }
1110− addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
1110+ addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
11111111 if (!addrs) {
11121112 prog = orig_prog;
11131113 goto out_addrs;
arch/x86/net/bpf_jit_comp32.c+1−1
@@ -2345,7 +2345,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *prog) · 2344 unmodified lines
23452345 prog = tmp;
23462346 }
23472347
2348− addrs = kmalloc(prog->len * sizeof(*addrs), GFP_KERNEL);
2348+ addrs = kmalloc_array(prog->len, sizeof(*addrs), GFP_KERNEL);
23492349 if (!addrs) {
23502350 prog = orig_prog;
23512351 goto out;
arch/x86/pci/xen.c+1−1
@@ -168,7 +168,7 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type) · 167 unmodified lines
168168 if (type == PCI_CAP_ID_MSI && nvec > 1)
169169 return 1;
170170
171− v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
171+ v = kcalloc(max(1, nvec), sizeof(int), GFP_KERNEL);
172172 if (!v)
173173 return -ENOMEM;
174174
arch/x86/platform/uv/tlb_uv.c+1−1
@@ -2142,7 +2142,7 @@ static int __init init_per_cpu(int nuvhubs, int base_part_pnode) · 2141 unmodified lines
21422142 if (is_uv3_hub() || is_uv2_hub() || is_uv1_hub())
21432143 timeout_us = calculate_destination_timeout();
21442144
2145− vp = kmalloc(nuvhubs * sizeof(struct uvhub_desc), GFP_KERNEL);
2145+ vp = kmalloc_array(nuvhubs, sizeof(struct uvhub_desc), GFP_KERNEL);
21462146 uvhub_descs = (struct uvhub_desc *)vp;
21472147 memset(uvhub_descs, 0, nuvhubs * sizeof(struct uvhub_desc));
21482148 uvhub_mask = kzalloc((nuvhubs+7)/8, GFP_KERNEL);
arch/x86/platform/uv/uv_time.c+1−1
@@ -158,7 +158,7 @@ static __init int uv_rtc_allocate_timers(void) · 157 unmodified lines
158158 {
159159 int cpu;
160160
161− blade_info = kzalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
161+ blade_info = kcalloc(uv_possible_blades, sizeof(void *), GFP_KERNEL);
162162 if (!blade_info)
163163 return -ENOMEM;
164164
block/bio.c+2−1
@@ -2091,7 +2091,8 @@ static int __init init_bio(void) · 2090 unmodified lines
20912091 {
20922092 bio_slab_max = 2;
20932093 bio_slab_nr = 0;
2094− bio_slabs = kzalloc(bio_slab_max * sizeof(struct bio_slab), GFP_KERNEL);
2094+ bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
2095+ GFP_KERNEL);
20952096 if (!bio_slabs)
20962097 panic("bio: can't allocate bios\n");
20972098
block/blk-mq.c+8−8
@@ -1903,7 +1903,7 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, · 1902 unmodified lines
19031903 if (!tags)
19041904 return NULL;
19051905
1906− tags->rqs = kzalloc_node(nr_tags * sizeof(struct request *),
1906+ tags->rqs = kcalloc_node(nr_tags, sizeof(struct request *),
19071907 GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
19081908 node);
19091909 if (!tags->rqs) {
@@ -1911,9 +1911,9 @@ struct blk_mq_tags *blk_mq_alloc_rq_map(struct blk_mq_tag_set *set, · 1 unmodified line
19111911 return NULL;
19121912 }
19131913
1914− tags->static_rqs = kzalloc_node(nr_tags * sizeof(struct request *),
1915− GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
1916− node);
1914+ tags->static_rqs = kcalloc_node(nr_tags, sizeof(struct request *),
1915+ GFP_NOIO | __GFP_NOWARN | __GFP_NORETRY,
1916+ node);
19171917 if (!tags->static_rqs) {
19181918 kfree(tags->rqs);
19191919 blk_mq_free_tags(tags);
@@ -2522,7 +2522,7 @@ struct request_queue *blk_mq_init_allocated_queue(struct blk_mq_tag_set *set, · 602 unmodified lines
25222522 /* init q->mq_kobj and sw queues' kobjects */
25232523 blk_mq_sysfs_init(q);
25242524
2525− q->queue_hw_ctx = kzalloc_node(nr_cpu_ids * sizeof(*(q->queue_hw_ctx)),
2525+ q->queue_hw_ctx = kcalloc_node(nr_cpu_ids, sizeof(*(q->queue_hw_ctx)),
25262526 GFP_KERNEL, set->numa_node);
25272527 if (!q->queue_hw_ctx)
25282528 goto err_percpu;
@@ -2741,14 +2741,14 @@ int blk_mq_alloc_tag_set(struct blk_mq_tag_set *set) · 212 unmodified lines
27412741 if (set->nr_hw_queues > nr_cpu_ids)
27422742 set->nr_hw_queues = nr_cpu_ids;
27432743
2744− set->tags = kzalloc_node(nr_cpu_ids * sizeof(struct blk_mq_tags *),
2744+ set->tags = kcalloc_node(nr_cpu_ids, sizeof(struct blk_mq_tags *),
27452745 GFP_KERNEL, set->numa_node);
27462746 if (!set->tags)
27472747 return -ENOMEM;
27482748
27492749 ret = -ENOMEM;
2750− set->mq_map = kzalloc_node(sizeof(*set->mq_map) * nr_cpu_ids,
2751− GFP_KERNEL, set->numa_node);
2750+ set->mq_map = kcalloc_node(nr_cpu_ids, sizeof(*set->mq_map),
2751+ GFP_KERNEL, set->numa_node);
27522752 if (!set->mq_map)
27532753 goto out_free_tags;
27542754
block/blk-tag.c+2−2
@@ -99,12 +99,12 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth) · 98 unmodified lines
9999 __func__, depth);
100100 }
101101
102− tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC);
102+ tag_index = kcalloc(depth, sizeof(struct request *), GFP_ATOMIC);
103103 if (!tag_index)
104104 goto fail;
105105
106106 nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
107− tag_map = kzalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
107+ tag_map = kcalloc(nr_ulongs, sizeof(unsigned long), GFP_ATOMIC);
108108 if (!tag_map)
109109 goto fail;
110110
block/blk-zoned.c+2−2
@@ -331,8 +331,8 @@ int blkdev_report_zones_ioctl(struct block_device *bdev, fmode_t mode, · 330 unmodified lines
331331 if (rep.nr_zones > INT_MAX / sizeof(struct blk_zone))
332332 return -ERANGE;
333333
334− zones = kvmalloc(rep.nr_zones * sizeof(struct blk_zone),
335− GFP_KERNEL | __GFP_ZERO);
334+ zones = kvmalloc_array(rep.nr_zones, sizeof(struct blk_zone),
335+ GFP_KERNEL | __GFP_ZERO);
336336 if (!zones)
337337 return -ENOMEM;
338338
block/partitions/check.c+1−1
@@ -122,7 +122,7 @@ static struct parsed_partitions *allocate_partitions(struct gendisk *hd) · 121 unmodified lines
122122 return NULL;
123123
124124 nr = disk_max_parts(hd);
125− state->parts = vzalloc(nr * sizeof(state->parts[0]));
125+ state->parts = vzalloc(array_size(nr, sizeof(state->parts[0])));
126126 if (!state->parts) {
127127 kfree(state);
128128 return NULL;
block/partitions/ldm.c+1−1
@@ -378,7 +378,7 @@ static bool ldm_validate_tocblocks(struct parsed_partitions *state, · 377 unmodified lines
378378 BUG_ON(!state || !ldb);
379379 ph = &ldb->ph;
380380 tb[0] = &ldb->toc;
381− tb[1] = kmalloc(sizeof(*tb[1]) * 3, GFP_KERNEL);
381+ tb[1] = kmalloc_array(3, sizeof(*tb[1]), GFP_KERNEL);
382382 if (!tb[1]) {
383383 ldm_crit("Out of memory.");
384384 goto err;
crypto/algif_aead.c+2−2
@@ -255,8 +255,8 @@ static int _aead_recvmsg(struct socket *sock, struct msghdr *msg, · 254 unmodified lines
255255 processed - as);
256256 if (!areq->tsgl_entries)
257257 areq->tsgl_entries = 1;
258− areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) *
259− areq->tsgl_entries,
258+ areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
259+ areq->tsgl_entries),
260260 GFP_KERNEL);
261261 if (!areq->tsgl) {
262262 err = -ENOMEM;
crypto/algif_skcipher.c+2−1
@@ -100,7 +100,8 @@ static int _skcipher_recvmsg(struct socket *sock, struct msghdr *msg, · 99 unmodified lines
100100 areq->tsgl_entries = af_alg_count_tsgl(sk, len, 0);
101101 if (!areq->tsgl_entries)
102102 areq->tsgl_entries = 1;
103− areq->tsgl = sock_kmalloc(sk, sizeof(*areq->tsgl) * areq->tsgl_entries,
103+ areq->tsgl = sock_kmalloc(sk, array_size(sizeof(*areq->tsgl),
104+ areq->tsgl_entries),
104105 GFP_KERNEL);
105106 if (!areq->tsgl) {
106107 err = -ENOMEM;
crypto/testmgr.c+2−1
@@ -603,7 +603,8 @@ static int __test_aead(struct crypto_aead *tfm, int enc, · 602 unmodified lines
603603 goto out_nooutbuf;
604604
605605 /* avoid "the frame size is larger than 1024 bytes" compiler warning */
606− sg = kmalloc(sizeof(*sg) * 8 * (diff_dst ? 4 : 2), GFP_KERNEL);
606+ sg = kmalloc(array3_size(sizeof(*sg), 8, (diff_dst ? 4 : 2)),
607+ GFP_KERNEL);
607608 if (!sg)
608609 goto out_nosg;
609610 sgout = &sg[16];
drivers/acpi/acpi_platform.c+1−1
@@ -82,7 +82,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev, · 81 unmodified lines
8282 if (count < 0) {
8383 return NULL;
8484 } else if (count > 0) {
85− resources = kzalloc(count * sizeof(struct resource),
85+ resources = kcalloc(count, sizeof(struct resource),
8686 GFP_KERNEL);
8787 if (!resources) {
8888 dev_err(&adev->dev, "No memory for resources\n");
drivers/acpi/acpi_video.c+3−2
@@ -832,8 +832,9 @@ int acpi_video_get_levels(struct acpi_device *device, · 831 unmodified lines
832832 * in order to account for buggy BIOS which don't export the first two
833833 * special levels (see below)
834834 */
835− br->levels = kmalloc((obj->package.count + ACPI_VIDEO_FIRST_LEVEL) *
836− sizeof(*br->levels), GFP_KERNEL);
835+ br->levels = kmalloc_array(obj->package.count + ACPI_VIDEO_FIRST_LEVEL,
836+ sizeof(*br->levels),
837+ GFP_KERNEL);
837838 if (!br->levels) {
838839 result = -ENOMEM;
839840 goto out_free;
drivers/acpi/apei/erst.c+2−1
@@ -524,7 +524,8 @@ retry: · 523 unmodified lines
524524 pr_warn(FW_WARN "too many record IDs!\n");
525525 return 0;
526526 }
527− new_entries = kvmalloc(new_size * sizeof(entries[0]), GFP_KERNEL);
527+ new_entries = kvmalloc_array(new_size, sizeof(entries[0]),
528+ GFP_KERNEL);
528529 if (!new_entries)
529530 return -ENOMEM;
530531 memcpy(new_entries, entries,
drivers/acpi/apei/hest.c+2−1
@@ -195,7 +195,8 @@ static int __init hest_ghes_dev_register(unsigned int ghes_count) · 194 unmodified lines
195195 struct ghes_arr ghes_arr;
196196
197197 ghes_arr.count = 0;
198− ghes_arr.ghes_devs = kmalloc(sizeof(void *) * ghes_count, GFP_KERNEL);
198+ ghes_arr.ghes_devs = kmalloc_array(ghes_count, sizeof(void *),
199+ GFP_KERNEL);
199200 if (!ghes_arr.ghes_devs)
200201 return -ENOMEM;
201202
drivers/acpi/fan.c+2−2
@@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device) · 297 unmodified lines
298298 }
299299
300300 fan->fps_count = obj->package.count - 1; /* minus revision field */
301− fan->fps = devm_kzalloc(&device->dev,
302− fan->fps_count * sizeof(struct acpi_fan_fps),
301+ fan->fps = devm_kcalloc(&device->dev,
302+ fan->fps_count, sizeof(struct acpi_fan_fps),
303303 GFP_KERNEL);
304304 if (!fan->fps) {
305305 dev_err(&device->dev, "Not enough memory\n");
drivers/acpi/nfit/core.c+4−3
@@ -1082,9 +1082,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc, · 1081 unmodified lines
10821082 continue;
10831083 nfit_mem->nfit_flush = nfit_flush;
10841084 flush = nfit_flush->flush;
1085− nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev,
1086− flush->hint_count
1087− * sizeof(struct resource), GFP_KERNEL);
1085+ nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev,
1086+ flush->hint_count,
1087+ sizeof(struct resource),
1088+ GFP_KERNEL);
10881089 if (!nfit_mem->flush_wpq)
10891090 return -ENOMEM;
10901091 for (i = 0; i < flush->hint_count; i++) {
drivers/acpi/processor_perflib.c+3−2
@@ -343,8 +343,9 @@ static int acpi_processor_get_performance_states(struct acpi_processor *pr) · 342 unmodified lines
343343
344344 pr->performance->state_count = pss->package.count;
345345 pr->performance->states =
346− kmalloc(sizeof(struct acpi_processor_px) * pss->package.count,
347− GFP_KERNEL);
346+ kmalloc_array(pss->package.count,
347+ sizeof(struct acpi_processor_px),
348+ GFP_KERNEL);
348349 if (!pr->performance->states) {
349350 result = -ENOMEM;
350351 goto end;
drivers/acpi/processor_throttling.c+3−2
@@ -534,8 +534,9 @@ static int acpi_processor_get_throttling_states(struct acpi_processor *pr) · 533 unmodified lines
534534
535535 pr->throttling.state_count = tss->package.count;
536536 pr->throttling.states_tss =
537− kmalloc(sizeof(struct acpi_processor_tx_tss) * tss->package.count,
538− GFP_KERNEL);
537+ kmalloc_array(tss->package.count,
538+ sizeof(struct acpi_processor_tx_tss),
539+ GFP_KERNEL);
539540 if (!pr->throttling.states_tss) {
540541 result = -ENOMEM;
541542 goto end;
drivers/acpi/sysfs.c+3−3
@@ -857,12 +857,12 @@ void acpi_irq_stats_init(void) · 856 unmodified lines
857857 num_gpes = acpi_current_gpe_count;
858858 num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
859859
860− all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
860+ all_attrs = kcalloc(num_counters + 1, sizeof(struct attribute *),
861861 GFP_KERNEL);
862862 if (all_attrs == NULL)
863863 return;
864864
865− all_counters = kzalloc(sizeof(struct event_counter) * (num_counters),
865+ all_counters = kcalloc(num_counters, sizeof(struct event_counter),
866866 GFP_KERNEL);
867867 if (all_counters == NULL)
868868 goto fail;
@@ -871,7 +871,7 @@ void acpi_irq_stats_init(void) · 2 unmodified lines
871871 if (ACPI_FAILURE(status))
872872 goto fail;
873873
874− counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
874+ counter_attrs = kcalloc(num_counters, sizeof(struct kobj_attribute),
875875 GFP_KERNEL);
876876 if (counter_attrs == NULL)
877877 goto fail;
drivers/android/binder_alloc.c+2−2
@@ -692,8 +692,8 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc, · 691 unmodified lines
692692 }
693693 }
694694 #endif
695− alloc->pages = kzalloc(sizeof(alloc->pages[0]) *
696− ((vma->vm_end - vma->vm_start) / PAGE_SIZE),
695+ alloc->pages = kcalloc((vma->vm_end - vma->vm_start) / PAGE_SIZE,
696+ sizeof(alloc->pages[0]),
697697 GFP_KERNEL);
698698 if (alloc->pages == NULL) {
699699 ret = -ENOMEM;
drivers/ata/libata-core.c+1−1
@@ -6987,7 +6987,7 @@ static void __init ata_parse_force_param(void) · 6986 unmodified lines
69876987 if (*p == ',')
69886988 size++;
69896989
6990− ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL);
6990+ ata_force_tbl = kcalloc(size, sizeof(ata_force_tbl[0]), GFP_KERNEL);
69916991 if (!ata_force_tbl) {
69926992 printk(KERN_WARNING "ata: failed to extend force table, "
69936993 "libata.force ignored\n");
drivers/ata/libata-pmp.c+1−1
@@ -340,7 +340,7 @@ static int sata_pmp_init_links (struct ata_port *ap, int nr_ports) · 339 unmodified lines
340340 int i, err;
341341
342342 if (!pmp_link) {
343− pmp_link = kzalloc(sizeof(pmp_link[0]) * SATA_PMP_MAX_PORTS,
343+ pmp_link = kcalloc(SATA_PMP_MAX_PORTS, sizeof(pmp_link[0]),
344344 GFP_NOIO);
345345 if (!pmp_link)
346346 return -ENOMEM;
drivers/ata/sata_mv.c+4−4
@@ -4114,13 +4114,13 @@ static int mv_platform_probe(struct platform_device *pdev) · 4113 unmodified lines
41144114
41154115 if (!host || !hpriv)
41164116 return -ENOMEM;
4117− hpriv->port_clks = devm_kzalloc(&pdev->dev,
4118− sizeof(struct clk *) * n_ports,
4117+ hpriv->port_clks = devm_kcalloc(&pdev->dev,
4118+ n_ports, sizeof(struct clk *),
41194119 GFP_KERNEL);
41204120 if (!hpriv->port_clks)
41214121 return -ENOMEM;
4122− hpriv->port_phys = devm_kzalloc(&pdev->dev,
4123− sizeof(struct phy *) * n_ports,
4122+ hpriv->port_phys = devm_kcalloc(&pdev->dev,
4123+ n_ports, sizeof(struct phy *),
41244124 GFP_KERNEL);
41254125 if (!hpriv->port_phys)
41264126 return -ENOMEM;
drivers/atm/fore200e.c+2−1
@@ -2094,7 +2094,8 @@ static int fore200e_alloc_rx_buf(struct fore200e *fore200e) · 2093 unmodified lines
20942094 DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn);
20952095
20962096 /* allocate the array of receive buffers */
2097− buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL);
2097+ buffer = bsq->buffer = kcalloc(nbr, sizeof(struct buffer),
2098+ GFP_KERNEL);
20982099
20992100 if (buffer == NULL)
21002101 return -ENOMEM;
drivers/atm/iphase.c+1−1
@@ -1618,7 +1618,7 @@ static int rx_init(struct atm_dev *dev) · 1617 unmodified lines
16181618 skb_queue_head_init(&iadev->rx_dma_q);
16191619 iadev->rx_free_desc_qhead = NULL;
16201620
1621− iadev->rx_open = kzalloc(4 * iadev->num_vc, GFP_KERNEL);
1621+ iadev->rx_open = kcalloc(4, iadev->num_vc, GFP_KERNEL);
16221622 if (!iadev->rx_open) {
16231623 printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
16241624 dev->number);
drivers/atm/solos-pci.c+2−1
@@ -1291,7 +1291,8 @@ static int fpga_probe(struct pci_dev *dev, const struct pci_device_id *id) · 1290 unmodified lines
12911291 card->using_dma = 1;
12921292 if (1) { /* All known FPGA versions so far */
12931293 card->dma_alignment = 3;
1294− card->dma_bounce = kmalloc(card->nr_ports * BUF_SIZE, GFP_KERNEL);
1294+ card->dma_bounce = kmalloc_array(card->nr_ports,
1295+ BUF_SIZE, GFP_KERNEL);
12951296 if (!card->dma_bounce) {
12961297 dev_warn(&card->dev->dev, "Failed to allocate DMA bounce buffers\n");
12971298 err = -ENOMEM;
drivers/auxdisplay/cfag12864b.c+2−2
@@ -333,8 +333,8 @@ static int __init cfag12864b_init(void) · 332 unmodified lines
333333 goto none;
334334 }
335335
336− cfag12864b_cache = kmalloc(sizeof(unsigned char) *
337− CFAG12864B_SIZE, GFP_KERNEL);
336+ cfag12864b_cache = kmalloc(CFAG12864B_SIZE,
337+ GFP_KERNEL);
338338 if (cfag12864b_cache == NULL) {
339339 printk(KERN_ERR CFAG12864B_NAME ": ERROR: "
340340 "can't alloc cache buffer (%i bytes)\n",
drivers/base/firmware_loader/fallback.c+1−1
@@ -403,7 +403,7 @@ static int fw_realloc_pages(struct fw_sysfs *fw_sysfs, int min_size) · 402 unmodified lines
403403 fw_priv->page_array_size * 2);
404404 struct page **new_pages;
405405
406− new_pages = vmalloc(new_array_size * sizeof(void *));
406+ new_pages = vmalloc(array_size(new_array_size, sizeof(void *)));
407407 if (!new_pages) {
408408 fw_load_abort(fw_sysfs);
409409 return -ENOMEM;
drivers/block/DAC960.c+2−2
@@ -5719,8 +5719,8 @@ static bool DAC960_CheckStatusBuffer(DAC960_Controller_T *Controller, · 5718 unmodified lines
57195719 Controller->CombinedStatusBufferLength = NewStatusBufferLength;
57205720 return true;
57215721 }
5722− NewStatusBuffer = kmalloc(2 * Controller->CombinedStatusBufferLength,
5723− GFP_ATOMIC);
5722+ NewStatusBuffer = kmalloc_array(2, Controller->CombinedStatusBufferLength,
5723+ GFP_ATOMIC);
57245724 if (NewStatusBuffer == NULL)
57255725 {
57265726 DAC960_Warning("Unable to expand Combined Status Buffer - Truncating\n",
drivers/block/drbd/drbd_main.c+2−1
@@ -511,7 +511,8 @@ static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask) · 510 unmodified lines
511511 {
512512 unsigned int *resources_per_cpu, min_index = ~0;
513513
514− resources_per_cpu = kzalloc(nr_cpu_ids * sizeof(*resources_per_cpu), GFP_KERNEL);
514+ resources_per_cpu = kcalloc(nr_cpu_ids, sizeof(*resources_per_cpu),
515+ GFP_KERNEL);
515516 if (resources_per_cpu) {
516517 struct drbd_resource *resource;
517518 unsigned int cpu, min = ~0;
drivers/block/loop.c+2−1
@@ -524,7 +524,8 @@ static int lo_rw_aio(struct loop_device *lo, struct loop_cmd *cmd, · 523 unmodified lines
524524
525525 __rq_for_each_bio(bio, rq)
526526 segments += bio_segments(bio);
527− bvec = kmalloc(sizeof(struct bio_vec) * segments, GFP_NOIO);
527+ bvec = kmalloc_array(segments, sizeof(struct bio_vec),
528+ GFP_NOIO);
528529 if (!bvec)
529530 return -EIO;
530531 cmd->bvec = bvec;
drivers/block/null_blk.c+5−4
@@ -1575,12 +1575,12 @@ static int setup_commands(struct nullb_queue *nq) · 1574 unmodified lines
15751575 struct nullb_cmd *cmd;
15761576 int i, tag_size;
15771577
1578− nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL);
1578+ nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL);
15791579 if (!nq->cmds)
15801580 return -ENOMEM;
15811581
15821582 tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG;
1583− nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL);
1583+ nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL);
15841584 if (!nq->tag_map) {
15851585 kfree(nq->cmds);
15861586 return -ENOMEM;
@@ -1598,8 +1598,9 @@ static int setup_commands(struct nullb_queue *nq) · 11 unmodified lines
15981598
15991599 static int setup_queues(struct nullb *nullb)
16001600 {
1601− nullb->queues = kzalloc(nullb->dev->submit_queues *
1602− sizeof(struct nullb_queue), GFP_KERNEL);
1601+ nullb->queues = kcalloc(nullb->dev->submit_queues,
1602+ sizeof(struct nullb_queue),
1603+ GFP_KERNEL);
16031604 if (!nullb->queues)
16041605 return -ENOMEM;
16051606
drivers/block/ps3vram.c+3−2
@@ -407,8 +407,9 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev) · 406 unmodified lines
407407
408408 priv->cache.page_count = CACHE_PAGE_COUNT;
409409 priv->cache.page_size = CACHE_PAGE_SIZE;
410− priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
411− CACHE_PAGE_COUNT, GFP_KERNEL);
410+ priv->cache.tags = kcalloc(CACHE_PAGE_COUNT,
411+ sizeof(struct ps3vram_tag),
412+ GFP_KERNEL);
412413 if (!priv->cache.tags)
413414 return -ENOMEM;
414415
drivers/block/rsxx/core.c+2−1
@@ -873,7 +873,8 @@ static int rsxx_pci_probe(struct pci_dev *dev, · 872 unmodified lines
873873 dev_info(CARD_TO_DEV(card),
874874 "Failed reading the number of DMA targets\n");
875875
876− card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL);
876+ card->ctrl = kcalloc(card->n_targets, sizeof(*card->ctrl),
877+ GFP_KERNEL);
877878 if (!card->ctrl) {
878879 st = -ENOMEM;
879880 goto failed_dma_setup;
drivers/block/rsxx/dma.c+1−1
@@ -1038,7 +1038,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card) · 1037 unmodified lines
10381038 struct rsxx_dma *dma;
10391039 struct list_head *issued_dmas;
10401040
1041− issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets,
1041+ issued_dmas = kcalloc(card->n_targets, sizeof(*issued_dmas),
10421042 GFP_KERNEL);
10431043 if (!issued_dmas)
10441044 return -ENOMEM;
drivers/block/xen-blkback/xenbus.c+2−1
@@ -139,7 +139,8 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif) · 138 unmodified lines
139139 {
140140 unsigned int r;
141141
142− blkif->rings = kzalloc(blkif->nr_rings * sizeof(struct xen_blkif_ring), GFP_KERNEL);
142+ blkif->rings = kcalloc(blkif->nr_rings, sizeof(struct xen_blkif_ring),
143+ GFP_KERNEL);
143144 if (!blkif->rings)
144145 return -ENOMEM;
145146
drivers/block/xen-blkfront.c+14−9
@@ -1906,7 +1906,9 @@ static int negotiate_mq(struct blkfront_info *info) · 1905 unmodified lines
19061906 if (!info->nr_rings)
19071907 info->nr_rings = 1;
19081908
1909− info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL);
1909+ info->rinfo = kcalloc(info->nr_rings,
1910+ sizeof(struct blkfront_ring_info),
1911+ GFP_KERNEL);
19101912 if (!info->rinfo) {
19111913 xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
19121914 return -ENOMEM;
@@ -2216,15 +2218,18 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo) · 303 unmodified lines
22162218 }
22172219
22182220 for (i = 0; i < BLK_RING_SIZE(info); i++) {
2219− rinfo->shadow[i].grants_used = kzalloc(
2220− sizeof(rinfo->shadow[i].grants_used[0]) * grants,
2221− GFP_NOIO);
2222− rinfo->shadow[i].sg = kzalloc(sizeof(rinfo->shadow[i].sg[0]) * psegs, GFP_NOIO);
2223− if (info->max_indirect_segments)
2224− rinfo->shadow[i].indirect_grants = kzalloc(
2225− sizeof(rinfo->shadow[i].indirect_grants[0]) *
2226− INDIRECT_GREFS(grants),
2221+ rinfo->shadow[i].grants_used =
2222+ kcalloc(grants,
2223+ sizeof(rinfo->shadow[i].grants_used[0]),
22272224 GFP_NOIO);
2225+ rinfo->shadow[i].sg = kcalloc(psegs,
2226+ sizeof(rinfo->shadow[i].sg[0]),
2227+ GFP_NOIO);
2228+ if (info->max_indirect_segments)
2229+ rinfo->shadow[i].indirect_grants =
2230+ kcalloc(INDIRECT_GREFS(grants),
2231+ sizeof(rinfo->shadow[i].indirect_grants[0]),
2232+ GFP_NOIO);
22282233 if ((rinfo->shadow[i].grants_used == NULL) ||
22292234 (rinfo->shadow[i].sg == NULL) ||
22302235 (info->max_indirect_segments &&
drivers/block/z2ram.c+3−2
@@ -197,8 +197,9 @@ static int z2_open(struct block_device *bdev, fmode_t mode) · 196 unmodified lines
197197 vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
198198 #endif
199199 z2ram_map =
200− kmalloc((size/Z2RAM_CHUNKSIZE)*sizeof(z2ram_map[0]),
201− GFP_KERNEL);
200+ kmalloc_array(size / Z2RAM_CHUNKSIZE,
201+ sizeof(z2ram_map[0]),
202+ GFP_KERNEL);
202203 if ( z2ram_map == NULL )
203204 {
204205 printk( KERN_ERR DEVICE_NAME
drivers/block/zram/zram_drv.c+1−1
@@ -898,7 +898,7 @@ static bool zram_meta_alloc(struct zram *zram, u64 disksize) · 897 unmodified lines
898898 size_t num_pages;
899899
900900 num_pages = disksize >> PAGE_SHIFT;
901− zram->table = vzalloc(num_pages * sizeof(*zram->table));
901+ zram->table = vzalloc(array_size(num_pages, sizeof(*zram->table)));
902902 if (!zram->table)
903903 return false;
904904
drivers/bus/fsl-mc/fsl-mc-allocator.c+3−3
@@ -354,8 +354,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, · 353 unmodified lines
354354 if (error < 0)
355355 return error;
356356
357− irq_resources = devm_kzalloc(&mc_bus_dev->dev,
358− sizeof(*irq_resources) * irq_count,
357+ irq_resources = devm_kcalloc(&mc_bus_dev->dev,
358+ irq_count, sizeof(*irq_resources),
359359 GFP_KERNEL);
360360 if (!irq_resources) {
361361 error = -ENOMEM;
@@ -455,7 +455,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev) · 93 unmodified lines
455455 return -ENOSPC;
456456 }
457457
458− irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]),
458+ irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]),
459459 GFP_KERNEL);
460460 if (!irqs)
461461 return -ENOMEM;
drivers/cdrom/cdrom.c+1−1
@@ -2132,7 +2132,7 @@ static int cdrom_read_cdda_old(struct cdrom_device_info *cdi, __u8 __user *ubuf, · 2131 unmodified lines
21322132 */
21332133 nr = nframes;
21342134 do {
2135− cgc.buffer = kmalloc(CD_FRAMESIZE_RAW * nr, GFP_KERNEL);
2135+ cgc.buffer = kmalloc_array(nr, CD_FRAMESIZE_RAW, GFP_KERNEL);
21362136 if (cgc.buffer)
21372137 break;
21382138
drivers/char/agp/amd-k7-agp.c+2−1
@@ -85,7 +85,8 @@ static int amd_create_gatt_pages(int nr_tables) · 84 unmodified lines
8585 int retval = 0;
8686 int i;
8787
88− tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
88+ tables = kcalloc(nr_tables + 1, sizeof(struct amd_page_map *),
89+ GFP_KERNEL);
8990 if (tables == NULL)
9091 return -ENOMEM;
9192
drivers/char/agp/ati-agp.c+2−1
@@ -108,7 +108,8 @@ static int ati_create_gatt_pages(int nr_tables) · 107 unmodified lines
108108 int retval = 0;
109109 int i;
110110
111− tables = kzalloc((nr_tables + 1) * sizeof(struct ati_page_map *),GFP_KERNEL);
111+ tables = kcalloc(nr_tables + 1, sizeof(struct ati_page_map *),
112+ GFP_KERNEL);
112113 if (tables == NULL)
113114 return -ENOMEM;
114115
drivers/char/agp/compat_ioctl.c+6−2
@@ -98,11 +98,15 @@ static int compat_agpioc_reserve_wrap(struct agp_file_private *priv, void __user · 97 unmodified lines
9898 if (ureserve.seg_count >= 16384)
9999 return -EINVAL;
100100
101− usegment = kmalloc(sizeof(*usegment) * ureserve.seg_count, GFP_KERNEL);
101+ usegment = kmalloc_array(ureserve.seg_count,
102+ sizeof(*usegment),
103+ GFP_KERNEL);
102104 if (!usegment)
103105 return -ENOMEM;
104106
105− ksegment = kmalloc(sizeof(*ksegment) * kreserve.seg_count, GFP_KERNEL);
107+ ksegment = kmalloc_array(kreserve.seg_count,
108+ sizeof(*ksegment),
109+ GFP_KERNEL);
106110 if (!ksegment) {
107111 kfree(usegment);
108112 return -ENOMEM;
drivers/char/agp/isoch.c+2−1
@@ -93,7 +93,8 @@ static int agp_3_5_isochronous_node_enable(struct agp_bridge_data *bridge, · 92 unmodified lines
9393 * We'll work with an array of isoch_data's (one for each
9494 * device in dev_list) throughout this function.
9595 */
96− if ((master = kmalloc(ndevs * sizeof(*master), GFP_KERNEL)) == NULL) {
96+ master = kmalloc_array(ndevs, sizeof(*master), GFP_KERNEL);
97+ if (master == NULL) {
9798 ret = -ENOMEM;
9899 goto get_out;
99100 }
drivers/char/agp/sgi-agp.c+3−3
@@ -280,9 +280,9 @@ static int agp_sgi_init(void) · 279 unmodified lines
280280 else
281281 return 0;
282282
283− sgi_tioca_agp_bridges = kmalloc(tioca_gart_found *
284− sizeof(struct agp_bridge_data *),
285− GFP_KERNEL);
283+ sgi_tioca_agp_bridges = kmalloc_array(tioca_gart_found,
284+ sizeof(struct agp_bridge_data *),
285+ GFP_KERNEL);
286286 if (!sgi_tioca_agp_bridges)
287287 return -ENOMEM;
288288
drivers/char/agp/sworks-agp.c+1−1
@@ -96,7 +96,7 @@ static int serverworks_create_gatt_pages(int nr_tables) · 95 unmodified lines
9696 int retval = 0;
9797 int i;
9898
99− tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
99+ tables = kcalloc(nr_tables + 1, sizeof(struct serverworks_page_map *),
100100 GFP_KERNEL);
101101 if (tables == NULL)
102102 return -ENOMEM;
drivers/char/agp/uninorth-agp.c+3−1
@@ -402,7 +402,9 @@ static int uninorth_create_gatt_table(struct agp_bridge_data *bridge) · 401 unmodified lines
402402 if (table == NULL)
403403 return -ENOMEM;
404404
405− uninorth_priv.pages_arr = kmalloc((1 << page_order) * sizeof(struct page*), GFP_KERNEL);
405+ uninorth_priv.pages_arr = kmalloc_array(1 << page_order,
406+ sizeof(struct page *),
407+ GFP_KERNEL);
406408 if (uninorth_priv.pages_arr == NULL)
407409 goto enomem;
408410
drivers/char/ipmi/ipmi_ssif.c+2−1
@@ -1757,7 +1757,8 @@ static unsigned short *ssif_address_list(void) · 1756 unmodified lines
17571757 list_for_each_entry(info, &ssif_infos, link)
17581758 count++;
17591759
1760− address_list = kzalloc(sizeof(*address_list) * (count + 1), GFP_KERNEL);
1760+ address_list = kcalloc(count + 1, sizeof(*address_list),
1761+ GFP_KERNEL);
17611762 if (!address_list)
17621763 return NULL;
17631764
drivers/char/raw.c+2−1
@@ -321,7 +321,8 @@ static int __init raw_init(void) · 320 unmodified lines
321321 max_raw_minors = MAX_RAW_MINORS;
322322 }
323323
324− raw_devices = vzalloc(sizeof(struct raw_device_data) * max_raw_minors);
324+ raw_devices = vzalloc(array_size(max_raw_minors,
325+ sizeof(struct raw_device_data)));
325326 if (!raw_devices) {
326327 printk(KERN_ERR "Not enough memory for raw device structures\n");
327328 ret = -ENOMEM;
drivers/char/tpm/tpm2-cmd.c+1−1
@@ -980,7 +980,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip) · 979 unmodified lines
980980 goto out;
981981 }
982982
983− chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands,
983+ chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands,
984984 GFP_KERNEL);
985985
986986 rc = tpm_buf_init(&buf, TPM2_ST_NO_SESSIONS, TPM2_CC_GET_CAPABILITY);
drivers/char/virtio_console.c+9−9
@@ -433,8 +433,7 @@ static struct port_buffer *alloc_buf(struct virtio_device *vdev, size_t buf_size · 432 unmodified lines
433433 * Allocate buffer and the sg list. The sg list array is allocated
434434 * directly after the port_buffer struct.
435435 */
436− buf = kmalloc(sizeof(*buf) + sizeof(struct scatterlist) * pages,
437− GFP_KERNEL);
436+ buf = kmalloc(struct_size(buf, sg, pages), GFP_KERNEL);
438437 if (!buf)
439438 goto fail;
440439
@@ -1892,13 +1891,14 @@ static int init_vqs(struct ports_device *portdev) · 1451 unmodified lines
18921891 nr_ports = portdev->max_nr_ports;
18931892 nr_queues = use_multiport(portdev) ? (nr_ports + 1) * 2 : 2;
18941893
1895− vqs = kmalloc(nr_queues * sizeof(struct virtqueue *), GFP_KERNEL);
1896− io_callbacks = kmalloc(nr_queues * sizeof(vq_callback_t *), GFP_KERNEL);
1897− io_names = kmalloc(nr_queues * sizeof(char *), GFP_KERNEL);
1898− portdev->in_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
1899− GFP_KERNEL);
1900− portdev->out_vqs = kmalloc(nr_ports * sizeof(struct virtqueue *),
1901− GFP_KERNEL);
1894+ vqs = kmalloc_array(nr_queues, sizeof(struct virtqueue *), GFP_KERNEL);
1895+ io_callbacks = kmalloc_array(nr_queues, sizeof(vq_callback_t *),
1896+ GFP_KERNEL);
1897+ io_names = kmalloc_array(nr_queues, sizeof(char *), GFP_KERNEL);
1898+ portdev->in_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
1899+ GFP_KERNEL);
1900+ portdev->out_vqs = kmalloc_array(nr_ports, sizeof(struct virtqueue *),
1901+ GFP_KERNEL);
19021902 if (!vqs || !io_callbacks || !io_names || !portdev->in_vqs ||
19031903 !portdev->out_vqs) {
19041904 err = -ENOMEM;
drivers/clk/bcm/clk-bcm2835.c+2−2
@@ -734,7 +734,7 @@ static void bcm2835_pll_debug_init(struct clk_hw *hw, · 733 unmodified lines
734734 const struct bcm2835_pll_data *data = pll->data;
735735 struct debugfs_reg32 *regs;
736736
737− regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
737+ regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
738738 if (!regs)
739739 return;
740740
@@ -865,7 +865,7 @@ static void bcm2835_pll_divider_debug_init(struct clk_hw *hw, · 124 unmodified lines
865865 const struct bcm2835_pll_divider_data *data = divider->data;
866866 struct debugfs_reg32 *regs;
867867
868− regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL);
868+ regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL);
869869 if (!regs)
870870 return;
871871
drivers/clk/renesas/clk-r8a7740.c+1−1
@@ -161,7 +161,7 @@ static void __init r8a7740_cpg_clocks_init(struct device_node *np) · 160 unmodified lines
161161 }
162162
163163 cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
164− clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
164+ clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
165165 if (cpg == NULL || clks == NULL) {
166166 /* We're leaking memory on purpose, there's no point in cleaning
167167 * up as the system won't boot anyway.
drivers/clk/renesas/clk-r8a7779.c+1−1
@@ -138,7 +138,7 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np) · 137 unmodified lines
138138 }
139139
140140 cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
141− clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL);
141+ clks = kcalloc(CPG_NUM_CLOCKS, sizeof(*clks), GFP_KERNEL);
142142 if (cpg == NULL || clks == NULL) {
143143 /* We're leaking memory on purpose, there's no point in cleaning
144144 * up as the system won't boot anyway.
drivers/clk/renesas/clk-rcar-gen2.c+1−1
@@ -417,7 +417,7 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np) · 416 unmodified lines
417417 }
418418
419419 cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
420− clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
420+ clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
421421 if (cpg == NULL || clks == NULL) {
422422 /* We're leaking memory on purpose, there's no point in cleaning
423423 * up as the system won't boot anyway.
drivers/clk/renesas/clk-rz.c+1−1
@@ -97,7 +97,7 @@ static void __init rz_cpg_clocks_init(struct device_node *np) · 96 unmodified lines
9797 return;
9898
9999 cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
100− clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
100+ clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
101101 BUG_ON(!cpg || !clks);
102102
103103 cpg->data.clks = clks;
drivers/clk/st/clkgen-fsyn.c+1−1
@@ -874,7 +874,7 @@ static void __init st_of_create_quadfs_fsynths( · 873 unmodified lines
874874 return;
875875
876876 clk_data->clk_num = QUADFS_MAX_CHAN;
877− clk_data->clks = kzalloc(QUADFS_MAX_CHAN * sizeof(struct clk *),
877+ clk_data->clks = kcalloc(QUADFS_MAX_CHAN, sizeof(struct clk *),
878878 GFP_KERNEL);
879879
880880 if (!clk_data->clks) {
drivers/clk/st/clkgen-pll.c+1−1
@@ -738,7 +738,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np, · 737 unmodified lines
738738 return;
739739
740740 clk_data->clk_num = num_odfs;
741− clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *),
741+ clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
742742 GFP_KERNEL);
743743
744744 if (!clk_data->clks)
drivers/clk/sunxi/clk-usb.c+1−1
@@ -122,7 +122,7 @@ static void __init sunxi_usb_clk_setup(struct device_node *node, · 121 unmodified lines
122122 if (!clk_data)
123123 return;
124124
125− clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
125+ clk_data->clks = kcalloc(qty + 1, sizeof(struct clk *), GFP_KERNEL);
126126 if (!clk_data->clks) {
127127 kfree(clk_data);
128128 return;
drivers/clk/tegra/clk.c+4−3
@@ -216,14 +216,15 @@ struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks) · 215 unmodified lines
216216 if (WARN_ON(banks > ARRAY_SIZE(periph_regs)))
217217 return NULL;
218218
219− periph_clk_enb_refcnt = kzalloc(32 * banks *
220− sizeof(*periph_clk_enb_refcnt), GFP_KERNEL);
219+ periph_clk_enb_refcnt = kcalloc(32 * banks,
220+ sizeof(*periph_clk_enb_refcnt),
221+ GFP_KERNEL);
221222 if (!periph_clk_enb_refcnt)
222223 return NULL;
223224
224225 periph_banks = banks;
225226
226− clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL);
227+ clks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL);
227228 if (!clks)
228229 kfree(periph_clk_enb_refcnt);
229230
drivers/clk/ti/adpll.c+4−2
@@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d) · 500 unmodified lines
501501 const char *postfix;
502502 int width, err;
503503
504− d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) *
504+ d->outputs.clks = devm_kcalloc(d->dev,
505505 MAX_ADPLL_OUTPUTS,
506+ sizeof(struct clk *),
506507 GFP_KERNEL);
507508 if (!d->outputs.clks)
508509 return -ENOMEM;
@@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev) · 406 unmodified lines
915916 if (err)
916917 return err;
917918
918− d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) *
919+ d->clocks = devm_kcalloc(d->dev,
919920 TI_ADPLL_NR_CLOCKS,
921+ sizeof(struct ti_adpll_clock),
920922 GFP_KERNEL);
921923 if (!d->clocks)
922924 return -ENOMEM;
drivers/clk/ti/apll.c+1−1
@@ -206,7 +206,7 @@ static void __init of_dra7_apll_setup(struct device_node *node) · 205 unmodified lines
206206 goto cleanup;
207207 }
208208
209− parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
209+ parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
210210 if (!parent_names)
211211 goto cleanup;
212212
drivers/clk/ti/divider.c+2−2
@@ -366,7 +366,7 @@ int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div, · 365 unmodified lines
366366
367367 num_dividers = i;
368368
369− tmp = kzalloc(sizeof(*tmp) * (valid_div + 1), GFP_KERNEL);
369+ tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL);
370370 if (!tmp)
371371 return -ENOMEM;
372372
@@ -496,7 +496,7 @@ __init ti_clk_get_div_table(struct device_node *node) · 123 unmodified lines
496496 return ERR_PTR(-EINVAL);
497497 }
498498
499− table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL);
499+ table = kcalloc(valid_div + 1, sizeof(*table), GFP_KERNEL);
500500
501501 if (!table)
502502 return ERR_PTR(-ENOMEM);
drivers/clk/ti/dpll.c+1−1
@@ -309,7 +309,7 @@ static void __init of_ti_dpll_setup(struct device_node *node, · 308 unmodified lines
309309 goto cleanup;
310310 }
311311
312− parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
312+ parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
313313 if (!parent_names)
314314 goto cleanup;
315315
drivers/clocksource/sh_cmt.c+1−1
@@ -1000,7 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev) · 999 unmodified lines
10001000
10011001 /* Allocate and setup the channels. */
10021002 cmt->num_channels = hweight8(cmt->hw_channels);
1003− cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
1003+ cmt->channels = kcalloc(cmt->num_channels, sizeof(*cmt->channels),
10041004 GFP_KERNEL);
10051005 if (cmt->channels == NULL) {
10061006 ret = -ENOMEM;
drivers/clocksource/sh_mtu2.c+1−1
@@ -418,7 +418,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu, · 417 unmodified lines
418418 /* Allocate and setup the channels. */
419419 mtu->num_channels = 3;
420420
421− mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
421+ mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
422422 GFP_KERNEL);
423423 if (mtu->channels == NULL) {
424424 ret = -ENOMEM;
drivers/clocksource/sh_tmu.c+1−1
@@ -569,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev) · 568 unmodified lines
569569 }
570570
571571 /* Allocate and setup the channels. */
572− tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
572+ tmu->channels = kcalloc(tmu->num_channels, sizeof(*tmu->channels),
573573 GFP_KERNEL);
574574 if (tmu->channels == NULL) {
575575 ret = -ENOMEM;
drivers/cpufreq/acpi-cpufreq.c+2−2
@@ -759,8 +759,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy) · 758 unmodified lines
759759 goto err_unreg;
760760 }
761761
762− freq_table = kzalloc(sizeof(*freq_table) *
763− (perf->state_count+1), GFP_KERNEL);
762+ freq_table = kcalloc(perf->state_count + 1, sizeof(*freq_table),
763+ GFP_KERNEL);
764764 if (!freq_table) {
765765 result = -ENOMEM;
766766 goto err_unreg;
drivers/cpufreq/arm_big_little.c+1−1
@@ -280,7 +280,7 @@ static int merge_cluster_tables(void) · 279 unmodified lines
280280 for (i = 0; i < MAX_CLUSTERS; i++)
281281 count += get_table_count(freq_table[i]);
282282
283− table = kzalloc(sizeof(*table) * count, GFP_KERNEL);
283+ table = kcalloc(count, sizeof(*table), GFP_KERNEL);
284284 if (!table)
285285 return -ENOMEM;
286286
drivers/cpufreq/bmips-cpufreq.c+1−1
@@ -71,7 +71,7 @@ bmips_cpufreq_get_freq_table(const struct cpufreq_policy *policy) · 70 unmodified lines
7171
7272 cpu_freq = htp_freq_to_cpu_freq(priv->clk_mult);
7373
74− table = kmalloc((priv->max_freqs + 1) * sizeof(*table), GFP_KERNEL);
74+ table = kmalloc_array(priv->max_freqs + 1, sizeof(*table), GFP_KERNEL);
7575 if (!table)
7676 return ERR_PTR(-ENOMEM);
7777
drivers/cpufreq/brcmstb-avs-cpufreq.c+1−1
@@ -410,7 +410,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv) · 409 unmodified lines
410410 if (ret)
411411 return ERR_PTR(ret);
412412
413− table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table),
413+ table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table),
414414 GFP_KERNEL);
415415 if (!table)
416416 return ERR_PTR(-ENOMEM);
drivers/cpufreq/cppc_cpufreq.c+2−1
@@ -313,7 +313,8 @@ static int __init cppc_cpufreq_init(void) · 312 unmodified lines
313313 if (acpi_disabled)
314314 return -ENODEV;
315315
316− all_cpu_data = kzalloc(sizeof(void *) * num_possible_cpus(), GFP_KERNEL);
316+ all_cpu_data = kcalloc(num_possible_cpus(), sizeof(void *),
317+ GFP_KERNEL);
317318 if (!all_cpu_data)
318319 return -ENOMEM;
319320
drivers/cpufreq/ia64-acpi-cpufreq.c+2−2
@@ -241,8 +241,8 @@ acpi_cpufreq_cpu_init ( · 240 unmodified lines
241241 }
242242
243243 /* alloc freq_table */
244− freq_table = kzalloc(sizeof(*freq_table) *
245− (data->acpi_data.state_count + 1),
244+ freq_table = kcalloc(data->acpi_data.state_count + 1,
245+ sizeof(*freq_table),
246246 GFP_KERNEL);
247247 if (!freq_table) {
248248 result = -ENOMEM;
drivers/cpufreq/imx6q-cpufreq.c+2−1
@@ -377,7 +377,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) · 376 unmodified lines
377377 }
378378
379379 /* Make imx6_soc_volt array's size same as arm opp number */
380− imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL);
380+ imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt),
381+ GFP_KERNEL);
381382 if (imx6_soc_volt == NULL) {
382383 ret = -ENOMEM;
383384 goto free_freq_table;
drivers/cpufreq/intel_pstate.c+1−1
@@ -2339,7 +2339,7 @@ hwp_cpu_matched: · 2338 unmodified lines
23392339
23402340 pr_info("Intel P-state driver initializing\n");
23412341
2342− all_cpu_data = vzalloc(sizeof(void *) * num_possible_cpus());
2342+ all_cpu_data = vzalloc(array_size(sizeof(void *), num_possible_cpus()));
23432343 if (!all_cpu_data)
23442344 return -ENOMEM;
23452345
drivers/cpufreq/longhaul.c+2−2
@@ -474,8 +474,8 @@ static int longhaul_get_ranges(void) · 473 unmodified lines
474474 return -EINVAL;
475475 }
476476
477− longhaul_table = kzalloc((numscales + 1) * sizeof(*longhaul_table),
478− GFP_KERNEL);
477+ longhaul_table = kcalloc(numscales + 1, sizeof(*longhaul_table),
478+ GFP_KERNEL);
479479 if (!longhaul_table)
480480 return -ENOMEM;
481481
drivers/cpufreq/pxa3xx-cpufreq.c+1−1
@@ -93,7 +93,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy, · 92 unmodified lines
9393 struct cpufreq_frequency_table *table;
9494 int i;
9595
96− table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
96+ table = kcalloc(num + 1, sizeof(*table), GFP_KERNEL);
9797 if (table == NULL)
9898 return -ENOMEM;
9999
drivers/cpufreq/s3c24xx-cpufreq.c+1−1
@@ -562,7 +562,7 @@ static int s3c_cpufreq_build_freq(void) · 561 unmodified lines
562562 size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0);
563563 size++;
564564
565− ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL);
565+ ftab = kcalloc(size, sizeof(*ftab), GFP_KERNEL);
566566 if (!ftab)
567567 return -ENOMEM;
568568
drivers/cpufreq/sfi-cpufreq.c+2−2
@@ -95,8 +95,8 @@ static int __init sfi_cpufreq_init(void) · 94 unmodified lines
9595 if (ret)
9696 return ret;
9797
98− freq_table = kzalloc(sizeof(*freq_table) *
99− (num_freq_table_entries + 1), GFP_KERNEL);
98+ freq_table = kcalloc(num_freq_table_entries + 1, sizeof(*freq_table),
99+ GFP_KERNEL);
100100 if (!freq_table) {
101101 ret = -ENOMEM;
102102 goto err_free_array;
drivers/cpufreq/spear-cpufreq.c+1−1
@@ -195,7 +195,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev) · 194 unmodified lines
195195 cnt = prop->length / sizeof(u32);
196196 val = prop->value;
197197
198− freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
198+ freq_tbl = kcalloc(cnt + 1, sizeof(*freq_tbl), GFP_KERNEL);
199199 if (!freq_tbl) {
200200 ret = -ENOMEM;
201201 goto out_put_node;
drivers/crypto/amcc/crypto4xx_core.c+4−4
@@ -141,11 +141,11 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev) · 140 unmodified lines
141141
142142 int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size)
143143 {
144− ctx->sa_in = kzalloc(size * 4, GFP_ATOMIC);
144+ ctx->sa_in = kcalloc(size, 4, GFP_ATOMIC);
145145 if (ctx->sa_in == NULL)
146146 return -ENOMEM;
147147
148− ctx->sa_out = kzalloc(size * 4, GFP_ATOMIC);
148+ ctx->sa_out = kcalloc(size, 4, GFP_ATOMIC);
149149 if (ctx->sa_out == NULL) {
150150 kfree(ctx->sa_in);
151151 ctx->sa_in = NULL;
@@ -180,8 +180,8 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev) · 28 unmodified lines
180180 if (!dev->pdr)
181181 return -ENOMEM;
182182
183− dev->pdr_uinfo = kzalloc(sizeof(struct pd_uinfo) * PPC4XX_NUM_PD,
184− GFP_KERNEL);
183+ dev->pdr_uinfo = kcalloc(PPC4XX_NUM_PD, sizeof(struct pd_uinfo),
184+ GFP_KERNEL);
185185 if (!dev->pdr_uinfo) {
186186 dma_free_coherent(dev->core_dev->device,
187187 sizeof(struct ce_pd) * PPC4XX_NUM_PD,
drivers/crypto/cavium/nitrox/nitrox_isr.c+1−1
@@ -254,7 +254,7 @@ static int nitrox_enable_msix(struct nitrox_device *ndev) · 253 unmodified lines
254254 * Entry 192: NPS_CORE_INT_ACTIVE
255255 */
256256 nr_entries = (ndev->nr_queues * NR_RING_VECTORS) + 1;
257− entries = kzalloc_node(nr_entries * sizeof(struct msix_entry),
257+ entries = kcalloc_node(nr_entries, sizeof(struct msix_entry),
258258 GFP_KERNEL, ndev->node);
259259 if (!entries)
260260 return -ENOMEM;
drivers/crypto/chelsio/chtls/chtls_io.c+1−1
@@ -240,7 +240,7 @@ static int tls_copy_ivs(struct sock *sk, struct sk_buff *skb) · 239 unmodified lines
240240 }
241241
242242 /* generate the IVs */
243− ivs = kmalloc(number_of_ivs * CIPHER_BLOCK_SIZE, GFP_ATOMIC);
243+ ivs = kmalloc_array(CIPHER_BLOCK_SIZE, number_of_ivs, GFP_ATOMIC);
244244 if (!ivs)
245245 return -ENOMEM;
246246 get_random_bytes(ivs, number_of_ivs * CIPHER_BLOCK_SIZE);
drivers/crypto/inside-secure/safexcel_hash.c+1−1
@@ -922,7 +922,7 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen, · 921 unmodified lines
922922 crypto_ahash_clear_flags(tfm, ~0);
923923 blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
924924
925− ipad = kzalloc(2 * blocksize, GFP_KERNEL);
925+ ipad = kcalloc(2, blocksize, GFP_KERNEL);
926926 if (!ipad) {
927927 ret = -ENOMEM;
928928 goto free_request;
drivers/crypto/marvell/cesa.c+1−1
@@ -471,7 +471,7 @@ static int mv_cesa_probe(struct platform_device *pdev) · 470 unmodified lines
471471 sram_size = CESA_SA_MIN_SRAM_SIZE;
472472
473473 cesa->sram_size = sram_size;
474− cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines),
474+ cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines),
475475 GFP_KERNEL);
476476 if (!cesa->engines)
477477 return -ENOMEM;
drivers/crypto/marvell/hash.c+1−1
@@ -1198,7 +1198,7 @@ static int mv_cesa_ahmac_setkey(const char *hash_alg_name, · 1197 unmodified lines
11981198
11991199 blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
12001200
1201− ipad = kzalloc(2 * blocksize, GFP_KERNEL);
1201+ ipad = kcalloc(2, blocksize, GFP_KERNEL);
12021202 if (!ipad) {
12031203 ret = -ENOMEM;
12041204 goto free_req;
drivers/crypto/n2_core.c+2−2
@@ -1919,12 +1919,12 @@ static int grab_global_resources(void) · 1918 unmodified lines
19191919 goto out_hvapi_release;
19201920
19211921 err = -ENOMEM;
1922− cpu_to_cwq = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
1922+ cpu_to_cwq = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
19231923 GFP_KERNEL);
19241924 if (!cpu_to_cwq)
19251925 goto out_queue_cache_destroy;
19261926
1927− cpu_to_mau = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
1927+ cpu_to_mau = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
19281928 GFP_KERNEL);
19291929 if (!cpu_to_mau)
19301930 goto out_free_cwq_table;
drivers/crypto/qat/qat_common/adf_isr.c+1−1
@@ -238,7 +238,7 @@ static int adf_isr_alloc_msix_entry_table(struct adf_accel_dev *accel_dev) · 237 unmodified lines
238238 if (!accel_dev->pf.vf_info)
239239 msix_num_entries += hw_data->num_banks;
240240
241− entries = kzalloc_node(msix_num_entries * sizeof(*entries),
241+ entries = kcalloc_node(msix_num_entries, sizeof(*entries),
242242 GFP_KERNEL, dev_to_node(&GET_DEV(accel_dev)));
243243 if (!entries)
244244 return -ENOMEM;
drivers/crypto/qat/qat_common/qat_uclo.c+3−2
@@ -1162,8 +1162,9 @@ static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle, · 1161 unmodified lines
11621162 suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1;
11631163
11641164 if (suof_handle->img_table.num_simgs != 0) {
1165− suof_img_hdr = kzalloc(suof_handle->img_table.num_simgs *
1166− sizeof(img_header), GFP_KERNEL);
1165+ suof_img_hdr = kcalloc(suof_handle->img_table.num_simgs,
1166+ sizeof(img_header),
1167+ GFP_KERNEL);
11671168 if (!suof_img_hdr)
11681169 return -ENOMEM;
11691170 suof_handle->img_table.simg_hdr = suof_img_hdr;
drivers/crypto/stm32/stm32-hash.c+3−2
@@ -970,8 +970,9 @@ static int stm32_hash_export(struct ahash_request *req, void *out) · 969 unmodified lines
970970 while (!(stm32_hash_read(hdev, HASH_SR) & HASH_SR_DATA_INPUT_READY))
971971 cpu_relax();
972972
973− rctx->hw_context = kmalloc(sizeof(u32) * (3 + HASH_CSR_REGISTER_NUMBER),
974− GFP_KERNEL);
973+ rctx->hw_context = kmalloc_array(3 + HASH_CSR_REGISTER_NUMBER,
974+ sizeof(u32),
975+ GFP_KERNEL);
975976
976977 preg = rctx->hw_context;
977978
drivers/crypto/talitos.c+8−5
@@ -3393,8 +3393,10 @@ static int talitos_probe(struct platform_device *ofdev) · 3392 unmodified lines
33933393 }
33943394 }
33953395
3396− priv->chan = devm_kzalloc(dev, sizeof(struct talitos_channel) *
3397− priv->num_channels, GFP_KERNEL);
3396+ priv->chan = devm_kcalloc(dev,
3397+ priv->num_channels,
3398+ sizeof(struct talitos_channel),
3399+ GFP_KERNEL);
33983400 if (!priv->chan) {
33993401 dev_err(dev, "failed to allocate channel management space\n");
34003402 err = -ENOMEM;
@@ -3411,9 +3413,10 @@ static int talitos_probe(struct platform_device *ofdev) · 10 unmodified lines
34113413 spin_lock_init(&priv->chan[i].head_lock);
34123414 spin_lock_init(&priv->chan[i].tail_lock);
34133415
3414− priv->chan[i].fifo = devm_kzalloc(dev,
3415− sizeof(struct talitos_request) *
3416− priv->fifo_len, GFP_KERNEL);
3416+ priv->chan[i].fifo = devm_kcalloc(dev,
3417+ priv->fifo_len,
3418+ sizeof(struct talitos_request),
3419+ GFP_KERNEL);
34173420 if (!priv->chan[i].fifo) {
34183421 dev_err(dev, "failed to allocate request fifo %d\n", i);
34193422 err = -ENOMEM;
drivers/crypto/virtio/virtio_crypto_algs.c+1−1
@@ -371,7 +371,7 @@ __virtio_crypto_ablkcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req, · 370 unmodified lines
371371
372372 /* Why 3? outhdr + iv + inhdr */
373373 sg_total = src_nents + dst_nents + 3;
374− sgs = kzalloc_node(sg_total * sizeof(*sgs), GFP_ATOMIC,
374+ sgs = kcalloc_node(sg_total, sizeof(*sgs), GFP_ATOMIC,
375375 dev_to_node(&vcrypto->vdev->dev));
376376 if (!sgs)
377377 return -ENOMEM;
drivers/devfreq/devfreq.c+8−7
@@ -628,14 +628,15 @@ struct devfreq *devfreq_add_device(struct device *dev, · 627 unmodified lines
628628 goto err_dev;
629629 }
630630
631− devfreq->trans_table = devm_kzalloc(&devfreq->dev,
632− sizeof(unsigned int) *
633− devfreq->profile->max_state *
634− devfreq->profile->max_state,
635− GFP_KERNEL);
636− devfreq->time_in_state = devm_kzalloc(&devfreq->dev,
637− sizeof(unsigned long) *
631+ devfreq->trans_table =
632+ devm_kzalloc(&devfreq->dev,
633+ array3_size(sizeof(unsigned int),
634+ devfreq->profile->max_state,
635+ devfreq->profile->max_state),
636+ GFP_KERNEL);
637+ devfreq->time_in_state = devm_kcalloc(&devfreq->dev,
638638 devfreq->profile->max_state,
639+ sizeof(unsigned long),
639640 GFP_KERNEL);
640641 devfreq->last_stat_updated = jiffies;
641642
drivers/devfreq/event/exynos-ppmu.c+1−1
@@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np, · 517 unmodified lines
518518 event_ops = exynos_bus_get_ops(np);
519519
520520 count = of_get_child_count(events_np);
521− desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL);
521+ desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL);
522522 if (!desc)
523523 return -ENOMEM;
524524 info->num_events = count;
drivers/dma/bestcomm/bestcomm.c+2−1
@@ -87,7 +87,8 @@ bcom_task_alloc(int bd_count, int bd_size, int priv_size) · 86 unmodified lines
8787
8888 /* Init the BDs, if needed */
8989 if (bd_count) {
90− tsk->cookie = kmalloc(sizeof(void*) * bd_count, GFP_KERNEL);
90+ tsk->cookie = kmalloc_array(bd_count, sizeof(void *),
91+ GFP_KERNEL);
9192 if (!tsk->cookie)
9293 goto error;
9394
drivers/dma/ioat/init.c+2−2
@@ -322,10 +322,10 @@ static int ioat_dma_self_test(struct ioatdma_device *ioat_dma) · 321 unmodified lines
322322 unsigned long tmo;
323323 unsigned long flags;
324324
325− src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
325+ src = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
326326 if (!src)
327327 return -ENOMEM;
328− dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
328+ dest = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
329329 if (!dest) {
330330 kfree(src);
331331 return -ENOMEM;
drivers/dma/ipu/ipu_idmac.c+2−1
@@ -910,7 +910,8 @@ out: · 909 unmodified lines
910910 /* Called with ichan->chan_mutex held */
911911 static int idmac_desc_alloc(struct idmac_channel *ichan, int n)
912912 {
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)));
914915 struct idmac *idmac = to_idmac(ichan->dma_chan.device);
915916
916917 if (!desc)
drivers/dma/k3dma.c+4−4
@@ -848,8 +848,8 @@ static int k3_dma_probe(struct platform_device *op) · 847 unmodified lines
848848 return -ENOMEM;
849849
850850 /* init phy channel */
851− d->phy = devm_kzalloc(&op->dev,
852− d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL);
851+ d->phy = devm_kcalloc(&op->dev,
852+ d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL);
853853 if (d->phy == NULL)
854854 return -ENOMEM;
855855
@@ -879,8 +879,8 @@ static int k3_dma_probe(struct platform_device *op) · 23 unmodified lines
879879 d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES;
880880
881881 /* init virtual channel */
882− d->chans = devm_kzalloc(&op->dev,
883− d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL);
882+ d->chans = devm_kcalloc(&op->dev,
883+ d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL);
884884 if (d->chans == NULL)
885885 return -ENOMEM;
886886
drivers/dma/mic_x100_dma.c+2−1
@@ -385,7 +385,8 @@ static int mic_dma_alloc_desc_ring(struct mic_dma_chan *ch) · 384 unmodified lines
385385 if (dma_mapping_error(dev, ch->desc_ring_micpa))
386386 goto map_error;
387387
388− ch->tx_array = vzalloc(MIC_DMA_DESC_RX_SIZE * sizeof(*ch->tx_array));
388+ ch->tx_array = vzalloc(array_size(MIC_DMA_DESC_RX_SIZE,
389+ sizeof(*ch->tx_array)));
389390 if (!ch->tx_array)
390391 goto tx_error;
391392 return 0;
drivers/dma/mv_xor.c+2−2
@@ -777,11 +777,11 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan) · 776 unmodified lines
777777 struct dmaengine_unmap_data *unmap;
778778 int err = 0;
779779
780− src = kmalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
780+ src = kmalloc(PAGE_SIZE, GFP_KERNEL);
781781 if (!src)
782782 return -ENOMEM;
783783
784− dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
784+ dest = kzalloc(PAGE_SIZE, GFP_KERNEL);
785785 if (!dest) {
786786 kfree(src);
787787 return -ENOMEM;
drivers/dma/mv_xor_v2.c+3−2
@@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev) · 808 unmodified lines
809809 }
810810
811811 /* alloc memory for the SW descriptors */
812− xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) *
813− MV_XOR_V2_DESC_NUM, GFP_KERNEL);
812+ xor_dev->sw_desq = devm_kcalloc(&pdev->dev,
813+ MV_XOR_V2_DESC_NUM, sizeof(*sw_desc),
814+ GFP_KERNEL);
814815 if (!xor_dev->sw_desq) {
815816 ret = -ENOMEM;
816817 goto free_hw_desq;
drivers/dma/pl330.c+2−2
@@ -1866,7 +1866,7 @@ static int dmac_alloc_threads(struct pl330_dmac *pl330) · 1865 unmodified lines
18661866 int i;
18671867
18681868 /* Allocate 1 Manager and 'chans' Channel threads */
1869− pl330->channels = kzalloc((1 + chans) * sizeof(*thrd),
1869+ pl330->channels = kcalloc(1 + chans, sizeof(*thrd),
18701870 GFP_KERNEL);
18711871 if (!pl330->channels)
18721872 return -ENOMEM;
@@ -2990,7 +2990,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id) · 1117 unmodified lines
29902990
29912991 pl330->num_peripherals = num_chan;
29922992
2993− pl330->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
2993+ pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL);
29942994 if (!pl330->peripherals) {
29952995 ret = -ENOMEM;
29962996 goto probe_err2;
drivers/dma/s3c24xx-dma.c+3−3
@@ -1223,9 +1223,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev) · 1222 unmodified lines
12231223 if (IS_ERR(s3cdma->base))
12241224 return PTR_ERR(s3cdma->base);
12251225
1226− s3cdma->phy_chans = devm_kzalloc(&pdev->dev,
1227− sizeof(struct s3c24xx_dma_phy) *
1228− pdata->num_phy_channels,
1226+ s3cdma->phy_chans = devm_kcalloc(&pdev->dev,
1227+ pdata->num_phy_channels,
1228+ sizeof(struct s3c24xx_dma_phy),
12291229 GFP_KERNEL);
12301230 if (!s3cdma->phy_chans)
12311231 return -ENOMEM;
drivers/dma/sh/shdma-base.c+3−2
@@ -1045,8 +1045,9 @@ EXPORT_SYMBOL(shdma_cleanup); · 1044 unmodified lines
10451045
10461046 static int __init shdma_enter(void)
10471047 {
1048− shdma_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) *
1049− sizeof(long), GFP_KERNEL);
1048+ shdma_slave_used = kcalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG),
1049+ sizeof(long),
1050+ GFP_KERNEL);
10501051 if (!shdma_slave_used)
10511052 return -ENOMEM;
10521053 return 0;
drivers/dma/xilinx/zynqmp_dma.c+1−1
@@ -471,7 +471,7 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan) · 470 unmodified lines
471471 if (ret < 0)
472472 return ret;
473473
474− chan->sw_desc_pool = kzalloc(sizeof(*desc) * ZYNQMP_DMA_NUM_DESCS,
474+ chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc),
475475 GFP_KERNEL);
476476 if (!chan->sw_desc_pool)
477477 return -ENOMEM;
drivers/dma/zx_dma.c+4−4
@@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op) · 797 unmodified lines
798798 return -ENOMEM;
799799
800800 /* init phy channel */
801− d->phy = devm_kzalloc(&op->dev,
802− d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL);
801+ d->phy = devm_kcalloc(&op->dev,
802+ d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL);
803803 if (!d->phy)
804804 return -ENOMEM;
805805
@@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op) · 28 unmodified lines
834834 d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT;
835835
836836 /* init virtual channel */
837− d->chans = devm_kzalloc(&op->dev,
838− d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL);
837+ d->chans = devm_kcalloc(&op->dev,
838+ d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL);
839839 if (!d->chans)
840840 return -ENOMEM;
841841
drivers/edac/amd64_edac.c+1−1
@@ -3451,7 +3451,7 @@ static int __init amd64_edac_init(void) · 3450 unmodified lines
34513451 opstate_init();
34523452
34533453 err = -ENOMEM;
3454− ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
3454+ ecc_stngs = kcalloc(amd_nb_num(), sizeof(ecc_stngs[0]), GFP_KERNEL);
34553455 if (!ecc_stngs)
34563456 goto err_free;
34573457
drivers/edac/i7core_edac.c+1−1
@@ -461,7 +461,7 @@ static struct i7core_dev *alloc_i7core_dev(u8 socket, · 460 unmodified lines
461461 if (!i7core_dev)
462462 return NULL;
463463
464− i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs,
464+ i7core_dev->pdev = kcalloc(table->n_devs, sizeof(*i7core_dev->pdev),
465465 GFP_KERNEL);
466466 if (!i7core_dev->pdev) {
467467 kfree(i7core_dev);
drivers/extcon/extcon.c+14−10
@@ -1126,8 +1126,9 @@ int extcon_dev_register(struct extcon_dev *edev) · 1125 unmodified lines
11261126 char *str;
11271127 struct extcon_cable *cable;
11281128
1129− edev->cables = kzalloc(sizeof(struct extcon_cable) *
1130− edev->max_supported, GFP_KERNEL);
1129+ edev->cables = kcalloc(edev->max_supported,
1130+ sizeof(struct extcon_cable),
1131+ GFP_KERNEL);
11311132 if (!edev->cables) {
11321133 ret = -ENOMEM;
11331134 goto err_sysfs_alloc;
@@ -1136,7 +1137,7 @@ int extcon_dev_register(struct extcon_dev *edev) · 2 unmodified lines
11361137 cable = &edev->cables[index];
11371138
11381139 snprintf(buf, 10, "cable.%d", index);
1139− str = kzalloc(sizeof(char) * (strlen(buf) + 1),
1140+ str = kzalloc(strlen(buf) + 1,
11401141 GFP_KERNEL);
11411142 if (!str) {
11421143 for (index--; index >= 0; index--) {
@@ -1177,15 +1178,17 @@ int extcon_dev_register(struct extcon_dev *edev) · 34 unmodified lines
11771178 for (index = 0; edev->mutually_exclusive[index]; index++)
11781179 ;
11791180
1180− edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
1181− (index + 1), GFP_KERNEL);
1181+ edev->attrs_muex = kcalloc(index + 1,
1182+ sizeof(struct attribute *),
1183+ GFP_KERNEL);
11821184 if (!edev->attrs_muex) {
11831185 ret = -ENOMEM;
11841186 goto err_muex;
11851187 }
11861188
1187− edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
1188− index, GFP_KERNEL);
1189+ edev->d_attrs_muex = kcalloc(index,
1190+ sizeof(struct device_attribute),
1191+ GFP_KERNEL);
11891192 if (!edev->d_attrs_muex) {
11901193 ret = -ENOMEM;
11911194 kfree(edev->attrs_muex);
@@ -1194,7 +1197,7 @@ int extcon_dev_register(struct extcon_dev *edev) · 2 unmodified lines
11941197
11951198 for (index = 0; edev->mutually_exclusive[index]; index++) {
11961199 sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
1197− name = kzalloc(sizeof(char) * (strlen(buf) + 1),
1200+ name = kzalloc(strlen(buf) + 1,
11981201 GFP_KERNEL);
11991202 if (!name) {
12001203 for (index--; index >= 0; index--) {
@@ -1220,8 +1223,9 @@ int extcon_dev_register(struct extcon_dev *edev) · 19 unmodified lines
12201223
12211224 if (edev->max_supported) {
12221225 edev->extcon_dev_type.groups =
1223− kzalloc(sizeof(struct attribute_group *) *
1224− (edev->max_supported + 2), GFP_KERNEL);
1226+ kcalloc(edev->max_supported + 2,
1227+ sizeof(struct attribute_group *),
1228+ GFP_KERNEL);
12251229 if (!edev->extcon_dev_type.groups) {
12261230 ret = -ENOMEM;
12271231 goto err_alloc_groups;
drivers/firewire/core-iso.c+2−2
@@ -45,8 +45,8 @@ int fw_iso_buffer_alloc(struct fw_iso_buffer *buffer, int page_count) · 44 unmodified lines
4545
4646 buffer->page_count = 0;
4747 buffer->page_count_mapped = 0;
48− buffer->pages = kmalloc(page_count * sizeof(buffer->pages[0]),
49− GFP_KERNEL);
48+ buffer->pages = kmalloc_array(page_count, sizeof(buffer->pages[0]),
49+ GFP_KERNEL);
5050 if (buffer->pages == NULL)
5151 return -ENOMEM;
5252
drivers/firewire/net.c+1−1
@@ -1121,7 +1121,7 @@ static int fwnet_broadcast_start(struct fwnet_device *dev) · 1120 unmodified lines
11211121 max_receive = 1U << (dev->card->max_receive + 1);
11221122 num_packets = (FWNET_ISO_PAGE_COUNT * PAGE_SIZE) / max_receive;
11231123
1124− ptrptr = kmalloc(sizeof(void *) * num_packets, GFP_KERNEL);
1124+ ptrptr = kmalloc_array(num_packets, sizeof(void *), GFP_KERNEL);
11251125 if (!ptrptr) {
11261126 retval = -ENOMEM;
11271127 goto failed;
drivers/firmware/arm_scpi.c+1−1
@@ -890,7 +890,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch) · 889 unmodified lines
890890 int i;
891891 struct scpi_xfer *xfers;
892892
893− xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL);
893+ xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL);
894894 if (!xfers)
895895 return -ENOMEM;
896896
drivers/firmware/dell_rbu.c+1−1
@@ -146,7 +146,7 @@ static int create_packet(void *data, size_t length) · 145 unmodified lines
146146 packet_array_size = max(
147147 (unsigned int)(allocation_floor / rbu_data.packetsize),
148148 (unsigned int)1);
149− invalid_addr_packet_array = kzalloc(packet_array_size * sizeof(void*),
149+ invalid_addr_packet_array = kcalloc(packet_array_size, sizeof(void *),
150150 GFP_KERNEL);
151151
152152 if (!invalid_addr_packet_array) {
drivers/firmware/efi/capsule.c+1−1
@@ -231,7 +231,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages) · 230 unmodified lines
231231 count = DIV_ROUND_UP(imagesize, PAGE_SIZE);
232232 sg_count = sg_pages_num(count);
233233
234− sg_pages = kzalloc(sg_count * sizeof(*sg_pages), GFP_KERNEL);
234+ sg_pages = kcalloc(sg_count, sizeof(*sg_pages), GFP_KERNEL);
235235 if (!sg_pages)
236236 return -ENOMEM;
237237
drivers/firmware/efi/runtime-map.c+1−1
@@ -166,7 +166,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj) · 165 unmodified lines
166166 if (!efi_enabled(EFI_MEMMAP))
167167 return 0;
168168
169− map_entries = kzalloc(efi.memmap.nr_map * sizeof(entry), GFP_KERNEL);
169+ map_entries = kcalloc(efi.memmap.nr_map, sizeof(entry), GFP_KERNEL);
170170 if (!map_entries) {
171171 ret = -ENOMEM;
172172 goto out;
drivers/firmware/ti_sci.c+3−3
@@ -1854,9 +1854,9 @@ static int ti_sci_probe(struct platform_device *pdev) · 1853 unmodified lines
18541854 if (!minfo->xfer_block)
18551855 return -ENOMEM;
18561856
1857− minfo->xfer_alloc_table = devm_kzalloc(dev,
1858− BITS_TO_LONGS(desc->max_msgs)
1859− * sizeof(unsigned long),
1857+ minfo->xfer_alloc_table = devm_kcalloc(dev,
1858+ BITS_TO_LONGS(desc->max_msgs),
1859+ sizeof(unsigned long),
18601860 GFP_KERNEL);
18611861 if (!minfo->xfer_alloc_table)
18621862 return -ENOMEM;
drivers/fmc/fmc-sdb.c+2−2
@@ -48,8 +48,8 @@ static struct sdb_array *__fmc_scan_sdb_tree(struct fmc_device *fmc, · 47 unmodified lines
4848 arr = kzalloc(sizeof(*arr), GFP_KERNEL);
4949 if (!arr)
5050 return ERR_PTR(-ENOMEM);
51− arr->record = kzalloc(sizeof(arr->record[0]) * n, GFP_KERNEL);
52− arr->subtree = kzalloc(sizeof(arr->subtree[0]) * n, GFP_KERNEL);
51+ arr->record = kcalloc(n, sizeof(arr->record[0]), GFP_KERNEL);
52+ arr->subtree = kcalloc(n, sizeof(arr->subtree[0]), GFP_KERNEL);
5353 if (!arr->record || !arr->subtree) {
5454 kfree(arr->record);
5555 kfree(arr->subtree);
drivers/gpio/gpio-adnp.c+1−1
@@ -427,7 +427,7 @@ static int adnp_irq_setup(struct adnp *adnp) · 426 unmodified lines
427427 * is chosen to match the register layout of the hardware in that
428428 * each segment contains the corresponding bits for all interrupts.
429429 */
430− adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6,
430+ adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6,
431431 GFP_KERNEL);
432432 if (!adnp->irq_enable)
433433 return -ENOMEM;
drivers/gpio/gpio-aspeed.c+2−2
@@ -897,8 +897,8 @@ static int __init aspeed_gpio_probe(struct platform_device *pdev) · 896 unmodified lines
897897
898898 /* Allocate a cache of the output registers */
899899 banks = gpio->config->nr_gpios >> 5;
900− gpio->dcache = devm_kzalloc(&pdev->dev,
901− sizeof(u32) * banks, GFP_KERNEL);
900+ gpio->dcache = devm_kcalloc(&pdev->dev,
901+ banks, sizeof(u32), GFP_KERNEL);
902902 if (!gpio->dcache)
903903 return -ENOMEM;
904904
drivers/gpio/gpio-bcm-kona.c+4−3
@@ -601,9 +601,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) · 600 unmodified lines
601601 GPIO_MAX_BANK_NUM);
602602 return -ENXIO;
603603 }
604− kona_gpio->banks = devm_kzalloc(dev,
605− kona_gpio->num_bank *
606− sizeof(*kona_gpio->banks), GFP_KERNEL);
604+ kona_gpio->banks = devm_kcalloc(dev,
605+ kona_gpio->num_bank,
606+ sizeof(*kona_gpio->banks),
607+ GFP_KERNEL);
607608 if (!kona_gpio->banks)
608609 return -ENOMEM;
609610
drivers/gpio/gpio-davinci.c+2−2
@@ -198,8 +198,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) · 197 unmodified lines
198198 ngpio = ARCH_NR_GPIOS;
199199
200200 nbank = DIV_ROUND_UP(ngpio, 32);
201− chips = devm_kzalloc(dev,
202− nbank * sizeof(struct davinci_gpio_controller),
201+ chips = devm_kcalloc(dev,
202+ nbank, sizeof(struct davinci_gpio_controller),
203203 GFP_KERNEL);
204204 if (!chips)
205205 return -ENOMEM;
drivers/gpio/gpio-htc-egpio.c+2−2
@@ -321,8 +321,8 @@ static int __init egpio_probe(struct platform_device *pdev) · 320 unmodified lines
321321 platform_set_drvdata(pdev, ei);
322322
323323 ei->nchips = pdata->num_chips;
324− ei->chip = devm_kzalloc(&pdev->dev,
325− sizeof(struct egpio_chip) * ei->nchips,
324+ ei->chip = devm_kcalloc(&pdev->dev,
325+ ei->nchips, sizeof(struct egpio_chip),
326326 GFP_KERNEL);
327327 if (!ei->chip) {
328328 ret = -ENOMEM;
drivers/gpio/gpio-ml-ioh.c+1−1
@@ -443,7 +443,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev, · 442 unmodified lines
443443 goto err_iomap;
444444 }
445445
446− chip_save = kzalloc(sizeof(*chip) * 8, GFP_KERNEL);
446+ chip_save = kcalloc(8, sizeof(*chip), GFP_KERNEL);
447447 if (chip_save == NULL) {
448448 ret = -ENOMEM;
449449 goto err_kzalloc;
drivers/gpio/gpio-thunderx.c+5−4
@@ -504,16 +504,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev, · 503 unmodified lines
504504 txgpio->base_msi = (c >> 8) & 0xff;
505505 }
506506
507− txgpio->msix_entries = devm_kzalloc(dev,
508− sizeof(struct msix_entry) * ngpio,
507+ txgpio->msix_entries = devm_kcalloc(dev,
508+ ngpio, sizeof(struct msix_entry),
509509 GFP_KERNEL);
510510 if (!txgpio->msix_entries) {
511511 err = -ENOMEM;
512512 goto out;
513513 }
514514
515− txgpio->line_entries = devm_kzalloc(dev,
516− sizeof(struct thunderx_line) * ngpio,
515+ txgpio->line_entries = devm_kcalloc(dev,
516+ ngpio,
517+ sizeof(struct thunderx_line),
517518 GFP_KERNEL);
518519 if (!txgpio->line_entries) {
519520 err = -ENOMEM;
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c+3−3
@@ -310,20 +310,20 @@ static int acp_hw_init(void *handle) · 309 unmodified lines
310310 pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
311311 }
312312
313− adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS,
313+ adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell),
314314 GFP_KERNEL);
315315
316316 if (adev->acp.acp_cell == NULL)
317317 return -ENOMEM;
318318
319− adev->acp.acp_res = kzalloc(sizeof(struct resource) * 4, GFP_KERNEL);
319+ adev->acp.acp_res = kcalloc(4, sizeof(struct resource), GFP_KERNEL);
320320
321321 if (adev->acp.acp_res == NULL) {
322322 kfree(adev->acp.acp_cell);
323323 return -ENOMEM;
324324 }
325325
326− i2s_pdata = kzalloc(sizeof(struct i2s_platform_data) * 2, GFP_KERNEL);
326+ i2s_pdata = kcalloc(2, sizeof(struct i2s_platform_data), GFP_KERNEL);
327327 if (i2s_pdata == NULL) {
328328 kfree(adev->acp.acp_res);
329329 kfree(adev->acp.acp_cell);
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v7.c+2−2
@@ -407,7 +407,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, · 406 unmodified lines
407407 (*dump)[i++][1] = RREG32(addr); \
408408 } while (0)
409409
410− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
410+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
411411 if (*dump == NULL)
412412 return -ENOMEM;
413413
@@ -504,7 +504,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, · 90 unmodified lines
504504 #undef HQD_N_REGS
505505 #define HQD_N_REGS (19+4)
506506
507− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
507+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
508508 if (*dump == NULL)
509509 return -ENOMEM;
510510
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v8.c+2−2
@@ -395,7 +395,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, · 394 unmodified lines
395395 (*dump)[i++][1] = RREG32(addr); \
396396 } while (0)
397397
398− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
398+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
399399 if (*dump == NULL)
400400 return -ENOMEM;
401401
@@ -491,7 +491,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, · 89 unmodified lines
491491 #undef HQD_N_REGS
492492 #define HQD_N_REGS (19+4+2+3+7)
493493
494− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
494+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
495495 if (*dump == NULL)
496496 return -ENOMEM;
497497
drivers/gpu/drm/amd/amdgpu/amdgpu_amdkfd_gfx_v9.c+2−2
@@ -504,7 +504,7 @@ static int kgd_hqd_dump(struct kgd_dev *kgd, · 503 unmodified lines
504504 (*dump)[i++][1] = RREG32(addr); \
505505 } while (0)
506506
507− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
507+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
508508 if (*dump == NULL)
509509 return -ENOMEM;
510510
@@ -606,7 +606,7 @@ static int kgd_hqd_sdma_dump(struct kgd_dev *kgd, · 95 unmodified lines
606606 #undef HQD_N_REGS
607607 #define HQD_N_REGS (19+6+7+10)
608608
609− *dump = kmalloc(HQD_N_REGS*2*sizeof(uint32_t), GFP_KERNEL);
609+ *dump = kmalloc_array(HQD_N_REGS * 2, sizeof(uint32_t), GFP_KERNEL);
610610 if (*dump == NULL)
611611 return -ENOMEM;
612612
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c+1−1
@@ -452,7 +452,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev) · 451 unmodified lines
452452 ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
453453
454454 adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
455− kzalloc(psl->ucNumEntries *
455+ kcalloc(psl->ucNumEntries,
456456 sizeof(struct amdgpu_phase_shedding_limits_entry),
457457 GFP_KERNEL);
458458 if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
drivers/gpu/drm/amd/amdgpu/amdgpu_gart.c+2−1
@@ -369,7 +369,8 @@ int amdgpu_gart_init(struct amdgpu_device *adev) · 368 unmodified lines
369369
370370 #ifdef CONFIG_DRM_AMDGPU_GART_DEBUGFS
371371 /* Allocate pages table */
372− adev->gart.pages = vzalloc(sizeof(void *) * adev->gart.num_cpu_pages);
372+ adev->gart.pages = vzalloc(array_size(sizeof(void *),
373+ adev->gart.num_cpu_pages));
373374 if (adev->gart.pages == NULL)
374375 return -ENOMEM;
375376 #endif
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c+1−1
@@ -53,7 +53,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev) · 52 unmodified lines
5353 n -= adev->irq.ih.ring_size;
5454 n /= size;
5555
56− gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
56+ gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
5757 if (!gtt_obj) {
5858 DRM_ERROR("Failed to allocate %d pointers\n", n);
5959 r = 1;
drivers/gpu/drm/amd/amdgpu/atom.c+1−1
@@ -1221,7 +1221,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index, · 1220 unmodified lines
12211221 ectx.abort = false;
12221222 ectx.last_jump = 0;
12231223 if (ws)
1224− ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
1224+ ectx.ws = kcalloc(4, ws, GFP_KERNEL);
12251225 else
12261226 ectx.ws = NULL;
12271227
drivers/gpu/drm/amd/amdgpu/ci_dpm.c+6−3
@@ -5679,8 +5679,9 @@ static int ci_parse_power_table(struct amdgpu_device *adev) · 5678 unmodified lines
56795679 (mode_info->atom_context->bios + data_offset +
56805680 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
56815681
5682− adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
5683− state_array->ucNumEntries, GFP_KERNEL);
5682+ adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
5683+ sizeof(struct amdgpu_ps),
5684+ GFP_KERNEL);
56845685 if (!adev->pm.dpm.ps)
56855686 return -ENOMEM;
56865687 power_state_offset = (u8 *)state_array->states;
@@ -5927,7 +5928,9 @@ static int ci_dpm_init(struct amdgpu_device *adev) · 240 unmodified lines
59275928 ci_set_private_data_variables_based_on_pptable(adev);
59285929
59295930 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
5930− kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
5931+ kcalloc(4,
5932+ sizeof(struct amdgpu_clock_voltage_dependency_entry),
5933+ GFP_KERNEL);
59315934 if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
59325935 ci_dpm_fini(adev);
59335936 return -ENOMEM;
drivers/gpu/drm/amd/amdgpu/kv_dpm.c+3−2
@@ -2727,8 +2727,9 @@ static int kv_parse_power_table(struct amdgpu_device *adev) · 2726 unmodified lines
27272727 (mode_info->atom_context->bios + data_offset +
27282728 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
27292729
2730− adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
2731− state_array->ucNumEntries, GFP_KERNEL);
2730+ adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
2731+ sizeof(struct amdgpu_ps),
2732+ GFP_KERNEL);
27322733 if (!adev->pm.dpm.ps)
27332734 return -ENOMEM;
27342735 power_state_offset = (u8 *)state_array->states;
drivers/gpu/drm/amd/amdgpu/si_dpm.c+6−3
@@ -7242,8 +7242,9 @@ static int si_parse_power_table(struct amdgpu_device *adev) · 7241 unmodified lines
72427242 (mode_info->atom_context->bios + data_offset +
72437243 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
72447244
7245− adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
7246− state_array->ucNumEntries, GFP_KERNEL);
7245+ adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
7246+ sizeof(struct amdgpu_ps),
7247+ GFP_KERNEL);
72477248 if (!adev->pm.dpm.ps)
72487249 return -ENOMEM;
72497250 power_state_offset = (u8 *)state_array->states;
@@ -7346,7 +7347,9 @@ static int si_dpm_init(struct amdgpu_device *adev) · 96 unmodified lines
73467347 return ret;
73477348
73487349 adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
7349− kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
7350+ kcalloc(4,
7351+ sizeof(struct amdgpu_clock_voltage_dependency_entry),
7352+ GFP_KERNEL);
73507353 if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
73517354 amdgpu_free_extended_power_table(adev);
73527355 return -ENOMEM;
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c+1−1
@@ -435,7 +435,7 @@ bool dm_helpers_submit_i2c( · 434 unmodified lines
435435 return false;
436436 }
437437
438− msgs = kzalloc(num * sizeof(struct i2c_msg), GFP_KERNEL);
438+ msgs = kcalloc(num, sizeof(struct i2c_msg), GFP_KERNEL);
439439
440440 if (!msgs)
441441 return false;
drivers/gpu/drm/amd/display/dc/basics/logger.c+1−1
@@ -364,7 +364,7 @@ void dm_logger_open( · 363 unmodified lines
364364 entry->type = log_type;
365365 entry->logger = logger;
366366
367− entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE * sizeof(char),
367+ entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE,
368368 GFP_KERNEL);
369369
370370 entry->buf_offset = 0;
drivers/gpu/drm/amd/display/dc/basics/vector.c+2−2
@@ -40,7 +40,7 @@ bool dal_vector_construct( · 39 unmodified lines
4040 return false;
4141 }
4242
43− vector->container = kzalloc(struct_size * capacity, GFP_KERNEL);
43+ vector->container = kcalloc(capacity, struct_size, GFP_KERNEL);
4444 if (vector->container == NULL)
4545 return false;
4646 vector->capacity = capacity;
@@ -67,7 +67,7 @@ bool dal_vector_presized_costruct( · 20 unmodified lines
6767 return false;
6868 }
6969
70− vector->container = kzalloc(struct_size * count, GFP_KERNEL);
70+ vector->container = kcalloc(count, struct_size, GFP_KERNEL);
7171
7272 if (vector->container == NULL)
7373 return false;
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c+4−2
@@ -1079,13 +1079,15 @@ static void get_ss_info_from_atombios( · 1078 unmodified lines
10791079 if (*ss_entries_num == 0)
10801080 return;
10811081
1082− ss_info = kzalloc(sizeof(struct spread_spectrum_info) * (*ss_entries_num),
1082+ ss_info = kcalloc(*ss_entries_num,
1083+ sizeof(struct spread_spectrum_info),
10831084 GFP_KERNEL);
10841085 ss_info_cur = ss_info;
10851086 if (ss_info == NULL)
10861087 return;
10871088
1088− ss_data = kzalloc(sizeof(struct spread_spectrum_data) * (*ss_entries_num),
1089+ ss_data = kcalloc(*ss_entries_num,
1090+ sizeof(struct spread_spectrum_data),
10891091 GFP_KERNEL);
10901092 if (ss_data == NULL)
10911093 goto out_free_info;
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c+2−1
@@ -98,7 +98,8 @@ struct gpio_service *dal_gpio_service_create( · 97 unmodified lines
9898 if (number_of_bits) {
9999 uint32_t index_of_uint = 0;
100100
101− slot = kzalloc(number_of_uints * sizeof(uint32_t),
101+ slot = kcalloc(number_of_uints,
102+ sizeof(uint32_t),
102103 GFP_KERNEL);
103104
104105 if (!slot) {
drivers/gpu/drm/amd/display/modules/color/color_gamma.c+27−20
@@ -1274,19 +1274,22 @@ bool mod_color_calculate_regamma_params(struct dc_transfer_func *output_tf, · 1273 unmodified lines
12741274
12751275 output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
12761276
1277− rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
1277+ rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS,
1278+ sizeof(*rgb_user),
12781279 GFP_KERNEL);
12791280 if (!rgb_user)
12801281 goto rgb_user_alloc_fail;
1281− rgb_regamma = kvzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
1282+ rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1283+ sizeof(*rgb_regamma),
12821284 GFP_KERNEL);
12831285 if (!rgb_regamma)
12841286 goto rgb_regamma_alloc_fail;
1285− axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + 3),
1287+ axix_x = kvcalloc(ramp->num_entries + 3, sizeof(*axix_x),
12861288 GFP_KERNEL);
12871289 if (!axix_x)
12881290 goto axix_x_alloc_fail;
1289− coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
1291+ coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff),
1292+ GFP_KERNEL);
12901293 if (!coeff)
12911294 goto coeff_alloc_fail;
12921295
@@ -1413,13 +1416,15 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf, · 120 unmodified lines
14131416
14141417 output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
14151418
1416− rgb_user = kzalloc(sizeof(*rgb_user) * (GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS),
1417− GFP_KERNEL);
1419+ rgb_user = kcalloc(GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS,
1420+ sizeof(*rgb_user),
1421+ GFP_KERNEL);
14181422 if (!rgb_user)
14191423 goto rgb_user_alloc_fail;
14201424
1421− rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
1422− GFP_KERNEL);
1425+ rgb_regamma = kcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1426+ sizeof(*rgb_regamma),
1427+ GFP_KERNEL);
14231428 if (!rgb_regamma)
14241429 goto rgb_regamma_alloc_fail;
14251430
@@ -1480,19 +1485,21 @@ bool mod_color_calculate_degamma_params(struct dc_transfer_func *input_tf, · 54 unmodified lines
14801485
14811486 input_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
14821487
1483− rgb_user = kvzalloc(sizeof(*rgb_user) * (ramp->num_entries + _EXTRA_POINTS),
1488+ rgb_user = kvcalloc(ramp->num_entries + _EXTRA_POINTS,
1489+ sizeof(*rgb_user),
14841490 GFP_KERNEL);
14851491 if (!rgb_user)
14861492 goto rgb_user_alloc_fail;
1487− curve = kvzalloc(sizeof(*curve) * (MAX_HW_POINTS + _EXTRA_POINTS),
1493+ curve = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*curve),
14881494 GFP_KERNEL);
14891495 if (!curve)
14901496 goto curve_alloc_fail;
1491− axix_x = kvzalloc(sizeof(*axix_x) * (ramp->num_entries + _EXTRA_POINTS),
1497+ axix_x = kvcalloc(ramp->num_entries + _EXTRA_POINTS, sizeof(*axix_x),
14921498 GFP_KERNEL);
14931499 if (!axix_x)
14941500 goto axix_x_alloc_fail;
1495− coeff = kvzalloc(sizeof(*coeff) * (MAX_HW_POINTS + _EXTRA_POINTS), GFP_KERNEL);
1501+ coeff = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS, sizeof(*coeff),
1502+ GFP_KERNEL);
14961503 if (!coeff)
14971504 goto coeff_alloc_fail;
14981505
@@ -1569,8 +1576,8 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, · 70 unmodified lines
15691576 }
15701577 ret = true;
15711578 } else if (trans == TRANSFER_FUNCTION_PQ) {
1572− rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
1573− (MAX_HW_POINTS + _EXTRA_POINTS),
1579+ rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1580+ sizeof(*rgb_regamma),
15741581 GFP_KERNEL);
15751582 if (!rgb_regamma)
15761583 goto rgb_regamma_alloc_fail;
@@ -1594,8 +1601,8 @@ bool mod_color_calculate_curve(enum dc_transfer_func_predefined trans, · 17 unmodified lines
15941601 kvfree(rgb_regamma);
15951602 } else if (trans == TRANSFER_FUNCTION_SRGB ||
15961603 trans == TRANSFER_FUNCTION_BT709) {
1597− rgb_regamma = kvzalloc(sizeof(*rgb_regamma) *
1598− (MAX_HW_POINTS + _EXTRA_POINTS),
1604+ rgb_regamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1605+ sizeof(*rgb_regamma),
15991606 GFP_KERNEL);
16001607 if (!rgb_regamma)
16011608 goto rgb_regamma_alloc_fail;
@@ -1638,8 +1645,8 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, · 36 unmodified lines
16381645 }
16391646 ret = true;
16401647 } else if (trans == TRANSFER_FUNCTION_PQ) {
1641− rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
1642− (MAX_HW_POINTS + _EXTRA_POINTS),
1648+ rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1649+ sizeof(*rgb_degamma),
16431650 GFP_KERNEL);
16441651 if (!rgb_degamma)
16451652 goto rgb_degamma_alloc_fail;
@@ -1658,8 +1665,8 @@ bool mod_color_calculate_degamma_curve(enum dc_transfer_func_predefined trans, · 12 unmodified lines
16581665 kvfree(rgb_degamma);
16591666 } else if (trans == TRANSFER_FUNCTION_SRGB ||
16601667 trans == TRANSFER_FUNCTION_BT709) {
1661− rgb_degamma = kvzalloc(sizeof(*rgb_degamma) *
1662− (MAX_HW_POINTS + _EXTRA_POINTS),
1668+ rgb_degamma = kvcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
1669+ sizeof(*rgb_degamma),
16631670 GFP_KERNEL);
16641671 if (!rgb_degamma)
16651672 goto rgb_degamma_alloc_fail;
drivers/gpu/drm/amd/display/modules/freesync/freesync.c+2−1
@@ -155,7 +155,8 @@ struct mod_freesync *mod_freesync_create(struct dc *dc) · 154 unmodified lines
155155 if (core_freesync == NULL)
156156 goto fail_alloc_context;
157157
158− core_freesync->map = kzalloc(sizeof(struct freesync_entity) * MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
158+ core_freesync->map = kcalloc(MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
159+ sizeof(struct freesync_entity),
159160 GFP_KERNEL);
160161
161162 if (core_freesync->map == NULL)
drivers/gpu/drm/amd/display/modules/stats/stats.c+5−7
@@ -141,19 +141,17 @@ struct mod_stats *mod_stats_create(struct dc *dc) · 140 unmodified lines
141141 else
142142 core_stats->entries = reg_data;
143143 }
144− core_stats->time = kzalloc(
145− sizeof(struct stats_time_cache) *
146− core_stats->entries,
144+ core_stats->time = kcalloc(core_stats->entries,
145+ sizeof(struct stats_time_cache),
147146 GFP_KERNEL);
148147
149148 if (core_stats->time == NULL)
150149 goto fail_construct_time;
151150
152151 core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT;
153− core_stats->events = kzalloc(
154− sizeof(struct stats_event_cache) *
155− core_stats->event_entries,
156− GFP_KERNEL);
152+ core_stats->events = kcalloc(core_stats->event_entries,
153+ sizeof(struct stats_event_cache),
154+ GFP_KERNEL);
157155
158156 if (core_stats->events == NULL)
159157 goto fail_construct_events;
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c+1−1
@@ -50,7 +50,7 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr) · 49 unmodified lines
5050 return 0;
5151 }
5252
53− hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL);
53+ hwmgr->ps = kcalloc(table_entries, size, GFP_KERNEL);
5454 if (hwmgr->ps == NULL)
5555 return -ENOMEM;
5656
drivers/gpu/drm/drm_edid.c+2−1
@@ -1633,7 +1633,8 @@ struct edid *drm_do_get_edid(struct drm_connector *connector, · 1632 unmodified lines
16331633 edid[EDID_LENGTH-1] += edid[0x7e] - valid_extensions;
16341634 edid[0x7e] = valid_extensions;
16351635
1636− new = kmalloc((valid_extensions + 1) * EDID_LENGTH, GFP_KERNEL);
1636+ new = kmalloc_array(valid_extensions + 1, EDID_LENGTH,
1637+ GFP_KERNEL);
16371638 if (!new)
16381639 goto out;
16391640
drivers/gpu/drm/drm_hashtab.c+1−1
@@ -47,7 +47,7 @@ int drm_ht_create(struct drm_open_hash *ht, unsigned int order) · 46 unmodified lines
4747 if (size <= PAGE_SIZE / sizeof(*ht->table))
4848 ht->table = kcalloc(size, sizeof(*ht->table), GFP_KERNEL);
4949 else
50− ht->table = vzalloc(size*sizeof(*ht->table));
50+ ht->table = vzalloc(array_size(size, sizeof(*ht->table)));
5151 if (!ht->table) {
5252 DRM_ERROR("Out of memory for hash table\n");
5353 return -ENOMEM;
drivers/gpu/drm/drm_memory.c+1−1
@@ -80,7 +80,7 @@ static void *agp_remap(unsigned long offset, unsigned long size, · 79 unmodified lines
8080 * page-table instead (that's probably faster anyhow...).
8181 */
8282 /* 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 *)));
8484 if (!page_map)
8585 return NULL;
8686
drivers/gpu/drm/exynos/exynos_drm_dsi.c+2−2
@@ -1723,8 +1723,8 @@ static int exynos_dsi_probe(struct platform_device *pdev) · 1722 unmodified lines
17231723 return -EPROBE_DEFER;
17241724 }
17251725
1726− dsi->clks = devm_kzalloc(dev,
1727− sizeof(*dsi->clks) * dsi->driver_data->num_clks,
1726+ dsi->clks = devm_kcalloc(dev,
1727+ dsi->driver_data->num_clks, sizeof(*dsi->clks),
17281728 GFP_KERNEL);
17291729 if (!dsi->clks)
17301730 return -ENOMEM;
drivers/gpu/drm/exynos/exynos_drm_fimc.c+2−1
@@ -1271,7 +1271,8 @@ static int fimc_probe(struct platform_device *pdev) · 1270 unmodified lines
12711271
12721272 /* construct formats/limits array */
12731273 num_formats = ARRAY_SIZE(fimc_formats) + ARRAY_SIZE(fimc_tiled_formats);
1274− formats = devm_kzalloc(dev, sizeof(*formats) * num_formats, GFP_KERNEL);
1274+ formats = devm_kcalloc(dev, num_formats, sizeof(*formats),
1275+ GFP_KERNEL);
12751276 if (!formats)
12761277 return -ENOMEM;
12771278
drivers/gpu/drm/exynos/exynos_drm_gsc.c+3−2
@@ -1202,8 +1202,9 @@ static int gsc_probe(struct platform_device *pdev) · 1201 unmodified lines
12021202 if (!ctx)
12031203 return -ENOMEM;
12041204
1205− formats = devm_kzalloc(dev, sizeof(*formats) *
1206− (ARRAY_SIZE(gsc_formats)), GFP_KERNEL);
1205+ formats = devm_kcalloc(dev,
1206+ ARRAY_SIZE(gsc_formats), sizeof(*formats),
1207+ GFP_KERNEL);
12071208 if (!formats)
12081209 return -ENOMEM;
12091210
drivers/gpu/drm/exynos/exynos_hdmi.c+1−1
@@ -1692,7 +1692,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata) · 1691 unmodified lines
16921692 if (!count)
16931693 return 0;
16941694
1695− clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL);
1695+ clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL);
16961696 if (!clks)
16971697 return -ENOMEM;
16981698
drivers/gpu/drm/gma500/mid_bios.c+1−1
@@ -239,7 +239,7 @@ static int mid_get_vbt_data_r10(struct drm_psb_private *dev_priv, u32 addr) · 238 unmodified lines
239239 if (read_vbt_r10(addr, &vbt))
240240 return -1;
241241
242− gct = kmalloc(sizeof(*gct) * vbt.panel_count, GFP_KERNEL);
242+ gct = kmalloc_array(vbt.panel_count, sizeof(*gct), GFP_KERNEL);
243243 if (!gct)
244244 return -ENOMEM;
245245
drivers/gpu/drm/i915/gvt/gtt.c+3−2
@@ -1585,8 +1585,9 @@ static struct intel_vgpu_mm *intel_vgpu_create_ggtt_mm(struct intel_vgpu *vgpu) · 1584 unmodified lines
15851585 mm->type = INTEL_GVT_MM_GGTT;
15861586
15871587 nr_entries = gvt_ggtt_gm_sz(vgpu->gvt) >> I915_GTT_PAGE_SHIFT;
1588− mm->ggtt_mm.virtual_ggtt = vzalloc(nr_entries *
1589− vgpu->gvt->device_info.gtt_entry_size);
1588+ mm->ggtt_mm.virtual_ggtt =
1589+ vzalloc(array_size(nr_entries,
1590+ vgpu->gvt->device_info.gtt_entry_size));
15901591 if (!mm->ggtt_mm.virtual_ggtt) {
15911592 vgpu_free_mm(mm);
15921593 return ERR_PTR(-ENOMEM);
drivers/gpu/drm/i915/gvt/mmio.c+1−1
@@ -267,7 +267,7 @@ int intel_vgpu_init_mmio(struct intel_vgpu *vgpu) · 266 unmodified lines
267267 {
268268 const struct intel_gvt_device_info *info = &vgpu->gvt->device_info;
269269
270− vgpu->mmio.vreg = vzalloc(info->mmio_size * 2);
270+ vgpu->mmio.vreg = vzalloc(array_size(info->mmio_size, 2));
271271 if (!vgpu->mmio.vreg)
272272 return -ENOMEM;
273273
drivers/gpu/drm/i915/gvt/vgpu.c+1−1
@@ -121,7 +121,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt) · 120 unmodified lines
121121 high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE;
122122 num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]);
123123
124− gvt->types = kzalloc(num_types * sizeof(struct intel_vgpu_type),
124+ gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type),
125125 GFP_KERNEL);
126126 if (!gvt->types)
127127 return -ENOMEM;
drivers/gpu/drm/i915/intel_hdcp.c+1−1
@@ -429,7 +429,7 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port, · 428 unmodified lines
429429 if (num_downstream == 0)
430430 return -EINVAL;
431431
432− ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL);
432+ ksv_fifo = kcalloc(DRM_HDCP_KSV_LEN, num_downstream, GFP_KERNEL);
433433 if (!ksv_fifo)
434434 return -ENOMEM;
435435
drivers/gpu/drm/i915/selftests/intel_uncore.c+1−1
@@ -137,7 +137,7 @@ static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_pri · 136 unmodified lines
137137 if (!IS_ENABLED(CONFIG_DRM_I915_SELFTEST_BROKEN))
138138 return 0;
139139
140− valid = kzalloc(BITS_TO_LONGS(FW_RANGE) * sizeof(*valid),
140+ valid = kcalloc(BITS_TO_LONGS(FW_RANGE), sizeof(*valid),
141141 GFP_KERNEL);
142142 if (!valid)
143143 return -ENOMEM;
drivers/gpu/drm/msm/hdmi/hdmi.c+16−8
@@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) · 156 unmodified lines
157157 hdmi->qfprom_mmio = NULL;
158158 }
159159
160− hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) *
161− config->hpd_reg_cnt, GFP_KERNEL);
160+ hdmi->hpd_regs = devm_kcalloc(&pdev->dev,
161+ config->hpd_reg_cnt,
162+ sizeof(hdmi->hpd_regs[0]),
163+ GFP_KERNEL);
162164 if (!hdmi->hpd_regs) {
163165 ret = -ENOMEM;
164166 goto fail;
@@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) · 13 unmodified lines
178180 hdmi->hpd_regs[i] = reg;
179181 }
180182
181− hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) *
182− config->pwr_reg_cnt, GFP_KERNEL);
183+ hdmi->pwr_regs = devm_kcalloc(&pdev->dev,
184+ config->pwr_reg_cnt,
185+ sizeof(hdmi->pwr_regs[0]),
186+ GFP_KERNEL);
183187 if (!hdmi->pwr_regs) {
184188 ret = -ENOMEM;
185189 goto fail;
@@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) · 13 unmodified lines
199203 hdmi->pwr_regs[i] = reg;
200204 }
201205
202− hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) *
203− config->hpd_clk_cnt, GFP_KERNEL);
206+ hdmi->hpd_clks = devm_kcalloc(&pdev->dev,
207+ config->hpd_clk_cnt,
208+ sizeof(hdmi->hpd_clks[0]),
209+ GFP_KERNEL);
204210 if (!hdmi->hpd_clks) {
205211 ret = -ENOMEM;
206212 goto fail;
@@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) · 12 unmodified lines
219225 hdmi->hpd_clks[i] = clk;
220226 }
221227
222− hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) *
223− config->pwr_clk_cnt, GFP_KERNEL);
228+ hdmi->pwr_clks = devm_kcalloc(&pdev->dev,
229+ config->pwr_clk_cnt,
230+ sizeof(hdmi->pwr_clks[0]),
231+ GFP_KERNEL);
224232 if (!hdmi->pwr_clks) {
225233 ret = -ENOMEM;
226234 goto fail;
drivers/gpu/drm/msm/hdmi/hdmi_phy.c+2−2
@@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy) · 20 unmodified lines
2121 struct device *dev = &phy->pdev->dev;
2222 int i, ret;
2323
24− phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs,
24+ phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]),
2525 GFP_KERNEL);
2626 if (!phy->regs)
2727 return -ENOMEM;
2828
29− phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks,
29+ phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]),
3030 GFP_KERNEL);
3131 if (!phy->clks)
3232 return -ENOMEM;
drivers/gpu/drm/nouveau/nv84_fence.c+1−1
@@ -141,7 +141,7 @@ nv84_fence_suspend(struct nouveau_drm *drm) · 140 unmodified lines
141141 struct nv84_fence_priv *priv = drm->fence;
142142 int i;
143143
144− priv->suspend = vmalloc(drm->chan.nr * sizeof(u32));
144+ priv->suspend = vmalloc(array_size(sizeof(u32), drm->chan.nr));
145145 if (priv->suspend) {
146146 for (i = 0; i < drm->chan.nr; i++)
147147 priv->suspend[i] = nouveau_bo_rd32(priv->bo, i*4);
drivers/gpu/drm/nouveau/nvif/fifo.c+2−2
@@ -50,8 +50,8 @@ nvif_fifo_runlists(struct nvif_device *device) · 49 unmodified lines
5050 goto done;
5151
5252 device->runlists = fls64(a->v.runlists.data);
53− device->runlist = kzalloc(sizeof(*device->runlist) *
54− device->runlists, GFP_KERNEL);
53+ device->runlist = kcalloc(device->runlists, sizeof(*device->runlist),
54+ GFP_KERNEL);
5555 if (!device->runlist) {
5656 ret = -ENOMEM;
5757 goto done;
drivers/gpu/drm/nouveau/nvif/mmu.c+6−3
@@ -65,12 +65,15 @@ nvif_mmu_init(struct nvif_object *parent, s32 oclass, struct nvif_mmu *mmu) · 64 unmodified lines
6565 goto done;
6666 mmu->mem = mems[ret].oclass;
6767
68− mmu->heap = kmalloc(sizeof(*mmu->heap) * mmu->heap_nr, GFP_KERNEL);
69− mmu->type = kmalloc(sizeof(*mmu->type) * mmu->type_nr, GFP_KERNEL);
68+ mmu->heap = kmalloc_array(mmu->heap_nr, sizeof(*mmu->heap),
69+ GFP_KERNEL);
70+ mmu->type = kmalloc_array(mmu->type_nr, sizeof(*mmu->type),
71+ GFP_KERNEL);
7072 if (ret = -ENOMEM, !mmu->heap || !mmu->type)
7173 goto done;
7274
73− mmu->kind = kmalloc(sizeof(*mmu->kind) * mmu->kind_nr, GFP_KERNEL);
75+ mmu->kind = kmalloc_array(mmu->kind_nr, sizeof(*mmu->kind),
76+ GFP_KERNEL);
7477 if (!mmu->kind && mmu->kind_nr)
7578 goto done;
7679
drivers/gpu/drm/nouveau/nvif/object.c+1−1
@@ -83,7 +83,7 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass) · 82 unmodified lines
8383 return ret;
8484 }
8585
86− *psclass = kzalloc(sizeof(**psclass) * args->sclass.count, GFP_KERNEL);
86+ *psclass = kcalloc(args->sclass.count, sizeof(**psclass), GFP_KERNEL);
8787 if (*psclass) {
8888 for (i = 0; i < args->sclass.count; i++) {
8989 (*psclass)[i].oclass = args->sclass.oclass[i].oclass;
drivers/gpu/drm/nouveau/nvif/vmm.c+2−1
@@ -138,7 +138,8 @@ nvif_vmm_init(struct nvif_mmu *mmu, s32 oclass, u64 addr, u64 size, · 137 unmodified lines
138138 vmm->limit = args->size;
139139
140140 vmm->page_nr = args->page_nr;
141− vmm->page = kmalloc(sizeof(*vmm->page) * vmm->page_nr, GFP_KERNEL);
141+ vmm->page = kmalloc_array(vmm->page_nr, sizeof(*vmm->page),
142+ GFP_KERNEL);
142143 if (!vmm->page) {
143144 ret = -ENOMEM;
144145 goto done;
drivers/gpu/drm/nouveau/nvkm/core/event.c+2−1
@@ -84,7 +84,8 @@ int · 83 unmodified lines
8484 nvkm_event_init(const struct nvkm_event_func *func, int types_nr, int index_nr,
8585 struct nvkm_event *event)
8686 {
87− event->refs = kzalloc(sizeof(*event->refs) * index_nr * types_nr,
87+ event->refs = kzalloc(array3_size(index_nr, types_nr,
88+ sizeof(*event->refs)),
8889 GFP_KERNEL);
8990 if (!event->refs)
9091 return -ENOMEM;
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c+1−1
@@ -910,7 +910,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base) · 909 unmodified lines
910910 nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr);
911911
912912 /* Read PBDMA->runlist(s) mapping from HW. */
913− if (!(map = kzalloc(sizeof(*map) * fifo->pbdma_nr, GFP_KERNEL)))
913+ if (!(map = kcalloc(fifo->pbdma_nr, sizeof(*map), GFP_KERNEL)))
914914 return -ENOMEM;
915915
916916 for (i = 0; i < fifo->pbdma_nr; i++)
drivers/gpu/drm/nouveau/nvkm/subdev/bios/iccsense.c+2−1
@@ -73,7 +73,8 @@ nvbios_iccsense_parse(struct nvkm_bios *bios, struct nvbios_iccsense *iccsense) · 72 unmodified lines
7373 }
7474
7575 iccsense->nr_entry = cnt;
76− iccsense->rail = kmalloc(sizeof(struct pwr_rail_t) * cnt, GFP_KERNEL);
76+ iccsense->rail = kmalloc_array(cnt, sizeof(struct pwr_rail_t),
77+ GFP_KERNEL);
7778 if (!iccsense->rail)
7879 return -ENOMEM;
7980
drivers/gpu/drm/nouveau/nvkm/subdev/fb/ramgt215.c+1−1
@@ -171,7 +171,7 @@ gt215_link_train(struct gt215_ram *ram) · 170 unmodified lines
171171 return -ENOSYS;
172172
173173 /* XXX: Multiple partitions? */
174− result = kmalloc(64 * sizeof(u32), GFP_KERNEL);
174+ result = kmalloc_array(64, sizeof(u32), GFP_KERNEL);
175175 if (!result)
176176 return -ENOMEM;
177177
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/mem.c+2−2
@@ -191,9 +191,9 @@ nvkm_mem_new_host(struct nvkm_mmu *mmu, int type, u8 page, u64 size, · 190 unmodified lines
191191 nvkm_memory_ctor(&nvkm_mem_dma, &mem->memory);
192192 size = ALIGN(size, PAGE_SIZE) >> PAGE_SHIFT;
193193
194− if (!(mem->mem = kvmalloc(sizeof(*mem->mem) * size, GFP_KERNEL)))
194+ if (!(mem->mem = kvmalloc_array(size, sizeof(*mem->mem), GFP_KERNEL)))
195195 return -ENOMEM;
196− if (!(mem->dma = kvmalloc(sizeof(*mem->dma) * size, GFP_KERNEL)))
196+ if (!(mem->dma = kvmalloc_array(size, sizeof(*mem->dma), GFP_KERNEL)))
197197 return -ENOMEM;
198198
199199 if (mmu->dma_bits > 32)
drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c+1−1
@@ -59,7 +59,7 @@ nvkm_vmm_pt_new(const struct nvkm_vmm_desc *desc, bool sparse, · 58 unmodified lines
5959 pgt->sparse = sparse;
6060
6161 if (desc->type == PGD) {
62− pgt->pde = kvzalloc(sizeof(*pgt->pde) * pten, GFP_KERNEL);
62+ pgt->pde = kvcalloc(pten, sizeof(*pgt->pde), GFP_KERNEL);
6363 if (!pgt->pde) {
6464 kfree(pgt);
6565 return NULL;
drivers/gpu/drm/omapdrm/omap_dmm_tiler.c+2−2
@@ -940,8 +940,8 @@ int tiler_map_show(struct seq_file *s, void *arg) · 939 unmodified lines
940940 h_adj = omap_dmm->container_height / ydiv;
941941 w_adj = omap_dmm->container_width / xdiv;
942942
943− map = kmalloc(h_adj * sizeof(*map), GFP_KERNEL);
944− global_map = kmalloc((w_adj + 1) * h_adj, GFP_KERNEL);
943+ map = kmalloc_array(h_adj, sizeof(*map), GFP_KERNEL);
944+ global_map = kmalloc_array(w_adj + 1, h_adj, GFP_KERNEL);
945945
946946 if (!map || !global_map)
947947 goto error;
drivers/gpu/drm/omapdrm/omap_gem.c+2−2
@@ -244,7 +244,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj) · 243 unmodified lines
244244 * DSS, GPU, etc. are not cache coherent:
245245 */
246246 if (omap_obj->flags & (OMAP_BO_WC|OMAP_BO_UNCACHED)) {
247− addrs = kmalloc(npages * sizeof(*addrs), GFP_KERNEL);
247+ addrs = kmalloc_array(npages, sizeof(*addrs), GFP_KERNEL);
248248 if (!addrs) {
249249 ret = -ENOMEM;
250250 goto free_pages;
@@ -268,7 +268,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj) · 17 unmodified lines
268268 }
269269 }
270270 } else {
271− addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
271+ addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL);
272272 if (!addrs) {
273273 ret = -ENOMEM;
274274 goto free_pages;
drivers/gpu/drm/qxl/qxl_fb.c+1−1
@@ -241,7 +241,7 @@ static int qxlfb_create(struct qxl_fbdev *qfbdev, · 240 unmodified lines
241241 DRM_DEBUG_DRIVER("%dx%d %d\n", mode_cmd.width,
242242 mode_cmd.height, mode_cmd.pitches[0]);
243243
244− shadow = vmalloc(mode_cmd.pitches[0] * mode_cmd.height);
244+ shadow = vmalloc(array_size(mode_cmd.pitches[0], mode_cmd.height));
245245 /* TODO: what's the usual response to memory allocation errors? */
246246 BUG_ON(!shadow);
247247 DRM_DEBUG_DRIVER("surface0 at gpu offset %lld, mmap_offset %lld (virt %p, shadow %p)\n",
drivers/gpu/drm/qxl/qxl_kms.c+2−2
@@ -200,8 +200,8 @@ int qxl_device_init(struct qxl_device *qdev, · 199 unmodified lines
200200 (~(uint64_t)0) >> (qdev->slot_id_bits + qdev->slot_gen_bits);
201201
202202 qdev->mem_slots =
203− kmalloc(qdev->n_mem_slots * sizeof(struct qxl_memslot),
204− GFP_KERNEL);
203+ kmalloc_array(qdev->n_mem_slots, sizeof(struct qxl_memslot),
204+ GFP_KERNEL);
205205
206206 idr_init(&qdev->release_idr);
207207 spin_lock_init(&qdev->release_idr_lock);
drivers/gpu/drm/radeon/atom.c+1−1
@@ -1176,7 +1176,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32 · 1175 unmodified lines
11761176 ectx.abort = false;
11771177 ectx.last_jump = 0;
11781178 if (ws)
1179− ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
1179+ ectx.ws = kcalloc(4, ws, GFP_KERNEL);
11801180 else
11811181 ectx.ws = NULL;
11821182
drivers/gpu/drm/radeon/btc_dpm.c+3−1
@@ -2581,7 +2581,9 @@ int btc_dpm_init(struct radeon_device *rdev) · 2580 unmodified lines
25812581 return ret;
25822582
25832583 rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
2584− kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
2584+ kcalloc(4,
2585+ sizeof(struct radeon_clock_voltage_dependency_entry),
2586+ GFP_KERNEL);
25852587 if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
25862588 r600_free_extended_power_table(rdev);
25872589 return -ENOMEM;
drivers/gpu/drm/radeon/ci_dpm.c+6−3
@@ -5568,8 +5568,9 @@ static int ci_parse_power_table(struct radeon_device *rdev) · 5567 unmodified lines
55685568 (mode_info->atom_context->bios + data_offset +
55695569 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
55705570
5571− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
5572− state_array->ucNumEntries, GFP_KERNEL);
5571+ rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
5572+ sizeof(struct radeon_ps),
5573+ GFP_KERNEL);
55735574 if (!rdev->pm.dpm.ps)
55745575 return -ENOMEM;
55755576 power_state_offset = (u8 *)state_array->states;
@@ -5770,7 +5771,9 @@ int ci_dpm_init(struct radeon_device *rdev) · 194 unmodified lines
57705771 ci_set_private_data_variables_based_on_pptable(rdev);
57715772
57725773 rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
5773− kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
5774+ kcalloc(4,
5775+ sizeof(struct radeon_clock_voltage_dependency_entry),
5776+ GFP_KERNEL);
57745777 if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
57755778 ci_dpm_fini(rdev);
57765779 return -ENOMEM;
drivers/gpu/drm/radeon/kv_dpm.c+3−2
@@ -2660,8 +2660,9 @@ static int kv_parse_power_table(struct radeon_device *rdev) · 2659 unmodified lines
26602660 (mode_info->atom_context->bios + data_offset +
26612661 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
26622662
2663− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
2664− state_array->ucNumEntries, GFP_KERNEL);
2663+ rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
2664+ sizeof(struct radeon_ps),
2665+ GFP_KERNEL);
26652666 if (!rdev->pm.dpm.ps)
26662667 return -ENOMEM;
26672668 power_state_offset = (u8 *)state_array->states;
drivers/gpu/drm/radeon/ni_dpm.c+6−3
@@ -3998,8 +3998,9 @@ static int ni_parse_power_table(struct radeon_device *rdev) · 3997 unmodified lines
39983998 return -EINVAL;
39993999 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
40004000
4001− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
4002− power_info->pplib.ucNumStates, GFP_KERNEL);
4001+ rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
4002+ sizeof(struct radeon_ps),
4003+ GFP_KERNEL);
40034004 if (!rdev->pm.dpm.ps)
40044005 return -ENOMEM;
40054006
@@ -4075,7 +4076,9 @@ int ni_dpm_init(struct radeon_device *rdev) · 69 unmodified lines
40754076 return ret;
40764077
40774078 rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
4078− kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
4079+ kcalloc(4,
4080+ sizeof(struct radeon_clock_voltage_dependency_entry),
4081+ GFP_KERNEL);
40794082 if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
40804083 r600_free_extended_power_table(rdev);
40814084 return -ENOMEM;
drivers/gpu/drm/radeon/r600_dpm.c+1−1
@@ -991,7 +991,7 @@ int r600_parse_extended_power_table(struct radeon_device *rdev) · 990 unmodified lines
991991 ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
992992
993993 rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
994− kzalloc(psl->ucNumEntries *
994+ kcalloc(psl->ucNumEntries,
995995 sizeof(struct radeon_phase_shedding_limits_entry),
996996 GFP_KERNEL);
997997 if (!rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
drivers/gpu/drm/radeon/radeon_atombios.c+24−15
@@ -2126,13 +2126,16 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev) · 2125 unmodified lines
21262126 num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
21272127 if (num_modes == 0)
21282128 return state_index;
2129− rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * num_modes, GFP_KERNEL);
2129+ rdev->pm.power_state = kcalloc(num_modes,
2130+ sizeof(struct radeon_power_state),
2131+ GFP_KERNEL);
21302132 if (!rdev->pm.power_state)
21312133 return state_index;
21322134 /* last mode is usually default, array is low to high */
21332135 for (i = 0; i < num_modes; i++) {
21342136 rdev->pm.power_state[state_index].clock_info =
2135− kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
2137+ kcalloc(1, sizeof(struct radeon_pm_clock_info),
2138+ GFP_KERNEL);
21362139 if (!rdev->pm.power_state[state_index].clock_info)
21372140 return state_index;
21382141 rdev->pm.power_state[state_index].num_clock_modes = 1;
@@ -2587,8 +2590,9 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev) · 448 unmodified lines
25872590 radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController);
25882591 if (power_info->pplib.ucNumStates == 0)
25892592 return state_index;
2590− rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
2591− power_info->pplib.ucNumStates, GFP_KERNEL);
2593+ rdev->pm.power_state = kcalloc(power_info->pplib.ucNumStates,
2594+ sizeof(struct radeon_power_state),
2595+ GFP_KERNEL);
25922596 if (!rdev->pm.power_state)
25932597 return state_index;
25942598 /* first mode is usually default, followed by low to high */
@@ -2603,10 +2607,11 @@ static int radeon_atombios_parse_power_table_4_5(struct radeon_device *rdev) · 8 unmodified lines
26032607 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset) +
26042608 (power_state->v1.ucNonClockStateIndex *
26052609 power_info->pplib.ucNonClockSize));
2606− rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
2607− ((power_info->pplib.ucStateEntrySize - 1) ?
2608− (power_info->pplib.ucStateEntrySize - 1) : 1),
2609− GFP_KERNEL);
2610+ rdev->pm.power_state[i].clock_info =
2611+ kcalloc((power_info->pplib.ucStateEntrySize - 1) ?
2612+ (power_info->pplib.ucStateEntrySize - 1) : 1,
2613+ sizeof(struct radeon_pm_clock_info),
2614+ GFP_KERNEL);
26102615 if (!rdev->pm.power_state[i].clock_info)
26112616 return state_index;
26122617 if (power_info->pplib.ucStateEntrySize - 1) {
@@ -2688,8 +2693,9 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev) · 75 unmodified lines
26882693 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
26892694 if (state_array->ucNumEntries == 0)
26902695 return state_index;
2691− rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
2692− state_array->ucNumEntries, GFP_KERNEL);
2696+ rdev->pm.power_state = kcalloc(state_array->ucNumEntries,
2697+ sizeof(struct radeon_power_state),
2698+ GFP_KERNEL);
26932699 if (!rdev->pm.power_state)
26942700 return state_index;
26952701 power_state_offset = (u8 *)state_array->states;
@@ -2699,10 +2705,11 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev) · 3 unmodified lines
26992705 non_clock_array_index = power_state->v2.nonClockInfoIndex;
27002706 non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
27012707 &non_clock_info_array->nonClockInfo[non_clock_array_index];
2702− rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
2703− (power_state->v2.ucNumDPMLevels ?
2704− power_state->v2.ucNumDPMLevels : 1),
2705− GFP_KERNEL);
2708+ rdev->pm.power_state[i].clock_info =
2709+ kcalloc(power_state->v2.ucNumDPMLevels ?
2710+ power_state->v2.ucNumDPMLevels : 1,
2711+ sizeof(struct radeon_pm_clock_info),
2712+ GFP_KERNEL);
27062713 if (!rdev->pm.power_state[i].clock_info)
27072714 return state_index;
27082715 if (power_state->v2.ucNumDPMLevels) {
@@ -2782,7 +2789,9 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev) · 73 unmodified lines
27822789 rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL);
27832790 if (rdev->pm.power_state) {
27842791 rdev->pm.power_state[0].clock_info =
2785− kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
2792+ kcalloc(1,
2793+ sizeof(struct radeon_pm_clock_info),
2794+ GFP_KERNEL);
27862795 if (rdev->pm.power_state[0].clock_info) {
27872796 /* add the default mode */
27882797 rdev->pm.power_state[state_index].type =
drivers/gpu/drm/radeon/radeon_combios.c+6−3
@@ -2642,13 +2642,16 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev) · 2641 unmodified lines
26422642 rdev->pm.default_power_state_index = -1;
26432643
26442644 /* allocate 2 power states */
2645− rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL);
2645+ rdev->pm.power_state = kcalloc(2, sizeof(struct radeon_power_state),
2646+ GFP_KERNEL);
26462647 if (rdev->pm.power_state) {
26472648 /* allocate 1 clock mode per state */
26482649 rdev->pm.power_state[0].clock_info =
2649− kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
2650+ kcalloc(1, sizeof(struct radeon_pm_clock_info),
2651+ GFP_KERNEL);
26502652 rdev->pm.power_state[1].clock_info =
2651− kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
2653+ kcalloc(1, sizeof(struct radeon_pm_clock_info),
2654+ GFP_KERNEL);
26522655 if (!rdev->pm.power_state[0].clock_info ||
26532656 !rdev->pm.power_state[1].clock_info)
26542657 goto pm_failed;
drivers/gpu/drm/radeon/radeon_gart.c+4−3
@@ -347,13 +347,14 @@ int radeon_gart_init(struct radeon_device *rdev) · 346 unmodified lines
347347 DRM_INFO("GART: num cpu pages %u, num gpu pages %u\n",
348348 rdev->gart.num_cpu_pages, rdev->gart.num_gpu_pages);
349349 /* Allocate pages table */
350− rdev->gart.pages = vzalloc(sizeof(void *) * rdev->gart.num_cpu_pages);
350+ rdev->gart.pages = vzalloc(array_size(sizeof(void *),
351+ rdev->gart.num_cpu_pages));
351352 if (rdev->gart.pages == NULL) {
352353 radeon_gart_fini(rdev);
353354 return -ENOMEM;
354355 }
355− rdev->gart.pages_entry = vmalloc(sizeof(uint64_t) *
356− rdev->gart.num_gpu_pages);
356+ rdev->gart.pages_entry = vmalloc(array_size(sizeof(uint64_t),
357+ rdev->gart.num_gpu_pages));
357358 if (rdev->gart.pages_entry == NULL) {
358359 radeon_gart_fini(rdev);
359360 return -ENOMEM;
drivers/gpu/drm/radeon/radeon_test.c+1−1
@@ -59,7 +59,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag) · 58 unmodified lines
5959 n = rdev->mc.gtt_size - rdev->gart_pin_size;
6060 n /= size;
6161
62− gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
62+ gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
6363 if (!gtt_obj) {
6464 DRM_ERROR("Failed to allocate %d pointers\n", n);
6565 r = 1;
drivers/gpu/drm/radeon/rs780_dpm.c+3−2
@@ -804,8 +804,9 @@ static int rs780_parse_power_table(struct radeon_device *rdev) · 803 unmodified lines
804804 return -EINVAL;
805805 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
806806
807− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
808− power_info->pplib.ucNumStates, GFP_KERNEL);
807+ rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
808+ sizeof(struct radeon_ps),
809+ GFP_KERNEL);
809810 if (!rdev->pm.dpm.ps)
810811 return -ENOMEM;
811812
drivers/gpu/drm/radeon/rv6xx_dpm.c+3−2
@@ -1888,8 +1888,9 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev) · 1887 unmodified lines
18881888 return -EINVAL;
18891889 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
18901890
1891− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
1892− power_info->pplib.ucNumStates, GFP_KERNEL);
1891+ rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
1892+ sizeof(struct radeon_ps),
1893+ GFP_KERNEL);
18931894 if (!rdev->pm.dpm.ps)
18941895 return -ENOMEM;
18951896
drivers/gpu/drm/radeon/rv770_dpm.c+3−2
@@ -2282,8 +2282,9 @@ int rv7xx_parse_power_table(struct radeon_device *rdev) · 2281 unmodified lines
22822282 return -EINVAL;
22832283 power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
22842284
2285− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
2286− power_info->pplib.ucNumStates, GFP_KERNEL);
2285+ rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
2286+ sizeof(struct radeon_ps),
2287+ GFP_KERNEL);
22872288 if (!rdev->pm.dpm.ps)
22882289 return -ENOMEM;
22892290
drivers/gpu/drm/radeon/si_dpm.c+6−3
@@ -6832,8 +6832,9 @@ static int si_parse_power_table(struct radeon_device *rdev) · 6831 unmodified lines
68326832 (mode_info->atom_context->bios + data_offset +
68336833 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
68346834
6835− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
6836− state_array->ucNumEntries, GFP_KERNEL);
6835+ rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
6836+ sizeof(struct radeon_ps),
6837+ GFP_KERNEL);
68376838 if (!rdev->pm.dpm.ps)
68386839 return -ENOMEM;
68396840 power_state_offset = (u8 *)state_array->states;
@@ -6941,7 +6942,9 @@ int si_dpm_init(struct radeon_device *rdev) · 101 unmodified lines
69416942 return ret;
69426943
69436944 rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
6944− kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
6945+ kcalloc(4,
6946+ sizeof(struct radeon_clock_voltage_dependency_entry),
6947+ GFP_KERNEL);
69456948 if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
69466949 r600_free_extended_power_table(rdev);
69476950 return -ENOMEM;
drivers/gpu/drm/radeon/sumo_dpm.c+3−2
@@ -1482,8 +1482,9 @@ static int sumo_parse_power_table(struct radeon_device *rdev) · 1481 unmodified lines
14821482 (mode_info->atom_context->bios + data_offset +
14831483 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
14841484
1485− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
1486− state_array->ucNumEntries, GFP_KERNEL);
1485+ rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
1486+ sizeof(struct radeon_ps),
1487+ GFP_KERNEL);
14871488 if (!rdev->pm.dpm.ps)
14881489 return -ENOMEM;
14891490 power_state_offset = (u8 *)state_array->states;
drivers/gpu/drm/radeon/trinity_dpm.c+3−2
@@ -1757,8 +1757,9 @@ static int trinity_parse_power_table(struct radeon_device *rdev) · 1756 unmodified lines
17571757 (mode_info->atom_context->bios + data_offset +
17581758 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
17591759
1760− rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
1761− state_array->ucNumEntries, GFP_KERNEL);
1760+ rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
1761+ sizeof(struct radeon_ps),
1762+ GFP_KERNEL);
17621763 if (!rdev->pm.dpm.ps)
17631764 return -ENOMEM;
17641765 power_state_offset = (u8 *)state_array->states;
drivers/gpu/drm/savage/savage_bci.c+3−2
@@ -298,8 +298,9 @@ static int savage_dma_init(drm_savage_private_t * dev_priv) · 297 unmodified lines
298298
299299 dev_priv->nr_dma_pages = dev_priv->cmd_dma->size /
300300 (SAVAGE_DMA_PAGE_SIZE * 4);
301− dev_priv->dma_pages = kmalloc(sizeof(drm_savage_dma_page_t) *
302− dev_priv->nr_dma_pages, GFP_KERNEL);
301+ dev_priv->dma_pages = kmalloc_array(dev_priv->nr_dma_pages,
302+ sizeof(drm_savage_dma_page_t),
303+ GFP_KERNEL);
303304 if (dev_priv->dma_pages == NULL)
304305 return -ENOMEM;
305306
drivers/gpu/drm/selftests/test-drm_mm.c+12−12
@@ -389,7 +389,7 @@ static int __igt_reserve(unsigned int count, u64 size) · 388 unmodified lines
389389 if (!order)
390390 goto err;
391391
392− nodes = vzalloc(sizeof(*nodes) * count);
392+ nodes = vzalloc(array_size(count, sizeof(*nodes)));
393393 if (!nodes)
394394 goto err_order;
395395
@@ -579,7 +579,7 @@ static int __igt_insert(unsigned int count, u64 size, bool replace) · 183 unmodified lines
579579 DRM_MM_BUG_ON(!size);
580580
581581 ret = -ENOMEM;
582− nodes = vmalloc(count * sizeof(*nodes));
582+ nodes = vmalloc(array_size(count, sizeof(*nodes)));
583583 if (!nodes)
584584 goto err;
585585
@@ -889,7 +889,7 @@ static int __igt_insert_range(unsigned int count, u64 size, u64 start, u64 end) · 303 unmodified lines
889889 */
890890
891891 ret = -ENOMEM;
892− nodes = vzalloc(count * sizeof(*nodes));
892+ nodes = vzalloc(array_size(count, sizeof(*nodes)));
893893 if (!nodes)
894894 goto err;
895895
@@ -1046,7 +1046,7 @@ static int igt_align(void *ignored) · 150 unmodified lines
10461046 * meets our requirements.
10471047 */
10481048
1049− nodes = vzalloc(max_count * sizeof(*nodes));
1049+ nodes = vzalloc(array_size(max_count, sizeof(*nodes)));
10501050 if (!nodes)
10511051 goto err;
10521052
@@ -1416,7 +1416,7 @@ static int igt_evict(void *ignored) · 363 unmodified lines
14161416 */
14171417
14181418 ret = -ENOMEM;
1419− nodes = vzalloc(size * sizeof(*nodes));
1419+ nodes = vzalloc(array_size(size, sizeof(*nodes)));
14201420 if (!nodes)
14211421 goto err;
14221422
@@ -1526,7 +1526,7 @@ static int igt_evict_range(void *ignored) · 103 unmodified lines
15261526 */
15271527
15281528 ret = -ENOMEM;
1529− nodes = vzalloc(size * sizeof(*nodes));
1529+ nodes = vzalloc(array_size(size, sizeof(*nodes)));
15301530 if (!nodes)
15311531 goto err;
15321532
@@ -1627,11 +1627,11 @@ static int igt_topdown(void *ignored) · 94 unmodified lines
16271627 */
16281628
16291629 ret = -ENOMEM;
1630− nodes = vzalloc(count * sizeof(*nodes));
1630+ nodes = vzalloc(array_size(count, sizeof(*nodes)));
16311631 if (!nodes)
16321632 goto err;
16331633
1634− bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
1634+ bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
16351635 GFP_KERNEL);
16361636 if (!bitmap)
16371637 goto err_nodes;
@@ -1741,11 +1741,11 @@ static int igt_bottomup(void *ignored) · 103 unmodified lines
17411741 */
17421742
17431743 ret = -ENOMEM;
1744− nodes = vzalloc(count * sizeof(*nodes));
1744+ nodes = vzalloc(array_size(count, sizeof(*nodes)));
17451745 if (!nodes)
17461746 goto err;
17471747
1748− bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
1748+ bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
17491749 GFP_KERNEL);
17501750 if (!bitmap)
17511751 goto err_nodes;
@@ -2098,7 +2098,7 @@ static int igt_color_evict(void *ignored) · 346 unmodified lines
20982098 */
20992099
21002100 ret = -ENOMEM;
2101− nodes = vzalloc(total_size * sizeof(*nodes));
2101+ nodes = vzalloc(array_size(total_size, sizeof(*nodes)));
21022102 if (!nodes)
21032103 goto err;
21042104
@@ -2199,7 +2199,7 @@ static int igt_color_evict_range(void *ignored) · 94 unmodified lines
21992199 */
22002200
22012201 ret = -ENOMEM;
2202− nodes = vzalloc(total_size * sizeof(*nodes));
2202+ nodes = vzalloc(array_size(total_size, sizeof(*nodes)));
22032203 if (!nodes)
22042204 goto err;
22052205
drivers/gpu/drm/tinydrm/repaper.c+1−1
@@ -548,7 +548,7 @@ static int repaper_fb_dirty(struct drm_framebuffer *fb, · 547 unmodified lines
548548 DRM_DEBUG("Flushing [FB:%d] st=%ums\n", fb->base.id,
549549 epd->factored_stage_time);
550550
551− buf = kmalloc(fb->width * fb->height, GFP_KERNEL);
551+ buf = kmalloc_array(fb->width, fb->height, GFP_KERNEL);
552552 if (!buf)
553553 return -ENOMEM;
554554
drivers/gpu/drm/ttm/ttm_page_alloc.c+5−3
@@ -348,8 +348,9 @@ static int ttm_page_pool_free(struct ttm_page_pool *pool, unsigned nr_free, · 347 unmodified lines
348348 if (use_static)
349349 pages_to_free = static_buf;
350350 else
351− pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
352− GFP_KERNEL);
351+ pages_to_free = kmalloc_array(npages_to_free,
352+ sizeof(struct page *),
353+ GFP_KERNEL);
353354 if (!pages_to_free) {
354355 pr_debug("Failed to allocate memory for pool free operation\n");
355356 return 0;
@@ -547,7 +548,8 @@ static int ttm_alloc_new_pages(struct list_head *pages, gfp_t gfp_flags, · 191 unmodified lines
547548 unsigned max_cpages = min(count << order, (unsigned)NUM_PAGES_TO_ALLOC);
548549
549550 /* allocate array for page caching change */
550− caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
551+ caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
552+ GFP_KERNEL);
551553
552554 if (!caching_array) {
553555 pr_debug("Unable to allocate table for new pages\n");
drivers/gpu/drm/ttm/ttm_page_alloc_dma.c+5−3
@@ -463,8 +463,9 @@ static unsigned ttm_dma_page_pool_free(struct dma_pool *pool, unsigned nr_free, · 462 unmodified lines
463463 if (use_static)
464464 pages_to_free = static_buf;
465465 else
466− pages_to_free = kmalloc(npages_to_free * sizeof(struct page *),
467− GFP_KERNEL);
466+ pages_to_free = kmalloc_array(npages_to_free,
467+ sizeof(struct page *),
468+ GFP_KERNEL);
468469
469470 if (!pages_to_free) {
470471 pr_debug("%s: Failed to allocate memory for pool free operation\n",
@@ -753,7 +754,8 @@ static int ttm_dma_pool_alloc_new_pages(struct dma_pool *pool, · 282 unmodified lines
753754 (unsigned)(PAGE_SIZE/sizeof(struct page *)));
754755
755756 /* allocate array for page caching change */
756− caching_array = kmalloc(max_cpages*sizeof(struct page *), GFP_KERNEL);
757+ caching_array = kmalloc_array(max_cpages, sizeof(struct page *),
758+ GFP_KERNEL);
757759
758760 if (!caching_array) {
759761 pr_debug("%s: Unable to allocate table for new pages\n",
drivers/gpu/drm/vc4/vc4_plane.c+1−1
@@ -209,7 +209,7 @@ static void vc4_dlist_write(struct vc4_plane_state *vc4_state, u32 val) · 208 unmodified lines
209209 {
210210 if (vc4_state->dlist_count == vc4_state->dlist_size) {
211211 u32 new_size = max(4u, vc4_state->dlist_count * 2);
212− u32 *new_dlist = kmalloc(new_size * 4, GFP_KERNEL);
212+ u32 *new_dlist = kmalloc_array(new_size, 4, GFP_KERNEL);
213213
214214 if (!new_dlist)
215215 return;
drivers/gpu/drm/via/via_dmablit.c+1−1
@@ -235,7 +235,7 @@ via_lock_all_dma_pages(drm_via_sg_info_t *vsg, drm_via_dmablit_t *xfer) · 234 unmodified lines
235235 vsg->num_pages = VIA_PFN(xfer->mem_addr + (xfer->num_lines * xfer->mem_stride - 1)) -
236236 first_pfn + 1;
237237
238− vsg->pages = vzalloc(sizeof(struct page *) * vsg->num_pages);
238+ vsg->pages = vzalloc(array_size(sizeof(struct page *), vsg->num_pages));
239239 if (NULL == vsg->pages)
240240 return -ENOMEM;
241241 ret = get_user_pages_fast((unsigned long)xfer->mem_addr,
drivers/hid/hid-core.c+6−3
@@ -134,8 +134,11 @@ static int open_collection(struct hid_parser *parser, unsigned type) · 133 unmodified lines
134134 }
135135
136136 if (parser->device->maxcollection == parser->device->collection_size) {
137− collection = kmalloc(sizeof(struct hid_collection) *
138− parser->device->collection_size * 2, GFP_KERNEL);
137+ collection = kmalloc(
138+ array3_size(sizeof(struct hid_collection),
139+ parser->device->collection_size,
140+ 2),
141+ GFP_KERNEL);
139142 if (collection == NULL) {
140143 hid_err(parser->device, "failed to reallocate collection array\n");
141144 return -ENOMEM;
@@ -1278,7 +1281,7 @@ static void hid_input_field(struct hid_device *hid, struct hid_field *field, · 1136 unmodified lines
12781281 __s32 max = field->logical_maximum;
12791282 __s32 *value;
12801283
1281− value = kmalloc(sizeof(__s32) * count, GFP_ATOMIC);
1284+ value = kmalloc_array(count, sizeof(__s32), GFP_ATOMIC);
12821285 if (!value)
12831286 return;
12841287
drivers/hid/hid-debug.c+3−3
@@ -457,7 +457,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) { · 456 unmodified lines
457457 char *buf = NULL;
458458
459459 if (!f) {
460− buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
460+ buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
461461 if (!buf)
462462 return ERR_PTR(-ENOMEM);
463463 }
@@ -685,7 +685,7 @@ void hid_dump_report(struct hid_device *hid, int type, u8 *data, · 221 unmodified lines
685685 char *buf;
686686 unsigned int i;
687687
688− buf = kmalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
688+ buf = kmalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
689689
690690 if (!buf)
691691 return;
@@ -1088,7 +1088,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file) · 396 unmodified lines
10881088 goto out;
10891089 }
10901090
1091− if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
1091+ if (!(list->hid_debug_buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
10921092 err = -ENOMEM;
10931093 kfree(list);
10941094 goto out;
drivers/hid/hid-picolcd_fb.c+2−1
@@ -394,7 +394,8 @@ static int picolcd_set_par(struct fb_info *info) · 393 unmodified lines
394394 return -EINVAL;
395395
396396 o_fb = fbdata->bitmap;
397− tmp_fb = kmalloc(PICOLCDFB_SIZE*info->var.bits_per_pixel, GFP_KERNEL);
397+ tmp_fb = kmalloc_array(PICOLCDFB_SIZE, info->var.bits_per_pixel,
398+ GFP_KERNEL);
398399 if (!tmp_fb)
399400 return -ENOMEM;
400401
drivers/hid/hid-sensor-hub.c+2−1
@@ -624,7 +624,8 @@ static int sensor_hub_probe(struct hid_device *hdev, · 623 unmodified lines
624624 ret = -EINVAL;
625625 goto err_stop_hw;
626626 }
627− sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt *
627+ sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev,
628+ dev_cnt,
628629 sizeof(struct mfd_cell),
629630 GFP_KERNEL);
630631 if (sd->hid_sensor_hub_client_devs == NULL) {
drivers/hid/hidraw.c+1−1
@@ -218,7 +218,7 @@ static ssize_t hidraw_get_report(struct file *file, char __user *buffer, size_t · 217 unmodified lines
218218 goto out;
219219 }
220220
221− buf = kmalloc(count * sizeof(__u8), GFP_KERNEL);
221+ buf = kmalloc(count, GFP_KERNEL);
222222 if (!buf) {
223223 ret = -ENOMEM;
224224 goto out;
drivers/hid/intel-ish-hid/ishtp-hid-client.c+2−2
@@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, · 120 unmodified lines
121121 }
122122 client_data->hid_dev_count = (unsigned int)*payload;
123123 if (!client_data->hid_devices)
124− client_data->hid_devices = devm_kzalloc(
124+ client_data->hid_devices = devm_kcalloc(
125125 &client_data->cl_device->dev,
126− client_data->hid_dev_count *
126+ client_data->hid_dev_count,
127127 sizeof(struct device_info),
128128 GFP_KERNEL);
129129 if (!client_data->hid_devices) {
drivers/hid/wacom_sys.c+2−2
@@ -1363,7 +1363,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev, · 1362 unmodified lines
13631363 if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL))
13641364 return -ENOMEM;
13651365
1366− leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL);
1366+ leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL);
13671367 if (!leds) {
13681368 error = -ENOMEM;
13691369 goto err;
@@ -1463,7 +1463,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count) · 93 unmodified lines
14631463 struct wacom_group_leds *groups;
14641464 int error;
14651465
1466− groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count,
1466+ groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds),
14671467 GFP_KERNEL);
14681468 if (!groups)
14691469 return -ENOMEM;
drivers/hv/hv.c+1−1
@@ -190,7 +190,7 @@ int hv_synic_alloc(void) · 189 unmodified lines
190190 {
191191 int cpu;
192192
193− hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
193+ hv_context.hv_numa_map = kcalloc(nr_node_ids, sizeof(struct cpumask),
194194 GFP_KERNEL);
195195 if (hv_context.hv_numa_map == NULL) {
196196 pr_err("Unable to allocate NUMA map\n");
drivers/hv/ring_buffer.c+1−1
@@ -202,7 +202,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info, · 201 unmodified lines
202202 * First page holds struct hv_ring_buffer, do wraparound mapping for
203203 * the rest.
204204 */
205− pages_wraparound = kzalloc(sizeof(struct page *) * (page_cnt * 2 - 1),
205+ pages_wraparound = kcalloc(page_cnt * 2 - 1, sizeof(struct page *),
206206 GFP_KERNEL);
207207 if (!pages_wraparound)
208208 return -ENOMEM;
drivers/hwmon/acpi_power_meter.c+4−3
@@ -575,8 +575,9 @@ static int read_domain_devices(struct acpi_power_meter_resource *resource) · 574 unmodified lines
575575 if (!pss->package.count)
576576 goto end;
577577
578− resource->domain_devices = kzalloc(sizeof(struct acpi_device *) *
579− pss->package.count, GFP_KERNEL);
578+ resource->domain_devices = kcalloc(pss->package.count,
579+ sizeof(struct acpi_device *),
580+ GFP_KERNEL);
580581 if (!resource->domain_devices) {
581582 res = -ENOMEM;
582583 goto end;
@@ -796,7 +797,7 @@ static int read_capabilities(struct acpi_power_meter_resource *resource) · 213 unmodified lines
796797 goto error;
797798 }
798799
799− *str = kzalloc(sizeof(u8) * (element->string.length + 1),
800+ *str = kcalloc(element->string.length + 1, sizeof(u8),
800801 GFP_KERNEL);
801802 if (!*str) {
802803 res = -ENOMEM;
drivers/hwmon/aspeed-pwm-tacho.c+1−1
@@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev, · 893 unmodified lines
894894 count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch");
895895 if (count < 1)
896896 return -EINVAL;
897− fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count,
897+ fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch),
898898 GFP_KERNEL);
899899 if (!fan_tach_ch)
900900 return -ENOMEM;
drivers/hwmon/coretemp.c+1−1
@@ -742,7 +742,7 @@ static int __init coretemp_init(void) · 741 unmodified lines
742742 return -ENODEV;
743743
744744 max_packages = topology_max_packages();
745− pkg_devices = kzalloc(max_packages * sizeof(struct platform_device *),
745+ pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
746746 GFP_KERNEL);
747747 if (!pkg_devices)
748748 return -ENOMEM;
drivers/hwmon/gpio-fan.c+4−4
@@ -441,8 +441,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data) · 440 unmodified lines
441441 dev_err(dev, "DT properties empty / missing");
442442 return -ENODEV;
443443 }
444− gpios = devm_kzalloc(dev,
445− fan_data->num_gpios * sizeof(struct gpio_desc *),
444+ gpios = devm_kcalloc(dev,
445+ fan_data->num_gpios, sizeof(struct gpio_desc *),
446446 GFP_KERNEL);
447447 if (!gpios)
448448 return -ENOMEM;
@@ -471,8 +471,8 @@ static int gpio_fan_get_of_data(struct gpio_fan_data *fan_data) · 22 unmodified lines
471471 * Speed map is in the form <RPM ctrl_val RPM ctrl_val ...>
472472 * this needs splitting into pairs to create gpio_fan_speed structs
473473 */
474− speed = devm_kzalloc(dev,
475− fan_data->num_speed * sizeof(struct gpio_fan_speed),
474+ speed = devm_kcalloc(dev,
475+ fan_data->num_speed, sizeof(struct gpio_fan_speed),
476476 GFP_KERNEL);
477477 if (!speed)
478478 return -ENOMEM;
drivers/hwmon/i5k_amb.c+3−2
@@ -274,8 +274,9 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev) · 273 unmodified lines
274274 num_ambs += hweight16(data->amb_present[i] & 0x7fff);
275275
276276 /* Set up sysfs stuff */
277− data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB,
278− GFP_KERNEL);
277+ data->attrs = kzalloc(array3_size(num_ambs, KNOBS_PER_AMB,
278+ sizeof(*data->attrs)),
279+ GFP_KERNEL);
279280 if (!data->attrs)
280281 return -ENOMEM;
281282 data->num_attrs = 0;
drivers/hwmon/ibmpex.c+1−1
@@ -387,7 +387,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data) · 386 unmodified lines
387387 return -ENOENT;
388388 data->num_sensors = err;
389389
390− data->sensors = kzalloc(data->num_sensors * sizeof(*data->sensors),
390+ data->sensors = kcalloc(data->num_sensors, sizeof(*data->sensors),
391391 GFP_KERNEL);
392392 if (!data->sensors)
393393 return -ENOMEM;
drivers/hwmon/ibmpowernv.c+5−4
@@ -326,9 +326,9 @@ static int populate_attr_groups(struct platform_device *pdev) · 325 unmodified lines
326326 of_node_put(opal);
327327
328328 for (type = 0; type < MAX_SENSOR_TYPE; type++) {
329− sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev,
330− sizeof(struct attribute *) *
331− (sensor_groups[type].attr_count + 1),
329+ sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev,
330+ sensor_groups[type].attr_count + 1,
331+ sizeof(struct attribute *),
332332 GFP_KERNEL);
333333 if (!sensor_groups[type].group.attrs)
334334 return -ENOMEM;
@@ -409,7 +409,8 @@ static int create_device_attrs(struct platform_device *pdev) · 74 unmodified lines
409409 int err = 0;
410410
411411 opal = of_find_node_by_path("/ibm,opal/sensors");
412− sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata),
412+ sdata = devm_kcalloc(&pdev->dev,
413+ pdata->sensors_count, sizeof(*sdata),
413414 GFP_KERNEL);
414415 if (!sdata) {
415416 err = -ENOMEM;
drivers/hwmon/iio_hwmon.c+2−2
@@ -92,8 +92,8 @@ static int iio_hwmon_probe(struct platform_device *pdev) · 91 unmodified lines
9292 while (st->channels[st->num_channels].indio_dev)
9393 st->num_channels++;
9494
95− st->attrs = devm_kzalloc(dev,
96− sizeof(*st->attrs) * (st->num_channels + 1),
95+ st->attrs = devm_kcalloc(dev,
96+ st->num_channels + 1, sizeof(*st->attrs),
9797 GFP_KERNEL);
9898 if (st->attrs == NULL) {
9999 ret = -ENOMEM;
drivers/hwmon/nct6683.c+2−2
@@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev, · 425 unmodified lines
426426 if (group == NULL)
427427 return ERR_PTR(-ENOMEM);
428428
429− attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
429+ attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
430430 GFP_KERNEL);
431431 if (attrs == NULL)
432432 return ERR_PTR(-ENOMEM);
433433
434− su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
434+ su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
435435 GFP_KERNEL);
436436 if (su == NULL)
437437 return ERR_PTR(-ENOMEM);
drivers/hwmon/nct6775.c+2−2
@@ -1190,12 +1190,12 @@ nct6775_create_attr_group(struct device *dev, · 1189 unmodified lines
11901190 if (group == NULL)
11911191 return ERR_PTR(-ENOMEM);
11921192
1193− attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1),
1193+ attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs),
11941194 GFP_KERNEL);
11951195 if (attrs == NULL)
11961196 return ERR_PTR(-ENOMEM);
11971197
1198− su = devm_kzalloc(dev, sizeof(*su) * repeat * count,
1198+ su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)),
11991199 GFP_KERNEL);
12001200 if (su == NULL)
12011201 return ERR_PTR(-ENOMEM);
drivers/hwmon/pmbus/pmbus_core.c+2−2
@@ -2176,8 +2176,8 @@ static int pmbus_init_debugfs(struct i2c_client *client, · 2175 unmodified lines
21762176 }
21772177
21782178 /* Allocate the max possible entries we need. */
2179− entries = devm_kzalloc(data->dev,
2180− sizeof(*entries) * (data->info->pages * 10),
2179+ entries = devm_kcalloc(data->dev,
2180+ data->info->pages * 10, sizeof(*entries),
21812181 GFP_KERNEL);
21822182 if (!entries)
21832183 return -ENOMEM;
drivers/hwmon/pmbus/ucd9000.c+2−2
@@ -454,8 +454,8 @@ static int ucd9000_init_debugfs(struct i2c_client *client, · 453 unmodified lines
454454 */
455455 if (mid->driver_data == ucd9090 || mid->driver_data == ucd90160 ||
456456 mid->driver_data == ucd90910) {
457− entries = devm_kzalloc(&client->dev,
458− sizeof(*entries) * UCD9000_GPI_COUNT,
457+ entries = devm_kcalloc(&client->dev,
458+ UCD9000_GPI_COUNT, sizeof(*entries),
459459 GFP_KERNEL);
460460 if (!entries)
461461 return -ENOMEM;
drivers/hwmon/pwm-fan.c+1−1
@@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev, · 179 unmodified lines
180180 }
181181
182182 num = ret;
183− ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32),
183+ ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32),
184184 GFP_KERNEL);
185185 if (!ctx->pwm_fan_cooling_levels)
186186 return -ENOMEM;
drivers/hwtracing/coresight/coresight-etb10.c+2−2
@@ -683,8 +683,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) · 682 unmodified lines
683683 if (drvdata->buffer_depth & 0x80000000)
684684 return -EINVAL;
685685
686− drvdata->buf = devm_kzalloc(dev,
687− drvdata->buffer_depth * 4, GFP_KERNEL);
686+ drvdata->buf = devm_kcalloc(dev,
687+ drvdata->buffer_depth, 4, GFP_KERNEL);
688688 if (!drvdata->buf)
689689 return -ENOMEM;
690690
drivers/hwtracing/coresight/of_coresight.c+6−3
@@ -71,21 +71,24 @@ static int of_coresight_alloc_memory(struct device *dev, · 70 unmodified lines
7171 struct coresight_platform_data *pdata)
7272 {
7373 /* List of output port on this component */
74− pdata->outports = devm_kzalloc(dev, pdata->nr_outport *
74+ pdata->outports = devm_kcalloc(dev,
75+ pdata->nr_outport,
7576 sizeof(*pdata->outports),
7677 GFP_KERNEL);
7778 if (!pdata->outports)
7879 return -ENOMEM;
7980
8081 /* Children connected to this component via @outports */
81− pdata->child_names = devm_kzalloc(dev, pdata->nr_outport *
82+ pdata->child_names = devm_kcalloc(dev,
83+ pdata->nr_outport,
8284 sizeof(*pdata->child_names),
8385 GFP_KERNEL);
8486 if (!pdata->child_names)
8587 return -ENOMEM;
8688
8789 /* Port number on the child this component is connected to */
88− pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport *
90+ pdata->child_ports = devm_kcalloc(dev,
91+ pdata->nr_outport,
8992 sizeof(*pdata->child_ports),
9093 GFP_KERNEL);
9194 if (!pdata->child_ports)
drivers/i2c/busses/i2c-amd756-s4882.c+2−2
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void) · 168 unmodified lines
169169
170170 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
171171 /* Define the 5 virtual adapters and algorithms structures */
172− if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
172+ if (!(s4882_adapter = kcalloc(5, sizeof(struct i2c_adapter),
173173 GFP_KERNEL))) {
174174 error = -ENOMEM;
175175 goto ERROR1;
176176 }
177− if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm),
177+ if (!(s4882_algo = kcalloc(5, sizeof(struct i2c_algorithm),
178178 GFP_KERNEL))) {
179179 error = -ENOMEM;
180180 goto ERROR2;
drivers/i2c/busses/i2c-nforce2-s4985.c+2−2
@@ -164,12 +164,12 @@ static int __init nforce2_s4985_init(void) · 163 unmodified lines
164164
165165 printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n");
166166 /* Define the 5 virtual adapters and algorithms structures */
167− s4985_adapter = kzalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL);
167+ s4985_adapter = kcalloc(5, sizeof(struct i2c_adapter), GFP_KERNEL);
168168 if (!s4985_adapter) {
169169 error = -ENOMEM;
170170 goto ERROR1;
171171 }
172− s4985_algo = kzalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL);
172+ s4985_algo = kcalloc(5, sizeof(struct i2c_algorithm), GFP_KERNEL);
173173 if (!s4985_algo) {
174174 error = -ENOMEM;
175175 goto ERROR2;
drivers/i2c/busses/i2c-nforce2.c+1−1
@@ -381,7 +381,7 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id) · 380 unmodified lines
381381 int res1, res2;
382382
383383 /* we support 2 SMBus adapters */
384− smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
384+ smbuses = kcalloc(2, sizeof(struct nforce2_smbus), GFP_KERNEL);
385385 if (!smbuses)
386386 return -ENOMEM;
387387 pci_set_drvdata(dev, smbuses);
drivers/i2c/busses/i2c-qup.c+4−4
@@ -1691,8 +1691,8 @@ static int qup_i2c_probe(struct platform_device *pdev) · 1690 unmodified lines
16911691
16921692 qup->max_xfer_sg_len = (MX_BLOCKS << 1);
16931693 blocks = (MX_DMA_BLOCKS << 1) + 1;
1694− qup->btx.sg = devm_kzalloc(&pdev->dev,
1695− sizeof(*qup->btx.sg) * blocks,
1694+ qup->btx.sg = devm_kcalloc(&pdev->dev,
1695+ blocks, sizeof(*qup->btx.sg),
16961696 GFP_KERNEL);
16971697 if (!qup->btx.sg) {
16981698 ret = -ENOMEM;
@@ -1700,8 +1700,8 @@ static int qup_i2c_probe(struct platform_device *pdev) · 1 unmodified line
17001700 }
17011701 sg_init_table(qup->btx.sg, blocks);
17021702
1703− qup->brx.sg = devm_kzalloc(&pdev->dev,
1704− sizeof(*qup->brx.sg) * blocks,
1703+ qup->brx.sg = devm_kcalloc(&pdev->dev,
1704+ blocks, sizeof(*qup->brx.sg),
17051705 GFP_KERNEL);
17061706 if (!qup->brx.sg) {
17071707 ret = -ENOMEM;
drivers/i2c/i2c-dev.c+1−1
@@ -244,7 +244,7 @@ static noinline int i2cdev_ioctl_rdwr(struct i2c_client *client, · 243 unmodified lines
244244 u8 __user **data_ptrs;
245245 int i, res;
246246
247− data_ptrs = kmalloc(nmsgs * sizeof(u8 __user *), GFP_KERNEL);
247+ data_ptrs = kmalloc_array(nmsgs, sizeof(u8 __user *), GFP_KERNEL);
248248 if (data_ptrs == NULL) {
249249 kfree(msgs);
250250 return -ENOMEM;
drivers/i2c/i2c-stub.c+3−2
@@ -338,8 +338,9 @@ static int __init i2c_stub_allocate_banks(int i) · 337 unmodified lines
338338 chip->bank_mask >>= 1;
339339 }
340340
341− chip->bank_words = kzalloc(chip->bank_mask * chip->bank_size *
342− sizeof(u16), GFP_KERNEL);
341+ chip->bank_words = kcalloc(chip->bank_mask * chip->bank_size,
342+ sizeof(u16),
343+ GFP_KERNEL);
343344 if (!chip->bank_words)
344345 return -ENOMEM;
345346
drivers/i2c/muxes/i2c-mux-gpio.c+5−4
@@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, · 87 unmodified lines
8888
8989 mux->data.n_values = of_get_child_count(np);
9090
91− values = devm_kzalloc(&pdev->dev,
92− sizeof(*mux->data.values) * mux->data.n_values,
91+ values = devm_kcalloc(&pdev->dev,
92+ mux->data.n_values, sizeof(*mux->data.values),
9393 GFP_KERNEL);
9494 if (!values) {
9595 dev_err(&pdev->dev, "Cannot allocate values array");
@@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, · 15 unmodified lines
111111 return -EINVAL;
112112 }
113113
114− gpios = devm_kzalloc(&pdev->dev,
115− sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL);
114+ gpios = devm_kcalloc(&pdev->dev,
115+ mux->data.n_gpios, sizeof(*mux->data.gpios),
116+ GFP_KERNEL);
116117 if (!gpios) {
117118 dev_err(&pdev->dev, "Cannot allocate gpios array");
118119 return -ENOMEM;
drivers/i2c/muxes/i2c-mux-reg.c+2−2
@@ -124,8 +124,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, · 123 unmodified lines
124124 }
125125 mux->data.write_only = of_property_read_bool(np, "write-only");
126126
127− values = devm_kzalloc(&pdev->dev,
128− sizeof(*mux->data.values) * mux->data.n_values,
127+ values = devm_kcalloc(&pdev->dev,
128+ mux->data.n_values, sizeof(*mux->data.values),
129129 GFP_KERNEL);
130130 if (!values) {
131131 dev_err(&pdev->dev, "Cannot allocate values array");
drivers/ide/hpt366.c+1−1
@@ -1455,7 +1455,7 @@ static int hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id) · 1454 unmodified lines
14551455 if (info == &hpt36x || info == &hpt374)
14561456 dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
14571457
1458− dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
1458+ dyn_info = kcalloc(dev2 ? 2 : 1, sizeof(*dyn_info), GFP_KERNEL);
14591459 if (dyn_info == NULL) {
14601460 printk(KERN_ERR "%s %s: out of memory!\n",
14611461 d.name, pci_name(dev));
drivers/ide/ide-probe.c+3−2
@@ -985,8 +985,9 @@ static int hwif_init(ide_hwif_t *hwif) · 984 unmodified lines
985985 if (!hwif->sg_max_nents)
986986 hwif->sg_max_nents = PRD_ENTRIES;
987987
988− hwif->sg_table = kmalloc(sizeof(struct scatterlist)*hwif->sg_max_nents,
989− GFP_KERNEL);
988+ hwif->sg_table = kmalloc_array(hwif->sg_max_nents,
989+ sizeof(struct scatterlist),
990+ GFP_KERNEL);
990991 if (!hwif->sg_table) {
991992 printk(KERN_ERR "%s: unable to allocate SG table.\n", hwif->name);
992993 goto out;
drivers/ide/it821x.c+1−1
@@ -652,7 +652,7 @@ static int it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id) · 651 unmodified lines
652652 struct it821x_dev *itdevs;
653653 int rc;
654654
655− itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
655+ itdevs = kcalloc(2, sizeof(*itdevs), GFP_KERNEL);
656656 if (itdevs == NULL) {
657657 printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev));
658658 return -ENOMEM;
drivers/iio/adc/at91_adc.c+4−3
@@ -624,8 +624,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev) · 623 unmodified lines
624624 struct at91_adc_state *st = iio_priv(idev);
625625 int i, ret;
626626
627− st->trig = devm_kzalloc(&idev->dev,
628− st->trigger_number * sizeof(*st->trig),
627+ st->trig = devm_kcalloc(&idev->dev,
628+ st->trigger_number, sizeof(*st->trig),
629629 GFP_KERNEL);
630630
631631 if (st->trig == NULL) {
@@ -908,7 +908,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, · 276 unmodified lines
908908 st->registers = &st->caps->registers;
909909 st->num_channels = st->caps->num_channels;
910910 st->trigger_number = of_get_child_count(node);
911− st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number *
911+ st->trigger_list = devm_kcalloc(&idev->dev,
912+ st->trigger_number,
912913 sizeof(struct at91_adc_trigger),
913914 GFP_KERNEL);
914915 if (!st->trigger_list) {
drivers/iio/adc/max1027.c+2−2
@@ -422,8 +422,8 @@ static int max1027_probe(struct spi_device *spi) · 421 unmodified lines
422422 indio_dev->num_channels = st->info->num_channels;
423423 indio_dev->available_scan_masks = st->info->available_scan_masks;
424424
425− st->buffer = devm_kmalloc(&indio_dev->dev,
426− indio_dev->num_channels * 2,
425+ st->buffer = devm_kmalloc_array(&indio_dev->dev,
426+ indio_dev->num_channels, 2,
427427 GFP_KERNEL);
428428 if (st->buffer == NULL) {
429429 dev_err(&indio_dev->dev, "Can't allocate buffer\n");
drivers/iio/adc/max1363.c+4−2
@@ -1453,8 +1453,10 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev) · 1452 unmodified lines
14531453 int i;
14541454
14551455 masks = devm_kzalloc(&indio_dev->dev,
1456− BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) *
1457− (st->chip_info->num_modes + 1), GFP_KERNEL);
1456+ array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS),
1457+ sizeof(long),
1458+ st->chip_info->num_modes + 1),
1459+ GFP_KERNEL);
14581460 if (!masks)
14591461 return -ENOMEM;
14601462
drivers/iio/adc/twl6030-gpadc.c+4−3
@@ -898,9 +898,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) · 897 unmodified lines
898898
899899 gpadc = iio_priv(indio_dev);
900900
901− gpadc->twl6030_cal_tbl = devm_kzalloc(dev,
902− sizeof(*gpadc->twl6030_cal_tbl) *
903− pdata->nchannels, GFP_KERNEL);
901+ gpadc->twl6030_cal_tbl = devm_kcalloc(dev,
902+ pdata->nchannels,
903+ sizeof(*gpadc->twl6030_cal_tbl),
904+ GFP_KERNEL);
904905 if (!gpadc->twl6030_cal_tbl)
905906 return -ENOMEM;
906907
drivers/iio/dac/ad5592r-base.c+3−2
@@ -536,8 +536,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st) · 535 unmodified lines
536536 st->channel_offstate[reg] = tmp;
537537 }
538538
539− channels = devm_kzalloc(st->dev,
540− (1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL);
539+ channels = devm_kcalloc(st->dev,
540+ 1 + 2 * num_channels, sizeof(*channels),
541+ GFP_KERNEL);
541542 if (!channels)
542543 return -ENOMEM;
543544
drivers/iio/imu/adis_buffer.c+1−1
@@ -38,7 +38,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev, · 37 unmodified lines
3838 if (!adis->xfer)
3939 return -ENOMEM;
4040
41− adis->buffer = kzalloc(indio_dev->scan_bytes * 2, GFP_KERNEL);
41+ adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL);
4242 if (!adis->buffer)
4343 return -ENOMEM;
4444
drivers/iio/inkern.c+1−1
@@ -436,7 +436,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev) · 435 unmodified lines
436436 }
437437
438438 /* NULL terminated array to save passing size */
439− chans = kzalloc(sizeof(*chans)*(nummaps + 1), GFP_KERNEL);
439+ chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
440440 if (chans == NULL) {
441441 ret = -ENOMEM;
442442 goto error_ret;
drivers/iio/multiplexer/iio-mux.c+4−3
@@ -281,9 +281,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux, · 280 unmodified lines
281281 if (!page)
282282 return -ENOMEM;
283283 }
284− child->ext_info_cache = devm_kzalloc(dev,
285− sizeof(*child->ext_info_cache) *
286− num_ext_info, GFP_KERNEL);
284+ child->ext_info_cache = devm_kcalloc(dev,
285+ num_ext_info,
286+ sizeof(*child->ext_info_cache),
287+ GFP_KERNEL);
287288 if (!child->ext_info_cache)
288289 return -ENOMEM;
289290
drivers/infiniband/core/cache.c+3−2
@@ -1245,8 +1245,9 @@ int ib_cache_setup_one(struct ib_device *device) · 1244 unmodified lines
12451245 rwlock_init(&device->cache.lock);
12461246
12471247 device->cache.ports =
1248− kzalloc(sizeof(*device->cache.ports) *
1249− (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
1248+ kcalloc(rdma_end_port(device) - rdma_start_port(device) + 1,
1249+ sizeof(*device->cache.ports),
1250+ GFP_KERNEL);
12501251 if (!device->cache.ports)
12511252 return -ENOMEM;
12521253
drivers/infiniband/core/cma.c+2−2
@@ -1855,8 +1855,8 @@ static struct rdma_id_private *cma_new_conn_id(struct rdma_cm_id *listen_id, · 1854 unmodified lines
18551855
18561856 rt = &id->route;
18571857 rt->num_paths = ib_event->param.req_rcvd.alternate_path ? 2 : 1;
1858− rt->path_rec = kmalloc(sizeof *rt->path_rec * rt->num_paths,
1859− GFP_KERNEL);
1858+ rt->path_rec = kmalloc_array(rt->num_paths, sizeof(*rt->path_rec),
1859+ GFP_KERNEL);
18601860 if (!rt->path_rec)
18611861 goto err;
18621862
drivers/infiniband/core/device.c+2−2
@@ -336,8 +336,8 @@ static int read_port_immutable(struct ib_device *device) · 335 unmodified lines
336336 * Therefore port_immutable is declared as a 1 based array with
337337 * potential empty slots at the beginning.
338338 */
339− device->port_immutable = kzalloc(sizeof(*device->port_immutable)
340− * (end_port + 1),
339+ device->port_immutable = kcalloc(end_port + 1,
340+ sizeof(*device->port_immutable),
341341 GFP_KERNEL);
342342 if (!device->port_immutable)
343343 return -ENOMEM;
drivers/infiniband/core/fmr_pool.c+3−2
@@ -235,8 +235,9 @@ struct ib_fmr_pool *ib_create_fmr_pool(struct ib_pd *pd, · 234 unmodified lines
235235
236236 if (params->cache) {
237237 pool->cache_bucket =
238− kmalloc(IB_FMR_HASH_SIZE * sizeof *pool->cache_bucket,
239− GFP_KERNEL);
238+ kmalloc_array(IB_FMR_HASH_SIZE,
239+ sizeof(*pool->cache_bucket),
240+ GFP_KERNEL);
240241 if (!pool->cache_bucket) {
241242 ret = -ENOMEM;
242243 goto out_free_pool;
drivers/infiniband/core/iwpm_util.c+6−4
@@ -56,14 +56,16 @@ int iwpm_init(u8 nl_client) · 55 unmodified lines
5656 int ret = 0;
5757 mutex_lock(&iwpm_admin_lock);
5858 if (atomic_read(&iwpm_admin.refcount) == 0) {
59− iwpm_hash_bucket = kzalloc(IWPM_MAPINFO_HASH_SIZE *
60− sizeof(struct hlist_head), GFP_KERNEL);
59+ iwpm_hash_bucket = kcalloc(IWPM_MAPINFO_HASH_SIZE,
60+ sizeof(struct hlist_head),
61+ GFP_KERNEL);
6162 if (!iwpm_hash_bucket) {
6263 ret = -ENOMEM;
6364 goto init_exit;
6465 }
65− iwpm_reminfo_bucket = kzalloc(IWPM_REMINFO_HASH_SIZE *
66− sizeof(struct hlist_head), GFP_KERNEL);
66+ iwpm_reminfo_bucket = kcalloc(IWPM_REMINFO_HASH_SIZE,
67+ sizeof(struct hlist_head),
68+ GFP_KERNEL);
6769 if (!iwpm_reminfo_bucket) {
6870 kfree(iwpm_hash_bucket);
6971 ret = -ENOMEM;
drivers/infiniband/core/umem_odp.c+10−6
@@ -285,13 +285,15 @@ struct ib_umem *ib_alloc_odp_umem(struct ib_ucontext *context, · 284 unmodified lines
285285 mutex_init(&odp_data->umem_mutex);
286286 init_completion(&odp_data->notifier_completion);
287287
288− odp_data->page_list = vzalloc(pages * sizeof(*odp_data->page_list));
288+ odp_data->page_list =
289+ vzalloc(array_size(pages, sizeof(*odp_data->page_list)));
289290 if (!odp_data->page_list) {
290291 ret = -ENOMEM;
291292 goto out_odp_data;
292293 }
293294
294− odp_data->dma_list = vzalloc(pages * sizeof(*odp_data->dma_list));
295+ odp_data->dma_list =
296+ vzalloc(array_size(pages, sizeof(*odp_data->dma_list)));
295297 if (!odp_data->dma_list) {
296298 ret = -ENOMEM;
297299 goto out_page_list;
@@ -371,15 +373,17 @@ int ib_umem_odp_get(struct ib_ucontext *context, struct ib_umem *umem, · 73 unmodified lines
371373 init_completion(&umem->odp_data->notifier_completion);
372374
373375 if (ib_umem_num_pages(umem)) {
374− umem->odp_data->page_list = vzalloc(ib_umem_num_pages(umem) *
375− sizeof(*umem->odp_data->page_list));
376+ umem->odp_data->page_list =
377+ vzalloc(array_size(sizeof(*umem->odp_data->page_list),
378+ ib_umem_num_pages(umem)));
376379 if (!umem->odp_data->page_list) {
377380 ret_val = -ENOMEM;
378381 goto out_odp_data;
379382 }
380383
381− umem->odp_data->dma_list = vzalloc(ib_umem_num_pages(umem) *
382− sizeof(*umem->odp_data->dma_list));
384+ umem->odp_data->dma_list =
385+ vzalloc(array_size(sizeof(*umem->odp_data->dma_list),
386+ ib_umem_num_pages(umem)));
383387 if (!umem->odp_data->dma_list) {
384388 ret_val = -ENOMEM;
385389 goto out_page_list;
drivers/infiniband/core/uverbs_cmd.c+2−2
@@ -3559,8 +3559,8 @@ int ib_uverbs_ex_create_flow(struct ib_uverbs_file *file, · 3558 unmodified lines
35593559 goto err_uobj;
35603560 }
35613561
3562− flow_attr = kzalloc(sizeof(*flow_attr) + cmd.flow_attr.num_of_specs *
3563− sizeof(union ib_flow_spec), GFP_KERNEL);
3562+ flow_attr = kzalloc(struct_size(flow_attr, flows,
3563+ cmd.flow_attr.num_of_specs), GFP_KERNEL);
35643564 if (!flow_attr) {
35653565 err = -ENOMEM;
35663566 goto err_put;
drivers/infiniband/hw/cxgb3/cxio_hal.c+2−2
@@ -279,7 +279,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, · 278 unmodified lines
279279 if (!wq->qpid)
280280 return -ENOMEM;
281281
282− wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL);
282+ wq->rq = kcalloc(depth, sizeof(struct t3_swrq), GFP_KERNEL);
283283 if (!wq->rq)
284284 goto err1;
285285
@@ -287,7 +287,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain, · 1 unmodified line
287287 if (!wq->rq_addr)
288288 goto err2;
289289
290− wq->sq = kzalloc(depth * sizeof(struct t3_swsq), GFP_KERNEL);
290+ wq->sq = kcalloc(depth, sizeof(struct t3_swsq), GFP_KERNEL);
291291 if (!wq->sq)
292292 goto err3;
293293
drivers/infiniband/hw/cxgb4/device.c+4−3
@@ -859,8 +859,9 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev) · 858 unmodified lines
859859 rdev->status_page->cq_size = rdev->lldi.vr->cq.size;
860860
861861 if (c4iw_wr_log) {
862− rdev->wr_log = kzalloc((1 << c4iw_wr_log_size_order) *
863− sizeof(*rdev->wr_log), GFP_KERNEL);
862+ rdev->wr_log = kcalloc(1 << c4iw_wr_log_size_order,
863+ sizeof(*rdev->wr_log),
864+ GFP_KERNEL);
864865 if (rdev->wr_log) {
865866 rdev->wr_log_size = 1 << c4iw_wr_log_size_order;
866867 atomic_set(&rdev->wr_log_idx, 0);
@@ -1445,7 +1446,7 @@ static void recover_queues(struct uld_ctx *ctx) · 578 unmodified lines
14451446 ctx->dev->db_state = RECOVERY;
14461447 idr_for_each(&ctx->dev->qpidr, count_qps, &count);
14471448
1448− qp_list.qps = kzalloc(count * sizeof *qp_list.qps, GFP_ATOMIC);
1449+ qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC);
14491450 if (!qp_list.qps) {
14501451 spin_unlock_irq(&ctx->dev->lock);
14511452 return;
drivers/infiniband/hw/cxgb4/id_table.c+2−2
@@ -92,8 +92,8 @@ int c4iw_id_table_alloc(struct c4iw_id_table *alloc, u32 start, u32 num, · 91 unmodified lines
9292 alloc->last = 0;
9393 alloc->max = num;
9494 spin_lock_init(&alloc->lock);
95− alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof(long),
96− GFP_KERNEL);
95+ alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
96+ GFP_KERNEL);
9797 if (!alloc->table)
9898 return -ENOMEM;
9999
drivers/infiniband/hw/cxgb4/qp.c+4−4
@@ -216,15 +216,15 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq, · 215 unmodified lines
216216 }
217217
218218 if (!user) {
219− wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
220− GFP_KERNEL);
219+ wq->sq.sw_sq = kcalloc(wq->sq.size, sizeof(*wq->sq.sw_sq),
220+ GFP_KERNEL);
221221 if (!wq->sq.sw_sq) {
222222 ret = -ENOMEM;
223223 goto free_rq_qid;
224224 }
225225
226− wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
227− GFP_KERNEL);
226+ wq->rq.sw_rq = kcalloc(wq->rq.size, sizeof(*wq->rq.sw_rq),
227+ GFP_KERNEL);
228228 if (!wq->rq.sw_rq) {
229229 ret = -ENOMEM;
230230 goto free_sw_sq;
drivers/infiniband/hw/hfi1/sdma.c+2−1
@@ -1461,7 +1461,8 @@ int sdma_init(struct hfi1_devdata *dd, u8 port) · 1460 unmodified lines
14611461 if (!sde->descq)
14621462 goto bail;
14631463 sde->tx_ring =
1464− kvzalloc_node(sizeof(struct sdma_txreq *) * descq_cnt,
1464+ kvzalloc_node(array_size(descq_cnt,
1465+ sizeof(struct sdma_txreq *)),
14651466 GFP_KERNEL, dd->node);
14661467 if (!sde->tx_ring)
14671468 goto bail;
drivers/infiniband/hw/hns/hns_roce_hw_v2.c+1−1
@@ -3177,7 +3177,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp, · 3176 unmodified lines
31773177 struct device *dev = hr_dev->dev;
31783178 int ret = -EINVAL;
31793179
3180− context = kzalloc(2 * sizeof(*context), GFP_KERNEL);
3180+ context = kcalloc(2, sizeof(*context), GFP_KERNEL);
31813181 if (!context)
31823182 return -ENOMEM;
31833183
drivers/infiniband/hw/hns/hns_roce_mr.c+1−1
@@ -144,7 +144,7 @@ static int hns_roce_buddy_init(struct hns_roce_buddy *buddy, int max_order) · 143 unmodified lines
144144 buddy->bits[i] = kcalloc(s, sizeof(long), GFP_KERNEL |
145145 __GFP_NOWARN);
146146 if (!buddy->bits[i]) {
147− buddy->bits[i] = vzalloc(s * sizeof(long));
147+ buddy->bits[i] = vzalloc(array_size(s, sizeof(long)));
148148 if (!buddy->bits[i])
149149 goto err_out_free;
150150 }
drivers/infiniband/hw/mlx4/mad.c+2−1
@@ -1613,7 +1613,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx, · 1612 unmodified lines
16131613
16141614 tun_qp = &ctx->qp[qp_type];
16151615
1616− tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
1616+ tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
1617+ sizeof(struct mlx4_ib_buf),
16171618 GFP_KERNEL);
16181619 if (!tun_qp->ring)
16191620 return -ENOMEM;
drivers/infiniband/hw/mlx4/main.c+7−5
@@ -302,7 +302,8 @@ static int mlx4_ib_add_gid(const union ib_gid *gid, · 301 unmodified lines
302302 ctx->refcount++;
303303 }
304304 if (!ret && hw_update) {
305− gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
305+ gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
306+ GFP_ATOMIC);
306307 if (!gids) {
307308 ret = -ENOMEM;
308309 } else {
@@ -355,7 +356,8 @@ static int mlx4_ib_del_gid(const struct ib_gid_attr *attr, void **context) · 46 unmodified lines
355356 if (!ret && hw_update) {
356357 int i;
357358
358− gids = kmalloc(sizeof(*gids) * MLX4_MAX_PORT_GIDS, GFP_ATOMIC);
359+ gids = kmalloc_array(MLX4_MAX_PORT_GIDS, sizeof(*gids),
360+ GFP_ATOMIC);
359361 if (!gids) {
360362 ret = -ENOMEM;
361363 } else {
@@ -2872,9 +2874,9 @@ static void *mlx4_ib_add(struct mlx4_dev *dev) · 2510 unmodified lines
28722874 goto err_counter;
28732875
28742876 ibdev->ib_uc_qpns_bitmap =
2875− kmalloc(BITS_TO_LONGS(ibdev->steer_qpn_count) *
2876− sizeof(long),
2877− GFP_KERNEL);
2877+ kmalloc_array(BITS_TO_LONGS(ibdev->steer_qpn_count),
2878+ sizeof(long),
2879+ GFP_KERNEL);
28782880 if (!ibdev->ib_uc_qpns_bitmap)
28792881 goto err_steer_qp_release;
28802882
drivers/infiniband/hw/mlx4/qp.c+2−2
@@ -573,8 +573,8 @@ static int alloc_proxy_bufs(struct ib_device *dev, struct mlx4_ib_qp *qp) · 572 unmodified lines
573573 int i;
574574
575575 qp->sqp_proxy_rcv =
576− kmalloc(sizeof (struct mlx4_ib_buf) * qp->rq.wqe_cnt,
577− GFP_KERNEL);
576+ kmalloc_array(qp->rq.wqe_cnt, sizeof(struct mlx4_ib_buf),
577+ GFP_KERNEL);
578578 if (!qp->sqp_proxy_rcv)
579579 return -ENOMEM;
580580 for (i = 0; i < qp->rq.wqe_cnt; i++) {
drivers/infiniband/hw/mlx5/srq.c+2−2
@@ -127,7 +127,7 @@ static int create_srq_user(struct ib_pd *pd, struct mlx5_ib_srq *srq, · 126 unmodified lines
127127 goto err_umem;
128128 }
129129
130− in->pas = kvzalloc(sizeof(*in->pas) * ncont, GFP_KERNEL);
130+ in->pas = kvcalloc(ncont, sizeof(*in->pas), GFP_KERNEL);
131131 if (!in->pas) {
132132 err = -ENOMEM;
133133 goto err_umem;
@@ -189,7 +189,7 @@ static int create_srq_kernel(struct mlx5_ib_dev *dev, struct mlx5_ib_srq *srq, · 55 unmodified lines
189189 }
190190
191191 mlx5_ib_dbg(dev, "srq->buf.page_shift = %d\n", srq->buf.page_shift);
192− in->pas = kvzalloc(sizeof(*in->pas) * srq->buf.npages, GFP_KERNEL);
192+ in->pas = kvcalloc(srq->buf.npages, sizeof(*in->pas), GFP_KERNEL);
193193 if (!in->pas) {
194194 err = -ENOMEM;
195195 goto err_buf;
drivers/infiniband/hw/mthca/mthca_allocator.c+11−7
@@ -90,8 +90,8 @@ int mthca_alloc_init(struct mthca_alloc *alloc, u32 num, u32 mask, · 89 unmodified lines
9090 alloc->max = num;
9191 alloc->mask = mask;
9292 spin_lock_init(&alloc->lock);
93− alloc->table = kmalloc(BITS_TO_LONGS(num) * sizeof (long),
94− GFP_KERNEL);
93+ alloc->table = kmalloc_array(BITS_TO_LONGS(num), sizeof(long),
94+ GFP_KERNEL);
9595 if (!alloc->table)
9696 return -ENOMEM;
9797
@@ -162,7 +162,8 @@ int mthca_array_init(struct mthca_array *array, int nent) · 64 unmodified lines
162162 int npage = (nent * sizeof (void *) + PAGE_SIZE - 1) / PAGE_SIZE;
163163 int i;
164164
165− array->page_list = kmalloc(npage * sizeof *array->page_list, GFP_KERNEL);
165+ array->page_list = kmalloc_array(npage, sizeof(*array->page_list),
166+ GFP_KERNEL);
166167 if (!array->page_list)
167168 return -ENOMEM;
168169
@@ -220,7 +221,8 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, · 51 unmodified lines
220221 npages *= 2;
221222 }
222223
223− dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
224+ dma_list = kmalloc_array(npages, sizeof(*dma_list),
225+ GFP_KERNEL);
224226 if (!dma_list)
225227 goto err_free;
226228
@@ -231,12 +233,14 @@ int mthca_buf_alloc(struct mthca_dev *dev, int size, int max_direct, · 4 unmodified lines
231233 npages = (size + PAGE_SIZE - 1) / PAGE_SIZE;
232234 shift = PAGE_SHIFT;
233235
234− dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
236+ dma_list = kmalloc_array(npages, sizeof(*dma_list),
237+ GFP_KERNEL);
235238 if (!dma_list)
236239 return -ENOMEM;
237240
238− buf->page_list = kmalloc(npages * sizeof *buf->page_list,
239− GFP_KERNEL);
241+ buf->page_list = kmalloc_array(npages,
242+ sizeof(*buf->page_list),
243+ GFP_KERNEL);
240244 if (!buf->page_list)
241245 goto err_out;
242246
drivers/infiniband/hw/mthca/mthca_cmd.c+3−3
@@ -565,9 +565,9 @@ int mthca_cmd_use_events(struct mthca_dev *dev) · 564 unmodified lines
565565 {
566566 int i;
567567
568− dev->cmd.context = kmalloc(dev->cmd.max_cmds *
569− sizeof (struct mthca_cmd_context),
570− GFP_KERNEL);
568+ dev->cmd.context = kmalloc_array(dev->cmd.max_cmds,
569+ sizeof(struct mthca_cmd_context),
570+ GFP_KERNEL);
571571 if (!dev->cmd.context)
572572 return -ENOMEM;
573573
drivers/infiniband/hw/mthca/mthca_eq.c+3−3
@@ -479,15 +479,15 @@ static int mthca_create_eq(struct mthca_dev *dev, · 478 unmodified lines
479479 eq->nent = roundup_pow_of_two(max(nent, 2));
480480 npages = ALIGN(eq->nent * MTHCA_EQ_ENTRY_SIZE, PAGE_SIZE) / PAGE_SIZE;
481481
482− eq->page_list = kmalloc(npages * sizeof *eq->page_list,
483− GFP_KERNEL);
482+ eq->page_list = kmalloc_array(npages, sizeof(*eq->page_list),
483+ GFP_KERNEL);
484484 if (!eq->page_list)
485485 goto err_out;
486486
487487 for (i = 0; i < npages; ++i)
488488 eq->page_list[i].buf = NULL;
489489
490− dma_list = kmalloc(npages * sizeof *dma_list, GFP_KERNEL);
490+ dma_list = kmalloc_array(npages, sizeof(*dma_list), GFP_KERNEL);
491491 if (!dma_list)
492492 goto err_out_free;
493493
drivers/infiniband/hw/mthca/mthca_memfree.c+3−3
@@ -712,9 +712,9 @@ int mthca_init_db_tab(struct mthca_dev *dev) · 711 unmodified lines
712712 dev->db_tab->max_group1 = 0;
713713 dev->db_tab->min_group2 = dev->db_tab->npages - 1;
714714
715− dev->db_tab->page = kmalloc(dev->db_tab->npages *
716− sizeof *dev->db_tab->page,
717− GFP_KERNEL);
715+ dev->db_tab->page = kmalloc_array(dev->db_tab->npages,
716+ sizeof(*dev->db_tab->page),
717+ GFP_KERNEL);
718718 if (!dev->db_tab->page) {
719719 kfree(dev->db_tab);
720720 return -ENOMEM;
drivers/infiniband/hw/mthca/mthca_mr.c+2−2
@@ -144,7 +144,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) · 143 unmodified lines
144144 buddy->max_order = max_order;
145145 spin_lock_init(&buddy->lock);
146146
147− buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
147+ buddy->bits = kcalloc(buddy->max_order + 1, sizeof(long *),
148148 GFP_KERNEL);
149149 buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
150150 GFP_KERNEL);
@@ -153,7 +153,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order) · 2 unmodified lines
153153
154154 for (i = 0; i <= buddy->max_order; ++i) {
155155 s = BITS_TO_LONGS(1 << (buddy->max_order - i));
156− buddy->bits[i] = kmalloc(s * sizeof (long), GFP_KERNEL);
156+ buddy->bits[i] = kmalloc_array(s, sizeof(long), GFP_KERNEL);
157157 if (!buddy->bits[i])
158158 goto err_out_free;
159159 bitmap_zero(buddy->bits[i],
drivers/infiniband/hw/mthca/mthca_profile.c+1−1
@@ -79,7 +79,7 @@ s64 mthca_make_profile(struct mthca_dev *dev, · 78 unmodified lines
7979 struct mthca_resource *profile;
8080 int i, j;
8181
82− profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
82+ profile = kcalloc(MTHCA_RES_NUM, sizeof(*profile), GFP_KERNEL);
8383 if (!profile)
8484 return -ENOMEM;
8585
drivers/infiniband/hw/mthca/mthca_qp.c+2−2
@@ -1054,8 +1054,8 @@ static int mthca_alloc_wqe_buf(struct mthca_dev *dev, · 1053 unmodified lines
10541054 size = PAGE_ALIGN(qp->send_wqe_offset +
10551055 (qp->sq.max << qp->sq.wqe_shift));
10561056
1057− qp->wrid = kmalloc((qp->rq.max + qp->sq.max) * sizeof (u64),
1058− GFP_KERNEL);
1057+ qp->wrid = kmalloc_array(qp->rq.max + qp->sq.max, sizeof(u64),
1058+ GFP_KERNEL);
10591059 if (!qp->wrid)
10601060 goto err_out;
10611061
drivers/infiniband/hw/mthca/mthca_srq.c+1−1
@@ -155,7 +155,7 @@ static int mthca_alloc_srq_buf(struct mthca_dev *dev, struct mthca_pd *pd, · 154 unmodified lines
155155 if (pd->ibpd.uobject)
156156 return 0;
157157
158− srq->wrid = kmalloc(srq->max * sizeof (u64), GFP_KERNEL);
158+ srq->wrid = kmalloc_array(srq->max, sizeof(u64), GFP_KERNEL);
159159 if (!srq->wrid)
160160 return -ENOMEM;
161161
drivers/infiniband/hw/nes/nes_mgt.c+2−1
@@ -878,7 +878,8 @@ int nes_init_mgt_qp(struct nes_device *nesdev, struct net_device *netdev, struct · 877 unmodified lines
878878 int ret;
879879
880880 /* Allocate space the all mgt QPs once */
881− mgtvnic = kzalloc(NES_MGT_QP_COUNT * sizeof(struct nes_vnic_mgt), GFP_KERNEL);
881+ mgtvnic = kcalloc(NES_MGT_QP_COUNT, sizeof(struct nes_vnic_mgt),
882+ GFP_KERNEL);
882883 if (!mgtvnic)
883884 return -ENOMEM;
884885
drivers/infiniband/hw/nes/nes_nic.c+1−1
@@ -904,7 +904,7 @@ static void nes_netdev_set_multicast_list(struct net_device *netdev) · 903 unmodified lines
904904 int i;
905905 struct netdev_hw_addr *ha;
906906
907− addrs = kmalloc(ETH_ALEN * mc_count, GFP_ATOMIC);
907+ addrs = kmalloc_array(mc_count, ETH_ALEN, GFP_ATOMIC);
908908 if (!addrs) {
909909 set_allmulti(nesdev, nic_active_bit);
910910 goto unlock;
drivers/infiniband/hw/nes/nes_verbs.c+3−2
@@ -2254,8 +2254,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length, · 2253 unmodified lines
22542254 ibmr = ERR_PTR(-ENOMEM);
22552255 goto reg_user_mr_err;
22562256 }
2257− root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024,
2258− GFP_KERNEL);
2257+ root_vpbl.leaf_vpbl = kcalloc(1024,
2258+ sizeof(*root_vpbl.leaf_vpbl),
2259+ GFP_KERNEL);
22592260 if (!root_vpbl.leaf_vpbl) {
22602261 ib_umem_release(region);
22612262 pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase,
drivers/infiniband/hw/ocrdma/ocrdma_hw.c+1−1
@@ -3096,7 +3096,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev) · 3095 unmodified lines
30963096 if (!num_eq)
30973097 return -EINVAL;
30983098
3099− dev->eq_tbl = kzalloc(sizeof(struct ocrdma_eq) * num_eq, GFP_KERNEL);
3099+ dev->eq_tbl = kcalloc(num_eq, sizeof(struct ocrdma_eq), GFP_KERNEL);
31003100 if (!dev->eq_tbl)
31013101 return -ENOMEM;
31023102
drivers/infiniband/hw/ocrdma/ocrdma_main.c+6−5
@@ -221,19 +221,20 @@ static int ocrdma_register_device(struct ocrdma_dev *dev) · 220 unmodified lines
221221 static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
222222 {
223223 mutex_init(&dev->dev_lock);
224− dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) *
225− OCRDMA_MAX_CQ, GFP_KERNEL);
224+ dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(struct ocrdma_cq *),
225+ GFP_KERNEL);
226226 if (!dev->cq_tbl)
227227 goto alloc_err;
228228
229229 if (dev->attr.max_qp) {
230− dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) *
231− OCRDMA_MAX_QP, GFP_KERNEL);
230+ dev->qp_tbl = kcalloc(OCRDMA_MAX_QP,
231+ sizeof(struct ocrdma_qp *),
232+ GFP_KERNEL);
232233 if (!dev->qp_tbl)
233234 goto alloc_err;
234235 }
235236
236− dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL);
237+ dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(u64), GFP_KERNEL);
237238 if (dev->stag_arr == NULL)
238239 goto alloc_err;
239240
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c+8−7
@@ -843,8 +843,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr) · 842 unmodified lines
843843 void *va;
844844 dma_addr_t pa;
845845
846− mr->pbl_table = kzalloc(sizeof(struct ocrdma_pbl) *
847− mr->num_pbls, GFP_KERNEL);
846+ mr->pbl_table = kcalloc(mr->num_pbls, sizeof(struct ocrdma_pbl),
847+ GFP_KERNEL);
848848
849849 if (!mr->pbl_table)
850850 return -ENOMEM;
@@ -1323,12 +1323,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp, · 472 unmodified lines
13231323 static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp)
13241324 {
13251325 qp->wqe_wr_id_tbl =
1326− kzalloc(sizeof(*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt,
1326+ kcalloc(qp->sq.max_cnt, sizeof(*(qp->wqe_wr_id_tbl)),
13271327 GFP_KERNEL);
13281328 if (qp->wqe_wr_id_tbl == NULL)
13291329 return -ENOMEM;
13301330 qp->rqe_wr_id_tbl =
1331− kzalloc(sizeof(u64) * qp->rq.max_cnt, GFP_KERNEL);
1331+ kcalloc(qp->rq.max_cnt, sizeof(u64), GFP_KERNEL);
13321332 if (qp->rqe_wr_id_tbl == NULL)
13331333 return -ENOMEM;
13341334
@@ -1865,15 +1865,16 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd, · 530 unmodified lines
18651865
18661866 if (udata == NULL) {
18671867 status = -ENOMEM;
1868− srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt,
1869− GFP_KERNEL);
1868+ srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, sizeof(u64),
1869+ GFP_KERNEL);
18701870 if (srq->rqe_wr_id_tbl == NULL)
18711871 goto arm_err;
18721872
18731873 srq->bit_fields_len = (srq->rq.max_cnt / 32) +
18741874 (srq->rq.max_cnt % 32 ? 1 : 0);
18751875 srq->idx_bit_fields =
1876− kmalloc(srq->bit_fields_len * sizeof(u32), GFP_KERNEL);
1876+ kmalloc_array(srq->bit_fields_len, sizeof(u32),
1877+ GFP_KERNEL);
18771878 if (srq->idx_bit_fields == NULL)
18781879 goto arm_err;
18791880 memset(srq->idx_bit_fields, 0xff,
drivers/infiniband/hw/qedr/main.c+2−2
@@ -317,8 +317,8 @@ static int qedr_alloc_resources(struct qedr_dev *dev) · 316 unmodified lines
317317 u16 n_entries;
318318 int i, rc;
319319
320− dev->sgid_tbl = kzalloc(sizeof(union ib_gid) *
321− QEDR_MAX_SGID, GFP_KERNEL);
320+ dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid),
321+ GFP_KERNEL);
322322 if (!dev->sgid_tbl)
323323 return -ENOMEM;
324324
drivers/infiniband/hw/qedr/verbs.c+2−2
@@ -1614,7 +1614,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev, · 1613 unmodified lines
16141614 qp->sq.max_wr = min_t(u32, attrs->cap.max_send_wr * dev->wq_multiplier,
16151615 dev->attr.max_sqe);
16161616
1617− qp->wqe_wr_id = kzalloc(qp->sq.max_wr * sizeof(*qp->wqe_wr_id),
1617+ qp->wqe_wr_id = kcalloc(qp->sq.max_wr, sizeof(*qp->wqe_wr_id),
16181618 GFP_KERNEL);
16191619 if (!qp->wqe_wr_id) {
16201620 DP_ERR(dev, "create qp: failed SQ shadow memory allocation\n");
@@ -1632,7 +1632,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev, · 11 unmodified lines
16321632 qp->rq.max_wr = (u16) max_t(u32, attrs->cap.max_recv_wr, 1);
16331633
16341634 /* Allocate driver internal RQ array */
1635− qp->rqe_wr_id = kzalloc(qp->rq.max_wr * sizeof(*qp->rqe_wr_id),
1635+ qp->rqe_wr_id = kcalloc(qp->rq.max_wr, sizeof(*qp->rqe_wr_id),
16361636 GFP_KERNEL);
16371637 if (!qp->rqe_wr_id) {
16381638 DP_ERR(dev,
drivers/infiniband/hw/qib/qib_iba6120.c+5−4
@@ -2496,15 +2496,16 @@ static void init_6120_cntrnames(struct qib_devdata *dd) · 2495 unmodified lines
24962496 dd->cspec->cntrnamelen = sizeof(cntr6120names) - 1;
24972497 else
24982498 dd->cspec->cntrnamelen = 1 + s - cntr6120names;
2499− dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
2500− * sizeof(u64), GFP_KERNEL);
2499+ dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
2500+ GFP_KERNEL);
25012501
25022502 for (i = 0, s = (char *)portcntr6120names; s; i++)
25032503 s = strchr(s + 1, '\n');
25042504 dd->cspec->nportcntrs = i - 1;
25052505 dd->cspec->portcntrnamelen = sizeof(portcntr6120names) - 1;
2506− dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
2507− * sizeof(u64), GFP_KERNEL);
2506+ dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
2507+ sizeof(u64),
2508+ GFP_KERNEL);
25082509 }
25092510
25102511 static u32 qib_read_6120cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
drivers/infiniband/hw/qib/qib_iba7220.c+5−4
@@ -3147,15 +3147,16 @@ static void init_7220_cntrnames(struct qib_devdata *dd) · 3146 unmodified lines
31473147 dd->cspec->cntrnamelen = sizeof(cntr7220names) - 1;
31483148 else
31493149 dd->cspec->cntrnamelen = 1 + s - cntr7220names;
3150− dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
3151− * sizeof(u64), GFP_KERNEL);
3150+ dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
3151+ GFP_KERNEL);
31523152
31533153 for (i = 0, s = (char *)portcntr7220names; s; i++)
31543154 s = strchr(s + 1, '\n');
31553155 dd->cspec->nportcntrs = i - 1;
31563156 dd->cspec->portcntrnamelen = sizeof(portcntr7220names) - 1;
3157− dd->cspec->portcntrs = kmalloc(dd->cspec->nportcntrs
3158− * sizeof(u64), GFP_KERNEL);
3157+ dd->cspec->portcntrs = kmalloc_array(dd->cspec->nportcntrs,
3158+ sizeof(u64),
3159+ GFP_KERNEL);
31593160 }
31603161
31613162 static u32 qib_read_7220cntrs(struct qib_devdata *dd, loff_t pos, char **namep,
drivers/infiniband/hw/qib/qib_iba7322.c+20−14
@@ -3648,8 +3648,9 @@ static int qib_do_7322_reset(struct qib_devdata *dd) · 3647 unmodified lines
36483648
36493649 if (msix_entries) {
36503650 /* can be up to 512 bytes, too big for stack */
3651− msix_vecsave = kmalloc(2 * dd->cspec->num_msix_entries *
3652− sizeof(u64), GFP_KERNEL);
3651+ msix_vecsave = kmalloc_array(2 * dd->cspec->num_msix_entries,
3652+ sizeof(u64),
3653+ GFP_KERNEL);
36533654 }
36543655
36553656 /*
@@ -5009,16 +5010,17 @@ static void init_7322_cntrnames(struct qib_devdata *dd) · 1353 unmodified lines
50095010 dd->cspec->cntrnamelen = sizeof(cntr7322names) - 1;
50105011 else
50115012 dd->cspec->cntrnamelen = 1 + s - cntr7322names;
5012− dd->cspec->cntrs = kmalloc(dd->cspec->ncntrs
5013− * sizeof(u64), GFP_KERNEL);
5013+ dd->cspec->cntrs = kmalloc_array(dd->cspec->ncntrs, sizeof(u64),
5014+ GFP_KERNEL);
50145015
50155016 for (i = 0, s = (char *)portcntr7322names; s; i++)
50165017 s = strchr(s + 1, '\n');
50175018 dd->cspec->nportcntrs = i - 1;
50185019 dd->cspec->portcntrnamelen = sizeof(portcntr7322names) - 1;
50195020 for (i = 0; i < dd->num_pports; ++i) {
5020− dd->pport[i].cpspec->portcntrs = kmalloc(dd->cspec->nportcntrs
5021− * sizeof(u64), GFP_KERNEL);
5021+ dd->pport[i].cpspec->portcntrs =
5022+ kmalloc_array(dd->cspec->nportcntrs, sizeof(u64),
5023+ GFP_KERNEL);
50225024 }
50235025 }
50245026
@@ -6412,12 +6414,15 @@ static int qib_init_7322_variables(struct qib_devdata *dd) · 1387 unmodified lines
64126414 sbufcnt = dd->piobcnt2k + dd->piobcnt4k +
64136415 NUM_VL15_BUFS + BITS_PER_LONG - 1;
64146416 sbufcnt /= BITS_PER_LONG;
6415− dd->cspec->sendchkenable = kmalloc(sbufcnt *
6416− sizeof(*dd->cspec->sendchkenable), GFP_KERNEL);
6417− dd->cspec->sendgrhchk = kmalloc(sbufcnt *
6418− sizeof(*dd->cspec->sendgrhchk), GFP_KERNEL);
6419− dd->cspec->sendibchk = kmalloc(sbufcnt *
6420− sizeof(*dd->cspec->sendibchk), GFP_KERNEL);
6417+ dd->cspec->sendchkenable =
6418+ kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendchkenable),
6419+ GFP_KERNEL);
6420+ dd->cspec->sendgrhchk =
6421+ kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendgrhchk),
6422+ GFP_KERNEL);
6423+ dd->cspec->sendibchk =
6424+ kmalloc_array(sbufcnt, sizeof(*dd->cspec->sendibchk),
6425+ GFP_KERNEL);
64216426 if (!dd->cspec->sendchkenable || !dd->cspec->sendgrhchk ||
64226427 !dd->cspec->sendibchk) {
64236428 ret = -ENOMEM;
@@ -7290,8 +7295,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev, · 866 unmodified lines
72907295 actual_cnt -= dd->num_pports;
72917296
72927297 tabsize = actual_cnt;
7293− dd->cspec->msix_entries = kzalloc(tabsize *
7294− sizeof(struct qib_msix_entry), GFP_KERNEL);
7298+ dd->cspec->msix_entries = kcalloc(tabsize,
7299+ sizeof(struct qib_msix_entry),
7300+ GFP_KERNEL);
72957301 if (!dd->cspec->msix_entries)
72967302 tabsize = 0;
72977303
drivers/infiniband/hw/qib/qib_init.c+8−6
@@ -369,11 +369,13 @@ static void init_shadow_tids(struct qib_devdata *dd) · 368 unmodified lines
369369 struct page **pages;
370370 dma_addr_t *addrs;
371371
372− pages = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(struct page *));
372+ pages = vzalloc(array_size(sizeof(struct page *),
373+ dd->cfgctxts * dd->rcvtidcnt));
373374 if (!pages)
374375 goto bail;
375376
376− addrs = vzalloc(dd->cfgctxts * dd->rcvtidcnt * sizeof(dma_addr_t));
377+ addrs = vzalloc(array_size(sizeof(dma_addr_t),
378+ dd->cfgctxts * dd->rcvtidcnt));
377379 if (!addrs)
378380 goto bail_free;
379381
@@ -1134,8 +1136,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra) · 754 unmodified lines
11341136 if (!qib_cpulist_count) {
11351137 u32 count = num_online_cpus();
11361138
1137− qib_cpulist = kzalloc(BITS_TO_LONGS(count) *
1138− sizeof(long), GFP_KERNEL);
1139+ qib_cpulist = kcalloc(BITS_TO_LONGS(count), sizeof(long),
1140+ GFP_KERNEL);
11391141 if (qib_cpulist)
11401142 qib_cpulist_count = count;
11411143 }
@@ -1673,8 +1675,8 @@ int qib_setup_eagerbufs(struct qib_ctxtdata *rcd) · 531 unmodified lines
16731675 size = rcd->rcvegrbuf_size;
16741676 if (!rcd->rcvegrbuf) {
16751677 rcd->rcvegrbuf =
1676− kzalloc_node(chunk * sizeof(rcd->rcvegrbuf[0]),
1677− GFP_KERNEL, rcd->node_id);
1678+ kcalloc_node(chunk, sizeof(rcd->rcvegrbuf[0]),
1679+ GFP_KERNEL, rcd->node_id);
16781680 if (!rcd->rcvegrbuf)
16791681 goto bail;
16801682 }
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c+1−1
@@ -543,7 +543,7 @@ alloc_res_chunk_list(struct usnic_vnic *vnic, · 542 unmodified lines
543543 /* Do Nothing */
544544 }
545545
546− res_chunk_list = kzalloc(sizeof(*res_chunk_list)*(res_lst_sz+1),
546+ res_chunk_list = kcalloc(res_lst_sz + 1, sizeof(*res_chunk_list),
547547 GFP_ATOMIC);
548548 if (!res_chunk_list)
549549 return ERR_PTR(-ENOMEM);
drivers/infiniband/hw/usnic/usnic_vnic.c+1−1
@@ -312,7 +312,7 @@ static int usnic_vnic_alloc_res_chunk(struct usnic_vnic *vnic, · 311 unmodified lines
312312 }
313313
314314 chunk->cnt = chunk->free_cnt = cnt;
315− chunk->res = kzalloc(sizeof(*(chunk->res))*cnt, GFP_KERNEL);
315+ chunk->res = kcalloc(cnt, sizeof(*(chunk->res)), GFP_KERNEL);
316316 if (!chunk->res)
317317 return -ENOMEM;
318318
drivers/infiniband/sw/rdmavt/qp.c+5−6
@@ -813,7 +813,7 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, · 812 unmodified lines
813813 sz = sizeof(struct rvt_sge) *
814814 init_attr->cap.max_send_sge +
815815 sizeof(struct rvt_swqe);
816− swq = vzalloc_node(sqsize * sz, rdi->dparms.node);
816+ swq = vzalloc_node(array_size(sz, sqsize), rdi->dparms.node);
817817 if (!swq)
818818 return ERR_PTR(-ENOMEM);
819819
@@ -836,11 +836,10 @@ struct ib_qp *rvt_create_qp(struct ib_pd *ibpd, · 16 unmodified lines
836836 RCU_INIT_POINTER(qp->next, NULL);
837837 if (init_attr->qp_type == IB_QPT_RC) {
838838 qp->s_ack_queue =
839− kzalloc_node(
840− sizeof(*qp->s_ack_queue) *
841− rvt_max_atomic(rdi),
842− GFP_KERNEL,
843− rdi->dparms.node);
839+ kcalloc_node(rvt_max_atomic(rdi),
840+ sizeof(*qp->s_ack_queue),
841+ GFP_KERNEL,
842+ rdi->dparms.node);
844843 if (!qp->s_ack_queue)
845844 goto bail_qp;
846845 }
drivers/infiniband/ulp/ipoib/ipoib_cm.c+5−3
@@ -358,7 +358,8 @@ static int ipoib_cm_nonsrq_init_rx(struct net_device *dev, struct ib_cm_id *cm_i · 357 unmodified lines
358358 int ret;
359359 int i;
360360
361− rx->rx_ring = vzalloc(ipoib_recvq_size * sizeof *rx->rx_ring);
361+ rx->rx_ring = vzalloc(array_size(ipoib_recvq_size,
362+ sizeof(*rx->rx_ring)));
362363 if (!rx->rx_ring)
363364 return -ENOMEM;
364365
@@ -1145,7 +1146,7 @@ static int ipoib_cm_tx_init(struct ipoib_cm_tx *p, u32 qpn, · 780 unmodified lines
11451146 int ret;
11461147
11471148 noio_flag = memalloc_noio_save();
1148− p->tx_ring = vzalloc(ipoib_sendq_size * sizeof(*p->tx_ring));
1149+ p->tx_ring = vzalloc(array_size(ipoib_sendq_size, sizeof(*p->tx_ring)));
11491150 if (!p->tx_ring) {
11501151 memalloc_noio_restore(noio_flag);
11511152 ret = -ENOMEM;
@@ -1570,7 +1571,8 @@ static void ipoib_cm_create_srq(struct net_device *dev, int max_sge) · 418 unmodified lines
15701571 return;
15711572 }
15721573
1573− priv->cm.srq_ring = vzalloc(ipoib_recvq_size * sizeof *priv->cm.srq_ring);
1574+ priv->cm.srq_ring = vzalloc(array_size(ipoib_recvq_size,
1575+ sizeof(*priv->cm.srq_ring)));
15741576 if (!priv->cm.srq_ring) {
15751577 ib_destroy_srq(priv->cm.srq);
15761578 priv->cm.srq = NULL;
drivers/infiniband/ulp/ipoib/ipoib_main.c+6−4
@@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv) · 1525 unmodified lines
15261526 return -ENOMEM;
15271527 set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
15281528 size = roundup_pow_of_two(arp_tbl.gc_thresh3);
1529− buckets = kzalloc(size * sizeof(*buckets), GFP_KERNEL);
1529+ buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
15301530 if (!buckets) {
15311531 kfree(htbl);
15321532 return -ENOMEM;
@@ -1704,12 +1704,14 @@ static int ipoib_dev_init_default(struct net_device *dev) · 171 unmodified lines
17041704 ipoib_napi_add(dev);
17051705
17061706 /* Allocate RX/TX "rings" to hold queued skbs */
1707− priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring,
1708− GFP_KERNEL);
1707+ priv->rx_ring = kcalloc(ipoib_recvq_size,
1708+ sizeof(*priv->rx_ring),
1709+ GFP_KERNEL);
17091710 if (!priv->rx_ring)
17101711 goto out;
17111712
1712− priv->tx_ring = vzalloc(ipoib_sendq_size * sizeof *priv->tx_ring);
1713+ priv->tx_ring = vzalloc(array_size(ipoib_sendq_size,
1714+ sizeof(*priv->tx_ring)));
17131715 if (!priv->tx_ring) {
17141716 pr_warn("%s: failed to allocate TX ring (%d entries)\n",
17151717 priv->ca->name, ipoib_sendq_size);
drivers/infiniband/ulp/iser/iser_initiator.c+3−2
@@ -258,8 +258,9 @@ int iser_alloc_rx_descriptors(struct iser_conn *iser_conn, · 257 unmodified lines
258258 goto alloc_login_buf_fail;
259259
260260 iser_conn->num_rx_descs = session->cmds_max;
261− iser_conn->rx_descs = kmalloc(iser_conn->num_rx_descs *
262− sizeof(struct iser_rx_desc), GFP_KERNEL);
261+ iser_conn->rx_descs = kmalloc_array(iser_conn->num_rx_descs,
262+ sizeof(struct iser_rx_desc),
263+ GFP_KERNEL);
263264 if (!iser_conn->rx_descs)
264265 goto rx_desc_alloc_fail;
265266
drivers/infiniband/ulp/isert/ib_isert.c+3−2
@@ -181,8 +181,9 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn) · 180 unmodified lines
181181 u64 dma_addr;
182182 int i, j;
183183
184− isert_conn->rx_descs = kzalloc(ISERT_QP_MAX_RECV_DTOS *
185− sizeof(struct iser_rx_desc), GFP_KERNEL);
184+ isert_conn->rx_descs = kcalloc(ISERT_QP_MAX_RECV_DTOS,
185+ sizeof(struct iser_rx_desc),
186+ GFP_KERNEL);
186187 if (!isert_conn->rx_descs)
187188 return -ENOMEM;
188189
drivers/infiniband/ulp/srp/ib_srp.c+5−4
@@ -1035,16 +1035,17 @@ static int srp_alloc_req_data(struct srp_rdma_ch *ch) · 1034 unmodified lines
10351035
10361036 for (i = 0; i < target->req_ring_size; ++i) {
10371037 req = &ch->req_ring[i];
1038− mr_list = kmalloc(target->mr_per_cmd * sizeof(void *),
1039− GFP_KERNEL);
1038+ mr_list = kmalloc_array(target->mr_per_cmd, sizeof(void *),
1039+ GFP_KERNEL);
10401040 if (!mr_list)
10411041 goto out;
10421042 if (srp_dev->use_fast_reg) {
10431043 req->fr_list = mr_list;
10441044 } else {
10451045 req->fmr_list = mr_list;
1046− req->map_page = kmalloc(srp_dev->max_pages_per_mr *
1047− sizeof(void *), GFP_KERNEL);
1046+ req->map_page = kmalloc_array(srp_dev->max_pages_per_mr,
1047+ sizeof(void *),
1048+ GFP_KERNEL);
10481049 if (!req->map_page)
10491050 goto out;
10501051 }
drivers/infiniband/ulp/srpt/ib_srpt.c+1−1
@@ -720,7 +720,7 @@ static struct srpt_ioctx **srpt_alloc_ioctx_ring(struct srpt_device *sdev, · 719 unmodified lines
720720 WARN_ON(ioctx_size != sizeof(struct srpt_recv_ioctx)
721721 && ioctx_size != sizeof(struct srpt_send_ioctx));
722722
723− ring = kmalloc(ring_size * sizeof(ring[0]), GFP_KERNEL);
723+ ring = kmalloc_array(ring_size, sizeof(ring[0]), GFP_KERNEL);
724724 if (!ring)
725725 goto out;
726726 for (i = 0; i < ring_size; ++i) {
drivers/input/joystick/joydump.c+1−1
@@ -80,7 +80,7 @@ static int joydump_connect(struct gameport *gameport, struct gameport_driver *dr · 79 unmodified lines
8080
8181 timeout = gameport_time(gameport, 10000); /* 10 ms */
8282
83− buf = kmalloc(BUF_SIZE * sizeof(struct joydump), GFP_KERNEL);
83+ buf = kmalloc_array(BUF_SIZE, sizeof(struct joydump), GFP_KERNEL);
8484 if (!buf) {
8585 printk(KERN_INFO "joydump: no memory for testing\n");
8686 goto jd_end;
drivers/input/keyboard/clps711x-keypad.c+2−2
@@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev) · 108 unmodified lines
109109 if (priv->row_count < 1)
110110 return -EINVAL;
111111
112− priv->gpio_data = devm_kzalloc(dev,
113− sizeof(*priv->gpio_data) * priv->row_count,
112+ priv->gpio_data = devm_kcalloc(dev,
113+ priv->row_count, sizeof(*priv->gpio_data),
114114 GFP_KERNEL);
115115 if (!priv->gpio_data)
116116 return -ENOMEM;
drivers/input/keyboard/matrix_keypad.c+3−3
@@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev) · 442 unmodified lines
443443 of_property_read_u32(np, "col-scan-delay-us",
444444 &pdata->col_scan_delay_us);
445445
446− gpios = devm_kzalloc(dev,
447− sizeof(unsigned int) *
448− (pdata->num_row_gpios + pdata->num_col_gpios),
446+ gpios = devm_kcalloc(dev,
447+ pdata->num_row_gpios + pdata->num_col_gpios,
448+ sizeof(unsigned int),
449449 GFP_KERNEL);
450450 if (!gpios) {
451451 dev_err(dev, "could not allocate memory for gpios\n");
drivers/input/keyboard/omap4-keypad.c+2−1
@@ -337,7 +337,8 @@ static int omap4_keypad_probe(struct platform_device *pdev) · 336 unmodified lines
337337
338338 keypad_data->row_shift = get_count_order(keypad_data->cols);
339339 max_keys = keypad_data->rows << keypad_data->row_shift;
340− keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]),
340+ keypad_data->keymap = kcalloc(max_keys,
341+ sizeof(keypad_data->keymap[0]),
341342 GFP_KERNEL);
342343 if (!keypad_data->keymap) {
343344 dev_err(&pdev->dev, "Not enough memory for keymap\n");
drivers/input/keyboard/samsung-keypad.c+1−1
@@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev) · 280 unmodified lines
281281
282282 key_count = of_get_child_count(np);
283283 keymap_data->keymap_size = key_count;
284− keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL);
284+ keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL);
285285 if (!keymap) {
286286 dev_err(dev, "could not allocate memory for keymap\n");
287287 return ERR_PTR(-ENOMEM);
drivers/input/matrix-keymap.c+2−2
@@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, · 169 unmodified lines
170170 return -EINVAL;
171171
172172 if (!keymap) {
173− keymap = devm_kzalloc(input_dev->dev.parent,
174− max_keys * sizeof(*keymap),
173+ keymap = devm_kcalloc(input_dev->dev.parent,
174+ max_keys, sizeof(*keymap),
175175 GFP_KERNEL);
176176 if (!keymap) {
177177 dev_err(input_dev->dev.parent,
drivers/input/misc/rotary_encoder.c+2−2
@@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) · 282 unmodified lines
283283 }
284284
285285 encoder->irq =
286− devm_kzalloc(dev,
287− sizeof(*encoder->irq) * encoder->gpios->ndescs,
286+ devm_kcalloc(dev,
287+ encoder->gpios->ndescs, sizeof(*encoder->irq),
288288 GFP_KERNEL);
289289 if (!encoder->irq)
290290 return -ENOMEM;
drivers/input/rmi4/rmi_driver.c+5−4
@@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, · 635 unmodified lines
636636 rdesc->num_registers = bitmap_weight(rdesc->presense_map,
637637 RMI_REG_DESC_PRESENSE_BITS);
638638
639− rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers *
640− sizeof(struct rmi_register_desc_item),
641− GFP_KERNEL);
639+ rdesc->registers = devm_kcalloc(&d->dev,
640+ rdesc->num_registers,
641+ sizeof(struct rmi_register_desc_item),
642+ GFP_KERNEL);
642643 if (!rdesc->registers)
643644 return -ENOMEM;
644645
@@ -1061,7 +1062,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data) · 416 unmodified lines
10611062 data->num_of_irq_regs = (data->irq_count + 7) / 8;
10621063
10631064 size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long);
1064− data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL);
1065+ data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL);
10651066 if (!data->irq_memory) {
10661067 dev_err(dev, "Failed to allocate memory for irq masks.\n");
10671068 return -ENOMEM;
drivers/input/rmi4/rmi_f11.c+8−7
@@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn) · 1189 unmodified lines
11901190 f11->sensor.attn_size += f11->sensor.nbr_fingers * 2;
11911191
11921192 /* allocate the in-kernel tracking buffers */
1193− sensor->tracking_pos = devm_kzalloc(&fn->dev,
1194− sizeof(struct input_mt_pos) * sensor->nbr_fingers,
1193+ sensor->tracking_pos = devm_kcalloc(&fn->dev,
1194+ sensor->nbr_fingers, sizeof(struct input_mt_pos),
1195+ GFP_KERNEL);
1196+ sensor->tracking_slots = devm_kcalloc(&fn->dev,
1197+ sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
1198+ sensor->objs = devm_kcalloc(&fn->dev,
1199+ sensor->nbr_fingers,
1200+ sizeof(struct rmi_2d_sensor_abs_object),
11951201 GFP_KERNEL);
1196− sensor->tracking_slots = devm_kzalloc(&fn->dev,
1197− sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
1198− sensor->objs = devm_kzalloc(&fn->dev,
1199− sizeof(struct rmi_2d_sensor_abs_object)
1200− * sensor->nbr_fingers, GFP_KERNEL);
12011202 if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
12021203 return -ENOMEM;
12031204
drivers/input/rmi4/rmi_f12.c+8−7
@@ -502,14 +502,15 @@ static int rmi_f12_probe(struct rmi_function *fn) · 501 unmodified lines
502502 }
503503
504504 /* allocate the in-kernel tracking buffers */
505− sensor->tracking_pos = devm_kzalloc(&fn->dev,
506− sizeof(struct input_mt_pos) * sensor->nbr_fingers,
505+ sensor->tracking_pos = devm_kcalloc(&fn->dev,
506+ sensor->nbr_fingers, sizeof(struct input_mt_pos),
507+ GFP_KERNEL);
508+ sensor->tracking_slots = devm_kcalloc(&fn->dev,
509+ sensor->nbr_fingers, sizeof(int), GFP_KERNEL);
510+ sensor->objs = devm_kcalloc(&fn->dev,
511+ sensor->nbr_fingers,
512+ sizeof(struct rmi_2d_sensor_abs_object),
507513 GFP_KERNEL);
508− sensor->tracking_slots = devm_kzalloc(&fn->dev,
509− sizeof(int) * sensor->nbr_fingers, GFP_KERNEL);
510− sensor->objs = devm_kzalloc(&fn->dev,
511− sizeof(struct rmi_2d_sensor_abs_object)
512− * sensor->nbr_fingers, GFP_KERNEL);
513514 if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs)
514515 return -ENOMEM;
515516
drivers/input/rmi4/rmi_f54.c+1−1
@@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn) · 684 unmodified lines
685685 rx = f54->num_rx_electrodes;
686686 tx = f54->num_tx_electrodes;
687687 f54->report_data = devm_kzalloc(&fn->dev,
688− sizeof(u16) * tx * rx,
688+ array3_size(tx, rx, sizeof(u16)),
689689 GFP_KERNEL);
690690 if (f54->report_data == NULL)
691691 return -ENOMEM;
drivers/input/rmi4/rmi_spi.c+5−4
@@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) · 68 unmodified lines
6969 buf_size = RMI_SPI_XFER_SIZE_LIMIT;
7070
7171 tmp = rmi_spi->rx_buf;
72− buf = devm_kzalloc(&spi->dev, buf_size * 2,
72+ buf = devm_kcalloc(&spi->dev, buf_size, 2,
7373 GFP_KERNEL | GFP_DMA);
7474 if (!buf)
7575 return -ENOMEM;
@@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) · 20 unmodified lines
9696 * per byte delays.
9797 */
9898 tmp = rmi_spi->rx_xfers;
99− xfer_buf = devm_kzalloc(&spi->dev,
100− (rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count)
101− * sizeof(struct spi_transfer), GFP_KERNEL);
99+ xfer_buf = devm_kcalloc(&spi->dev,
100+ rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count,
101+ sizeof(struct spi_transfer),
102+ GFP_KERNEL);
102103 if (!xfer_buf)
103104 return -ENOMEM;
104105
drivers/iommu/arm-smmu.c+1−1
@@ -2082,7 +2082,7 @@ static int arm_smmu_device_probe(struct platform_device *pdev) · 2081 unmodified lines
20822082 return -ENODEV;
20832083 }
20842084
2085− smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs,
2085+ smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs),
20862086 GFP_KERNEL);
20872087 if (!smmu->irqs) {
20882088 dev_err(dev, "failed to allocate %d irqs\n", num_irqs);
drivers/iommu/dmar.c+1−1
@@ -1458,7 +1458,7 @@ int dmar_enable_qi(struct intel_iommu *iommu) · 1457 unmodified lines
14581458
14591459 qi->desc = page_address(desc_page);
14601460
1461− qi->desc_status = kzalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC);
1461+ qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC);
14621462 if (!qi->desc_status) {
14631463 free_page((unsigned long) qi->desc);
14641464 kfree(qi);
drivers/iommu/intel-iommu.c+2−2
@@ -3189,7 +3189,7 @@ static int copy_translation_tables(struct intel_iommu *iommu) · 3188 unmodified lines
31893189 /* This is too big for the stack - allocate it from slab */
31903190 ctxt_table_entries = ext ? 512 : 256;
31913191 ret = -ENOMEM;
3192− ctxt_tbls = kzalloc(ctxt_table_entries * sizeof(void *), GFP_KERNEL);
3192+ ctxt_tbls = kcalloc(ctxt_table_entries, sizeof(void *), GFP_KERNEL);
31933193 if (!ctxt_tbls)
31943194 goto out_unmap;
31953195
@@ -4032,7 +4032,7 @@ static int iommu_suspend(void) · 836 unmodified lines
40324032 unsigned long flag;
40334033
40344034 for_each_active_iommu(iommu, drhd) {
4035− iommu->iommu_state = kzalloc(sizeof(u32) * MAX_SR_DMAR_REGS,
4035+ iommu->iommu_state = kcalloc(MAX_SR_DMAR_REGS, sizeof(u32),
40364036 GFP_ATOMIC);
40374037 if (!iommu->iommu_state)
40384038 goto nomem;
drivers/iommu/omap-iommu.c+1−1
@@ -1455,7 +1455,7 @@ static int omap_iommu_add_device(struct device *dev) · 1454 unmodified lines
14551455 if (num_iommus < 0)
14561456 return 0;
14571457
1458− arch_data = kzalloc((num_iommus + 1) * sizeof(*arch_data), GFP_KERNEL);
1458+ arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL);
14591459 if (!arch_data)
14601460 return -ENOMEM;
14611461
drivers/iommu/rockchip-iommu.c+1−1
@@ -1135,7 +1135,7 @@ static int rk_iommu_probe(struct platform_device *pdev) · 1134 unmodified lines
11351135 iommu->dev = dev;
11361136 iommu->num_mmu = 0;
11371137
1138− iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res,
1138+ iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases),
11391139 GFP_KERNEL);
11401140 if (!iommu->bases)
11411141 return -ENOMEM;
drivers/iommu/tegra-gart.c+1−1
@@ -465,7 +465,7 @@ static int tegra_gart_probe(struct platform_device *pdev) · 464 unmodified lines
465465 gart->iovmm_base = (dma_addr_t)res_remap->start;
466466 gart->page_count = (resource_size(res_remap) >> GART_PAGE_SHIFT);
467467
468− gart->savedata = vmalloc(sizeof(u32) * gart->page_count);
468+ gart->savedata = vmalloc(array_size(sizeof(u32), gart->page_count));
469469 if (!gart->savedata) {
470470 dev_err(dev, "failed to allocate context save area\n");
471471 return -ENOMEM;
drivers/ipack/carriers/tpci200.c+2−2
@@ -457,8 +457,8 @@ static int tpci200_install(struct tpci200_board *tpci200) · 456 unmodified lines
457457 {
458458 int res;
459459
460− tpci200->slots = kzalloc(
461− TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL);
460+ tpci200->slots = kcalloc(TPCI200_NB_SLOT, sizeof(struct tpci200_slot),
461+ GFP_KERNEL);
462462 if (tpci200->slots == NULL)
463463 return -ENOMEM;
464464
drivers/irqchip/irq-alpine-msi.c+2−1
@@ -268,7 +268,8 @@ static int alpine_msix_init(struct device_node *node, · 267 unmodified lines
268268 goto err_priv;
269269 }
270270
271− priv->msi_map = kzalloc(sizeof(*priv->msi_map) * BITS_TO_LONGS(priv->num_spis),
271+ priv->msi_map = kcalloc(BITS_TO_LONGS(priv->num_spis),
272+ sizeof(*priv->msi_map),
272273 GFP_KERNEL);
273274 if (!priv->msi_map) {
274275 ret = -ENOMEM;
drivers/irqchip/irq-gic-v2m.c+1−1
@@ -361,7 +361,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode, · 360 unmodified lines
361361 break;
362362 }
363363
364− v2m->bm = kzalloc(sizeof(long) * BITS_TO_LONGS(v2m->nr_spis),
364+ v2m->bm = kcalloc(BITS_TO_LONGS(v2m->nr_spis), sizeof(long),
365365 GFP_KERNEL);
366366 if (!v2m->bm) {
367367 ret = -ENOMEM;
drivers/irqchip/irq-gic-v3-its.c+10−9
@@ -1239,7 +1239,7 @@ static int its_vlpi_map(struct irq_data *d, struct its_cmd_info *info) · 1238 unmodified lines
12391239 if (!its_dev->event_map.vm) {
12401240 struct its_vlpi_map *maps;
12411241
1242− maps = kzalloc(sizeof(*maps) * its_dev->event_map.nr_lpis,
1242+ maps = kcalloc(its_dev->event_map.nr_lpis, sizeof(*maps),
12431243 GFP_KERNEL);
12441244 if (!maps) {
12451245 ret = -ENOMEM;
@@ -1437,7 +1437,7 @@ static int __init its_lpi_init(u32 id_bits) · 191 unmodified lines
14371437 {
14381438 lpi_chunks = its_lpi_to_chunk(1UL << id_bits);
14391439
1440− lpi_bitmap = kzalloc(BITS_TO_LONGS(lpi_chunks) * sizeof(long),
1440+ lpi_bitmap = kcalloc(BITS_TO_LONGS(lpi_chunks), sizeof(long),
14411441 GFP_KERNEL);
14421442 if (!lpi_bitmap) {
14431443 lpi_chunks = 0;
@@ -1471,7 +1471,8 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, int *base, int *nr_ids) · 27 unmodified lines
14711471 if (!nr_chunks)
14721472 goto out;
14731473
1474− bitmap = kzalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK) * sizeof (long),
1474+ bitmap = kcalloc(BITS_TO_LONGS(nr_chunks * IRQS_PER_CHUNK),
1475+ sizeof(long),
14751476 GFP_ATOMIC);
14761477 if (!bitmap)
14771478 goto out;
@@ -1823,7 +1824,7 @@ static int its_alloc_tables(struct its_node *its) · 345 unmodified lines
18231824
18241825 static int its_alloc_collections(struct its_node *its)
18251826 {
1826− its->collections = kzalloc(nr_cpu_ids * sizeof(*its->collections),
1827+ its->collections = kcalloc(nr_cpu_ids, sizeof(*its->collections),
18271828 GFP_KERNEL);
18281829 if (!its->collections)
18291830 return -ENOMEM;
@@ -2124,10 +2125,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id, · 294 unmodified lines
21242125 if (alloc_lpis) {
21252126 lpi_map = its_lpi_alloc_chunks(nvecs, &lpi_base, &nr_lpis);
21262127 if (lpi_map)
2127− col_map = kzalloc(sizeof(*col_map) * nr_lpis,
2128+ col_map = kcalloc(nr_lpis, sizeof(*col_map),
21282129 GFP_KERNEL);
21292130 } else {
2130− col_map = kzalloc(sizeof(*col_map) * nr_ites, GFP_KERNEL);
2131+ col_map = kcalloc(nr_ites, sizeof(*col_map), GFP_KERNEL);
21312132 nr_lpis = 0;
21322133 lpi_base = 0;
21332134 }
@@ -3183,7 +3184,7 @@ static int its_init_vpe_domain(void) · 1049 unmodified lines
31833184 its = list_first_entry(&its_nodes, struct its_node, entry);
31843185
31853186 entries = roundup_pow_of_two(nr_cpu_ids);
3186− vpe_proxy.vpes = kzalloc(sizeof(*vpe_proxy.vpes) * entries,
3187+ vpe_proxy.vpes = kcalloc(entries, sizeof(*vpe_proxy.vpes),
31873188 GFP_KERNEL);
31883189 if (!vpe_proxy.vpes) {
31893190 pr_err("ITS: Can't allocate GICv4 proxy device array\n");
@@ -3567,8 +3568,8 @@ static void __init acpi_table_parse_srat_its(void) · 377 unmodified lines
35673568 if (count <= 0)
35683569 return;
35693570
3570− its_srat_maps = kmalloc(count * sizeof(struct its_srat_map),
3571− GFP_KERNEL);
3571+ its_srat_maps = kmalloc_array(count, sizeof(struct its_srat_map),
3572+ GFP_KERNEL);
35723573 if (!its_srat_maps) {
35733574 pr_warn("SRAT: Failed to allocate memory for its_srat_maps!\n");
35743575 return;
drivers/irqchip/irq-gic-v3.c+3−2
@@ -1167,7 +1167,7 @@ static void __init gic_populate_ppi_partitions(struct device_node *gic_node) · 1166 unmodified lines
11671167 if (!nr_parts)
11681168 goto out_put_node;
11691169
1170− parts = kzalloc(sizeof(*parts) * nr_parts, GFP_KERNEL);
1170+ parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
11711171 if (WARN_ON(!parts))
11721172 goto out_put_node;
11731173
@@ -1289,7 +1289,8 @@ static int __init gic_of_init(struct device_node *node, struct device_node *pare · 115 unmodified lines
12891289 if (of_property_read_u32(node, "#redistributor-regions", &nr_redist_regions))
12901290 nr_redist_regions = 1;
12911291
1292− rdist_regs = kzalloc(sizeof(*rdist_regs) * nr_redist_regions, GFP_KERNEL);
1292+ rdist_regs = kcalloc(nr_redist_regions, sizeof(*rdist_regs),
1293+ GFP_KERNEL);
12931294 if (!rdist_regs) {
12941295 err = -ENOMEM;
12951296 goto out_unmap_dist;
drivers/irqchip/irq-imgpdc.c+1−1
@@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev) · 353 unmodified lines
354354 priv->nr_syswakes = val;
355355
356356 /* Get peripheral IRQ numbers */
357− priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips,
357+ priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips,
358358 GFP_KERNEL);
359359 if (!priv->perip_irqs) {
360360 dev_err(&pdev->dev, "cannot allocate perip IRQ list\n");
drivers/irqchip/irq-mvebu-gicp.c+4−4
@@ -191,8 +191,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) · 190 unmodified lines
191191 gicp->spi_ranges_cnt = ret / 2;
192192
193193 gicp->spi_ranges =
194− devm_kzalloc(&pdev->dev,
195− gicp->spi_ranges_cnt *
194+ devm_kcalloc(&pdev->dev,
195+ gicp->spi_ranges_cnt,
196196 sizeof(struct mvebu_gicp_spi_range),
197197 GFP_KERNEL);
198198 if (!gicp->spi_ranges)
@@ -210,8 +210,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) · 11 unmodified lines
210210 gicp->spi_cnt += gicp->spi_ranges[i].count;
211211 }
212212
213− gicp->spi_bitmap = devm_kzalloc(&pdev->dev,
214− BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long),
213+ gicp->spi_bitmap = devm_kcalloc(&pdev->dev,
214+ BITS_TO_LONGS(gicp->spi_cnt), sizeof(long),
215215 GFP_KERNEL);
216216 if (!gicp->spi_bitmap)
217217 return -ENOMEM;
drivers/irqchip/irq-partition-percpu.c+1−1
@@ -229,7 +229,7 @@ struct partition_desc *partition_create_desc(struct fwnode_handle *fwnode, · 228 unmodified lines
229229 goto out;
230230 desc->domain = d;
231231
232− desc->bitmap = kzalloc(sizeof(long) * BITS_TO_LONGS(nr_parts),
232+ desc->bitmap = kcalloc(BITS_TO_LONGS(nr_parts), sizeof(long),
233233 GFP_KERNEL);
234234 if (WARN_ON(!desc->bitmap))
235235 goto out;
drivers/irqchip/irq-s3c24xx.c+1−1
@@ -1261,7 +1261,7 @@ static int __init s3c_init_intc_of(struct device_node *np, · 1260 unmodified lines
12611261 return -ENOMEM;
12621262
12631263 intc->domain = domain;
1264− intc->irqs = kzalloc(sizeof(struct s3c_irq_data) * 32,
1264+ intc->irqs = kcalloc(32, sizeof(struct s3c_irq_data),
12651265 GFP_KERNEL);
12661266 if (!intc->irqs) {
12671267 kfree(intc);
drivers/isdn/capi/capi.c+1−1
@@ -1260,7 +1260,7 @@ static int __init capinc_tty_init(void) · 1259 unmodified lines
12601260 if (capi_ttyminors <= 0)
12611261 capi_ttyminors = CAPINC_NR_PORTS;
12621262
1263− capiminors = kzalloc(sizeof(struct capiminor *) * capi_ttyminors,
1263+ capiminors = kcalloc(capi_ttyminors, sizeof(struct capiminor *),
12641264 GFP_KERNEL);
12651265 if (!capiminors)
12661266 return -ENOMEM;
drivers/isdn/capi/capidrv.c+2−1
@@ -2268,7 +2268,8 @@ static int capidrv_addcontr(u16 contr, struct capi_profile *profp) · 2267 unmodified lines
22682268 strcpy(card->name, id);
22692269 card->contrnr = contr;
22702270 card->nbchan = profp->nbchannel;
2271− card->bchans = kmalloc(sizeof(capidrv_bchan) * card->nbchan, GFP_ATOMIC);
2271+ card->bchans = kmalloc_array(card->nbchan, sizeof(capidrv_bchan),
2272+ GFP_ATOMIC);
22722273 if (!card->bchans) {
22732274 printk(KERN_WARNING
22742275 "capidrv: (%s) Could not allocate bchan-structs.\n", id);
drivers/isdn/gigaset/capi.c+3−3
@@ -252,7 +252,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, · 251 unmodified lines
252252 return;
253253 if (l > 64)
254254 l = 64; /* arbitrary limit */
255− dbgline = kmalloc(3 * l, GFP_ATOMIC);
255+ dbgline = kmalloc_array(3, l, GFP_ATOMIC);
256256 if (!dbgline)
257257 return;
258258 for (i = 0; i < l; i++) {
@@ -272,7 +272,7 @@ static inline void dump_rawmsg(enum debuglevel level, const char *tag, · 13 unmodified lines
272272 return;
273273 if (l > 64)
274274 l = 64; /* arbitrary limit */
275− dbgline = kmalloc(3 * l, GFP_ATOMIC);
275+ dbgline = kmalloc_array(3, l, GFP_ATOMIC);
276276 if (!dbgline)
277277 return;
278278 data += CAPIMSG_LEN(data);
@@ -1370,7 +1370,7 @@ static void do_connect_req(struct gigaset_capi_ctr *iif, · 1091 unmodified lines
13701370 cmsg->adr.adrPLCI |= (bcs->channel + 1) << 8;
13711371
13721372 /* build command table */
1373− commands = kzalloc(AT_NUM * (sizeof *commands), GFP_KERNEL);
1373+ commands = kcalloc(AT_NUM, sizeof(*commands), GFP_KERNEL);
13741374 if (!commands)
13751375 goto oom;
13761376
drivers/isdn/gigaset/common.c+2−2
@@ -710,7 +710,7 @@ struct cardstate *gigaset_initcs(struct gigaset_driver *drv, int channels, · 709 unmodified lines
710710 cs->mode = M_UNKNOWN;
711711 cs->mstate = MS_UNINITIALIZED;
712712
713− cs->bcs = kmalloc(channels * sizeof(struct bc_state), GFP_KERNEL);
713+ cs->bcs = kmalloc_array(channels, sizeof(struct bc_state), GFP_KERNEL);
714714 cs->inbuf = kmalloc(sizeof(struct inbuf_t), GFP_KERNEL);
715715 if (!cs->bcs || !cs->inbuf) {
716716 pr_err("out of memory\n");
@@ -1089,7 +1089,7 @@ struct gigaset_driver *gigaset_initdriver(unsigned minor, unsigned minors, · 372 unmodified lines
10891089 drv->owner = owner;
10901090 INIT_LIST_HEAD(&drv->list);
10911091
1092− drv->cs = kmalloc(minors * sizeof *drv->cs, GFP_KERNEL);
1092+ drv->cs = kmalloc_array(minors, sizeof(*drv->cs), GFP_KERNEL);
10931093 if (!drv->cs)
10941094 goto error;
10951095
drivers/isdn/gigaset/i4l.c+1−1
@@ -243,7 +243,7 @@ static int command_from_LL(isdn_ctrl *cntrl) · 242 unmodified lines
243243 dev_kfree_skb(bcs->rx_skb);
244244 gigaset_new_rx_skb(bcs);
245245
246− commands = kzalloc(AT_NUM * (sizeof *commands), GFP_ATOMIC);
246+ commands = kcalloc(AT_NUM, sizeof(*commands), GFP_ATOMIC);
247247 if (!commands) {
248248 gigaset_free_channel(bcs);
249249 dev_err(cs->dev, "ISDN_CMD_DIAL: out of memory\n");
drivers/isdn/hardware/avm/b1.c+1−1
@@ -72,7 +72,7 @@ avmcard *b1_alloc_card(int nr_controllers) · 71 unmodified lines
7272 if (!card)
7373 return NULL;
7474
75− cinfo = kzalloc(sizeof(*cinfo) * nr_controllers, GFP_KERNEL);
75+ cinfo = kcalloc(nr_controllers, sizeof(*cinfo), GFP_KERNEL);
7676 if (!cinfo) {
7777 kfree(card);
7878 return NULL;
drivers/isdn/hisax/fsm.c+3−1
@@ -27,7 +27,9 @@ FsmNew(struct Fsm *fsm, struct FsmNode *fnlist, int fncount) · 26 unmodified lines
2727 int i;
2828
2929 fsm->jumpmatrix =
30− kzalloc(sizeof(FSMFNPTR) * fsm->state_count * fsm->event_count, GFP_KERNEL);
30+ kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count,
31+ fsm->event_count),
32+ GFP_KERNEL);
3133 if (!fsm->jumpmatrix)
3234 return -ENOMEM;
3335
drivers/isdn/hisax/hfc_2bds0.c+1−1
@@ -1024,7 +1024,7 @@ static unsigned int · 1023 unmodified lines
10241024 int i;
10251025 unsigned *send;
10261026
1027− if (!(send = kmalloc(cnt * sizeof(unsigned int), GFP_ATOMIC))) {
1027+ if (!(send = kmalloc_array(cnt, sizeof(unsigned int), GFP_ATOMIC))) {
10281028 printk(KERN_WARNING
10291029 "HiSax: No memory for hfcd.send\n");
10301030 return (NULL);
drivers/isdn/hisax/hfc_2bs0.c+2−1
@@ -557,7 +557,8 @@ init_send(struct BCState *bcs) · 556 unmodified lines
557557 {
558558 int i;
559559
560− if (!(bcs->hw.hfc.send = kmalloc(32 * sizeof(unsigned int), GFP_ATOMIC))) {
560+ bcs->hw.hfc.send = kmalloc_array(32, sizeof(unsigned int), GFP_ATOMIC);
561+ if (!bcs->hw.hfc.send) {
561562 printk(KERN_WARNING
562563 "HiSax: No memory for hfc.send\n");
563564 return;
drivers/isdn/hisax/netjet.c+8−4
@@ -912,8 +912,10 @@ setstack_tiger(struct PStack *st, struct BCState *bcs) · 911 unmodified lines
912912 void
913913 inittiger(struct IsdnCardState *cs)
914914 {
915− if (!(cs->bcs[0].hw.tiger.send = kmalloc(NETJET_DMA_TXSIZE * sizeof(unsigned int),
916− GFP_KERNEL | GFP_DMA))) {
915+ cs->bcs[0].hw.tiger.send = kmalloc_array(NETJET_DMA_TXSIZE,
916+ sizeof(unsigned int),
917+ GFP_KERNEL | GFP_DMA);
918+ if (!cs->bcs[0].hw.tiger.send) {
917919 printk(KERN_WARNING
918920 "HiSax: No memory for tiger.send\n");
919921 return;
@@ -933,8 +935,10 @@ inittiger(struct IsdnCardState *cs) · 13 unmodified lines
933935 cs->hw.njet.base + NETJET_DMA_READ_IRQ);
934936 outl(virt_to_bus(cs->bcs[0].hw.tiger.s_end),
935937 cs->hw.njet.base + NETJET_DMA_READ_END);
936− if (!(cs->bcs[0].hw.tiger.rec = kmalloc(NETJET_DMA_RXSIZE * sizeof(unsigned int),
937− GFP_KERNEL | GFP_DMA))) {
938+ cs->bcs[0].hw.tiger.rec = kmalloc_array(NETJET_DMA_RXSIZE,
939+ sizeof(unsigned int),
940+ GFP_KERNEL | GFP_DMA);
941+ if (!cs->bcs[0].hw.tiger.rec) {
938942 printk(KERN_WARNING
939943 "HiSax: No memory for tiger.rec\n");
940944 return;
drivers/isdn/i4l/isdn_bsdcomp.c+3−2
@@ -340,7 +340,7 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data) · 339 unmodified lines
340340 * Allocate space for the dictionary. This may be more than one page in
341341 * length.
342342 */
343− db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
343+ db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
344344 if (!db->dict) {
345345 bsd_free(db);
346346 return NULL;
@@ -353,7 +353,8 @@ static void *bsd_alloc(struct isdn_ppp_comp_data *data) · 6 unmodified lines
353353 if (!decomp)
354354 db->lens = NULL;
355355 else {
356− db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
356+ db->lens = vmalloc(array_size(sizeof(db->lens[0]),
357+ maxmaxcode + 1));
357358 if (!db->lens) {
358359 bsd_free(db);
359360 return (NULL);
drivers/isdn/i4l/isdn_common.c+6−4
@@ -2070,14 +2070,14 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) · 2069 unmodified lines
20702070
20712071 if ((adding) && (d->rcverr))
20722072 kfree(d->rcverr);
2073− if (!(d->rcverr = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
2073+ if (!(d->rcverr = kcalloc(m, sizeof(int), GFP_ATOMIC))) {
20742074 printk(KERN_WARNING "register_isdn: Could not alloc rcverr\n");
20752075 return -1;
20762076 }
20772077
20782078 if ((adding) && (d->rcvcount))
20792079 kfree(d->rcvcount);
2080− if (!(d->rcvcount = kzalloc(sizeof(int) * m, GFP_ATOMIC))) {
2080+ if (!(d->rcvcount = kcalloc(m, sizeof(int), GFP_ATOMIC))) {
20812081 printk(KERN_WARNING "register_isdn: Could not alloc rcvcount\n");
20822082 if (!adding)
20832083 kfree(d->rcverr);
@@ -2089,7 +2089,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) · 5 unmodified lines
20892089 skb_queue_purge(&d->rpqueue[j]);
20902090 kfree(d->rpqueue);
20912091 }
2092− if (!(d->rpqueue = kmalloc(sizeof(struct sk_buff_head) * m, GFP_ATOMIC))) {
2092+ d->rpqueue = kmalloc_array(m, sizeof(struct sk_buff_head), GFP_ATOMIC);
2093+ if (!d->rpqueue) {
20932094 printk(KERN_WARNING "register_isdn: Could not alloc rpqueue\n");
20942095 if (!adding) {
20952096 kfree(d->rcvcount);
@@ -2103,7 +2104,8 @@ isdn_add_channels(isdn_driver_t *d, int drvidx, int n, int adding) · 7 unmodified lines
21032104
21042105 if ((adding) && (d->rcv_waitq))
21052106 kfree(d->rcv_waitq);
2106− d->rcv_waitq = kmalloc(sizeof(wait_queue_head_t) * 2 * m, GFP_ATOMIC);
2107+ d->rcv_waitq = kmalloc(array3_size(sizeof(wait_queue_head_t), 2, m),
2108+ GFP_ATOMIC);
21072109 if (!d->rcv_waitq) {
21082110 printk(KERN_WARNING "register_isdn: Could not alloc rcv_waitq\n");
21092111 if (!adding) {
drivers/isdn/mISDN/fsm.c+4−2
@@ -32,8 +32,10 @@ mISDN_FsmNew(struct Fsm *fsm, · 31 unmodified lines
3232 {
3333 int i;
3434
35− fsm->jumpmatrix = kzalloc(sizeof(FSMFNPTR) * fsm->state_count *
36− fsm->event_count, GFP_KERNEL);
35+ fsm->jumpmatrix =
36+ kzalloc(array3_size(sizeof(FSMFNPTR), fsm->state_count,
37+ fsm->event_count),
38+ GFP_KERNEL);
3739 if (fsm->jumpmatrix == NULL)
3840 return -ENOMEM;
3941
drivers/leds/leds-adp5520.c+1−1
@@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev) · 107 unmodified lines
108108 return -EFAULT;
109109 }
110110
111− led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds,
111+ led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led),
112112 GFP_KERNEL);
113113 if (!led)
114114 return -ENOMEM;
drivers/leds/leds-apu.c+2−2
@@ -171,8 +171,8 @@ static int apu_led_config(struct device *dev, struct apu_led_pdata *apuld) · 170 unmodified lines
171171 int i;
172172 int err;
173173
174− apu_led->pled = devm_kzalloc(dev,
175− sizeof(struct apu_led_priv) * apu_led->num_led_instances,
174+ apu_led->pled = devm_kcalloc(dev,
175+ apu_led->num_led_instances, sizeof(struct apu_led_priv),
176176 GFP_KERNEL);
177177
178178 if (!apu_led->pled)
drivers/leds/leds-cr0014114.c+1−2
@@ -237,8 +237,7 @@ static int cr0014114_probe(struct spi_device *spi) · 236 unmodified lines
237237 return -ENODEV;
238238 }
239239
240− priv = devm_kzalloc(&spi->dev,
241− sizeof(*priv) + sizeof(*priv->leds) * count,
240+ priv = devm_kzalloc(&spi->dev, struct_size(priv, leds, count),
242241 GFP_KERNEL);
243242 if (!priv)
244243 return -ENOMEM;
drivers/leds/leds-da9052.c+2−2
@@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev) · 112 unmodified lines
113113 goto err;
114114 }
115115
116− led = devm_kzalloc(&pdev->dev,
117− sizeof(struct da9052_led) * pled->num_leds,
116+ led = devm_kcalloc(&pdev->dev,
117+ pled->num_leds, sizeof(struct da9052_led),
118118 GFP_KERNEL);
119119 if (!led) {
120120 error = -ENOMEM;
drivers/leds/leds-lp5521.c+2−2
@@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client, · 532 unmodified lines
533533 if (!chip)
534534 return -ENOMEM;
535535
536− led = devm_kzalloc(&client->dev,
537− sizeof(*led) * pdata->num_channels, GFP_KERNEL);
536+ led = devm_kcalloc(&client->dev,
537+ pdata->num_channels, sizeof(*led), GFP_KERNEL);
538538 if (!led)
539539 return -ENOMEM;
540540
drivers/leds/leds-lp5523.c+2−2
@@ -898,8 +898,8 @@ static int lp5523_probe(struct i2c_client *client, · 897 unmodified lines
898898 if (!chip)
899899 return -ENOMEM;
900900
901− led = devm_kzalloc(&client->dev,
902− sizeof(*led) * pdata->num_channels, GFP_KERNEL);
901+ led = devm_kcalloc(&client->dev,
902+ pdata->num_channels, sizeof(*led), GFP_KERNEL);
903903 if (!led)
904904 return -ENOMEM;
905905
drivers/leds/leds-lp5562.c+2−2
@@ -534,8 +534,8 @@ static int lp5562_probe(struct i2c_client *client, · 533 unmodified lines
534534 if (!chip)
535535 return -ENOMEM;
536536
537− led = devm_kzalloc(&client->dev,
538− sizeof(*led) * pdata->num_channels, GFP_KERNEL);
537+ led = devm_kcalloc(&client->dev,
538+ pdata->num_channels, sizeof(*led), GFP_KERNEL);
539539 if (!led)
540540 return -ENOMEM;
541541
drivers/leds/leds-lp55xx-common.c+1−1
@@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, · 559 unmodified lines
560560 return ERR_PTR(-EINVAL);
561561 }
562562
563− cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL);
563+ cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL);
564564 if (!cfg)
565565 return ERR_PTR(-ENOMEM);
566566
drivers/leds/leds-lp8501.c+2−2
@@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client, · 326 unmodified lines
327327 if (!chip)
328328 return -ENOMEM;
329329
330− led = devm_kzalloc(&client->dev,
331− sizeof(*led) * pdata->num_channels, GFP_KERNEL);
330+ led = devm_kcalloc(&client->dev,
331+ pdata->num_channels, sizeof(*led), GFP_KERNEL);
332332 if (!led)
333333 return -ENOMEM;
334334
drivers/leds/leds-lt3593.c+2−2
@@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev) · 127 unmodified lines
128128 if (!pdata)
129129 return -EBUSY;
130130
131− leds_data = devm_kzalloc(&pdev->dev,
132− sizeof(struct lt3593_led_data) * pdata->num_leds,
131+ leds_data = devm_kcalloc(&pdev->dev,
132+ pdata->num_leds, sizeof(struct lt3593_led_data),
133133 GFP_KERNEL);
134134 if (!leds_data)
135135 return -ENOMEM;
drivers/leds/leds-mc13783.c+2−2
@@ -136,7 +136,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( · 135 unmodified lines
136136
137137 pdata->num_leds = of_get_child_count(parent);
138138
139− pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led),
139+ pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led),
140140 GFP_KERNEL);
141141 if (!pdata->led) {
142142 ret = -ENOMEM;
@@ -210,7 +210,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) · 67 unmodified lines
210210 return -EINVAL;
211211 }
212212
213− leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led),
213+ leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led),
214214 GFP_KERNEL);
215215 if (!leds->led)
216216 return -ENOMEM;
drivers/leds/leds-mlxcpld.c+4−2
@@ -329,8 +329,10 @@ static int mlxcpld_led_config(struct device *dev, · 328 unmodified lines
329329 int i;
330330 int err;
331331
332− cpld->pled = devm_kzalloc(dev, sizeof(struct mlxcpld_led_priv) *
333− cpld->num_led_instances, GFP_KERNEL);
332+ cpld->pled = devm_kcalloc(dev,
333+ cpld->num_led_instances,
334+ sizeof(struct mlxcpld_led_priv),
335+ GFP_KERNEL);
334336 if (!cpld->pled)
335337 return -ENOMEM;
336338
drivers/leds/leds-netxbig.c+8−8
@@ -335,7 +335,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, · 334 unmodified lines
335335 return ret;
336336 }
337337 num_addr = ret;
338− addr = devm_kzalloc(dev, num_addr * sizeof(*addr), GFP_KERNEL);
338+ addr = devm_kcalloc(dev, num_addr, sizeof(*addr), GFP_KERNEL);
339339 if (!addr)
340340 return -ENOMEM;
341341
@@ -355,7 +355,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, · 13 unmodified lines
355355 return ret;
356356 }
357357 num_data = ret;
358− data = devm_kzalloc(dev, num_data * sizeof(*data), GFP_KERNEL);
358+ data = devm_kcalloc(dev, num_data, sizeof(*data), GFP_KERNEL);
359359 if (!data)
360360 return -ENOMEM;
361361
@@ -415,7 +415,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, · 53 unmodified lines
415415 if (ret % 3)
416416 return -EINVAL;
417417 num_timers = ret / 3;
418− timers = devm_kzalloc(dev, num_timers * sizeof(*timers),
418+ timers = devm_kcalloc(dev, num_timers, sizeof(*timers),
419419 GFP_KERNEL);
420420 if (!timers)
421421 return -ENOMEM;
@@ -444,7 +444,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, · 22 unmodified lines
444444 return -ENODEV;
445445 }
446446
447− leds = devm_kzalloc(dev, num_leds * sizeof(*leds), GFP_KERNEL);
447+ leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL);
448448 if (!leds)
449449 return -ENOMEM;
450450
@@ -470,8 +470,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev, · 19 unmodified lines
470470 goto err_node_put;
471471
472472 mode_val =
473− devm_kzalloc(dev,
474− NETXBIG_LED_MODE_NUM * sizeof(*mode_val),
473+ devm_kcalloc(dev,
474+ NETXBIG_LED_MODE_NUM, sizeof(*mode_val),
475475 GFP_KERNEL);
476476 if (!mode_val) {
477477 ret = -ENOMEM;
@@ -560,8 +560,8 @@ static int netxbig_led_probe(struct platform_device *pdev) · 82 unmodified lines
560560 return ret;
561561 }
562562
563− leds_data = devm_kzalloc(&pdev->dev,
564− pdata->num_leds * sizeof(*leds_data),
563+ leds_data = devm_kcalloc(&pdev->dev,
564+ pdata->num_leds, sizeof(*leds_data),
565565 GFP_KERNEL);
566566 if (!leds_data)
567567 return -ENOMEM;
drivers/leds/leds-ns2.c+4−3
@@ -264,7 +264,7 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) · 263 unmodified lines
264264 if (!num_leds)
265265 return -ENODEV;
266266
267− leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led),
267+ leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led),
268268 GFP_KERNEL);
269269 if (!leds)
270270 return -ENOMEM;
@@ -298,8 +298,9 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) · 27 unmodified lines
298298 }
299299
300300 num_modes = ret / 3;
301− modval = devm_kzalloc(dev,
302− num_modes * sizeof(struct ns2_led_modval),
301+ modval = devm_kcalloc(dev,
302+ num_modes,
303+ sizeof(struct ns2_led_modval),
303304 GFP_KERNEL);
304305 if (!modval)
305306 return -ENOMEM;
drivers/leds/leds-pca955x.c+4−4
@@ -390,8 +390,8 @@ pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip) · 389 unmodified lines
390390 if (!pdata)
391391 return ERR_PTR(-ENOMEM);
392392
393− pdata->leds = devm_kzalloc(&client->dev,
394− sizeof(struct pca955x_led) * chip->bits,
393+ pdata->leds = devm_kcalloc(&client->dev,
394+ chip->bits, sizeof(struct pca955x_led),
395395 GFP_KERNEL);
396396 if (!pdata->leds)
397397 return ERR_PTR(-ENOMEM);
@@ -494,8 +494,8 @@ static int pca955x_probe(struct i2c_client *client, · 96 unmodified lines
494494 if (!pca955x)
495495 return -ENOMEM;
496496
497− pca955x->leds = devm_kzalloc(&client->dev,
498− sizeof(*pca955x_led) * chip->bits, GFP_KERNEL);
497+ pca955x->leds = devm_kcalloc(&client->dev,
498+ chip->bits, sizeof(*pca955x_led), GFP_KERNEL);
499499 if (!pca955x->leds)
500500 return -ENOMEM;
501501
drivers/leds/leds-pca963x.c+3−3
@@ -300,8 +300,8 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) · 299 unmodified lines
300300 if (!count || count > chip->n_leds)
301301 return ERR_PTR(-ENODEV);
302302
303− pca963x_leds = devm_kzalloc(&client->dev,
304− sizeof(struct led_info) * chip->n_leds, GFP_KERNEL);
303+ pca963x_leds = devm_kcalloc(&client->dev,
304+ chip->n_leds, sizeof(struct led_info), GFP_KERNEL);
305305 if (!pca963x_leds)
306306 return ERR_PTR(-ENOMEM);
307307
@@ -407,7 +407,7 @@ static int pca963x_probe(struct i2c_client *client, · 99 unmodified lines
407407 GFP_KERNEL);
408408 if (!pca963x_chip)
409409 return -ENOMEM;
410− pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x),
410+ pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x),
411411 GFP_KERNEL);
412412 if (!pca963x)
413413 return -ENOMEM;
drivers/leds/leds-tca6507.c+2−2
@@ -697,8 +697,8 @@ tca6507_led_dt_init(struct i2c_client *client) · 696 unmodified lines
697697 if (!count || count > NUM_LEDS)
698698 return ERR_PTR(-ENODEV);
699699
700− tca_leds = devm_kzalloc(&client->dev,
701− sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL);
700+ tca_leds = devm_kcalloc(&client->dev,
701+ NUM_LEDS, sizeof(struct led_info), GFP_KERNEL);
702702 if (!tca_leds)
703703 return ERR_PTR(-ENOMEM);
704704
drivers/lightnvm/pblk-gc.c+1−1
@@ -88,7 +88,7 @@ static void pblk_gc_line_ws(struct work_struct *work) · 87 unmodified lines
8888
8989 up(&gc->gc_sem);
9090
91− gc_rq->data = vmalloc(gc_rq->nr_secs * geo->csecs);
91+ gc_rq->data = vmalloc(array_size(gc_rq->nr_secs, geo->csecs));
9292 if (!gc_rq->data) {
9393 pr_err("pblk: could not GC line:%d (%d/%d)\n",
9494 line->id, *line->vsc, gc_rq->nr_secs);
drivers/lightnvm/pblk-init.c+4−4
@@ -187,7 +187,7 @@ static int pblk_rwb_init(struct pblk *pblk) · 186 unmodified lines
187187
188188 nr_entries = pblk_rb_calculate_size(buffer_size);
189189
190− entries = vzalloc(nr_entries * sizeof(struct pblk_rb_entry));
190+ entries = vzalloc(array_size(nr_entries, sizeof(struct pblk_rb_entry)));
191191 if (!entries)
192192 return -ENOMEM;
193193
@@ -379,7 +379,7 @@ static int pblk_core_init(struct pblk *pblk) · 185 unmodified lines
379379 return -EINVAL;
380380 }
381381
382− pblk->pad_dist = kzalloc((pblk->min_write_pgs - 1) * sizeof(atomic64_t),
382+ pblk->pad_dist = kcalloc(pblk->min_write_pgs - 1, sizeof(atomic64_t),
383383 GFP_KERNEL);
384384 if (!pblk->pad_dist)
385385 return -ENOMEM;
@@ -833,8 +833,8 @@ static int pblk_alloc_line_meta(struct pblk *pblk, struct pblk_line *line) · 447 unmodified lines
833833 goto free_blk_bitmap;
834834
835835
836− line->chks = kmalloc(lm->blk_per_line * sizeof(struct nvm_chk_meta),
837− GFP_KERNEL);
836+ line->chks = kmalloc_array(lm->blk_per_line,
837+ sizeof(struct nvm_chk_meta), GFP_KERNEL);
838838 if (!line->chks)
839839 goto free_erase_bitmap;
840840
drivers/lightnvm/pblk-recovery.c+1−1
@@ -260,7 +260,7 @@ static int pblk_recov_pad_oob(struct pblk *pblk, struct pblk_line *line, · 259 unmodified lines
260260 if (!pad_rq)
261261 return -ENOMEM;
262262
263− data = vzalloc(pblk->max_write_pgs * geo->csecs);
263+ data = vzalloc(array_size(pblk->max_write_pgs, geo->csecs));
264264 if (!data) {
265265 ret = -ENOMEM;
266266 goto free_rq;
drivers/mailbox/hi6220-mailbox.c+4−4
@@ -282,13 +282,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev) · 281 unmodified lines
282282
283283 mbox->dev = dev;
284284 mbox->chan_num = MBOX_CHAN_MAX;
285− mbox->mchan = devm_kzalloc(dev,
286− mbox->chan_num * sizeof(*mbox->mchan), GFP_KERNEL);
285+ mbox->mchan = devm_kcalloc(dev,
286+ mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL);
287287 if (!mbox->mchan)
288288 return -ENOMEM;
289289
290− mbox->chan = devm_kzalloc(dev,
291− mbox->chan_num * sizeof(*mbox->chan), GFP_KERNEL);
290+ mbox->chan = devm_kcalloc(dev,
291+ mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL);
292292 if (!mbox->chan)
293293 return -ENOMEM;
294294
drivers/mailbox/mailbox-sti.c+2−2
@@ -442,8 +442,8 @@ static int sti_mbox_probe(struct platform_device *pdev) · 441 unmodified lines
442442 if (!mbox)
443443 return -ENOMEM;
444444
445− chans = devm_kzalloc(&pdev->dev,
446− sizeof(*chans) * STI_MBOX_CHAN_MAX, GFP_KERNEL);
445+ chans = devm_kcalloc(&pdev->dev,
446+ STI_MBOX_CHAN_MAX, sizeof(*chans), GFP_KERNEL);
447447 if (!chans)
448448 return -ENOMEM;
449449
drivers/mailbox/omap-mailbox.c+5−5
@@ -729,7 +729,7 @@ static int omap_mbox_probe(struct platform_device *pdev) · 728 unmodified lines
729729 return -ENODEV;
730730 }
731731
732− finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk),
732+ finfoblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*finfoblk),
733733 GFP_KERNEL);
734734 if (!finfoblk)
735735 return -ENOMEM;
@@ -773,23 +773,23 @@ static int omap_mbox_probe(struct platform_device *pdev) · 37 unmodified lines
773773 if (IS_ERR(mdev->mbox_base))
774774 return PTR_ERR(mdev->mbox_base);
775775
776− mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32),
776+ mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32),
777777 GFP_KERNEL);
778778 if (!mdev->irq_ctx)
779779 return -ENOMEM;
780780
781781 /* allocate one extra for marking end of list */
782− list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list),
782+ list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list),
783783 GFP_KERNEL);
784784 if (!list)
785785 return -ENOMEM;
786786
787− chnls = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*chnls),
787+ chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls),
788788 GFP_KERNEL);
789789 if (!chnls)
790790 return -ENOMEM;
791791
792− mboxblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*mbox),
792+ mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox),
793793 GFP_KERNEL);
794794 if (!mboxblk)
795795 return -ENOMEM;
drivers/mailbox/pcc.c+2−1
@@ -466,7 +466,8 @@ static int __init acpi_pcc_probe(void) · 465 unmodified lines
466466 return -EINVAL;
467467 }
468468
469− pcc_mbox_channels = kzalloc(sizeof(struct mbox_chan) * count, GFP_KERNEL);
469+ pcc_mbox_channels = kcalloc(count, sizeof(struct mbox_chan),
470+ GFP_KERNEL);
470471 if (!pcc_mbox_channels) {
471472 pr_err("Could not allocate space for PCC mbox channels\n");
472473 return -ENOMEM;
drivers/mailbox/ti-msgmgr.c+2−2
@@ -568,12 +568,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev) · 567 unmodified lines
568568 }
569569 inst->num_valid_queues = queue_count;
570570
571− qinst = devm_kzalloc(dev, sizeof(*qinst) * queue_count, GFP_KERNEL);
571+ qinst = devm_kcalloc(dev, queue_count, sizeof(*qinst), GFP_KERNEL);
572572 if (!qinst)
573573 return -ENOMEM;
574574 inst->qinsts = qinst;
575575
576− chans = devm_kzalloc(dev, sizeof(*chans) * queue_count, GFP_KERNEL);
576+ chans = devm_kcalloc(dev, queue_count, sizeof(*chans), GFP_KERNEL);
577577 if (!chans)
578578 return -ENOMEM;
579579 inst->chans = chans;
drivers/md/bcache/super.c+6−5
@@ -1715,7 +1715,7 @@ struct cache_set *bch_cache_set_alloc(struct cache_sb *sb) · 1714 unmodified lines
17151715 iter_size = (sb->bucket_size / sb->block_size + 1) *
17161716 sizeof(struct btree_iter_set);
17171717
1718− if (!(c->devices = kzalloc(c->nr_uuids * sizeof(void *), GFP_KERNEL)) ||
1718+ if (!(c->devices = kcalloc(c->nr_uuids, sizeof(void *), GFP_KERNEL)) ||
17191719 mempool_init_slab_pool(&c->search, 32, bch_search_cache) ||
17201720 mempool_init_kmalloc_pool(&c->bio_meta, 2,
17211721 sizeof(struct bbio) + sizeof(struct bio_vec) *
@@ -2041,10 +2041,11 @@ static int cache_alloc(struct cache *ca) · 319 unmodified lines
20412041 !init_fifo(&ca->free[RESERVE_NONE], free, GFP_KERNEL) ||
20422042 !init_fifo(&ca->free_inc, free << 2, GFP_KERNEL) ||
20432043 !init_heap(&ca->heap, free << 3, GFP_KERNEL) ||
2044− !(ca->buckets = vzalloc(sizeof(struct bucket) *
2045− ca->sb.nbuckets)) ||
2046− !(ca->prio_buckets = kzalloc(sizeof(uint64_t) * prio_buckets(ca) *
2047− 2, GFP_KERNEL)) ||
2044+ !(ca->buckets = vzalloc(array_size(sizeof(struct bucket),
2045+ ca->sb.nbuckets))) ||
2046+ !(ca->prio_buckets = kzalloc(array3_size(sizeof(uint64_t),
2047+ prio_buckets(ca), 2),
2048+ GFP_KERNEL)) ||
20482049 !(ca->disk_buckets = alloc_bucket_pages(GFP_KERNEL, ca)))
20492050 return -ENOMEM;
20502051
drivers/md/bcache/sysfs.c+2−1
@@ -881,7 +881,8 @@ SHOW(__bch_cache) · 880 unmodified lines
881881 uint16_t q[31], *p, *cached;
882882 ssize_t ret;
883883
884− cached = p = vmalloc(ca->sb.nbuckets * sizeof(uint16_t));
884+ cached = p = vmalloc(array_size(sizeof(uint16_t),
885+ ca->sb.nbuckets));
885886 if (!p)
886887 return -ENOMEM;
887888
drivers/md/dm-cache-policy-smq.c+2−2
@@ -69,7 +69,7 @@ static int space_init(struct entry_space *es, unsigned nr_entries) · 68 unmodified lines
6969 return 0;
7070 }
7171
72− es->begin = vzalloc(sizeof(struct entry) * nr_entries);
72+ es->begin = vzalloc(array_size(nr_entries, sizeof(struct entry)));
7373 if (!es->begin)
7474 return -ENOMEM;
7575
@@ -588,7 +588,7 @@ static int h_init(struct smq_hash_table *ht, struct entry_space *es, unsigned nr · 512 unmodified lines
588588 nr_buckets = roundup_pow_of_two(max(nr_entries / 4u, 16u));
589589 ht->hash_bits = __ffs(nr_buckets);
590590
591− ht->buckets = vmalloc(sizeof(*ht->buckets) * nr_buckets);
591+ ht->buckets = vmalloc(array_size(nr_buckets, sizeof(*ht->buckets)));
592592 if (!ht->buckets)
593593 return -ENOMEM;
594594
drivers/md/dm-crypt.c+3−2
@@ -1878,8 +1878,9 @@ static int crypt_alloc_tfms_skcipher(struct crypt_config *cc, char *ciphermode) · 1877 unmodified lines
18781878 unsigned i;
18791879 int err;
18801880
1881− cc->cipher_tfm.tfms = kzalloc(cc->tfms_count *
1882− sizeof(struct crypto_skcipher *), GFP_KERNEL);
1881+ cc->cipher_tfm.tfms = kcalloc(cc->tfms_count,
1882+ sizeof(struct crypto_skcipher *),
1883+ GFP_KERNEL);
18831884 if (!cc->cipher_tfm.tfms)
18841885 return -ENOMEM;
18851886
drivers/md/dm-integrity.c+13−5
@@ -2448,7 +2448,9 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int · 2447 unmodified lines
24482448 struct scatterlist **sl;
24492449 unsigned i;
24502450
2451− sl = kvmalloc(ic->journal_sections * sizeof(struct scatterlist *), GFP_KERNEL | __GFP_ZERO);
2451+ sl = kvmalloc_array(ic->journal_sections,
2452+ sizeof(struct scatterlist *),
2453+ GFP_KERNEL | __GFP_ZERO);
24522454 if (!sl)
24532455 return NULL;
24542456
@@ -2464,7 +2466,8 @@ static struct scatterlist **dm_integrity_alloc_journal_scatterlist(struct dm_int · 9 unmodified lines
24642466
24652467 n_pages = (end_index - start_index + 1);
24662468
2467− s = kvmalloc(n_pages * sizeof(struct scatterlist), GFP_KERNEL);
2469+ s = kvmalloc_array(n_pages, sizeof(struct scatterlist),
2470+ GFP_KERNEL);
24682471 if (!s) {
24692472 dm_integrity_free_journal_scatterlist(ic, sl);
24702473 return NULL;
@@ -2643,7 +2646,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error) · 172 unmodified lines
26432646 goto bad;
26442647 }
26452648
2646− sg = kvmalloc((ic->journal_pages + 1) * sizeof(struct scatterlist), GFP_KERNEL);
2649+ sg = kvmalloc_array(ic->journal_pages + 1,
2650+ sizeof(struct scatterlist),
2651+ GFP_KERNEL);
26472652 if (!sg) {
26482653 *error = "Unable to allocate sg list";
26492654 r = -ENOMEM;
@@ -2709,7 +2714,9 @@ static int create_journal(struct dm_integrity_c *ic, char **error) · 59 unmodified lines
27092714 r = -ENOMEM;
27102715 goto bad;
27112716 }
2712− ic->sk_requests = kvmalloc(ic->journal_sections * sizeof(struct skcipher_request *), GFP_KERNEL | __GFP_ZERO);
2717+ ic->sk_requests = kvmalloc_array(ic->journal_sections,
2718+ sizeof(struct skcipher_request *),
2719+ GFP_KERNEL | __GFP_ZERO);
27132720 if (!ic->sk_requests) {
27142721 *error = "Unable to allocate sk requests";
27152722 r = -ENOMEM;
@@ -2743,7 +2750,8 @@ static int create_journal(struct dm_integrity_c *ic, char **error) · 27 unmodified lines
27432750 r = -ENOMEM;
27442751 goto bad;
27452752 }
2746− section_req->iv = kmalloc(ivsize * 2, GFP_KERNEL);
2753+ section_req->iv = kmalloc_array(ivsize, 2,
2754+ GFP_KERNEL);
27472755 if (!section_req->iv) {
27482756 skcipher_request_free(section_req);
27492757 *error = "Unable to allocate iv";
drivers/md/dm-region-hash.c+1−1
@@ -203,7 +203,7 @@ struct dm_region_hash *dm_region_hash_create( · 202 unmodified lines
203203 rh->shift = RH_HASH_SHIFT;
204204 rh->prime = RH_HASH_MULT;
205205
206− rh->buckets = vmalloc(nr_buckets * sizeof(*rh->buckets));
206+ rh->buckets = vmalloc(array_size(nr_buckets, sizeof(*rh->buckets)));
207207 if (!rh->buckets) {
208208 DMERR("unable to allocate region hash bucket memory");
209209 kfree(rh);
drivers/md/dm-snap.c+5−4
@@ -326,8 +326,8 @@ static int init_origin_hash(void) · 325 unmodified lines
326326 {
327327 int i;
328328
329− _origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
330− GFP_KERNEL);
329+ _origins = kmalloc_array(ORIGIN_HASH_SIZE, sizeof(struct list_head),
330+ GFP_KERNEL);
331331 if (!_origins) {
332332 DMERR("unable to allocate memory for _origins");
333333 return -ENOMEM;
@@ -335,8 +335,9 @@ static int init_origin_hash(void) · 1 unmodified line
335335 for (i = 0; i < ORIGIN_HASH_SIZE; i++)
336336 INIT_LIST_HEAD(_origins + i);
337337
338− _dm_origins = kmalloc(ORIGIN_HASH_SIZE * sizeof(struct list_head),
339− GFP_KERNEL);
338+ _dm_origins = kmalloc_array(ORIGIN_HASH_SIZE,
339+ sizeof(struct list_head),
340+ GFP_KERNEL);
340341 if (!_dm_origins) {
341342 DMERR("unable to allocate memory for _dm_origins");
342343 kfree(_origins);
drivers/md/dm-stats.c+3−1
@@ -915,7 +915,9 @@ static int parse_histogram(const char *h, unsigned *n_histogram_entries, · 914 unmodified lines
915915 if (*q == ',')
916916 (*n_histogram_entries)++;
917917
918− *histogram_boundaries = kmalloc(*n_histogram_entries * sizeof(unsigned long long), GFP_KERNEL);
918+ *histogram_boundaries = kmalloc_array(*n_histogram_entries,
919+ sizeof(unsigned long long),
920+ GFP_KERNEL);
919921 if (!*histogram_boundaries)
920922 return -ENOMEM;
921923
drivers/md/dm-switch.c+2−1
@@ -114,7 +114,8 @@ static int alloc_region_table(struct dm_target *ti, unsigned nr_paths) · 113 unmodified lines
114114 return -EINVAL;
115115 }
116116
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)));
118119 if (!sctx->region_table) {
119120 ti->error = "Cannot allocate region table";
120121 return -ENOMEM;
drivers/md/dm-table.c+1−1
@@ -561,7 +561,7 @@ static char **realloc_argv(unsigned *size, char **old_argv) · 560 unmodified lines
561561 new_size = 8;
562562 gfp = GFP_NOIO;
563563 }
564− argv = kmalloc(new_size * sizeof(*argv), gfp);
564+ argv = kmalloc_array(new_size, sizeof(*argv), gfp);
565565 if (argv) {
566566 memcpy(argv, old_argv, *size * sizeof(*argv));
567567 *size = new_size;
drivers/md/dm-thin.c+3−1
@@ -2940,7 +2940,9 @@ static struct pool *pool_create(struct mapped_device *pool_md, · 2939 unmodified lines
29402940 goto bad_mapping_pool;
29412941 }
29422942
2943− pool->cell_sort_array = vmalloc(sizeof(*pool->cell_sort_array) * CELL_SORT_ARRAY_SIZE);
2943+ pool->cell_sort_array =
2944+ vmalloc(array_size(CELL_SORT_ARRAY_SIZE,
2945+ sizeof(*pool->cell_sort_array)));
29442946 if (!pool->cell_sort_array) {
29452947 *error = "Error allocating cell sort array";
29462948 err_p = ERR_PTR(-ENOMEM);
drivers/md/dm-verity-target.c+3−2
@@ -797,8 +797,9 @@ static int verity_alloc_most_once(struct dm_verity *v) · 796 unmodified lines
797797 return -E2BIG;
798798 }
799799
800− v->validated_blocks = kvzalloc(BITS_TO_LONGS(v->data_blocks) *
801− sizeof(unsigned long), GFP_KERNEL);
800+ v->validated_blocks = kvcalloc(BITS_TO_LONGS(v->data_blocks),
801+ sizeof(unsigned long),
802+ GFP_KERNEL);
802803 if (!v->validated_blocks) {
803804 ti->error = "failed to allocate bitset for check_at_most_once";
804805 return -ENOMEM;
drivers/md/md-bitmap.c+3−3
@@ -789,8 +789,8 @@ static int bitmap_storage_alloc(struct bitmap_storage *store, · 788 unmodified lines
789789 num_pages = DIV_ROUND_UP(bytes, PAGE_SIZE);
790790 offset = slot_number * num_pages;
791791
792− store->filemap = kmalloc(sizeof(struct page *)
793− * num_pages, GFP_KERNEL);
792+ store->filemap = kmalloc_array(num_pages, sizeof(struct page *),
793+ GFP_KERNEL);
794794 if (!store->filemap)
795795 return -ENOMEM;
796796
@@ -2117,7 +2117,7 @@ int bitmap_resize(struct bitmap *bitmap, sector_t blocks, · 1320 unmodified lines
21172117
21182118 pages = DIV_ROUND_UP(chunks, PAGE_COUNTER_RATIO);
21192119
2120− new_bp = kzalloc(pages * sizeof(*new_bp), GFP_KERNEL);
2120+ new_bp = kcalloc(pages, sizeof(*new_bp), GFP_KERNEL);
21212121 ret = -ENOMEM;
21222122 if (!new_bp) {
21232123 bitmap_file_unmap(&store);
drivers/md/md-cluster.c+3−3
@@ -1380,9 +1380,9 @@ static int lock_all_bitmaps(struct mddev *mddev) · 1379 unmodified lines
13801380 char str[64];
13811381 struct md_cluster_info *cinfo = mddev->cluster_info;
13821382
1383− cinfo->other_bitmap_lockres = kzalloc((mddev->bitmap_info.nodes - 1) *
1384− sizeof(struct dlm_lock_resource *),
1385− GFP_KERNEL);
1383+ cinfo->other_bitmap_lockres =
1384+ kcalloc(mddev->bitmap_info.nodes - 1,
1385+ sizeof(struct dlm_lock_resource *), GFP_KERNEL);
13861386 if (!cinfo->other_bitmap_lockres) {
13871387 pr_err("md: can't alloc mem for other bitmap locks\n");
13881388 return 0;
drivers/md/md-multipath.c+2−1
@@ -399,7 +399,8 @@ static int multipath_run (struct mddev *mddev) · 398 unmodified lines
399399 if (!conf)
400400 goto out;
401401
402− conf->multipaths = kzalloc(sizeof(struct multipath_info)*mddev->raid_disks,
402+ conf->multipaths = kcalloc(mddev->raid_disks,
403+ sizeof(struct multipath_info),
403404 GFP_KERNEL);
404405 if (!conf->multipaths)
405406 goto out_free_conf;
drivers/md/raid0.c+6−4
@@ -159,12 +159,14 @@ static int create_strip_zones(struct mddev *mddev, struct r0conf **private_conf) · 158 unmodified lines
159159 }
160160
161161 err = -ENOMEM;
162− conf->strip_zone = kzalloc(sizeof(struct strip_zone)*
163− conf->nr_strip_zones, GFP_KERNEL);
162+ conf->strip_zone = kcalloc(conf->nr_strip_zones,
163+ sizeof(struct strip_zone),
164+ GFP_KERNEL);
164165 if (!conf->strip_zone)
165166 goto abort;
166− conf->devlist = kzalloc(sizeof(struct md_rdev*)*
167− conf->nr_strip_zones*mddev->raid_disks,
167+ conf->devlist = kzalloc(array3_size(sizeof(struct md_rdev *),
168+ conf->nr_strip_zones,
169+ mddev->raid_disks),
168170 GFP_KERNEL);
169171 if (!conf->devlist)
170172 goto abort;
drivers/md/raid1.c+7−6
@@ -126,8 +126,8 @@ static void * r1buf_pool_alloc(gfp_t gfp_flags, void *data) · 125 unmodified lines
126126 if (!r1_bio)
127127 return NULL;
128128
129− rps = kmalloc(sizeof(struct resync_pages) * pi->raid_disks,
130− gfp_flags);
129+ rps = kmalloc_array(pi->raid_disks, sizeof(struct resync_pages),
130+ gfp_flags);
131131 if (!rps)
132132 goto out_free_r1bio;
133133
@@ -2936,9 +2936,9 @@ static struct r1conf *setup_conf(struct mddev *mddev) · 2802 unmodified lines
29362936 if (!conf->barrier)
29372937 goto abort;
29382938
2939− conf->mirrors = kzalloc(sizeof(struct raid1_info)
2940− * mddev->raid_disks * 2,
2941− GFP_KERNEL);
2939+ conf->mirrors = kzalloc(array3_size(sizeof(struct raid1_info),
2940+ mddev->raid_disks, 2),
2941+ GFP_KERNEL);
29422942 if (!conf->mirrors)
29432943 goto abort;
29442944
@@ -3241,7 +3241,8 @@ static int raid1_reshape(struct mddev *mddev) · 296 unmodified lines
32413241 kfree(newpoolinfo);
32423242 return ret;
32433243 }
3244− newmirrors = kzalloc(sizeof(struct raid1_info) * raid_disks * 2,
3244+ newmirrors = kzalloc(array3_size(sizeof(struct raid1_info),
3245+ raid_disks, 2),
32453246 GFP_KERNEL);
32463247 if (!newmirrors) {
32473248 kfree(newpoolinfo);
drivers/md/raid10.c+7−8
@@ -175,7 +175,7 @@ static void * r10buf_pool_alloc(gfp_t gfp_flags, void *data) · 174 unmodified lines
175175 nalloc_rp = nalloc;
176176 else
177177 nalloc_rp = nalloc * 2;
178− rps = kmalloc(sizeof(struct resync_pages) * nalloc_rp, gfp_flags);
178+ rps = kmalloc_array(nalloc_rp, sizeof(struct resync_pages), gfp_flags);
179179 if (!rps)
180180 goto out_free_r10bio;
181181
@@ -3688,8 +3688,8 @@ static struct r10conf *setup_conf(struct mddev *mddev) · 3506 unmodified lines
36883688 goto out;
36893689
36903690 /* FIXME calc properly */
3691− conf->mirrors = kzalloc(sizeof(struct raid10_info)*(mddev->raid_disks +
3692− max(0,-mddev->delta_disks)),
3691+ conf->mirrors = kcalloc(mddev->raid_disks + max(0, -mddev->delta_disks),
3692+ sizeof(struct raid10_info),
36933693 GFP_KERNEL);
36943694 if (!conf->mirrors)
36953695 goto out;
@@ -4129,11 +4129,10 @@ static int raid10_check_reshape(struct mddev *mddev) · 433 unmodified lines
41294129 conf->mirrors_new = NULL;
41304130 if (mddev->delta_disks > 0) {
41314131 /* allocate new 'mirrors' list */
4132− conf->mirrors_new = kzalloc(
4133− sizeof(struct raid10_info)
4134− *(mddev->raid_disks +
4135− mddev->delta_disks),
4136− GFP_KERNEL);
4132+ conf->mirrors_new =
4133+ kcalloc(mddev->raid_disks + mddev->delta_disks,
4134+ sizeof(struct raid10_info),
4135+ GFP_KERNEL);
41374136 if (!conf->mirrors_new)
41384137 return -ENOMEM;
41394138 }
drivers/md/raid5.c+8−7
@@ -2396,7 +2396,7 @@ static int resize_stripes(struct r5conf *conf, int newsize) · 2395 unmodified lines
23962396 * is completely stalled, so now is a good time to resize
23972397 * conf->disks and the scribble region
23982398 */
2399− ndisks = kzalloc(newsize * sizeof(struct disk_info), GFP_NOIO);
2399+ ndisks = kcalloc(newsize, sizeof(struct disk_info), GFP_NOIO);
24002400 if (ndisks) {
24012401 for (i = 0; i < conf->pool_size; i++)
24022402 ndisks[i] = conf->disks[i];
@@ -6664,9 +6664,9 @@ static int alloc_thread_groups(struct r5conf *conf, int cnt, · 4261 unmodified lines
66646664 }
66656665 *group_cnt = num_possible_nodes();
66666666 size = sizeof(struct r5worker) * cnt;
6667− workers = kzalloc(size * *group_cnt, GFP_NOIO);
6668− *worker_groups = kzalloc(sizeof(struct r5worker_group) *
6669− *group_cnt, GFP_NOIO);
6667+ workers = kcalloc(size, *group_cnt, GFP_NOIO);
6668+ *worker_groups = kcalloc(*group_cnt, sizeof(struct r5worker_group),
6669+ GFP_NOIO);
66706670 if (!*worker_groups || !workers) {
66716671 kfree(workers);
66726672 kfree(*worker_groups);
@@ -6894,8 +6894,9 @@ static struct r5conf *setup_conf(struct mddev *mddev) · 221 unmodified lines
68946894 goto abort;
68956895 INIT_LIST_HEAD(&conf->free_list);
68966896 INIT_LIST_HEAD(&conf->pending_list);
6897− conf->pending_data = kzalloc(sizeof(struct r5pending_data) *
6898− PENDING_IO_MAX, GFP_KERNEL);
6897+ conf->pending_data = kcalloc(PENDING_IO_MAX,
6898+ sizeof(struct r5pending_data),
6899+ GFP_KERNEL);
68996900 if (!conf->pending_data)
69006901 goto abort;
69016902 for (i = 0; i < PENDING_IO_MAX; i++)
@@ -6944,7 +6945,7 @@ static struct r5conf *setup_conf(struct mddev *mddev) · 42 unmodified lines
69446945 conf->previous_raid_disks = mddev->raid_disks - mddev->delta_disks;
69456946 max_disks = max(conf->raid_disks, conf->previous_raid_disks);
69466947
6947− conf->disks = kzalloc(max_disks * sizeof(struct disk_info),
6948+ conf->disks = kcalloc(max_disks, sizeof(struct disk_info),
69486949 GFP_KERNEL);
69496950
69506951 if (!conf->disks)
drivers/media/common/v4l2-tpg/v4l2-tpg-core.c+10−5
@@ -119,12 +119,14 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) · 118 unmodified lines
119119 for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
120120 unsigned pixelsz = plane ? 2 : 4;
121121
122− tpg->lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
122+ tpg->lines[pat][plane] =
123+ vzalloc(array3_size(max_w, 2, pixelsz));
123124 if (!tpg->lines[pat][plane])
124125 return -ENOMEM;
125126 if (plane == 0)
126127 continue;
127− tpg->downsampled_lines[pat][plane] = vzalloc(max_w * 2 * pixelsz);
128+ tpg->downsampled_lines[pat][plane] =
129+ vzalloc(array3_size(max_w, 2, pixelsz));
128130 if (!tpg->downsampled_lines[pat][plane])
129131 return -ENOMEM;
130132 }
@@ -132,13 +134,16 @@ int tpg_alloc(struct tpg_data *tpg, unsigned max_w) · 1 unmodified line
132134 for (plane = 0; plane < TPG_MAX_PLANES; plane++) {
133135 unsigned pixelsz = plane ? 2 : 4;
134136
135− tpg->contrast_line[plane] = vzalloc(max_w * pixelsz);
137+ tpg->contrast_line[plane] =
138+ vzalloc(array_size(pixelsz, max_w));
136139 if (!tpg->contrast_line[plane])
137140 return -ENOMEM;
138− tpg->black_line[plane] = vzalloc(max_w * pixelsz);
141+ tpg->black_line[plane] =
142+ vzalloc(array_size(pixelsz, max_w));
139143 if (!tpg->black_line[plane])
140144 return -ENOMEM;
141− tpg->random_line[plane] = vzalloc(max_w * 2 * pixelsz);
145+ tpg->random_line[plane] =
146+ vzalloc(array3_size(max_w, 2, pixelsz));
142147 if (!tpg->random_line[plane])
143148 return -ENOMEM;
144149 }
drivers/media/dvb-core/dmxdev.c+2−1
@@ -1417,7 +1417,8 @@ int dvb_dmxdev_init(struct dmxdev *dmxdev, struct dvb_adapter *dvb_adapter) · 1416 unmodified lines
14171417 if (dmxdev->demux->open(dmxdev->demux) < 0)
14181418 return -EUSERS;
14191419
1420− dmxdev->filter = vmalloc(dmxdev->filternum * sizeof(struct dmxdev_filter));
1420+ dmxdev->filter = vmalloc(array_size(sizeof(struct dmxdev_filter),
1421+ dmxdev->filternum));
14211422 if (!dmxdev->filter)
14221423 return -ENOMEM;
14231424
drivers/media/dvb-core/dvb_demux.c+4−2
@@ -1247,12 +1247,14 @@ int dvb_dmx_init(struct dvb_demux *dvbdemux) · 1246 unmodified lines
12471247
12481248 dvbdemux->cnt_storage = NULL;
12491249 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));
12511252
12521253 if (!dvbdemux->filter)
12531254 return -ENOMEM;
12541255
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));
12561258 if (!dvbdemux->feed) {
12571259 vfree(dvbdemux->filter);
12581260 dvbdemux->filter = NULL;
drivers/media/dvb-frontends/dib7000p.c+2−2
@@ -2018,10 +2018,10 @@ static int dib7000pc_detection(struct i2c_adapter *i2c_adap) · 2017 unmodified lines
20182018 };
20192019 int ret = 0;
20202020
2021− tx = kzalloc(2*sizeof(u8), GFP_KERNEL);
2021+ tx = kzalloc(2, GFP_KERNEL);
20222022 if (!tx)
20232023 return -ENOMEM;
2024− rx = kzalloc(2*sizeof(u8), GFP_KERNEL);
2024+ rx = kzalloc(2, GFP_KERNEL);
20252025 if (!rx) {
20262026 ret = -ENOMEM;
20272027 goto rx_memory_error;
drivers/media/dvb-frontends/dib8000.c+2−2
@@ -4271,12 +4271,12 @@ static int dib8000_i2c_enumeration(struct i2c_adapter *host, int no_of_demods, · 4270 unmodified lines
42714271 u8 new_addr = 0;
42724272 struct i2c_device client = {.adap = host };
42734273
4274− client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
4274+ client.i2c_write_buffer = kzalloc(4, GFP_KERNEL);
42754275 if (!client.i2c_write_buffer) {
42764276 dprintk("%s: not enough memory\n", __func__);
42774277 return -ENOMEM;
42784278 }
4279− client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
4279+ client.i2c_read_buffer = kzalloc(4, GFP_KERNEL);
42804280 if (!client.i2c_read_buffer) {
42814281 dprintk("%s: not enough memory\n", __func__);
42824282 ret = -ENOMEM;
drivers/media/dvb-frontends/dib9000.c+2−2
@@ -2381,12 +2381,12 @@ int dib9000_i2c_enumeration(struct i2c_adapter *i2c, int no_of_demods, u8 defaul · 2380 unmodified lines
23812381 u8 new_addr = 0;
23822382 struct i2c_device client = {.i2c_adap = i2c };
23832383
2384− client.i2c_write_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
2384+ client.i2c_write_buffer = kzalloc(4, GFP_KERNEL);
23852385 if (!client.i2c_write_buffer) {
23862386 dprintk("%s: not enough memory\n", __func__);
23872387 return -ENOMEM;
23882388 }
2389− client.i2c_read_buffer = kzalloc(4 * sizeof(u8), GFP_KERNEL);
2389+ client.i2c_read_buffer = kzalloc(4, GFP_KERNEL);
23902390 if (!client.i2c_read_buffer) {
23912391 dprintk("%s: not enough memory\n", __func__);
23922392 ret = -ENOMEM;
drivers/media/i2c/s5k5baf.c+1−1
@@ -373,7 +373,7 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw, · 372 unmodified lines
373373 data += S5K5BAG_FW_TAG_LEN;
374374 count -= S5K5BAG_FW_TAG_LEN;
375375
376− d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL);
376+ d = devm_kcalloc(dev, count, sizeof(u16), GFP_KERNEL);
377377 if (!d)
378378 return -ENOMEM;
379379
drivers/media/pci/bt8xx/bttv-risc.c+2−1
@@ -256,7 +256,8 @@ bttv_risc_overlay(struct bttv *btv, struct btcx_riscmem *risc, · 255 unmodified lines
256256 u32 addr;
257257
258258 /* skip list for window clipping */
259− if (NULL == (skips = kmalloc(sizeof(*skips) * ov->nclips,GFP_KERNEL)))
259+ skips = kmalloc_array(ov->nclips, sizeof(*skips),GFP_KERNEL);
260+ if (NULL == skips)
260261 return -ENOMEM;
261262
262263 /* estimate risc mem: worst case is (1.5*clip+1) * lines instructions
drivers/media/pci/cx23885/cx23885-alsa.c+1−1
@@ -95,7 +95,7 @@ static int cx23885_alsa_dma_init(struct cx23885_audio_dev *chip, int nr_pages) · 94 unmodified lines
9595 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
9696 buf->nr_pages = nr_pages;
9797
98− buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
98+ buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
9999 if (NULL == buf->sglist)
100100 goto vzalloc_err;
101101
drivers/media/pci/cx25821/cx25821-alsa.c+1−1
@@ -159,7 +159,7 @@ static int cx25821_alsa_dma_init(struct cx25821_audio_dev *chip, int nr_pages) · 158 unmodified lines
159159 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
160160 buf->nr_pages = nr_pages;
161161
162− buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
162+ buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
163163 if (NULL == buf->sglist)
164164 goto vzalloc_err;
165165
drivers/media/pci/cx88/cx88-alsa.c+1−1
@@ -298,7 +298,7 @@ static int cx88_alsa_dma_init(struct cx88_audio_dev *chip, int nr_pages) · 297 unmodified lines
298298 memset(buf->vaddr, 0, nr_pages << PAGE_SHIFT);
299299 buf->nr_pages = nr_pages;
300300
301− buf->sglist = vzalloc(buf->nr_pages * sizeof(*buf->sglist));
301+ buf->sglist = vzalloc(array_size(sizeof(*buf->sglist), buf->nr_pages));
302302 if (!buf->sglist)
303303 goto vzalloc_err;
304304
drivers/media/pci/ivtv/ivtvfb.c+1−1
@@ -1077,7 +1077,7 @@ static int ivtvfb_init_vidmode(struct ivtv *itv) · 1076 unmodified lines
10771077
10781078 /* Allocate the pseudo palette */
10791079 oi->ivtvfb_info.pseudo_palette =
1080− kmalloc(sizeof(u32) * 16, GFP_KERNEL|__GFP_NOWARN);
1080+ kmalloc_array(16, sizeof(u32), GFP_KERNEL|__GFP_NOWARN);
10811081
10821082 if (!oi->ivtvfb_info.pseudo_palette) {
10831083 IVTVFB_ERR("abort, unable to alloc pseudo palette\n");
drivers/media/pci/meye/meye.c+1−1
@@ -1625,7 +1625,7 @@ static int meye_probe(struct pci_dev *pcidev, const struct pci_device_id *ent) · 1624 unmodified lines
16251625 ret = -ENOMEM;
16261626 meye.mchip_dev = pcidev;
16271627
1628− meye.grab_temp = vmalloc(MCHIP_NB_PAGES_MJPEG * PAGE_SIZE);
1628+ meye.grab_temp = vmalloc(array_size(PAGE_SIZE, MCHIP_NB_PAGES_MJPEG));
16291629 if (!meye.grab_temp)
16301630 goto outvmalloc;
16311631
drivers/media/pci/pt1/pt1.c+1−1
@@ -615,7 +615,7 @@ static int pt1_init_tables(struct pt1 *pt1) · 614 unmodified lines
615615 if (!pt1_nr_tables)
616616 return 0;
617617
618− tables = vmalloc(sizeof(struct pt1_table) * pt1_nr_tables);
618+ tables = vmalloc(array_size(pt1_nr_tables, sizeof(struct pt1_table)));
619619 if (tables == NULL)
620620 return -ENOMEM;
621621
drivers/media/pci/saa7134/saa7134-alsa.c+1−1
@@ -279,7 +279,7 @@ static int saa7134_alsa_dma_init(struct saa7134_dev *dev, int nr_pages) · 278 unmodified lines
279279 memset(dma->vaddr, 0, nr_pages << PAGE_SHIFT);
280280 dma->nr_pages = nr_pages;
281281
282− dma->sglist = vzalloc(dma->nr_pages * sizeof(*dma->sglist));
282+ dma->sglist = vzalloc(array_size(sizeof(*dma->sglist), dma->nr_pages));
283283 if (NULL == dma->sglist)
284284 goto vzalloc_err;
285285
drivers/media/pci/ttpci/av7110_ipack.c+1−1
@@ -24,7 +24,7 @@ void av7110_ipack_reset(struct ipack *p) · 23 unmodified lines
2424 int av7110_ipack_init(struct ipack *p, int size,
2525 void (*func)(u8 *buf, int size, void *priv))
2626 {
27− if (!(p->buf = vmalloc(size*sizeof(u8)))) {
27+ if (!(p->buf = vmalloc(size))) {
2828 printk(KERN_WARNING "Couldn't allocate memory for ipack\n");
2929 return -ENOMEM;
3030 }
drivers/media/platform/am437x/am437x-vpfe.c+4−2
@@ -2586,8 +2586,10 @@ static int vpfe_probe(struct platform_device *pdev) · 2585 unmodified lines
25862586
25872587 pm_runtime_put_sync(&pdev->dev);
25882588
2589− vpfe->sd = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_subdev *) *
2590− ARRAY_SIZE(vpfe->cfg->asd), GFP_KERNEL);
2589+ vpfe->sd = devm_kcalloc(&pdev->dev,
2590+ ARRAY_SIZE(vpfe->cfg->asd),
2591+ sizeof(struct v4l2_subdev *),
2592+ GFP_KERNEL);
25912593 if (!vpfe->sd) {
25922594 ret = -ENOMEM;
25932595 goto probe_out_v4l2_unregister;
drivers/media/platform/davinci/vpif_capture.c+6−4
@@ -1528,8 +1528,10 @@ vpif_capture_get_pdata(struct platform_device *pdev) · 1527 unmodified lines
15281528 if (!pdata)
15291529 return NULL;
15301530 pdata->subdev_info =
1531− devm_kzalloc(&pdev->dev, sizeof(*pdata->subdev_info) *
1532− VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL);
1531+ devm_kcalloc(&pdev->dev,
1532+ VPIF_CAPTURE_NUM_CHANNELS,
1533+ sizeof(*pdata->subdev_info),
1534+ GFP_KERNEL);
15331535
15341536 if (!pdata->subdev_info)
15351537 return NULL;
@@ -1546,9 +1548,9 @@ vpif_capture_get_pdata(struct platform_device *pdev) · 10 unmodified lines
15461548
15471549 sdinfo = &pdata->subdev_info[i];
15481550 chan = &pdata->chan_config[i];
1549− chan->inputs = devm_kzalloc(&pdev->dev,
1550− sizeof(*chan->inputs) *
1551+ chan->inputs = devm_kcalloc(&pdev->dev,
15511552 VPIF_CAPTURE_NUM_CHANNELS,
1553+ sizeof(*chan->inputs),
15521554 GFP_KERNEL);
15531555 if (!chan->inputs)
15541556 return NULL;
drivers/media/platform/qcom/camss-8x16/camss-csid.c+5−3
@@ -845,7 +845,7 @@ int msm_csid_subdev_init(struct csid_device *csid, · 844 unmodified lines
845845 while (res->clock[csid->nclocks])
846846 csid->nclocks++;
847847
848− csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock),
848+ csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock),
849849 GFP_KERNEL);
850850 if (!csid->clock)
851851 return -ENOMEM;
@@ -868,8 +868,10 @@ int msm_csid_subdev_init(struct csid_device *csid, · 16 unmodified lines
868868 continue;
869869 }
870870
871− clock->freq = devm_kzalloc(dev, clock->nfreqs *
872− sizeof(*clock->freq), GFP_KERNEL);
871+ clock->freq = devm_kcalloc(dev,
872+ clock->nfreqs,
873+ sizeof(*clock->freq),
874+ GFP_KERNEL);
873875 if (!clock->freq)
874876 return -ENOMEM;
875877
drivers/media/platform/qcom/camss-8x16/camss-csiphy.c+7−4
@@ -732,8 +732,9 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, · 731 unmodified lines
732732 while (res->clock[csiphy->nclocks])
733733 csiphy->nclocks++;
734734
735− csiphy->clock = devm_kzalloc(dev, csiphy->nclocks *
736− sizeof(*csiphy->clock), GFP_KERNEL);
735+ csiphy->clock = devm_kcalloc(dev,
736+ csiphy->nclocks, sizeof(*csiphy->clock),
737+ GFP_KERNEL);
737738 if (!csiphy->clock)
738739 return -ENOMEM;
739740
@@ -755,8 +756,10 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, · 15 unmodified lines
755756 continue;
756757 }
757758
758− clock->freq = devm_kzalloc(dev, clock->nfreqs *
759− sizeof(*clock->freq), GFP_KERNEL);
759+ clock->freq = devm_kcalloc(dev,
760+ clock->nfreqs,
761+ sizeof(*clock->freq),
762+ GFP_KERNEL);
760763 if (!clock->freq)
761764 return -ENOMEM;
762765
drivers/media/platform/qcom/camss-8x16/camss-ispif.c+6−3
@@ -948,7 +948,8 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, · 947 unmodified lines
948948 while (res->clock[ispif->nclocks])
949949 ispif->nclocks++;
950950
951− ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock),
951+ ispif->clock = devm_kcalloc(dev,
952+ ispif->nclocks, sizeof(*ispif->clock),
952953 GFP_KERNEL);
953954 if (!ispif->clock)
954955 return -ENOMEM;
@@ -968,8 +969,10 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, · 13 unmodified lines
968969 while (res->clock_for_reset[ispif->nclocks_for_reset])
969970 ispif->nclocks_for_reset++;
970971
971− ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset *
972− sizeof(*ispif->clock_for_reset), GFP_KERNEL);
972+ ispif->clock_for_reset = devm_kcalloc(dev,
973+ ispif->nclocks_for_reset,
974+ sizeof(*ispif->clock_for_reset),
975+ GFP_KERNEL);
973976 if (!ispif->clock_for_reset)
974977 return -ENOMEM;
975978
drivers/media/platform/qcom/camss-8x16/camss-vfe.c+5−3
@@ -2794,7 +2794,7 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) · 2793 unmodified lines
27942794 while (res->clock[vfe->nclocks])
27952795 vfe->nclocks++;
27962796
2797− vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock),
2797+ vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock),
27982798 GFP_KERNEL);
27992799 if (!vfe->clock)
28002800 return -ENOMEM;
@@ -2817,8 +2817,10 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) · 16 unmodified lines
28172817 continue;
28182818 }
28192819
2820− clock->freq = devm_kzalloc(dev, clock->nfreqs *
2821− sizeof(*clock->freq), GFP_KERNEL);
2820+ clock->freq = devm_kcalloc(dev,
2821+ clock->nfreqs,
2822+ sizeof(*clock->freq),
2823+ GFP_KERNEL);
28222824 if (!clock->freq)
28232825 return -ENOMEM;
28242826
drivers/media/platform/qcom/camss-8x16/camss.c+2−1
@@ -271,7 +271,8 @@ static int camss_of_parse_endpoint_node(struct device *dev, · 270 unmodified lines
271271 lncfg->clk.pol = mipi_csi2->lane_polarities[0];
272272 lncfg->num_data = mipi_csi2->num_data_lanes;
273273
274− lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data),
274+ lncfg->data = devm_kcalloc(dev,
275+ lncfg->num_data, sizeof(*lncfg->data),
275276 GFP_KERNEL);
276277 if (!lncfg->data)
277278 return -ENOMEM;
drivers/media/platform/soc_camera/soc_camera.c+2−1
@@ -481,7 +481,8 @@ static int soc_camera_init_user_formats(struct soc_camera_device *icd) · 480 unmodified lines
481481 return -ENXIO;
482482
483483 icd->user_formats =
484− vmalloc(fmts * sizeof(struct soc_camera_format_xlate));
484+ vmalloc(array_size(fmts,
485+ sizeof(struct soc_camera_format_xlate)));
485486 if (!icd->user_formats)
486487 return -ENOMEM;
487488
drivers/media/platform/vivid/vivid-core.c+5−4
@@ -844,10 +844,10 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) · 843 unmodified lines
844844 tpg_init(&dev->tpg, 640, 360);
845845 if (tpg_alloc(&dev->tpg, MAX_ZOOM * MAX_WIDTH))
846846 goto free_dev;
847− dev->scaled_line = vzalloc(MAX_ZOOM * MAX_WIDTH);
847+ dev->scaled_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM));
848848 if (!dev->scaled_line)
849849 goto free_dev;
850− dev->blended_line = vzalloc(MAX_ZOOM * MAX_WIDTH);
850+ dev->blended_line = vzalloc(array_size(MAX_WIDTH, MAX_ZOOM));
851851 if (!dev->blended_line)
852852 goto free_dev;
853853
@@ -859,8 +859,9 @@ static int vivid_create_instance(struct platform_device *pdev, int inst) · 5 unmodified lines
859859 /* create a string array containing the names of all the preset timings */
860860 while (v4l2_dv_timings_presets[dev->query_dv_timings_size].bt.width)
861861 dev->query_dv_timings_size++;
862− dev->query_dv_timings_qmenu = kmalloc(dev->query_dv_timings_size *
863− (sizeof(void *) + 32), GFP_KERNEL);
862+ dev->query_dv_timings_qmenu = kmalloc_array(dev->query_dv_timings_size,
863+ (sizeof(void *) + 32),
864+ GFP_KERNEL);
864865 if (dev->query_dv_timings_qmenu == NULL)
865866 goto free_dev;
866867 for (i = 0; i < dev->query_dv_timings_size; i++) {
drivers/media/platform/vsp1/vsp1_entity.c+2−1
@@ -630,7 +630,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, · 629 unmodified lines
630630 entity->source_pad = num_pads - 1;
631631
632632 /* Allocate and initialize pads. */
633− entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads),
633+ entity->pads = devm_kcalloc(vsp1->dev,
634+ num_pads, sizeof(*entity->pads),
634635 GFP_KERNEL);
635636 if (entity->pads == NULL)
636637 return -ENOMEM;
drivers/media/platform/xilinx/xilinx-vipp.c+1−1
@@ -532,7 +532,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev) · 531 unmodified lines
532532
533533 /* Register the subdevices notifier. */
534534 num_subdevs = xdev->num_subdevs;
535− subdevs = devm_kzalloc(xdev->dev, sizeof(*subdevs) * num_subdevs,
535+ subdevs = devm_kcalloc(xdev->dev, num_subdevs, sizeof(*subdevs),
536536 GFP_KERNEL);
537537 if (subdevs == NULL) {
538538 ret = -ENOMEM;
drivers/media/usb/au0828/au0828-video.c+3−3
@@ -217,14 +217,14 @@ static int au0828_init_isoc(struct au0828_dev *dev, int max_packets, · 216 unmodified lines
217217 dev->isoc_ctl.isoc_copy = isoc_copy;
218218 dev->isoc_ctl.num_bufs = num_bufs;
219219
220− dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
220+ dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
221221 if (!dev->isoc_ctl.urb) {
222222 au0828_isocdbg("cannot alloc memory for usb buffers\n");
223223 return -ENOMEM;
224224 }
225225
226− dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
227− GFP_KERNEL);
226+ dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *),
227+ GFP_KERNEL);
228228 if (!dev->isoc_ctl.transfer_buffer) {
229229 au0828_isocdbg("cannot allocate memory for usb transfer\n");
230230 kfree(dev->isoc_ctl.urb);
drivers/media/usb/cpia2/cpia2_usb.c+2−1
@@ -663,7 +663,8 @@ static int submit_urbs(struct camera_data *cam) · 662 unmodified lines
663663 if (cam->sbuf[i].data)
664664 continue;
665665 cam->sbuf[i].data =
666− kmalloc(FRAMES_PER_DESC * FRAME_SIZE_PER_DESC, GFP_KERNEL);
666+ kmalloc_array(FRAME_SIZE_PER_DESC, FRAMES_PER_DESC,
667+ GFP_KERNEL);
667668 if (!cam->sbuf[i].data) {
668669 while (--i >= 0) {
669670 kfree(cam->sbuf[i].data);
drivers/media/usb/cx231xx/cx231xx-audio.c+1−1
@@ -710,7 +710,7 @@ static int cx231xx_audio_init(struct cx231xx *dev) · 709 unmodified lines
710710 dev_info(dev->dev,
711711 "audio EndPoint Addr 0x%x, Alternate settings: %i\n",
712712 adev->end_point_addr, adev->num_alt);
713− adev->alt_max_pkt_size = kmalloc(32 * adev->num_alt, GFP_KERNEL);
713+ adev->alt_max_pkt_size = kmalloc_array(32, adev->num_alt, GFP_KERNEL);
714714 if (!adev->alt_max_pkt_size) {
715715 err = -ENOMEM;
716716 goto err_free_card;
drivers/media/usb/cx231xx/cx231xx-core.c+4−4
@@ -1034,7 +1034,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, · 1033 unmodified lines
10341034 dma_q->partial_buf[i] = 0;
10351035
10361036 dev->video_mode.isoc_ctl.urb =
1037− kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
1037+ kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
10381038 if (!dev->video_mode.isoc_ctl.urb) {
10391039 dev_err(dev->dev,
10401040 "cannot alloc memory for usb buffers\n");
@@ -1042,7 +1042,7 @@ int cx231xx_init_isoc(struct cx231xx *dev, int max_packets, · 1 unmodified line
10421042 }
10431043
10441044 dev->video_mode.isoc_ctl.transfer_buffer =
1045− kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
1045+ kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
10461046 if (!dev->video_mode.isoc_ctl.transfer_buffer) {
10471047 dev_err(dev->dev,
10481048 "cannot allocate memory for usbtransfer\n");
@@ -1169,7 +1169,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, · 120 unmodified lines
11691169 dma_q->partial_buf[i] = 0;
11701170
11711171 dev->video_mode.bulk_ctl.urb =
1172− kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
1172+ kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
11731173 if (!dev->video_mode.bulk_ctl.urb) {
11741174 dev_err(dev->dev,
11751175 "cannot alloc memory for usb buffers\n");
@@ -1177,7 +1177,7 @@ int cx231xx_init_bulk(struct cx231xx *dev, int max_packets, · 1 unmodified line
11771177 }
11781178
11791179 dev->video_mode.bulk_ctl.transfer_buffer =
1180− kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
1180+ kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
11811181 if (!dev->video_mode.bulk_ctl.transfer_buffer) {
11821182 dev_err(dev->dev,
11831183 "cannot allocate memory for usbtransfer\n");
drivers/media/usb/cx231xx/cx231xx-vbi.c+2−2
@@ -415,7 +415,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, · 414 unmodified lines
415415 for (i = 0; i < 8; i++)
416416 dma_q->partial_buf[i] = 0;
417417
418− dev->vbi_mode.bulk_ctl.urb = kzalloc(sizeof(void *) * num_bufs,
418+ dev->vbi_mode.bulk_ctl.urb = kcalloc(num_bufs, sizeof(void *),
419419 GFP_KERNEL);
420420 if (!dev->vbi_mode.bulk_ctl.urb) {
421421 dev_err(dev->dev,
@@ -424,7 +424,7 @@ int cx231xx_init_vbi_isoc(struct cx231xx *dev, int max_packets, · 2 unmodified lines
424424 }
425425
426426 dev->vbi_mode.bulk_ctl.transfer_buffer =
427− kzalloc(sizeof(void *) * num_bufs, GFP_KERNEL);
427+ kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
428428 if (!dev->vbi_mode.bulk_ctl.transfer_buffer) {
429429 dev_err(dev->dev,
430430 "cannot allocate memory for usbtransfer\n");
drivers/media/usb/go7007/go7007-fw.c+1−1
@@ -1579,7 +1579,7 @@ int go7007_construct_fw_image(struct go7007 *go, u8 **fw, int *fwlen) · 1578 unmodified lines
15791579 GO7007_FW_NAME);
15801580 return -1;
15811581 }
1582− code = kzalloc(codespace * 2, GFP_KERNEL);
1582+ code = kcalloc(codespace, 2, GFP_KERNEL);
15831583 if (code == NULL)
15841584 goto fw_failed;
15851585
drivers/media/usb/go7007/go7007-usb.c+2−1
@@ -1143,7 +1143,8 @@ static int go7007_usb_probe(struct usb_interface *intf, · 1142 unmodified lines
11431143 usb->intr_urb = usb_alloc_urb(0, GFP_KERNEL);
11441144 if (usb->intr_urb == NULL)
11451145 goto allocfail;
1146− usb->intr_urb->transfer_buffer = kmalloc(2*sizeof(u16), GFP_KERNEL);
1146+ usb->intr_urb->transfer_buffer = kmalloc_array(2, sizeof(u16),
1147+ GFP_KERNEL);
11471148 if (usb->intr_urb->transfer_buffer == NULL)
11481149 goto allocfail;
11491150
drivers/media/usb/gspca/t613.c+1−1
@@ -363,7 +363,7 @@ static void reg_w_ixbuf(struct gspca_dev *gspca_dev, · 362 unmodified lines
363363 if (len * 2 <= USB_BUF_SZ) {
364364 p = tmpbuf = gspca_dev->usb_buf;
365365 } else {
366− p = tmpbuf = kmalloc(len * 2, GFP_KERNEL);
366+ p = tmpbuf = kmalloc_array(len, 2, GFP_KERNEL);
367367 if (!tmpbuf) {
368368 pr_err("Out of memory\n");
369369 return;
drivers/media/usb/pvrusb2/pvrusb2-hdw.c+1−1
@@ -2413,7 +2413,7 @@ struct pvr2_hdw *pvr2_hdw_create(struct usb_interface *intf, · 2412 unmodified lines
24132413
24142414 hdw->control_cnt = CTRLDEF_COUNT;
24152415 hdw->control_cnt += MPEGDEF_COUNT;
2416− hdw->controls = kzalloc(sizeof(struct pvr2_ctrl) * hdw->control_cnt,
2416+ hdw->controls = kcalloc(hdw->control_cnt, sizeof(struct pvr2_ctrl),
24172417 GFP_KERNEL);
24182418 if (!hdw->controls) goto fail;
24192419 hdw->hdw_desc = hdw_desc;
drivers/media/usb/pvrusb2/pvrusb2-std.c+1−1
@@ -361,7 +361,7 @@ struct v4l2_standard *pvr2_std_create_enum(unsigned int *countptr, · 360 unmodified lines
361361 std_cnt);
362362 if (!std_cnt) return NULL; // paranoia
363363
364− stddefs = kzalloc(sizeof(struct v4l2_standard) * std_cnt,
364+ stddefs = kcalloc(std_cnt, sizeof(struct v4l2_standard),
365365 GFP_KERNEL);
366366 if (!stddefs)
367367 return NULL;
drivers/media/usb/stk1160/stk1160-core.c+3−2
@@ -290,8 +290,9 @@ static int stk1160_probe(struct usb_interface *interface, · 289 unmodified lines
290290 return -ENODEV;
291291
292292 /* Alloc an array for all possible max_pkt_size */
293− alt_max_pkt_size = kmalloc(sizeof(alt_max_pkt_size[0]) *
294− interface->num_altsetting, GFP_KERNEL);
293+ alt_max_pkt_size = kmalloc_array(interface->num_altsetting,
294+ sizeof(alt_max_pkt_size[0]),
295+ GFP_KERNEL);
295296 if (alt_max_pkt_size == NULL)
296297 return -ENOMEM;
297298
drivers/media/usb/stk1160/stk1160-video.c+3−3
@@ -439,14 +439,14 @@ int stk1160_alloc_isoc(struct stk1160 *dev) · 438 unmodified lines
439439
440440 dev->isoc_ctl.buf = NULL;
441441 dev->isoc_ctl.max_pkt_size = dev->max_pkt_size;
442− dev->isoc_ctl.urb = kzalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
442+ dev->isoc_ctl.urb = kcalloc(num_bufs, sizeof(void *), GFP_KERNEL);
443443 if (!dev->isoc_ctl.urb) {
444444 stk1160_err("out of memory for urb array\n");
445445 return -ENOMEM;
446446 }
447447
448− dev->isoc_ctl.transfer_buffer = kzalloc(sizeof(void *)*num_bufs,
449− GFP_KERNEL);
448+ dev->isoc_ctl.transfer_buffer = kcalloc(num_bufs, sizeof(void *),
449+ GFP_KERNEL);
450450 if (!dev->isoc_ctl.transfer_buffer) {
451451 stk1160_err("out of memory for usb transfers\n");
452452 kfree(dev->isoc_ctl.urb);
drivers/media/usb/stkwebcam/stk-webcam.c+3−2
@@ -567,8 +567,9 @@ static int stk_prepare_sio_buffers(struct stk_camera *dev, unsigned n_sbufs) · 566 unmodified lines
567567 if (dev->sio_bufs != NULL)
568568 pr_err("sio_bufs already allocated\n");
569569 else {
570− dev->sio_bufs = kzalloc(n_sbufs * sizeof(struct stk_sio_buffer),
571− GFP_KERNEL);
570+ dev->sio_bufs = kcalloc(n_sbufs,
571+ sizeof(struct stk_sio_buffer),
572+ GFP_KERNEL);
572573 if (dev->sio_bufs == NULL)
573574 return -ENOMEM;
574575 for (i = 0; i < n_sbufs; i++) {
drivers/media/usb/tm6000/tm6000-video.c+8−5
@@ -463,11 +463,12 @@ static int tm6000_alloc_urb_buffers(struct tm6000_core *dev) · 462 unmodified lines
463463 if (dev->urb_buffer)
464464 return 0;
465465
466− dev->urb_buffer = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
466+ dev->urb_buffer = kmalloc_array(num_bufs, sizeof(void *), GFP_KERNEL);
467467 if (!dev->urb_buffer)
468468 return -ENOMEM;
469469
470− dev->urb_dma = kmalloc(sizeof(dma_addr_t *)*num_bufs, GFP_KERNEL);
470+ dev->urb_dma = kmalloc_array(num_bufs, sizeof(dma_addr_t *),
471+ GFP_KERNEL);
471472 if (!dev->urb_dma)
472473 return -ENOMEM;
473474
@@ -583,12 +584,14 @@ static int tm6000_prepare_isoc(struct tm6000_core *dev) · 109 unmodified lines
583584
584585 dev->isoc_ctl.num_bufs = num_bufs;
585586
586− dev->isoc_ctl.urb = kmalloc(sizeof(void *)*num_bufs, GFP_KERNEL);
587+ dev->isoc_ctl.urb = kmalloc_array(num_bufs, sizeof(void *),
588+ GFP_KERNEL);
587589 if (!dev->isoc_ctl.urb)
588590 return -ENOMEM;
589591
590− dev->isoc_ctl.transfer_buffer = kmalloc(sizeof(void *)*num_bufs,
591− GFP_KERNEL);
592+ dev->isoc_ctl.transfer_buffer = kmalloc_array(num_bufs,
593+ sizeof(void *),
594+ GFP_KERNEL);
592595 if (!dev->isoc_ctl.transfer_buffer) {
593596 kfree(dev->isoc_ctl.urb);
594597 return -ENOMEM;
drivers/media/usb/usbtv/usbtv-video.c+1−1
@@ -507,7 +507,7 @@ static struct urb *usbtv_setup_iso_transfer(struct usbtv *usbtv) · 506 unmodified lines
507507 ip->pipe = usb_rcvisocpipe(usbtv->udev, USBTV_VIDEO_ENDP);
508508 ip->interval = 1;
509509 ip->transfer_flags = URB_ISO_ASAP;
510− ip->transfer_buffer = kzalloc(size * USBTV_ISOC_PACKETS,
510+ ip->transfer_buffer = kcalloc(USBTV_ISOC_PACKETS, size,
511511 GFP_KERNEL);
512512 if (!ip->transfer_buffer) {
513513 usb_free_urb(ip);
drivers/media/usb/usbvision/usbvision-video.c+2−1
@@ -1492,7 +1492,8 @@ static int usbvision_probe(struct usb_interface *intf, · 1491 unmodified lines
14921492
14931493 usbvision->num_alt = uif->num_altsetting;
14941494 PDEBUG(DBG_PROBE, "Alternate settings: %i", usbvision->num_alt);
1495− usbvision->alt_max_pkt_size = kmalloc(32 * usbvision->num_alt, GFP_KERNEL);
1495+ usbvision->alt_max_pkt_size = kmalloc_array(32, usbvision->num_alt,
1496+ GFP_KERNEL);
14961497 if (!usbvision->alt_max_pkt_size) {
14971498 ret = -ENOMEM;
14981499 goto err_pkt;
drivers/media/usb/uvc/uvc_video.c+2−2
@@ -513,8 +513,8 @@ static int uvc_video_clock_init(struct uvc_streaming *stream) · 512 unmodified lines
513513 spin_lock_init(&clock->lock);
514514 clock->size = 32;
515515
516− clock->samples = kmalloc(clock->size * sizeof(*clock->samples),
517− GFP_KERNEL);
516+ clock->samples = kmalloc_array(clock->size, sizeof(*clock->samples),
517+ GFP_KERNEL);
518518 if (clock->samples == NULL)
519519 return -ENOMEM;
520520
drivers/media/v4l2-core/v4l2-event.c+1−2
@@ -215,8 +215,7 @@ int v4l2_event_subscribe(struct v4l2_fh *fh, · 214 unmodified lines
215215 if (elems < 1)
216216 elems = 1;
217217
218− sev = kvzalloc(sizeof(*sev) + sizeof(struct v4l2_kevent) * elems,
219− GFP_KERNEL);
218+ sev = kvzalloc(struct_size(sev, events, elems), GFP_KERNEL);
220219 if (!sev)
221220 return -ENOMEM;
222221 for (i = 0; i < elems; i++)
drivers/media/v4l2-core/v4l2-flash-led-class.c+4−3
@@ -412,9 +412,10 @@ static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash, · 411 unmodified lines
412412 struct v4l2_ctrl_config *ctrl_cfg;
413413 int i, ret, num_ctrls = 0;
414414
415− v4l2_flash->ctrls = devm_kzalloc(v4l2_flash->sd.dev,
416− sizeof(*v4l2_flash->ctrls) *
417− (STROBE_SOURCE + 1), GFP_KERNEL);
415+ v4l2_flash->ctrls = devm_kcalloc(v4l2_flash->sd.dev,
416+ STROBE_SOURCE + 1,
417+ sizeof(*v4l2_flash->ctrls),
418+ GFP_KERNEL);
418419 if (!v4l2_flash->ctrls)
419420 return -ENOMEM;
420421
drivers/media/v4l2-core/videobuf-dma-sg.c+4−3
@@ -69,7 +69,7 @@ static struct scatterlist *videobuf_vmalloc_to_sg(unsigned char *virt, · 68 unmodified lines
6969 struct page *pg;
7070 int i;
7171
72− sglist = vzalloc(nr_pages * sizeof(*sglist));
72+ sglist = vzalloc(array_size(nr_pages, sizeof(*sglist)));
7373 if (NULL == sglist)
7474 return NULL;
7575 sg_init_table(sglist, nr_pages);
@@ -100,7 +100,7 @@ static struct scatterlist *videobuf_pages_to_sg(struct page **pages, · 24 unmodified lines
100100
101101 if (NULL == pages[0])
102102 return NULL;
103− sglist = vmalloc(nr_pages * sizeof(*sglist));
103+ sglist = vmalloc(array_size(nr_pages, sizeof(*sglist)));
104104 if (NULL == sglist)
105105 return NULL;
106106 sg_init_table(sglist, nr_pages);
@@ -175,7 +175,8 @@ static int videobuf_dma_init_user_locked(struct videobuf_dmabuf *dma, · 68 unmodified lines
175175 dma->offset = data & ~PAGE_MASK;
176176 dma->size = size;
177177 dma->nr_pages = last-first+1;
178− dma->pages = kmalloc(dma->nr_pages * sizeof(struct page *), GFP_KERNEL);
178+ dma->pages = kmalloc_array(dma->nr_pages, sizeof(struct page *),
179+ GFP_KERNEL);
179180 if (NULL == dma->pages)
180181 return -ENOMEM;
181182
drivers/memory/of_memory.c+2−2
@@ -126,8 +126,8 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr, · 125 unmodified lines
126126 arr_sz++;
127127
128128 if (arr_sz)
129− timings = devm_kzalloc(dev, sizeof(*timings) * arr_sz,
130− GFP_KERNEL);
129+ timings = devm_kcalloc(dev, arr_sz, sizeof(*timings),
130+ GFP_KERNEL);
131131
132132 if (!timings)
133133 goto default_timings;
drivers/memstick/core/ms_block.c+4−2
@@ -1201,7 +1201,8 @@ static int msb_read_boot_blocks(struct msb_data *msb) · 1200 unmodified lines
12011201 dbg_verbose("Start of a scan for the boot blocks");
12021202
12031203 if (!msb->boot_page) {
1204− page = kmalloc(sizeof(struct ms_boot_page)*2, GFP_KERNEL);
1204+ page = kmalloc_array(2, sizeof(struct ms_boot_page),
1205+ GFP_KERNEL);
12051206 if (!page)
12061207 return -ENOMEM;
12071208
@@ -1341,7 +1342,8 @@ static int msb_ftl_initialize(struct msb_data *msb) · 133 unmodified lines
13411342 msb->used_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
13421343 msb->erased_blocks_bitmap = kzalloc(msb->block_count / 8, GFP_KERNEL);
13431344 msb->lba_to_pba_table =
1344− kmalloc(msb->logical_block_count * sizeof(u16), GFP_KERNEL);
1345+ kmalloc_array(msb->logical_block_count, sizeof(u16),
1346+ GFP_KERNEL);
13451347
13461348 if (!msb->used_blocks_bitmap || !msb->lba_to_pba_table ||
13471349 !msb->erased_blocks_bitmap) {
drivers/message/fusion/mptlan.c+4−3
@@ -394,7 +394,8 @@ mpt_lan_open(struct net_device *dev) · 393 unmodified lines
394394 "a moment.\n");
395395 }
396396
397− priv->mpt_txfidx = kmalloc(priv->tx_max_out * sizeof(int), GFP_KERNEL);
397+ priv->mpt_txfidx = kmalloc_array(priv->tx_max_out, sizeof(int),
398+ GFP_KERNEL);
398399 if (priv->mpt_txfidx == NULL)
399400 goto out;
400401 priv->mpt_txfidx_tail = -1;
@@ -408,8 +409,8 @@ mpt_lan_open(struct net_device *dev) · 7 unmodified lines
408409
409410 dlprintk((KERN_INFO MYNAM "@lo: Finished initializing SendCtl\n"));
410411
411− priv->mpt_rxfidx = kmalloc(priv->max_buckets_out * sizeof(int),
412− GFP_KERNEL);
412+ priv->mpt_rxfidx = kmalloc_array(priv->max_buckets_out, sizeof(int),
413+ GFP_KERNEL);
413414 if (priv->mpt_rxfidx == NULL)
414415 goto out_SendCtl;
415416 priv->mpt_rxfidx_tail = -1;
drivers/mfd/ab8500-debugfs.c+6−6
@@ -2659,18 +2659,18 @@ static int ab8500_debug_probe(struct platform_device *plf) · 2658 unmodified lines
26592659 ab8500 = dev_get_drvdata(plf->dev.parent);
26602660 num_irqs = ab8500->mask_size;
26612661
2662− irq_count = devm_kzalloc(&plf->dev,
2663− sizeof(*irq_count)*num_irqs, GFP_KERNEL);
2662+ irq_count = devm_kcalloc(&plf->dev,
2663+ num_irqs, sizeof(*irq_count), GFP_KERNEL);
26642664 if (!irq_count)
26652665 return -ENOMEM;
26662666
2667− dev_attr = devm_kzalloc(&plf->dev,
2668− sizeof(*dev_attr)*num_irqs, GFP_KERNEL);
2667+ dev_attr = devm_kcalloc(&plf->dev,
2668+ num_irqs, sizeof(*dev_attr), GFP_KERNEL);
26692669 if (!dev_attr)
26702670 return -ENOMEM;
26712671
2672− event_name = devm_kzalloc(&plf->dev,
2673− sizeof(*event_name)*num_irqs, GFP_KERNEL);
2672+ event_name = devm_kcalloc(&plf->dev,
2673+ num_irqs, sizeof(*event_name), GFP_KERNEL);
26742674 if (!event_name)
26752675 return -ENOMEM;
26762676
drivers/mfd/cros_ec_dev.c+4−3
@@ -299,13 +299,14 @@ static void cros_ec_sensors_register(struct cros_ec_dev *ec) · 298 unmodified lines
299299 resp = (struct ec_response_motion_sense *)msg->data;
300300 sensor_num = resp->dump.sensor_count;
301301 /* Allocate 1 extra sensors in FIFO are needed */
302− sensor_cells = kzalloc(sizeof(struct mfd_cell) * (sensor_num + 1),
302+ sensor_cells = kcalloc(sensor_num + 1, sizeof(struct mfd_cell),
303303 GFP_KERNEL);
304304 if (sensor_cells == NULL)
305305 goto error;
306306
307− sensor_platforms = kzalloc(sizeof(struct cros_ec_sensor_platform) *
308− (sensor_num + 1), GFP_KERNEL);
307+ sensor_platforms = kcalloc(sensor_num + 1,
308+ sizeof(struct cros_ec_sensor_platform),
309+ GFP_KERNEL);
309310 if (sensor_platforms == NULL)
310311 goto error_platforms;
311312
drivers/mfd/htc-i2cpld.c+3−1
@@ -477,7 +477,9 @@ static int htcpld_setup_chips(struct platform_device *pdev) · 476 unmodified lines
477477
478478 /* Setup each chip's output GPIOs */
479479 htcpld->nchips = pdata->num_chip;
480− htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips,
480+ htcpld->chip = devm_kcalloc(dev,
481+ htcpld->nchips,
482+ sizeof(struct htcpld_chip),
481483 GFP_KERNEL);
482484 if (!htcpld->chip)
483485 return -ENOMEM;
drivers/mfd/mfd-core.c+1−1
@@ -158,7 +158,7 @@ static int mfd_add_device(struct device *parent, int id, · 157 unmodified lines
158158 if (!pdev)
159159 goto fail_alloc;
160160
161− res = kzalloc(sizeof(*res) * cell->num_resources, GFP_KERNEL);
161+ res = kcalloc(cell->num_resources, sizeof(*res), GFP_KERNEL);
162162 if (!res)
163163 goto fail_device;
164164
drivers/mfd/motorola-cpcap.c+3−3
@@ -173,9 +173,9 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap) · 172 unmodified lines
173173 int ret;
174174
175175 cpcap->irqs = devm_kzalloc(&cpcap->spi->dev,
176− sizeof(*cpcap->irqs) *
177− CPCAP_NR_IRQ_REG_BANKS *
178− cpcap->regmap_conf->val_bits,
176+ array3_size(sizeof(*cpcap->irqs),
177+ CPCAP_NR_IRQ_REG_BANKS,
178+ cpcap->regmap_conf->val_bits),
179179 GFP_KERNEL);
180180 if (!cpcap->irqs)
181181 return -ENOMEM;
drivers/mfd/sprd-sc27xx-spi.c+3−2
@@ -199,8 +199,9 @@ static int sprd_pmic_probe(struct spi_device *spi) · 198 unmodified lines
199199 ddata->irq_chip.num_irqs = pdata->num_irqs;
200200 ddata->irq_chip.mask_invert = true;
201201
202− ddata->irqs = devm_kzalloc(&spi->dev, sizeof(struct regmap_irq) *
203− pdata->num_irqs, GFP_KERNEL);
202+ ddata->irqs = devm_kcalloc(&spi->dev,
203+ pdata->num_irqs, sizeof(struct regmap_irq),
204+ GFP_KERNEL);
204205 if (!ddata->irqs)
205206 return -ENOMEM;
206207
drivers/mfd/timberdale.c+2−2
@@ -707,8 +707,8 @@ static int timb_probe(struct pci_dev *dev, · 706 unmodified lines
707707 goto err_config;
708708 }
709709
710− msix_entries = kzalloc(TIMBERDALE_NR_IRQS * sizeof(*msix_entries),
711− GFP_KERNEL);
710+ msix_entries = kcalloc(TIMBERDALE_NR_IRQS, sizeof(*msix_entries),
711+ GFP_KERNEL);
712712 if (!msix_entries)
713713 goto err_config;
714714
drivers/mfd/twl-core.c+3−2
@@ -1139,8 +1139,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) · 1138 unmodified lines
11391139 }
11401140
11411141 num_slaves = twl_get_num_slaves();
1142− twl_priv->twl_modules = devm_kzalloc(&client->dev,
1143− sizeof(struct twl_client) * num_slaves,
1142+ twl_priv->twl_modules = devm_kcalloc(&client->dev,
1143+ num_slaves,
1144+ sizeof(struct twl_client),
11441145 GFP_KERNEL);
11451146 if (!twl_priv->twl_modules) {
11461147 status = -ENOMEM;
drivers/mfd/wm8994-core.c+4−3
@@ -368,9 +368,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) · 367 unmodified lines
368368 goto err;
369369 }
370370
371− wm8994->supplies = devm_kzalloc(wm8994->dev,
372− sizeof(struct regulator_bulk_data) *
373− wm8994->num_supplies, GFP_KERNEL);
371+ wm8994->supplies = devm_kcalloc(wm8994->dev,
372+ wm8994->num_supplies,
373+ sizeof(struct regulator_bulk_data),
374+ GFP_KERNEL);
374375 if (!wm8994->supplies) {
375376 ret = -ENOMEM;
376377 goto err;
drivers/misc/altera-stapl/altera.c+3−3
@@ -304,13 +304,13 @@ static int altera_execute(struct altera_state *astate, · 303 unmodified lines
304304 if (sym_count <= 0)
305305 goto exit_done;
306306
307− vars = kzalloc(sym_count * sizeof(long), GFP_KERNEL);
307+ vars = kcalloc(sym_count, sizeof(long), GFP_KERNEL);
308308
309309 if (vars == NULL)
310310 status = -ENOMEM;
311311
312312 if (status == 0) {
313− var_size = kzalloc(sym_count * sizeof(s32), GFP_KERNEL);
313+ var_size = kcalloc(sym_count, sizeof(s32), GFP_KERNEL);
314314
315315 if (var_size == NULL)
316316 status = -ENOMEM;
@@ -1136,7 +1136,7 @@ exit_done: · 819 unmodified lines
11361136 /* Allocate a writable buffer for this array */
11371137 count = var_size[variable_id];
11381138 long_tmp = vars[variable_id];
1139− longptr_tmp = kzalloc(count * sizeof(long),
1139+ longptr_tmp = kcalloc(count, sizeof(long),
11401140 GFP_KERNEL);
11411141 vars[variable_id] = (long)longptr_tmp;
11421142
drivers/misc/cxl/guest.c+1−1
@@ -89,7 +89,7 @@ static ssize_t guest_collect_vpd(struct cxl *adapter, struct cxl_afu *afu, · 88 unmodified lines
8989 mod = 0;
9090 }
9191
92− vpd_buf = kzalloc(entries * sizeof(unsigned long *), GFP_KERNEL);
92+ vpd_buf = kcalloc(entries, sizeof(unsigned long *), GFP_KERNEL);
9393 if (!vpd_buf)
9494 return -ENOMEM;
9595
drivers/misc/cxl/of.c+1−1
@@ -302,7 +302,7 @@ static int read_adapter_irq_config(struct cxl *adapter, struct device_node *np) · 301 unmodified lines
302302 if (nranges == 0 || (nranges * 2 * sizeof(int)) != len)
303303 return -EINVAL;
304304
305− adapter->guest->irq_avail = kzalloc(nranges * sizeof(struct irq_avail),
305+ adapter->guest->irq_avail = kcalloc(nranges, sizeof(struct irq_avail),
306306 GFP_KERNEL);
307307 if (adapter->guest->irq_avail == NULL)
308308 return -ENOMEM;
drivers/misc/eeprom/idt_89hpesx.c+1−1
@@ -964,7 +964,7 @@ static ssize_t idt_dbgfs_csr_write(struct file *filep, const char __user *ubuf, · 963 unmodified lines
964964 if (colon_ch != NULL) {
965965 csraddr_len = colon_ch - buf;
966966 csraddr_str =
967− kmalloc(sizeof(char)*(csraddr_len + 1), GFP_KERNEL);
967+ kmalloc(csraddr_len + 1, GFP_KERNEL);
968968 if (csraddr_str == NULL) {
969969 ret = -ENOMEM;
970970 goto free_buf;
drivers/misc/genwqe/card_ddcb.c+5−4
@@ -1048,15 +1048,16 @@ static int setup_ddcb_queue(struct genwqe_dev *cd, struct ddcb_queue *queue) · 1047 unmodified lines
10481048 "[%s] **err: could not allocate DDCB **\n", __func__);
10491049 return -ENOMEM;
10501050 }
1051− queue->ddcb_req = kzalloc(sizeof(struct ddcb_requ *) *
1052− queue->ddcb_max, GFP_KERNEL);
1051+ queue->ddcb_req = kcalloc(queue->ddcb_max, sizeof(struct ddcb_requ *),
1052+ GFP_KERNEL);
10531053 if (!queue->ddcb_req) {
10541054 rc = -ENOMEM;
10551055 goto free_ddcbs;
10561056 }
10571057
1058− queue->ddcb_waitqs = kzalloc(sizeof(wait_queue_head_t) *
1059− queue->ddcb_max, GFP_KERNEL);
1058+ queue->ddcb_waitqs = kcalloc(queue->ddcb_max,
1059+ sizeof(wait_queue_head_t),
1060+ GFP_KERNEL);
10601061 if (!queue->ddcb_waitqs) {
10611062 rc = -ENOMEM;
10621063 goto free_requs;
drivers/misc/sgi-xp/xpc_main.c+5−3
@@ -416,7 +416,8 @@ xpc_setup_ch_structures(struct xpc_partition *part) · 415 unmodified lines
416416 * memory.
417417 */
418418 DBUG_ON(part->channels != NULL);
419− part->channels = kzalloc(sizeof(struct xpc_channel) * XPC_MAX_NCHANNELS,
419+ part->channels = kcalloc(XPC_MAX_NCHANNELS,
420+ sizeof(struct xpc_channel),
420421 GFP_KERNEL);
421422 if (part->channels == NULL) {
422423 dev_err(xpc_chan, "can't get memory for channels\n");
@@ -905,8 +906,9 @@ xpc_setup_partitions(void) · 482 unmodified lines
905906 short partid;
906907 struct xpc_partition *part;
907908
908− xpc_partitions = kzalloc(sizeof(struct xpc_partition) *
909− xp_max_npartitions, GFP_KERNEL);
909+ xpc_partitions = kcalloc(xp_max_npartitions,
910+ sizeof(struct xpc_partition),
911+ GFP_KERNEL);
910912 if (xpc_partitions == NULL) {
911913 dev_err(xpc_part, "can't get memory for partition structure\n");
912914 return -ENOMEM;
drivers/misc/sgi-xp/xpc_partition.c+1−1
@@ -425,7 +425,7 @@ xpc_discovery(void) · 424 unmodified lines
425425 if (remote_rp == NULL)
426426 return;
427427
428− discovered_nasids = kzalloc(sizeof(long) * xpc_nasid_mask_nlongs,
428+ discovered_nasids = kcalloc(xpc_nasid_mask_nlongs, sizeof(long),
429429 GFP_KERNEL);
430430 if (discovered_nasids == NULL) {
431431 kfree(remote_rp_base);
drivers/misc/sgi-xp/xpnet.c+3−2
@@ -520,8 +520,9 @@ xpnet_init(void) · 519 unmodified lines
520520
521521 dev_info(xpnet, "registering network device %s\n", XPNET_DEVICE_NAME);
522522
523− xpnet_broadcast_partitions = kzalloc(BITS_TO_LONGS(xp_max_npartitions) *
524− sizeof(long), GFP_KERNEL);
523+ xpnet_broadcast_partitions = kcalloc(BITS_TO_LONGS(xp_max_npartitions),
524+ sizeof(long),
525+ GFP_KERNEL);
525526 if (xpnet_broadcast_partitions == NULL)
526527 return -ENOMEM;
527528
drivers/misc/sram.c+3−3
@@ -185,7 +185,7 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) · 184 unmodified lines
185185 * after the reserved blocks from the dt are processed.
186186 */
187187 nblocks = (np) ? of_get_available_child_count(np) + 1 : 1;
188− rblocks = kzalloc((nblocks) * sizeof(*rblocks), GFP_KERNEL);
188+ rblocks = kcalloc(nblocks, sizeof(*rblocks), GFP_KERNEL);
189189 if (!rblocks)
190190 return -ENOMEM;
191191
@@ -264,8 +264,8 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) · 72 unmodified lines
264264 list_sort(NULL, &reserve_list, sram_reserve_cmp);
265265
266266 if (exports) {
267− sram->partition = devm_kzalloc(sram->dev,
268− exports * sizeof(*sram->partition),
267+ sram->partition = devm_kcalloc(sram->dev,
268+ exports, sizeof(*sram->partition),
269269 GFP_KERNEL);
270270 if (!sram->partition) {
271271 ret = -ENOMEM;
drivers/misc/vmw_vmci/vmci_queue_pair.c+4−2
@@ -449,12 +449,14 @@ static int qp_alloc_ppn_set(void *prod_q, · 448 unmodified lines
449449 return VMCI_ERROR_ALREADY_EXISTS;
450450
451451 produce_ppns =
452− kmalloc(num_produce_pages * sizeof(*produce_ppns), GFP_KERNEL);
452+ kmalloc_array(num_produce_pages, sizeof(*produce_ppns),
453+ GFP_KERNEL);
453454 if (!produce_ppns)
454455 return VMCI_ERROR_NO_MEM;
455456
456457 consume_ppns =
457− kmalloc(num_consume_pages * sizeof(*consume_ppns), GFP_KERNEL);
458+ kmalloc_array(num_consume_pages, sizeof(*consume_ppns),
459+ GFP_KERNEL);
458460 if (!consume_ppns) {
459461 kfree(produce_ppns);
460462 return VMCI_ERROR_NO_MEM;
drivers/mmc/host/sdhci-omap.c+4−2
@@ -797,8 +797,10 @@ static int sdhci_omap_config_iodelay_pinctrl_state(struct sdhci_omap_host · 796 unmodified lines
797797 if (!(omap_host->flags & SDHCI_OMAP_REQUIRE_IODELAY))
798798 return 0;
799799
800− pinctrl_state = devm_kzalloc(dev, sizeof(*pinctrl_state) *
801− (MMC_TIMING_MMC_HS200 + 1), GFP_KERNEL);
800+ pinctrl_state = devm_kcalloc(dev,
801+ MMC_TIMING_MMC_HS200 + 1,
802+ sizeof(*pinctrl_state),
803+ GFP_KERNEL);
802804 if (!pinctrl_state)
803805 return -ENOMEM;
804806
drivers/mtd/ar7part.c+1−1
@@ -55,7 +55,7 @@ static int create_mtd_partitions(struct mtd_info *master, · 54 unmodified lines
5555 int retries = 10;
5656 struct mtd_partition *ar7_parts;
5757
58− ar7_parts = kzalloc(sizeof(*ar7_parts) * AR7_PARTS, GFP_KERNEL);
58+ ar7_parts = kcalloc(AR7_PARTS, sizeof(*ar7_parts), GFP_KERNEL);
5959 if (!ar7_parts)
6060 return -ENOMEM;
6161 ar7_parts[0].name = "loader";
drivers/mtd/bcm47xxpart.c+1−1
@@ -110,7 +110,7 @@ static int bcm47xxpart_parse(struct mtd_info *master, · 109 unmodified lines
110110 blocksize = 0x1000;
111111
112112 /* Alloc */
113− parts = kzalloc(sizeof(struct mtd_partition) * BCM47XXPART_MAX_PARTS,
113+ parts = kcalloc(BCM47XXPART_MAX_PARTS, sizeof(struct mtd_partition),
114114 GFP_KERNEL);
115115 if (!parts)
116116 return -ENOMEM;
drivers/mtd/chips/cfi_cmdset_0001.c+6−3
@@ -608,8 +608,9 @@ static struct mtd_info *cfi_intelext_setup(struct mtd_info *mtd) · 607 unmodified lines
608608 mtd->size = devsize * cfi->numchips;
609609
610610 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
611− mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info)
612− * mtd->numeraseregions, GFP_KERNEL);
611+ mtd->eraseregions = kcalloc(mtd->numeraseregions,
612+ sizeof(struct mtd_erase_region_info),
613+ GFP_KERNEL);
613614 if (!mtd->eraseregions)
614615 goto setup_err;
615616
@@ -758,7 +759,9 @@ static int cfi_intelext_partition_fixup(struct mtd_info *mtd, · 142 unmodified lines
758759 newcfi = kmalloc(sizeof(struct cfi_private) + numvirtchips * sizeof(struct flchip), GFP_KERNEL);
759760 if (!newcfi)
760761 return -ENOMEM;
761− shared = kmalloc(sizeof(struct flchip_shared) * cfi->numchips, GFP_KERNEL);
762+ shared = kmalloc_array(cfi->numchips,
763+ sizeof(struct flchip_shared),
764+ GFP_KERNEL);
762765 if (!shared) {
763766 kfree(newcfi);
764767 return -ENOMEM;
drivers/mtd/chips/cfi_cmdset_0002.c+4−3
@@ -692,8 +692,9 @@ static struct mtd_info *cfi_amdstd_setup(struct mtd_info *mtd) · 691 unmodified lines
692692 mtd->size = devsize * cfi->numchips;
693693
694694 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
695− mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
696− * mtd->numeraseregions, GFP_KERNEL);
695+ mtd->eraseregions = kmalloc_array(mtd->numeraseregions,
696+ sizeof(struct mtd_erase_region_info),
697+ GFP_KERNEL);
697698 if (!mtd->eraseregions)
698699 goto setup_err;
699700
@@ -2635,7 +2636,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, · 1935 unmodified lines
26352636 * first check the locking status of all sectors and save
26362637 * it for future use.
26372638 */
2638− sect = kzalloc(MAX_SECTORS * sizeof(struct ppb_lock), GFP_KERNEL);
2639+ sect = kcalloc(MAX_SECTORS, sizeof(struct ppb_lock), GFP_KERNEL);
26392640 if (!sect)
26402641 return -ENOMEM;
26412642
drivers/mtd/chips/cfi_cmdset_0020.c+3−2
@@ -184,8 +184,9 @@ static struct mtd_info *cfi_staa_setup(struct map_info *map) · 183 unmodified lines
184184 mtd->size = devsize * cfi->numchips;
185185
186186 mtd->numeraseregions = cfi->cfiq->NumEraseRegions * cfi->numchips;
187− mtd->eraseregions = kmalloc(sizeof(struct mtd_erase_region_info)
188− * mtd->numeraseregions, GFP_KERNEL);
187+ mtd->eraseregions = kmalloc_array(mtd->numeraseregions,
188+ sizeof(struct mtd_erase_region_info),
189+ GFP_KERNEL);
189190 if (!mtd->eraseregions) {
190191 kfree(cfi->cmdset_priv);
191192 kfree(mtd);
drivers/mtd/devices/docg3.c+2−2
@@ -1827,7 +1827,7 @@ doc_probe_device(struct docg3_cascade *cascade, int floor, struct device *dev) · 1826 unmodified lines
18271827 mtd->dev.parent = dev;
18281828 bbt_nbpages = DIV_ROUND_UP(docg3->max_block + 1,
18291829 8 * DOC_LAYOUT_PAGE_SIZE);
1830− docg3->bbt = kzalloc(bbt_nbpages * DOC_LAYOUT_PAGE_SIZE, GFP_KERNEL);
1830+ docg3->bbt = kcalloc(DOC_LAYOUT_PAGE_SIZE, bbt_nbpages, GFP_KERNEL);
18311831 if (!docg3->bbt)
18321832 goto nomem3;
18331833
@@ -1993,7 +1993,7 @@ static int __init docg3_probe(struct platform_device *pdev) · 159 unmodified lines
19931993 base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE);
19941994
19951995 ret = -ENOMEM;
1996− cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS,
1996+ cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade),
19971997 GFP_KERNEL);
19981998 if (!cascade)
19991999 return ret;
drivers/mtd/ftl.c+8−7
@@ -201,15 +201,16 @@ static int build_maps(partition_t *part) · 200 unmodified lines
201201 /* Set up erase unit maps */
202202 part->DataUnits = le16_to_cpu(part->header.NumEraseUnits) -
203203 part->header.NumTransferUnits;
204− part->EUNInfo = kmalloc(part->DataUnits * sizeof(struct eun_info_t),
205− GFP_KERNEL);
204+ part->EUNInfo = kmalloc_array(part->DataUnits, sizeof(struct eun_info_t),
205+ GFP_KERNEL);
206206 if (!part->EUNInfo)
207207 goto out;
208208 for (i = 0; i < part->DataUnits; i++)
209209 part->EUNInfo[i].Offset = 0xffffffff;
210210 part->XferInfo =
211− kmalloc(part->header.NumTransferUnits * sizeof(struct xfer_info_t),
212− GFP_KERNEL);
211+ kmalloc_array(part->header.NumTransferUnits,
212+ sizeof(struct xfer_info_t),
213+ GFP_KERNEL);
213214 if (!part->XferInfo)
214215 goto out_EUNInfo;
215216
@@ -262,15 +263,15 @@ static int build_maps(partition_t *part) · 46 unmodified lines
262263
263264 /* Set up virtual page map */
264265 blocks = le32_to_cpu(header.FormattedSize) >> header.BlockSize;
265− part->VirtualBlockMap = vmalloc(blocks * sizeof(uint32_t));
266+ part->VirtualBlockMap = vmalloc(array_size(blocks, sizeof(uint32_t)));
266267 if (!part->VirtualBlockMap)
267268 goto out_XferInfo;
268269
269270 memset(part->VirtualBlockMap, 0xff, blocks * sizeof(uint32_t));
270271 part->BlocksPerUnit = (1 << header.EraseUnitSize) >> header.BlockSize;
271272
272− part->bam_cache = kmalloc(part->BlocksPerUnit * sizeof(uint32_t),
273− GFP_KERNEL);
273+ part->bam_cache = kmalloc_array(part->BlocksPerUnit, sizeof(uint32_t),
274+ GFP_KERNEL);
274275 if (!part->bam_cache)
275276 goto out_VirtualBlockMap;
276277
drivers/mtd/inftlmount.c+4−2
@@ -270,7 +270,8 @@ static int find_boot_record(struct INFTLrecord *inftl) · 269 unmodified lines
270270 inftl->nb_blocks = ip->lastUnit + 1;
271271
272272 /* Memory alloc */
273− inftl->PUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
273+ inftl->PUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
274+ GFP_KERNEL);
274275 if (!inftl->PUtable) {
275276 printk(KERN_WARNING "INFTL: allocation of PUtable "
276277 "failed (%zd bytes)\n",
@@ -278,7 +279,8 @@ static int find_boot_record(struct INFTLrecord *inftl) · 1 unmodified line
278279 return -ENOMEM;
279280 }
280281
281− inftl->VUtable = kmalloc(inftl->nb_blocks * sizeof(u16), GFP_KERNEL);
282+ inftl->VUtable = kmalloc_array(inftl->nb_blocks, sizeof(u16),
283+ GFP_KERNEL);
282284 if (!inftl->VUtable) {
283285 kfree(inftl->PUtable);
284286 printk(KERN_WARNING "INFTL: allocation of VUtable "
drivers/mtd/lpddr/lpddr_cmds.c+1−1
@@ -78,7 +78,7 @@ struct mtd_info *lpddr_cmdset(struct map_info *map) · 77 unmodified lines
7878 mtd->erasesize = 1 << lpddr->qinfo->UniformBlockSizeShift;
7979 mtd->writesize = 1 << lpddr->qinfo->BufSizeShift;
8080
81− shared = kmalloc(sizeof(struct flchip_shared) * lpddr->numchips,
81+ shared = kmalloc_array(lpddr->numchips, sizeof(struct flchip_shared),
8282 GFP_KERNEL);
8383 if (!shared) {
8484 kfree(lpddr);
drivers/mtd/maps/physmap_of_core.c+2−2
@@ -124,7 +124,7 @@ static const char * const *of_get_probes(struct device_node *dp) · 123 unmodified lines
124124 if (count < 0)
125125 return part_probe_types_def;
126126
127− res = kzalloc((count + 1) * sizeof(*res), GFP_KERNEL);
127+ res = kcalloc(count + 1, sizeof(*res), GFP_KERNEL);
128128 if (!res)
129129 return NULL;
130130
@@ -197,7 +197,7 @@ static int of_flash_probe(struct platform_device *dev) · 66 unmodified lines
197197
198198 dev_set_drvdata(&dev->dev, info);
199199
200− mtd_list = kzalloc(sizeof(*mtd_list) * count, GFP_KERNEL);
200+ mtd_list = kcalloc(count, sizeof(*mtd_list), GFP_KERNEL);
201201 if (!mtd_list)
202202 goto err_flash_remove;
203203
drivers/mtd/maps/vmu-flash.c+4−4
@@ -629,15 +629,15 @@ static int vmu_connect(struct maple_device *mdev) · 628 unmodified lines
629629 * Not sure there are actually any multi-partition devices in the
630630 * real world, but the hardware supports them, so, so will we
631631 */
632− card->parts = kmalloc(sizeof(struct vmupart) * card->partitions,
633− GFP_KERNEL);
632+ card->parts = kmalloc_array(card->partitions, sizeof(struct vmupart),
633+ GFP_KERNEL);
634634 if (!card->parts) {
635635 error = -ENOMEM;
636636 goto fail_partitions;
637637 }
638638
639− card->mtd = kmalloc(sizeof(struct mtd_info) * card->partitions,
640− GFP_KERNEL);
639+ card->mtd = kmalloc_array(card->partitions, sizeof(struct mtd_info),
640+ GFP_KERNEL);
641641 if (!card->mtd) {
642642 error = -ENOMEM;
643643 goto fail_mtd_info;
drivers/mtd/mtdconcat.c+3−2
@@ -778,8 +778,9 @@ struct mtd_info *mtd_concat_create(struct mtd_info *subdev[], /* subdevices to c · 777 unmodified lines
778778 concat->mtd.erasesize = max_erasesize;
779779 concat->mtd.numeraseregions = num_erase_region;
780780 concat->mtd.eraseregions = erase_region_p =
781− kmalloc(num_erase_region *
782− sizeof (struct mtd_erase_region_info), GFP_KERNEL);
781+ kmalloc_array(num_erase_region,
782+ sizeof(struct mtd_erase_region_info),
783+ GFP_KERNEL);
783784 if (!erase_region_p) {
784785 kfree(concat);
785786 printk
drivers/mtd/mtdoops.c+4−2
@@ -330,8 +330,10 @@ static void mtdoops_notify_add(struct mtd_info *mtd) · 329 unmodified lines
330330 }
331331
332332 /* oops_page_used is a bit field */
333− cxt->oops_page_used = vmalloc(DIV_ROUND_UP(mtdoops_pages,
334− BITS_PER_LONG) * sizeof(unsigned long));
333+ cxt->oops_page_used =
334+ vmalloc(array_size(sizeof(unsigned long),
335+ DIV_ROUND_UP(mtdoops_pages,
336+ BITS_PER_LONG)));
335337 if (!cxt->oops_page_used) {
336338 printk(KERN_ERR "mtdoops: could not allocate page array\n");
337339 return;
drivers/mtd/mtdswap.c+3−3
@@ -1317,11 +1317,11 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, · 1316 unmodified lines
13171317 for (i = 0; i < MTDSWAP_TREE_CNT; i++)
13181318 d->trees[i].root = RB_ROOT;
13191319
1320− d->page_data = vmalloc(sizeof(int)*pages);
1320+ d->page_data = vmalloc(array_size(pages, sizeof(int)));
13211321 if (!d->page_data)
13221322 goto page_data_fail;
13231323
1324− d->revmap = vmalloc(sizeof(int)*blocks);
1324+ d->revmap = vmalloc(array_size(blocks, sizeof(int)));
13251325 if (!d->revmap)
13261326 goto revmap_fail;
13271327
@@ -1340,7 +1340,7 @@ static int mtdswap_init(struct mtdswap_dev *d, unsigned int eblocks, · 12 unmodified lines
13401340 if (!d->page_buf)
13411341 goto page_buf_fail;
13421342
1343− d->oob_buf = kmalloc(2 * mtd->oobavail, GFP_KERNEL);
1343+ d->oob_buf = kmalloc_array(2, mtd->oobavail, GFP_KERNEL);
13441344 if (!d->oob_buf)
13451345 goto oob_buf_fail;
13461346
drivers/mtd/nand/onenand/onenand_base.c+4−2
@@ -3721,8 +3721,10 @@ static int onenand_probe(struct mtd_info *mtd) · 3720 unmodified lines
37213721 this->dies = ONENAND_IS_DDP(this) ? 2 : 1;
37223722 /* Maximum possible erase regions */
37233723 mtd->numeraseregions = this->dies << 1;
3724− mtd->eraseregions = kzalloc(sizeof(struct mtd_erase_region_info)
3725− * (this->dies << 1), GFP_KERNEL);
3724+ mtd->eraseregions =
3725+ kcalloc(this->dies << 1,
3726+ sizeof(struct mtd_erase_region_info),
3727+ GFP_KERNEL);
37263728 if (!mtd->eraseregions)
37273729 return -ENOMEM;
37283730 }
drivers/mtd/nand/raw/nand_bch.c+1−1
@@ -186,7 +186,7 @@ struct nand_bch_control *nand_bch_init(struct mtd_info *mtd) · 185 unmodified lines
186186 }
187187
188188 nbc->eccmask = kmalloc(eccbytes, GFP_KERNEL);
189− nbc->errloc = kmalloc(t*sizeof(*nbc->errloc), GFP_KERNEL);
189+ nbc->errloc = kmalloc_array(t, sizeof(*nbc->errloc), GFP_KERNEL);
190190 if (!nbc->eccmask || !nbc->errloc)
191191 goto fail;
192192 /*
drivers/mtd/nand/raw/nandsim.c+4−3
@@ -565,8 +565,9 @@ static int __init alloc_device(struct nandsim *ns) · 564 unmodified lines
565565 err = -EINVAL;
566566 goto err_close;
567567 }
568− ns->pages_written = vzalloc(BITS_TO_LONGS(ns->geom.pgnum) *
569− sizeof(unsigned long));
568+ ns->pages_written =
569+ vzalloc(array_size(sizeof(unsigned long),
570+ BITS_TO_LONGS(ns->geom.pgnum)));
570571 if (!ns->pages_written) {
571572 NS_ERR("alloc_device: unable to allocate pages written array\n");
572573 err = -ENOMEM;
@@ -582,7 +583,7 @@ static int __init alloc_device(struct nandsim *ns) · 9 unmodified lines
582583 return 0;
583584 }
584585
585− ns->pages = vmalloc(ns->geom.pgnum * sizeof(union ns_mem));
586+ ns->pages = vmalloc(array_size(sizeof(union ns_mem), ns->geom.pgnum));
586587 if (!ns->pages) {
587588 NS_ERR("alloc_device: unable to allocate page array\n");
588589 return -ENOMEM;
drivers/mtd/nand/raw/qcom_nandc.c+2−2
@@ -2510,8 +2510,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) · 2509 unmodified lines
25102510 if (!nandc->regs)
25112511 return -ENOMEM;
25122512
2513− nandc->reg_read_buf = devm_kzalloc(nandc->dev,
2514− MAX_REG_RD * sizeof(*nandc->reg_read_buf),
2513+ nandc->reg_read_buf = devm_kcalloc(nandc->dev,
2514+ MAX_REG_RD, sizeof(*nandc->reg_read_buf),
25152515 GFP_KERNEL);
25162516 if (!nandc->reg_read_buf)
25172517 return -ENOMEM;
drivers/mtd/nand/raw/s3c2410.c+1−1
@@ -1038,7 +1038,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev) · 1037 unmodified lines
10381038 if (!pdata->nr_sets)
10391039 return 0;
10401040
1041− sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets,
1041+ sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets),
10421042 GFP_KERNEL);
10431043 if (!sets)
10441044 return -ENOMEM;
drivers/mtd/nftlmount.c+5−2
@@ -199,13 +199,16 @@ device is already correct. · 198 unmodified lines
199199 nftl->lastEUN = nftl->nb_blocks - 1;
200200
201201 /* memory alloc */
202− nftl->EUNtable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
202+ nftl->EUNtable = kmalloc_array(nftl->nb_blocks, sizeof(u16),
203+ GFP_KERNEL);
203204 if (!nftl->EUNtable) {
204205 printk(KERN_NOTICE "NFTL: allocation of EUNtable failed\n");
205206 return -ENOMEM;
206207 }
207208
208− nftl->ReplUnitTable = kmalloc(nftl->nb_blocks * sizeof(u16), GFP_KERNEL);
209+ nftl->ReplUnitTable = kmalloc_array(nftl->nb_blocks,
210+ sizeof(u16),
211+ GFP_KERNEL);
209212 if (!nftl->ReplUnitTable) {
210213 kfree(nftl->EUNtable);
211214 printk(KERN_NOTICE "NFTL: allocation of ReplUnitTable failed\n");
drivers/mtd/ofpart.c+2−2
@@ -71,7 +71,7 @@ static int parse_fixed_partitions(struct mtd_info *master, · 70 unmodified lines
7171 if (nr_parts == 0)
7272 return 0;
7373
74− parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
74+ parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
7575 if (!parts)
7676 return -ENOMEM;
7777
@@ -177,7 +177,7 @@ static int parse_ofoldpart_partitions(struct mtd_info *master, · 99 unmodified lines
177177
178178 nr_parts = plen / sizeof(part[0]);
179179
180− parts = kzalloc(nr_parts * sizeof(*parts), GFP_KERNEL);
180+ parts = kcalloc(nr_parts, sizeof(*parts), GFP_KERNEL);
181181 if (!parts)
182182 return -ENOMEM;
183183
drivers/mtd/parsers/parser_trx.c+1−1
@@ -62,7 +62,7 @@ static int parser_trx_parse(struct mtd_info *mtd, · 61 unmodified lines
6262 uint8_t curr_part = 0, i = 0;
6363 int err;
6464
65− parts = kzalloc(sizeof(struct mtd_partition) * TRX_PARSER_MAX_PARTS,
65+ parts = kcalloc(TRX_PARSER_MAX_PARTS, sizeof(struct mtd_partition),
6666 GFP_KERNEL);
6767 if (!parts)
6868 return -ENOMEM;
drivers/mtd/parsers/sharpslpart.c+3−2
@@ -362,8 +362,9 @@ static int sharpsl_parse_mtd_partitions(struct mtd_info *master, · 361 unmodified lines
362362 return err;
363363 }
364364
365− sharpsl_nand_parts = kzalloc(sizeof(*sharpsl_nand_parts) *
366− SHARPSL_NAND_PARTS, GFP_KERNEL);
365+ sharpsl_nand_parts = kcalloc(SHARPSL_NAND_PARTS,
366+ sizeof(*sharpsl_nand_parts),
367+ GFP_KERNEL);
367368 if (!sharpsl_nand_parts)
368369 return -ENOMEM;
369370
drivers/mtd/rfd_ftl.c+2−1
@@ -189,7 +189,8 @@ static int scan_header(struct partition *part) · 188 unmodified lines
189189 if (!part->blocks)
190190 goto err;
191191
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));
193194 if (!part->sector_map) {
194195 printk(KERN_ERR PREFIX "'%s': unable to allocate memory for "
195196 "sector map", part->mbd.mtd->name);
drivers/mtd/sm_ftl.c+3−3
@@ -82,7 +82,7 @@ static struct attribute_group *sm_create_sysfs_attributes(struct sm_ftl *ftl) · 81 unmodified lines
8282
8383
8484 /* Create array of pointers to the attributes */
85− attributes = kzalloc(sizeof(struct attribute *) * (NUM_ATTRIBUTES + 1),
85+ attributes = kcalloc(NUM_ATTRIBUTES + 1, sizeof(struct attribute *),
8686 GFP_KERNEL);
8787 if (!attributes)
8888 goto error3;
@@ -750,7 +750,7 @@ static int sm_init_zone(struct sm_ftl *ftl, int zone_num) · 661 unmodified lines
750750 dbg("initializing zone %d", zone_num);
751751
752752 /* Allocate memory for FTL table */
753− zone->lba_to_phys_table = kmalloc(ftl->max_lba * 2, GFP_KERNEL);
753+ zone->lba_to_phys_table = kmalloc_array(ftl->max_lba, 2, GFP_KERNEL);
754754
755755 if (!zone->lba_to_phys_table)
756756 return -ENOMEM;
@@ -1137,7 +1137,7 @@ static void sm_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) · 380 unmodified lines
11371137 goto error2;
11381138
11391139 /* Allocate zone array, it will be initialized on demand */
1140− ftl->zones = kzalloc(sizeof(struct ftl_zone) * ftl->zone_count,
1140+ ftl->zones = kcalloc(ftl->zone_count, sizeof(struct ftl_zone),
11411141 GFP_KERNEL);
11421142 if (!ftl->zones)
11431143 goto error3;
drivers/mtd/ssfdc.c+3−2
@@ -332,8 +332,9 @@ static void ssfdcr_add_mtd(struct mtd_blktrans_ops *tr, struct mtd_info *mtd) · 331 unmodified lines
332332 (long)ssfdc->sectors;
333333
334334 /* Allocate logical block map */
335− ssfdc->logic_block_map = kmalloc(sizeof(ssfdc->logic_block_map[0]) *
336− ssfdc->map_len, GFP_KERNEL);
335+ ssfdc->logic_block_map =
336+ kmalloc_array(ssfdc->map_len,
337+ sizeof(ssfdc->logic_block_map[0]), GFP_KERNEL);
337338 if (!ssfdc->logic_block_map)
338339 goto out_err;
339340 memset(ssfdc->logic_block_map, 0xff, sizeof(ssfdc->logic_block_map[0]) *
drivers/mtd/tests/pagetest.c+1−1
@@ -127,7 +127,7 @@ static int crosstest(void) · 126 unmodified lines
127127 unsigned char *pp1, *pp2, *pp3, *pp4;
128128
129129 pr_info("crosstest\n");
130− pp1 = kzalloc(pgsize * 4, GFP_KERNEL);
130+ pp1 = kcalloc(pgsize, 4, GFP_KERNEL);
131131 if (!pp1)
132132 return -ENOMEM;
133133 pp2 = pp1 + pgsize;
drivers/mtd/tests/stresstest.c+1−1
@@ -199,7 +199,7 @@ static int __init mtd_stresstest_init(void) · 198 unmodified lines
199199 err = -ENOMEM;
200200 readbuf = vmalloc(bufsize);
201201 writebuf = vmalloc(bufsize);
202− offsets = kmalloc(ebcnt * sizeof(int), GFP_KERNEL);
202+ offsets = kmalloc_array(ebcnt, sizeof(int), GFP_KERNEL);
203203 if (!readbuf || !writebuf || !offsets)
204204 goto out;
205205 for (i = 0; i < ebcnt; i++)
drivers/mtd/ubi/eba.c+8−6
@@ -1536,11 +1536,11 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, · 1535 unmodified lines
15361536
15371537 num_volumes = ubi->vtbl_slots + UBI_INT_VOL_COUNT;
15381538
1539− scan_eba = kmalloc(sizeof(*scan_eba) * num_volumes, GFP_KERNEL);
1539+ scan_eba = kmalloc_array(num_volumes, sizeof(*scan_eba), GFP_KERNEL);
15401540 if (!scan_eba)
15411541 return -ENOMEM;
15421542
1543− fm_eba = kmalloc(sizeof(*fm_eba) * num_volumes, GFP_KERNEL);
1543+ fm_eba = kmalloc_array(num_volumes, sizeof(*fm_eba), GFP_KERNEL);
15441544 if (!fm_eba) {
15451545 kfree(scan_eba);
15461546 return -ENOMEM;
@@ -1551,15 +1551,17 @@ int self_check_eba(struct ubi_device *ubi, struct ubi_attach_info *ai_fastmap, · 4 unmodified lines
15511551 if (!vol)
15521552 continue;
15531553
1554− scan_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**scan_eba),
1555− GFP_KERNEL);
1554+ scan_eba[i] = kmalloc_array(vol->reserved_pebs,
1555+ sizeof(**scan_eba),
1556+ GFP_KERNEL);
15561557 if (!scan_eba[i]) {
15571558 ret = -ENOMEM;
15581559 goto out_free;
15591560 }
15601561
1561− fm_eba[i] = kmalloc(vol->reserved_pebs * sizeof(**fm_eba),
1562− GFP_KERNEL);
1562+ fm_eba[i] = kmalloc_array(vol->reserved_pebs,
1563+ sizeof(**fm_eba),
1564+ GFP_KERNEL);
15631565 if (!fm_eba[i]) {
15641566 ret = -ENOMEM;
15651567 goto out_free;
drivers/mtd/ubi/wl.c+1−1
@@ -1592,7 +1592,7 @@ int ubi_wl_init(struct ubi_device *ubi, struct ubi_attach_info *ai) · 1591 unmodified lines
15921592 sprintf(ubi->bgt_name, UBI_BGT_NAME_PATTERN, ubi->ubi_num);
15931593
15941594 err = -ENOMEM;
1595− ubi->lookuptbl = kzalloc(ubi->peb_count * sizeof(void *), GFP_KERNEL);
1595+ ubi->lookuptbl = kcalloc(ubi->peb_count, sizeof(void *), GFP_KERNEL);
15961596 if (!ubi->lookuptbl)
15971597 return err;
15981598
drivers/net/bonding/bond_main.c+1−1
@@ -2418,7 +2418,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev, · 2417 unmodified lines
24182418 struct list_head *iter;
24192419
24202420 if (start_dev == end_dev) {
2421− tags = kzalloc(sizeof(*tags) * (level + 1), GFP_ATOMIC);
2421+ tags = kcalloc(level + 1, sizeof(*tags), GFP_ATOMIC);
24222422 if (!tags)
24232423 return ERR_PTR(-ENOMEM);
24242424 tags[level].vlan_proto = VLAN_N_VID;
drivers/net/can/grcan.c+2−2
@@ -1057,7 +1057,7 @@ static int grcan_open(struct net_device *dev) · 1056 unmodified lines
10571057 return err;
10581058 }
10591059
1060− priv->echo_skb = kzalloc(dma->tx.size * sizeof(*priv->echo_skb),
1060+ priv->echo_skb = kcalloc(dma->tx.size, sizeof(*priv->echo_skb),
10611061 GFP_KERNEL);
10621062 if (!priv->echo_skb) {
10631063 err = -ENOMEM;
@@ -1066,7 +1066,7 @@ static int grcan_open(struct net_device *dev) · 2 unmodified lines
10661066 priv->can.echo_skb_max = dma->tx.size;
10671067 priv->can.echo_skb = priv->echo_skb;
10681068
1069− priv->txdlc = kzalloc(dma->tx.size * sizeof(*priv->txdlc), GFP_KERNEL);
1069+ priv->txdlc = kcalloc(dma->tx.size, sizeof(*priv->txdlc), GFP_KERNEL);
10701070 if (!priv->txdlc) {
10711071 err = -ENOMEM;
10721072 goto exit_free_echo_skb;
drivers/net/can/slcan.c+1−1
@@ -703,7 +703,7 @@ static int __init slcan_init(void) · 702 unmodified lines
703703 pr_info("slcan: serial line CAN interface driver\n");
704704 pr_info("slcan: %d dynamic interface channels.\n", maxdev);
705705
706− slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL);
706+ slcan_devs = kcalloc(maxdev, sizeof(struct net_device *), GFP_KERNEL);
707707 if (!slcan_devs)
708708 return -ENOMEM;
709709
drivers/net/dsa/b53/b53_common.c+4−4
@@ -2044,14 +2044,14 @@ static int b53_switch_init(struct b53_device *dev) · 2043 unmodified lines
20442044 }
20452045 }
20462046
2047− dev->ports = devm_kzalloc(dev->dev,
2048− sizeof(struct b53_port) * dev->num_ports,
2047+ dev->ports = devm_kcalloc(dev->dev,
2048+ dev->num_ports, sizeof(struct b53_port),
20492049 GFP_KERNEL);
20502050 if (!dev->ports)
20512051 return -ENOMEM;
20522052
2053− dev->vlans = devm_kzalloc(dev->dev,
2054− sizeof(struct b53_vlan) * dev->num_vlans,
2053+ dev->vlans = devm_kcalloc(dev->dev,
2054+ dev->num_vlans, sizeof(struct b53_vlan),
20552055 GFP_KERNEL);
20562056 if (!dev->vlans)
20572057 return -ENOMEM;
drivers/net/ethernet/amazon/ena/ena_ethtool.c+4−4
@@ -838,8 +838,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) · 837 unmodified lines
838838 return;
839839 }
840840
841− strings_buf = devm_kzalloc(&adapter->pdev->dev,
842− strings_num * ETH_GSTRING_LEN,
841+ strings_buf = devm_kcalloc(&adapter->pdev->dev,
842+ ETH_GSTRING_LEN, strings_num,
843843 GFP_ATOMIC);
844844 if (!strings_buf) {
845845 netif_err(adapter, drv, netdev,
@@ -847,8 +847,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) · 1 unmodified line
847847 return;
848848 }
849849
850− data_buf = devm_kzalloc(&adapter->pdev->dev,
851− strings_num * sizeof(u64),
850+ data_buf = devm_kcalloc(&adapter->pdev->dev,
851+ strings_num, sizeof(u64),
852852 GFP_ATOMIC);
853853 if (!data_buf) {
854854 netif_err(adapter, drv, netdev,
drivers/net/ethernet/amd/lance.c+4−4
@@ -551,13 +551,13 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int · 550 unmodified lines
551551 if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp);
552552 dev->ml_priv = lp;
553553 lp->name = chipname;
554− lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE,
555− GFP_DMA | GFP_KERNEL);
554+ lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ,
555+ GFP_DMA | GFP_KERNEL);
556556 if (!lp->rx_buffs)
557557 goto out_lp;
558558 if (lance_need_isa_bounce_buffers) {
559− lp->tx_bounce_buffs = kmalloc(PKT_BUF_SZ*TX_RING_SIZE,
560− GFP_DMA | GFP_KERNEL);
559+ lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ,
560+ GFP_DMA | GFP_KERNEL);
561561 if (!lp->tx_bounce_buffs)
562562 goto out_rx;
563563 } else
drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c+2−2
@@ -209,8 +209,8 @@ static int atl1c_get_eeprom(struct net_device *netdev, · 208 unmodified lines
209209 first_dword = eeprom->offset >> 2;
210210 last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
211211
212− eeprom_buff = kmalloc(sizeof(u32) *
213− (last_dword - first_dword + 1), GFP_KERNEL);
212+ eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
213+ GFP_KERNEL);
214214 if (eeprom_buff == NULL)
215215 return -ENOMEM;
216216
drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c+2−2
@@ -236,8 +236,8 @@ static int atl1e_get_eeprom(struct net_device *netdev, · 235 unmodified lines
236236 first_dword = eeprom->offset >> 2;
237237 last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
238238
239− eeprom_buff = kmalloc(sizeof(u32) *
240− (last_dword - first_dword + 1), GFP_KERNEL);
239+ eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
240+ GFP_KERNEL);
241241 if (eeprom_buff == NULL)
242242 return -ENOMEM;
243243
drivers/net/ethernet/atheros/atlx/atl2.c+2−2
@@ -1941,8 +1941,8 @@ static int atl2_get_eeprom(struct net_device *netdev, · 1940 unmodified lines
19411941 first_dword = eeprom->offset >> 2;
19421942 last_dword = (eeprom->offset + eeprom->len - 1) >> 2;
19431943
1944− eeprom_buff = kmalloc(sizeof(u32) * (last_dword - first_dword + 1),
1945− GFP_KERNEL);
1944+ eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32),
1945+ GFP_KERNEL);
19461946 if (!eeprom_buff)
19471947 return -ENOMEM;
19481948
drivers/net/ethernet/broadcom/bcm63xx_enet.c+2−2
@@ -2150,7 +2150,7 @@ static int bcm_enetsw_open(struct net_device *dev) · 2149 unmodified lines
21502150 priv->tx_desc_alloc_size = size;
21512151 priv->tx_desc_cpu = p;
21522152
2153− priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size,
2153+ priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *),
21542154 GFP_KERNEL);
21552155 if (!priv->tx_skb) {
21562156 dev_err(kdev, "cannot allocate rx skb queue\n");
@@ -2164,7 +2164,7 @@ static int bcm_enetsw_open(struct net_device *dev) · 7 unmodified lines
21642164 spin_lock_init(&priv->tx_lock);
21652165
21662166 /* init & fill rx ring with skbs */
2167− priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size,
2167+ priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *),
21682168 GFP_KERNEL);
21692169 if (!priv->rx_skb) {
21702170 dev_err(kdev, "cannot allocate rx skb queue\n");
drivers/net/ethernet/broadcom/bnx2.c+5−4
@@ -778,7 +778,7 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) · 777 unmodified lines
778778 int j;
779779
780780 rxr->rx_buf_ring =
781− vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring);
781+ vzalloc(array_size(SW_RXBD_RING_SIZE, bp->rx_max_ring));
782782 if (!rxr->rx_buf_ring)
783783 return -ENOMEM;
784784
@@ -794,8 +794,9 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) · 9 unmodified lines
794794 }
795795
796796 if (bp->rx_pg_ring_size) {
797− rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE *
798− bp->rx_max_pg_ring);
797+ rxr->rx_pg_ring =
798+ vzalloc(array_size(SW_RXPG_RING_SIZE,
799+ bp->rx_max_pg_ring));
799800 if (!rxr->rx_pg_ring)
800801 return -ENOMEM;
801802
@@ -2666,7 +2667,7 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp) · 1864 unmodified lines
26662667 u32 good_mbuf_cnt;
26672668 u32 val;
26682669
2669− good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL);
2670+ good_mbuf = kmalloc_array(512, sizeof(u16), GFP_KERNEL);
26702671 if (!good_mbuf)
26712672 return -ENOMEM;
26722673
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c+7−6
@@ -571,7 +571,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf, · 570 unmodified lines
571571 else
572572 set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags);
573573 if (mc_num) {
574− mc = kzalloc(mc_num * sizeof(struct bnx2x_mcast_list_elem),
574+ mc = kcalloc(mc_num, sizeof(struct bnx2x_mcast_list_elem),
575575 GFP_KERNEL);
576576 if (!mc) {
577577 BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n");
@@ -1253,8 +1253,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, · 675 unmodified lines
12531253 num_vfs_param, iov->nr_virtfn);
12541254
12551255 /* allocate the vf array */
1256− bp->vfdb->vfs = kzalloc(sizeof(struct bnx2x_virtf) *
1257− BNX2X_NR_VIRTFN(bp), GFP_KERNEL);
1256+ bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp),
1257+ sizeof(struct bnx2x_virtf),
1258+ GFP_KERNEL);
12581259 if (!bp->vfdb->vfs) {
12591260 BNX2X_ERR("failed to allocate vf array\n");
12601261 err = -ENOMEM;
@@ -1278,9 +1279,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, · 17 unmodified lines
12781279 }
12791280
12801281 /* allocate the queue arrays for all VFs */
1281− bp->vfdb->vfqs = kzalloc(
1282− BNX2X_MAX_NUM_VF_QUEUES * sizeof(struct bnx2x_vf_queue),
1283− GFP_KERNEL);
1282+ bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES,
1283+ sizeof(struct bnx2x_vf_queue),
1284+ GFP_KERNEL);
12841285
12851286 if (!bp->vfdb->vfqs) {
12861287 BNX2X_ERR("failed to allocate vf queue array\n");
drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c+2−2
@@ -444,8 +444,8 @@ static int bnxt_vf_reps_create(struct bnxt *bp) · 443 unmodified lines
444444 return -ENOMEM;
445445
446446 /* storage for cfa_code to vf-idx mapping */
447− cfa_code_map = kmalloc(sizeof(*bp->cfa_code_map) * MAX_CFA_CODE,
448− GFP_KERNEL);
447+ cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map),
448+ GFP_KERNEL);
449449 if (!cfa_code_map) {
450450 rc = -ENOMEM;
451451 goto err;
drivers/net/ethernet/broadcom/cnic.c+5−5
@@ -660,7 +660,7 @@ static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id, · 659 unmodified lines
660660 id_tbl->max = size;
661661 id_tbl->next = next;
662662 spin_lock_init(&id_tbl->lock);
663− id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
663+ id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
664664 if (!id_tbl->table)
665665 return -ENOMEM;
666666
@@ -1255,13 +1255,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) · 588 unmodified lines
12551255 cp->fcoe_init_cid = 0x10;
12561256 }
12571257
1258− cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ,
1258+ cp->iscsi_tbl = kcalloc(MAX_ISCSI_TBL_SZ, sizeof(struct cnic_iscsi),
12591259 GFP_KERNEL);
12601260 if (!cp->iscsi_tbl)
12611261 goto error;
12621262
1263− cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) *
1264− cp->max_cid_space, GFP_KERNEL);
1263+ cp->ctx_tbl = kcalloc(cp->max_cid_space, sizeof(struct cnic_context),
1264+ GFP_KERNEL);
12651265 if (!cp->ctx_tbl)
12661266 goto error;
12671267
@@ -4100,7 +4100,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) · 2832 unmodified lines
41004100 struct cnic_local *cp = dev->cnic_priv;
41014101 u32 port_id;
41024102
4103− cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ,
4103+ cp->csk_tbl = kcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock),
41044104 GFP_KERNEL);
41054105 if (!cp->csk_tbl)
41064106 return -ENOMEM;
drivers/net/ethernet/broadcom/tg3.c+3−2
@@ -8631,8 +8631,9 @@ static int tg3_mem_tx_acquire(struct tg3 *tp) · 8630 unmodified lines
86318631 tnapi++;
86328632
86338633 for (i = 0; i < tp->txq_cnt; i++, tnapi++) {
8634− tnapi->tx_buffers = kzalloc(sizeof(struct tg3_tx_ring_info) *
8635− TG3_TX_RING_SIZE, GFP_KERNEL);
8634+ tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE,
8635+ sizeof(struct tg3_tx_ring_info),
8636+ GFP_KERNEL);
86368637 if (!tnapi->tx_buffers)
86378638 goto err_out;
86388639
drivers/net/ethernet/brocade/bna/bnad.c+2−2
@@ -3141,7 +3141,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad) · 3140 unmodified lines
31413141 if (uc_count > bna_attr(&bnad->bna)->num_ucmac)
31423142 goto mode_default;
31433143
3144− mac_list = kzalloc(uc_count * ETH_ALEN, GFP_ATOMIC);
3144+ mac_list = kcalloc(ETH_ALEN, uc_count, GFP_ATOMIC);
31453145 if (mac_list == NULL)
31463146 goto mode_default;
31473147
@@ -3182,7 +3182,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad) · 34 unmodified lines
31823182 if (mc_count > bna_attr(&bnad->bna)->num_mcmac)
31833183 goto mode_allmulti;
31843184
3185− mac_list = kzalloc((mc_count + 1) * ETH_ALEN, GFP_ATOMIC);
3185+ mac_list = kcalloc(mc_count + 1, ETH_ALEN, GFP_ATOMIC);
31863186
31873187 if (mac_list == NULL)
31883188 goto mode_allmulti;
drivers/net/ethernet/calxeda/xgmac.c+2−2
@@ -739,7 +739,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) · 738 unmodified lines
739739
740740 netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize);
741741
742− priv->rx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_RX_RING_SZ,
742+ priv->rx_skbuff = kcalloc(DMA_RX_RING_SZ, sizeof(struct sk_buff *),
743743 GFP_KERNEL);
744744 if (!priv->rx_skbuff)
745745 return -ENOMEM;
@@ -752,7 +752,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) · 6 unmodified lines
752752 if (!priv->dma_rx)
753753 goto err_dma_rx;
754754
755− priv->tx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_TX_RING_SZ,
755+ priv->tx_skbuff = kcalloc(DMA_TX_RING_SZ, sizeof(struct sk_buff *),
756756 GFP_KERNEL);
757757 if (!priv->tx_skbuff)
758758 goto err_tx_skb;
drivers/net/ethernet/cavium/liquidio/octeon_droq.c+4−5
@@ -281,13 +281,12 @@ int octeon_init_droq(struct octeon_device *oct, · 280 unmodified lines
281281 droq->max_count);
282282
283283 droq->recv_buf_list = (struct octeon_recv_buffer *)
284− vzalloc_node(droq->max_count *
285− OCT_DROQ_RECVBUF_SIZE,
286− numa_node);
284+ vzalloc_node(array_size(droq->max_count, OCT_DROQ_RECVBUF_SIZE),
285+ numa_node);
287286 if (!droq->recv_buf_list)
288287 droq->recv_buf_list = (struct octeon_recv_buffer *)
289− vzalloc(droq->max_count *
290− OCT_DROQ_RECVBUF_SIZE);
288+ vzalloc(array_size(droq->max_count,
289+ OCT_DROQ_RECVBUF_SIZE));
291290 if (!droq->recv_buf_list) {
292291 dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n");
293292 goto init_droq_fail;
drivers/net/ethernet/cavium/liquidio/request_manager.c+3−2
@@ -98,8 +98,9 @@ int octeon_init_instr_queue(struct octeon_device *oct, · 97 unmodified lines
9898 iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs),
9999 numa_node);
100100 if (!iq->request_list)
101− iq->request_list = vmalloc(sizeof(*iq->request_list) *
102− num_descs);
101+ iq->request_list =
102+ vmalloc(array_size(num_descs,
103+ sizeof(*iq->request_list)));
103104 if (!iq->request_list) {
104105 lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma);
105106 dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n",
drivers/net/ethernet/cavium/thunder/nicvf_queues.c+2−2
@@ -292,8 +292,8 @@ static int nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr, · 291 unmodified lines
292292 rbdr->is_xdp = true;
293293 }
294294 rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt);
295− rbdr->pgcache = kzalloc(sizeof(*rbdr->pgcache) *
296− rbdr->pgcnt, GFP_KERNEL);
295+ rbdr->pgcache = kcalloc(rbdr->pgcnt, sizeof(*rbdr->pgcache),
296+ GFP_KERNEL);
297297 if (!rbdr->pgcache)
298298 return -ENOMEM;
299299 rbdr->pgidx = 0;
drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c+1−1
@@ -304,7 +304,7 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start, · 303 unmodified lines
304304 for (i = 0; i < ctbl->clipt_size; ++i)
305305 INIT_LIST_HEAD(&ctbl->hash_list[i]);
306306
307− cl_list = kvzalloc(clipt_size*sizeof(struct clip_entry), GFP_KERNEL);
307+ cl_list = kvcalloc(clipt_size, sizeof(struct clip_entry), GFP_KERNEL);
308308 if (!cl_list) {
309309 kvfree(ctbl);
310310 return NULL;
drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c+1−1
@@ -873,7 +873,7 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v) · 872 unmodified lines
873873 u16 (*incr)[NCCTRL_WIN];
874874 struct adapter *adap = seq->private;
875875
876− incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL);
876+ incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL);
877877 if (!incr)
878878 return -ENOMEM;
879879
drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c+5−5
@@ -713,7 +713,7 @@ int cxgb4_write_rss(const struct port_info *pi, const u16 *queues) · 712 unmodified lines
713713 const struct sge_eth_rxq *rxq;
714714
715715 rxq = &adapter->sge.ethrxq[pi->first_qset];
716− rss = kmalloc(pi->rss_size * sizeof(u16), GFP_KERNEL);
716+ rss = kmalloc_array(pi->rss_size, sizeof(u16), GFP_KERNEL);
717717 if (!rss)
718718 return -ENOMEM;
719719
@@ -4972,8 +4972,8 @@ static int enable_msix(struct adapter *adap) · 4252 unmodified lines
49724972 max_ingq += (MAX_OFLD_QSETS * adap->num_uld);
49734973 if (is_offload(adap))
49744974 max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld);
4975− entries = kmalloc(sizeof(*entries) * (max_ingq + 1),
4976− GFP_KERNEL);
4975+ entries = kmalloc_array(max_ingq + 1, sizeof(*entries),
4976+ GFP_KERNEL);
49774977 if (!entries)
49784978 return -ENOMEM;
49794979
@@ -5646,8 +5646,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) · 666 unmodified lines
56465646 adapter->params.offload = 0;
56475647 }
56485648
5649− adapter->mps_encap = kvzalloc(sizeof(struct mps_encap_entry) *
5650− adapter->params.arch.mps_tcam_size,
5649+ adapter->mps_encap = kvcalloc(adapter->params.arch.mps_tcam_size,
5650+ sizeof(struct mps_encap_entry),
56515651 GFP_KERNEL);
56525652 if (!adapter->mps_encap)
56535653 dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n");
drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c+2−1
@@ -457,7 +457,8 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap) · 456 unmodified lines
457457 unsigned int bmap_size;
458458
459459 bmap_size = BITS_TO_LONGS(max_tids);
460− link->tid_map = kvzalloc(sizeof(unsigned long) * bmap_size, GFP_KERNEL);
460+ link->tid_map = kvcalloc(bmap_size, sizeof(unsigned long),
461+ GFP_KERNEL);
461462 if (!link->tid_map)
462463 goto out_no_mem;
463464 bitmap_zero(link->tid_map, max_tids);
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c+2−2
@@ -561,13 +561,13 @@ int t4_uld_mem_alloc(struct adapter *adap) · 560 unmodified lines
561561 if (!adap->uld)
562562 return -ENOMEM;
563563
564− s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX *
564+ s->uld_rxq_info = kcalloc(CXGB4_ULD_MAX,
565565 sizeof(struct sge_uld_rxq_info *),
566566 GFP_KERNEL);
567567 if (!s->uld_rxq_info)
568568 goto err_uld;
569569
570− s->uld_txq_info = kzalloc(CXGB4_TX_MAX *
570+ s->uld_txq_info = kcalloc(CXGB4_TX_MAX,
571571 sizeof(struct sge_uld_txq_info *),
572572 GFP_KERNEL);
573573 if (!s->uld_txq_info)
drivers/net/ethernet/chelsio/cxgb4/sge.c+1−1
@@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size, · 698 unmodified lines
699699 if (!p)
700700 return NULL;
701701 if (sw_size) {
702− s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node);
702+ s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node);
703703
704704 if (!s) {
705705 dma_free_coherent(dev, len, p, *phys);
drivers/net/ethernet/cortina/gemini.c+2−2
@@ -910,8 +910,8 @@ static int geth_setup_freeq(struct gemini_ethernet *geth) · 909 unmodified lines
910910 }
911911
912912 /* Allocate a mapping to page look-up index */
913− geth->freeq_pages = kzalloc(pages * sizeof(*geth->freeq_pages),
914− GFP_KERNEL);
913+ geth->freeq_pages = kcalloc(pages, sizeof(*geth->freeq_pages),
914+ GFP_KERNEL);
915915 if (!geth->freeq_pages)
916916 goto err_freeq;
917917 geth->num_freeq_pages = pages;
drivers/net/ethernet/ethoc.c+2−1
@@ -1141,7 +1141,8 @@ static int ethoc_probe(struct platform_device *pdev) · 1140 unmodified lines
11411141 dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n",
11421142 priv->num_tx, priv->num_rx);
11431143
1144− priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL);
1144+ priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *),
1145+ GFP_KERNEL);
11451146 if (!priv->vma) {
11461147 ret = -ENOMEM;
11471148 goto free;
drivers/net/ethernet/freescale/dpaa/dpaa_eth.c+1−1
@@ -664,7 +664,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev, · 663 unmodified lines
664664 struct dpaa_fq *dpaa_fq;
665665 int i;
666666
667− dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count,
667+ dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq),
668668 GFP_KERNEL);
669669 if (!dpaa_fq)
670670 return NULL;
drivers/net/ethernet/freescale/ucc_geth.c+6−6
@@ -2253,9 +2253,9 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth) · 2252 unmodified lines
22532253 /* Init Tx bds */
22542254 for (j = 0; j < ug_info->numQueuesTx; j++) {
22552255 /* Setup the skbuff rings */
2256− ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
2257− ugeth->ug_info->bdRingLenTx[j],
2258− GFP_KERNEL);
2256+ ugeth->tx_skbuff[j] =
2257+ kmalloc_array(ugeth->ug_info->bdRingLenTx[j],
2258+ sizeof(struct sk_buff *), GFP_KERNEL);
22592259
22602260 if (ugeth->tx_skbuff[j] == NULL) {
22612261 if (netif_msg_ifup(ugeth))
@@ -2326,9 +2326,9 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth) · 64 unmodified lines
23262326 /* Init Rx bds */
23272327 for (j = 0; j < ug_info->numQueuesRx; j++) {
23282328 /* Setup the skbuff rings */
2329− ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) *
2330− ugeth->ug_info->bdRingLenRx[j],
2331− GFP_KERNEL);
2329+ ugeth->rx_skbuff[j] =
2330+ kmalloc_array(ugeth->ug_info->bdRingLenRx[j],
2331+ sizeof(struct sk_buff *), GFP_KERNEL);
23322332
23332333 if (ugeth->rx_skbuff[j] == NULL) {
23342334 if (netif_msg_ifup(ugeth))
drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c+2−2
@@ -1406,8 +1406,8 @@ static int hns_dsaf_init(struct dsaf_device *dsaf_dev) · 1405 unmodified lines
14061406 return ret;
14071407
14081408 /* malloc mem for tcam mac key(vlan+mac) */
1409− priv->soft_mac_tbl = vzalloc(sizeof(*priv->soft_mac_tbl)
1410− * DSAF_TCAM_SUM);
1409+ priv->soft_mac_tbl = vzalloc(array_size(DSAF_TCAM_SUM,
1410+ sizeof(*priv->soft_mac_tbl)));
14111411 if (!priv->soft_mac_tbl) {
14121412 ret = -ENOMEM;
14131413 goto remove_hw;
drivers/net/ethernet/hisilicon/hns/hns_enet.c+2−1
@@ -2197,7 +2197,8 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) · 2196 unmodified lines
21972197 return -EINVAL;
21982198 }
21992199
2200− priv->ring_data = kzalloc(h->q_num * sizeof(*priv->ring_data) * 2,
2200+ priv->ring_data = kzalloc(array3_size(h->q_num,
2201+ sizeof(*priv->ring_data), 2),
22012202 GFP_KERNEL);
22022203 if (!priv->ring_data)
22032204 return -ENOMEM;
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c+4−2
@@ -2846,8 +2846,10 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) · 2845 unmodified lines
28462846 struct pci_dev *pdev = h->pdev;
28472847 int i, ret;
28482848
2849− priv->ring_data = devm_kzalloc(&pdev->dev, h->kinfo.num_tqps *
2850− sizeof(*priv->ring_data) * 2,
2849+ priv->ring_data = devm_kzalloc(&pdev->dev,
2850+ array3_size(h->kinfo.num_tqps,
2851+ sizeof(*priv->ring_data),
2852+ 2),
28512853 GFP_KERNEL);
28522854 if (!priv->ring_data)
28532855 return -ENOMEM;
drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c+3−2
@@ -753,11 +753,12 @@ static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_wq *wq, · 752 unmodified lines
753753
754754 spin_lock_init(&cmdq->cmdq_lock);
755755
756− cmdq->done = vzalloc(wq->q_depth * sizeof(*cmdq->done));
756+ cmdq->done = vzalloc(array_size(sizeof(*cmdq->done), wq->q_depth));
757757 if (!cmdq->done)
758758 return -ENOMEM;
759759
760− cmdq->errcode = vzalloc(wq->q_depth * sizeof(*cmdq->errcode));
760+ cmdq->errcode = vzalloc(array_size(sizeof(*cmdq->errcode),
761+ wq->q_depth));
761762 if (!cmdq->errcode) {
762763 err = -ENOMEM;
763764 goto err_errcode;
drivers/net/ethernet/ibm/ibmveth.c+1−1
@@ -171,7 +171,7 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) · 170 unmodified lines
171171 {
172172 int i;
173173
174− pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL);
174+ pool->free_map = kmalloc_array(pool->size, sizeof(u16), GFP_KERNEL);
175175
176176 if (!pool->free_map)
177177 return -1;
drivers/net/ethernet/intel/e1000/e1000_ethtool.c+2−2
@@ -435,8 +435,8 @@ static int e1000_get_eeprom(struct net_device *netdev, · 434 unmodified lines
435435 first_word = eeprom->offset >> 1;
436436 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
437437
438− eeprom_buff = kmalloc(sizeof(u16) *
439− (last_word - first_word + 1), GFP_KERNEL);
438+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
439+ GFP_KERNEL);
440440 if (!eeprom_buff)
441441 return -ENOMEM;
442442
drivers/net/ethernet/intel/e1000e/ethtool.c+2−2
@@ -509,8 +509,8 @@ static int e1000_get_eeprom(struct net_device *netdev, · 508 unmodified lines
509509 first_word = eeprom->offset >> 1;
510510 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
511511
512− eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
513− GFP_KERNEL);
512+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
513+ GFP_KERNEL);
514514 if (!eeprom_buff)
515515 return -ENOMEM;
516516
drivers/net/ethernet/intel/e1000e/netdev.c+1−1
@@ -3312,7 +3312,7 @@ static int e1000e_write_mc_addr_list(struct net_device *netdev) · 3311 unmodified lines
33123312 return 0;
33133313 }
33143314
3315− mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC);
3315+ mta_list = kcalloc(netdev_mc_count(netdev), ETH_ALEN, GFP_ATOMIC);
33163316 if (!mta_list)
33173317 return -ENOMEM;
33183318
drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c+1−1
@@ -558,7 +558,7 @@ static int fm10k_set_ringparam(struct net_device *netdev, · 557 unmodified lines
558558
559559 /* allocate temporary buffer to store rings in */
560560 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)));
562562
563563 if (!temp_ring) {
564564 err = -ENOMEM;
drivers/net/ethernet/intel/igb/igb_ethtool.c+8−8
@@ -736,8 +736,8 @@ static int igb_get_eeprom(struct net_device *netdev, · 735 unmodified lines
736736 first_word = eeprom->offset >> 1;
737737 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
738738
739− eeprom_buff = kmalloc(sizeof(u16) *
740− (last_word - first_word + 1), GFP_KERNEL);
739+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
740+ GFP_KERNEL);
741741 if (!eeprom_buff)
742742 return -ENOMEM;
743743
@@ -902,11 +902,11 @@ static int igb_set_ringparam(struct net_device *netdev, · 158 unmodified lines
902902 }
903903
904904 if (adapter->num_tx_queues > adapter->num_rx_queues)
905− temp_ring = vmalloc(adapter->num_tx_queues *
906− sizeof(struct igb_ring));
905+ temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
906+ adapter->num_tx_queues));
907907 else
908− temp_ring = vmalloc(adapter->num_rx_queues *
909− sizeof(struct igb_ring));
908+ temp_ring = vmalloc(array_size(sizeof(struct igb_ring),
909+ adapter->num_rx_queues));
910910
911911 if (!temp_ring) {
912912 err = -ENOMEM;
@@ -3245,8 +3245,8 @@ static int igb_get_module_eeprom(struct net_device *netdev, · 2332 unmodified lines
32453245 first_word = ee->offset >> 1;
32463246 last_word = (ee->offset + ee->len - 1) >> 1;
32473247
3248− dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1),
3249− GFP_KERNEL);
3248+ dataword = kmalloc_array(last_word - first_word + 1, sizeof(u16),
3249+ GFP_KERNEL);
32503250 if (!dataword)
32513251 return -ENOMEM;
32523252
drivers/net/ethernet/intel/igb/igb_main.c+4−3
@@ -3763,8 +3763,9 @@ static int igb_sw_init(struct igb_adapter *adapter) · 3762 unmodified lines
37633763 /* Assume MSI-X interrupts, will be checked during IRQ allocation */
37643764 adapter->flags |= IGB_FLAG_HAS_MSIX;
37653765
3766− adapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) *
3767− hw->mac.rar_entry_count, GFP_ATOMIC);
3766+ adapter->mac_table = kcalloc(hw->mac.rar_entry_count,
3767+ sizeof(struct igb_mac_addr),
3768+ GFP_ATOMIC);
37683769 if (!adapter->mac_table)
37693770 return -ENOMEM;
37703771
@@ -4752,7 +4753,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev) · 981 unmodified lines
47524753 return 0;
47534754 }
47544755
4755− mta_list = kzalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC);
4756+ mta_list = kcalloc(netdev_mc_count(netdev), 6, GFP_ATOMIC);
47564757 if (!mta_list)
47574758 return -ENOMEM;
47584759
drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c+3−2
@@ -375,8 +375,9 @@ ixgb_get_eeprom(struct net_device *netdev, · 374 unmodified lines
375375 first_word = eeprom->offset >> 1;
376376 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
377377
378− eeprom_buff = kmalloc(sizeof(__le16) *
379− (last_word - first_word + 1), GFP_KERNEL);
378+ eeprom_buff = kmalloc_array(last_word - first_word + 1,
379+ sizeof(__le16),
380+ GFP_KERNEL);
380381 if (!eeprom_buff)
381382 return -ENOMEM;
382383
drivers/net/ethernet/intel/ixgb/ixgb_main.c+3−2
@@ -1093,8 +1093,9 @@ ixgb_set_multi(struct net_device *netdev) · 1092 unmodified lines
10931093 rctl |= IXGB_RCTL_MPE;
10941094 IXGB_WRITE_REG(hw, RCTL, rctl);
10951095 } else {
1096− u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES *
1097− ETH_ALEN, GFP_ATOMIC);
1096+ u8 *mta = kmalloc_array(ETH_ALEN,
1097+ IXGB_MAX_NUM_MULTICAST_ADDRESSES,
1098+ GFP_ATOMIC);
10981099 u8 *addr;
10991100 if (!mta)
11001101 goto alloc_failed;
drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c+2−2
@@ -901,7 +901,7 @@ static int ixgbe_get_eeprom(struct net_device *netdev, · 900 unmodified lines
901901 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
902902 eeprom_len = last_word - first_word + 1;
903903
904− eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL);
904+ eeprom_buff = kmalloc_array(eeprom_len, sizeof(u16), GFP_KERNEL);
905905 if (!eeprom_buff)
906906 return -ENOMEM;
907907
@@ -1063,7 +1063,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, · 155 unmodified lines
10631063 /* allocate temporary buffer to store rings in */
10641064 i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues,
10651065 adapter->num_rx_queues);
1066− temp_ring = vmalloc(i * sizeof(struct ixgbe_ring));
1066+ temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring)));
10671067
10681068 if (!temp_ring) {
10691069 err = -ENOMEM;
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c+2−2
@@ -6034,8 +6034,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter, · 6033 unmodified lines
60346034 for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++)
60356035 adapter->jump_tables[i] = NULL;
60366036
6037− adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) *
6038− hw->mac.num_rar_entries,
6037+ adapter->mac_table = kcalloc(hw->mac.num_rar_entries,
6038+ sizeof(struct ixgbe_mac_addr),
60396039 GFP_ATOMIC);
60406040 if (!adapter->mac_table)
60416041 return -ENOMEM;
drivers/net/ethernet/intel/ixgbevf/ethtool.c+5−3
@@ -282,8 +282,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, · 281 unmodified lines
282282 }
283283
284284 if (new_tx_count != adapter->tx_ring_count) {
285− tx_ring = vmalloc((adapter->num_tx_queues +
286− adapter->num_xdp_queues) * sizeof(*tx_ring));
285+ tx_ring = vmalloc(array_size(sizeof(*tx_ring),
286+ adapter->num_tx_queues +
287+ adapter->num_xdp_queues));
287288 if (!tx_ring) {
288289 err = -ENOMEM;
289290 goto clear_reset;
@@ -327,7 +328,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, · 37 unmodified lines
327328 }
328329
329330 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));
331333 if (!rx_ring) {
332334 err = -ENOMEM;
333335 goto clear_reset;
drivers/net/ethernet/jme.c+6−4
@@ -589,8 +589,9 @@ jme_setup_tx_resources(struct jme_adapter *jme) · 588 unmodified lines
589589 atomic_set(&txring->next_to_clean, 0);
590590 atomic_set(&txring->nr_free, jme->tx_ring_size);
591591
592− txring->bufinf = kzalloc(sizeof(struct jme_buffer_info) *
593− jme->tx_ring_size, GFP_ATOMIC);
592+ txring->bufinf = kcalloc(jme->tx_ring_size,
593+ sizeof(struct jme_buffer_info),
594+ GFP_ATOMIC);
594595 if (unlikely(!(txring->bufinf)))
595596 goto err_free_txring;
596597
@@ -838,8 +839,9 @@ jme_setup_rx_resources(struct jme_adapter *jme) · 241 unmodified lines
838839 rxring->next_to_use = 0;
839840 atomic_set(&rxring->next_to_clean, 0);
840841
841− rxring->bufinf = kzalloc(sizeof(struct jme_buffer_info) *
842− jme->rx_ring_size, GFP_ATOMIC);
842+ rxring->bufinf = kcalloc(jme->rx_ring_size,
843+ sizeof(struct jme_buffer_info),
844+ GFP_ATOMIC);
843845 if (unlikely(!(rxring->bufinf)))
844846 goto err_free_rxring;
845847
drivers/net/ethernet/mellanox/mlx4/alloc.c+2−2
@@ -185,8 +185,8 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, · 184 unmodified lines
185185 bitmap->avail = num - reserved_top - reserved_bot;
186186 bitmap->effective_len = bitmap->avail;
187187 spin_lock_init(&bitmap->lock);
188− bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) *
189− sizeof(long), GFP_KERNEL);
188+ bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long),
189+ GFP_KERNEL);
190190 if (!bitmap->table)
191191 return -ENOMEM;
192192
drivers/net/ethernet/mellanox/mlx4/cmd.c+12−9
@@ -2377,20 +2377,23 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) · 2376 unmodified lines
23772377 struct mlx4_vf_admin_state *vf_admin;
23782378
23792379 priv->mfunc.master.slave_state =
2380− kzalloc(dev->num_slaves *
2381− sizeof(struct mlx4_slave_state), GFP_KERNEL);
2380+ kcalloc(dev->num_slaves,
2381+ sizeof(struct mlx4_slave_state),
2382+ GFP_KERNEL);
23822383 if (!priv->mfunc.master.slave_state)
23832384 goto err_comm;
23842385
23852386 priv->mfunc.master.vf_admin =
2386− kzalloc(dev->num_slaves *
2387− sizeof(struct mlx4_vf_admin_state), GFP_KERNEL);
2387+ kcalloc(dev->num_slaves,
2388+ sizeof(struct mlx4_vf_admin_state),
2389+ GFP_KERNEL);
23882390 if (!priv->mfunc.master.vf_admin)
23892391 goto err_comm_admin;
23902392
23912393 priv->mfunc.master.vf_oper =
2392− kzalloc(dev->num_slaves *
2393− sizeof(struct mlx4_vf_oper_state), GFP_KERNEL);
2394+ kcalloc(dev->num_slaves,
2395+ sizeof(struct mlx4_vf_oper_state),
2396+ GFP_KERNEL);
23942397 if (!priv->mfunc.master.vf_oper)
23952398 goto err_comm_oper;
23962399
@@ -2636,9 +2639,9 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev) · 239 unmodified lines
26362639 int i;
26372640 int err = 0;
26382641
2639− priv->cmd.context = kmalloc(priv->cmd.max_cmds *
2640− sizeof(struct mlx4_cmd_context),
2641− GFP_KERNEL);
2642+ priv->cmd.context = kmalloc_array(priv->cmd.max_cmds,
2643+ sizeof(struct mlx4_cmd_context),
2644+ GFP_KERNEL);
26422645 if (!priv->cmd.context)
26432646 return -ENOMEM;
26442647
drivers/net/ethernet/mellanox/mlx4/en_netdev.c+12−8
@@ -2229,13 +2229,15 @@ static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, · 2228 unmodified lines
22292229 if (!dst->tx_ring_num[t])
22302230 continue;
22312231
2232− dst->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) *
2233− MAX_TX_RINGS, GFP_KERNEL);
2232+ dst->tx_ring[t] = kcalloc(MAX_TX_RINGS,
2233+ sizeof(struct mlx4_en_tx_ring *),
2234+ GFP_KERNEL);
22342235 if (!dst->tx_ring[t])
22352236 goto err_free_tx;
22362237
2237− dst->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
2238− MAX_TX_RINGS, GFP_KERNEL);
2238+ dst->tx_cq[t] = kcalloc(MAX_TX_RINGS,
2239+ sizeof(struct mlx4_en_cq *),
2240+ GFP_KERNEL);
22392241 if (!dst->tx_cq[t]) {
22402242 kfree(dst->tx_ring[t]);
22412243 goto err_free_tx;
@@ -3320,14 +3322,16 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, · 1078 unmodified lines
33203322 if (!priv->tx_ring_num[t])
33213323 continue;
33223324
3323− priv->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) *
3324− MAX_TX_RINGS, GFP_KERNEL);
3325+ priv->tx_ring[t] = kcalloc(MAX_TX_RINGS,
3326+ sizeof(struct mlx4_en_tx_ring *),
3327+ GFP_KERNEL);
33253328 if (!priv->tx_ring[t]) {
33263329 err = -ENOMEM;
33273330 goto out;
33283331 }
3329− priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) *
3330− MAX_TX_RINGS, GFP_KERNEL);
3332+ priv->tx_cq[t] = kcalloc(MAX_TX_RINGS,
3333+ sizeof(struct mlx4_en_cq *),
3334+ GFP_KERNEL);
33313335 if (!priv->tx_cq[t]) {
33323336 err = -ENOMEM;
33333337 goto out;
drivers/net/ethernet/mellanox/mlx4/eq.c+3−2
@@ -1211,8 +1211,9 @@ int mlx4_init_eq_table(struct mlx4_dev *dev) · 1210 unmodified lines
12111211 }
12121212
12131213 priv->eq_table.irq_names =
1214− kmalloc(MLX4_IRQNAME_SIZE * (dev->caps.num_comp_vectors + 1),
1215− GFP_KERNEL);
1214+ kmalloc_array(MLX4_IRQNAME_SIZE,
1215+ (dev->caps.num_comp_vectors + 1),
1216+ GFP_KERNEL);
12161217 if (!priv->eq_table.irq_names) {
12171218 err = -ENOMEM;
12181219 goto err_out_clr_int;
drivers/net/ethernet/mellanox/mlx4/icm.c+1−1
@@ -408,7 +408,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, · 407 unmodified lines
408408 return -EINVAL;
409409 num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk;
410410
411− table->icm = kvzalloc(num_icm * sizeof(*table->icm), GFP_KERNEL);
411+ table->icm = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL);
412412 if (!table->icm)
413413 return -ENOMEM;
414414 table->virt = virt;
drivers/net/ethernet/mellanox/mlx4/main.c+3−2
@@ -2982,7 +2982,8 @@ static int mlx4_init_steering(struct mlx4_dev *dev) · 2981 unmodified lines
29822982 int num_entries = dev->caps.num_ports;
29832983 int i, j;
29842984
2985− priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL);
2985+ priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer),
2986+ GFP_KERNEL);
29862987 if (!priv->steer)
29872988 return -ENOMEM;
29882989
@@ -3103,7 +3104,7 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev, · 114 unmodified lines
31033104 }
31043105 }
31053106
3106− dev->dev_vfs = kzalloc(total_vfs * sizeof(*dev->dev_vfs), GFP_KERNEL);
3107+ dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL);
31073108 if (NULL == dev->dev_vfs) {
31083109 mlx4_err(dev, "Failed to allocate memory for VFs\n");
31093110 goto disable_sriov;
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c+14−12
@@ -487,7 +487,7 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) · 486 unmodified lines
487487 int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev);
488488
489489 priv->mfunc.master.res_tracker.slave_list =
490− kzalloc(dev->num_slaves * sizeof(struct slave_list),
490+ kcalloc(dev->num_slaves, sizeof(struct slave_list),
491491 GFP_KERNEL);
492492 if (!priv->mfunc.master.res_tracker.slave_list)
493493 return -ENOMEM;
@@ -507,19 +507,21 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) · 13 unmodified lines
507507 for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) {
508508 struct resource_allocator *res_alloc =
509509 &priv->mfunc.master.res_tracker.res_alloc[i];
510− res_alloc->quota = kmalloc((dev->persist->num_vfs + 1) *
511− sizeof(int), GFP_KERNEL);
512− res_alloc->guaranteed = kmalloc((dev->persist->num_vfs + 1) *
513− sizeof(int), GFP_KERNEL);
510+ res_alloc->quota = kmalloc_array(dev->persist->num_vfs + 1,
511+ sizeof(int),
512+ GFP_KERNEL);
513+ res_alloc->guaranteed = kmalloc_array(dev->persist->num_vfs + 1,
514+ sizeof(int),
515+ GFP_KERNEL);
514516 if (i == RES_MAC || i == RES_VLAN)
515− res_alloc->allocated = kzalloc(MLX4_MAX_PORTS *
516− (dev->persist->num_vfs
517− + 1) *
518− sizeof(int), GFP_KERNEL);
517+ res_alloc->allocated =
518+ kcalloc(MLX4_MAX_PORTS *
519+ (dev->persist->num_vfs + 1),
520+ sizeof(int), GFP_KERNEL);
519521 else
520− res_alloc->allocated = kzalloc((dev->persist->
521− num_vfs + 1) *
522− sizeof(int), GFP_KERNEL);
522+ res_alloc->allocated =
523+ kcalloc(dev->persist->num_vfs + 1,
524+ sizeof(int), GFP_KERNEL);
523525 /* Reduce the sink counter */
524526 if (i == RES_COUNTER)
525527 res_alloc->res_free = dev->caps.max_counters - 1;
drivers/net/ethernet/mellanox/mlx5/core/en_main.c+8−8
@@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, · 351 unmodified lines
352352 {
353353 int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq);
354354
355− rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info),
355+ rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info),
356356 GFP_KERNEL, cpu_to_node(c->cpu));
357357 if (!rq->mpwqe.info)
358358 return -ENOMEM;
@@ -448,7 +448,7 @@ static int mlx5e_init_di_list(struct mlx5e_rq *rq, · 89 unmodified lines
448448 {
449449 int len = wq_sz << rq->wqe.info.log_num_frags;
450450
451− rq->wqe.di = kvzalloc_node(len * sizeof(*rq->wqe.di),
451+ rq->wqe.di = kvzalloc_node(array_size(len, sizeof(*rq->wqe.di)),
452452 GFP_KERNEL, cpu_to_node(cpu));
453453 if (!rq->wqe.di)
454454 return -ENOMEM;
@@ -563,8 +563,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, · 108 unmodified lines
563563
564564 rq->wqe.info = rqp->frags_info;
565565 rq->wqe.frags =
566− kvzalloc_node((wq_sz << rq->wqe.info.log_num_frags) *
567− sizeof(*rq->wqe.frags),
566+ kvzalloc_node(array_size(sizeof(*rq->wqe.frags),
567+ (wq_sz << rq->wqe.info.log_num_frags)),
568568 GFP_KERNEL, cpu_to_node(c->cpu));
569569 if (!rq->wqe.frags) {
570570 err = -ENOMEM;
@@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa) · 401 unmodified lines
972972 {
973973 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
974974
975− sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz,
975+ sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di),
976976 GFP_KERNEL, numa);
977977 if (!sq->db.di) {
978978 mlx5e_free_xdpsq_db(sq);
@@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa) · 52 unmodified lines
10311031 {
10321032 u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
10331033
1034− sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz,
1034+ sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe),
10351035 GFP_KERNEL, numa);
10361036 if (!sq->db.ico_wqe)
10371037 return -ENOMEM;
@@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa) · 48 unmodified lines
10861086 int wq_sz = mlx5_wq_cyc_get_size(&sq->wq);
10871087 int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS;
10881088
1089− sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo),
1089+ sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo),
10901090 GFP_KERNEL, numa);
1091− sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info),
1091+ sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info),
10921092 GFP_KERNEL, numa);
10931093 if (!sq->db.dma_fifo || !sq->db.wqe_info) {
10941094 mlx5e_free_txqsq_db(sq);
drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c+6−4
@@ -549,15 +549,17 @@ static int mlx5_fpga_conn_create_qp(struct mlx5_fpga_conn *conn, · 548 unmodified lines
549549 if (err)
550550 goto out;
551551
552− conn->qp.rq.bufs = kvzalloc(sizeof(conn->qp.rq.bufs[0]) *
553− conn->qp.rq.size, GFP_KERNEL);
552+ conn->qp.rq.bufs = kvcalloc(conn->qp.rq.size,
553+ sizeof(conn->qp.rq.bufs[0]),
554+ GFP_KERNEL);
554555 if (!conn->qp.rq.bufs) {
555556 err = -ENOMEM;
556557 goto err_wq;
557558 }
558559
559− conn->qp.sq.bufs = kvzalloc(sizeof(conn->qp.sq.bufs[0]) *
560− conn->qp.sq.size, GFP_KERNEL);
560+ conn->qp.sq.bufs = kvcalloc(conn->qp.sq.size,
561+ sizeof(conn->qp.sq.bufs[0]),
562+ GFP_KERNEL);
561563 if (!conn->qp.sq.bufs) {
562564 err = -ENOMEM;
563565 goto err_rq_bufs;
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c+1−1
@@ -381,7 +381,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters, · 380 unmodified lines
381381
382382 count = mlx5_fpga_ipsec_counters_count(mdev);
383383
384− data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL);
384+ data = kzalloc(array3_size(sizeof(*data), count, 2), GFP_KERNEL);
385385 if (!data) {
386386 ret = -ENOMEM;
387387 goto out;
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c+3−2
@@ -394,8 +394,9 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock) · 393 unmodified lines
394394 int i;
395395
396396 clock->ptp_info.pin_config =
397− kzalloc(sizeof(*clock->ptp_info.pin_config) *
398− clock->ptp_info.n_pins, GFP_KERNEL);
397+ kcalloc(clock->ptp_info.n_pins,
398+ sizeof(*clock->ptp_info.pin_config),
399+ GFP_KERNEL);
399400 if (!clock->ptp_info.pin_config)
400401 return -ENOMEM;
401402 clock->ptp_info.enable = mlx5_ptp_enable;
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c+2−1
@@ -740,7 +740,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port) · 739 unmodified lines
740740 mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff;
741741 mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS;
742742
743− mlxsw_sp_qdisc = kzalloc(sizeof(*mlxsw_sp_qdisc) * IEEE_8021QAZ_MAX_TCS,
743+ mlxsw_sp_qdisc = kcalloc(IEEE_8021QAZ_MAX_TCS,
744+ sizeof(*mlxsw_sp_qdisc),
744745 GFP_KERNEL);
745746 if (!mlxsw_sp_qdisc)
746747 goto err_tclass_qdiscs_init;
drivers/net/ethernet/micrel/ksz884x.c+1−1
@@ -4372,7 +4372,7 @@ static void ksz_update_timer(struct ksz_timer_info *info) · 4371 unmodified lines
43724372 */
43734373 static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit)
43744374 {
4375− desc_info->ring = kzalloc(sizeof(struct ksz_desc) * desc_info->alloc,
4375+ desc_info->ring = kcalloc(desc_info->alloc, sizeof(struct ksz_desc),
43764376 GFP_KERNEL);
43774377 if (!desc_info->ring)
43784378 return 1;
drivers/net/ethernet/moxa/moxart_ether.c+4−4
@@ -507,15 +507,15 @@ static int moxart_mac_probe(struct platform_device *pdev) · 506 unmodified lines
507507 goto init_fail;
508508 }
509509
510− priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM,
511− GFP_ATOMIC);
510+ priv->tx_buf_base = kmalloc_array(priv->tx_buf_size, TX_DESC_NUM,
511+ GFP_ATOMIC);
512512 if (!priv->tx_buf_base) {
513513 ret = -ENOMEM;
514514 goto init_fail;
515515 }
516516
517− priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM,
518− GFP_ATOMIC);
517+ priv->rx_buf_base = kmalloc_array(priv->rx_buf_size, RX_DESC_NUM,
518+ GFP_ATOMIC);
519519 if (!priv->rx_buf_base) {
520520 ret = -ENOMEM;
521521 goto init_fail;
drivers/net/ethernet/neterion/vxge/vxge-config.c+11−10
@@ -2220,22 +2220,22 @@ __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph, · 2219 unmodified lines
22202220 channel->length = length;
22212221 channel->vp_id = vp_id;
22222222
2223− channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
2223+ channel->work_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
22242224 if (channel->work_arr == NULL)
22252225 goto exit1;
22262226
2227− channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
2227+ channel->free_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
22282228 if (channel->free_arr == NULL)
22292229 goto exit1;
22302230 channel->free_ptr = length;
22312231
2232− channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
2232+ channel->reserve_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
22332233 if (channel->reserve_arr == NULL)
22342234 goto exit1;
22352235 channel->reserve_ptr = length;
22362236 channel->reserve_top = 0;
22372237
2238− channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL);
2238+ channel->orig_arr = kcalloc(length, sizeof(void *), GFP_KERNEL);
22392239 if (channel->orig_arr == NULL)
22402240 goto exit1;
22412241
@@ -2565,7 +2565,7 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate, · 323 unmodified lines
25652565 * allocate new memblock and its private part at once.
25662566 * This helps to minimize memory usage a lot. */
25672567 mempool->memblocks_priv_arr[i] =
2568− vzalloc(mempool->items_priv_size * n_items);
2568+ vzalloc(array_size(mempool->items_priv_size, n_items));
25692569 if (mempool->memblocks_priv_arr[i] == NULL) {
25702570 status = VXGE_HW_ERR_OUT_OF_MEMORY;
25712571 goto exit;
@@ -2665,7 +2665,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, · 93 unmodified lines
26652665
26662666 /* allocate array of memblocks */
26672667 mempool->memblocks_arr =
2668− vzalloc(sizeof(void *) * mempool->memblocks_max);
2668+ vzalloc(array_size(sizeof(void *), mempool->memblocks_max));
26692669 if (mempool->memblocks_arr == NULL) {
26702670 __vxge_hw_mempool_destroy(mempool);
26712671 status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2675,7 +2675,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, · 3 unmodified lines
26752675
26762676 /* allocate array of private parts of items per memblocks */
26772677 mempool->memblocks_priv_arr =
2678− vzalloc(sizeof(void *) * mempool->memblocks_max);
2678+ vzalloc(array_size(sizeof(void *), mempool->memblocks_max));
26792679 if (mempool->memblocks_priv_arr == NULL) {
26802680 __vxge_hw_mempool_destroy(mempool);
26812681 status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2685,8 +2685,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, · 3 unmodified lines
26852685
26862686 /* allocate array of memblocks DMA objects */
26872687 mempool->memblocks_dma_arr =
2688− vzalloc(sizeof(struct vxge_hw_mempool_dma) *
2689− mempool->memblocks_max);
2688+ vzalloc(array_size(sizeof(struct vxge_hw_mempool_dma),
2689+ mempool->memblocks_max));
26902690 if (mempool->memblocks_dma_arr == NULL) {
26912691 __vxge_hw_mempool_destroy(mempool);
26922692 status = VXGE_HW_ERR_OUT_OF_MEMORY;
@@ -2695,7 +2695,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, · 2 unmodified lines
26952695 }
26962696
26972697 /* allocate hash array of items */
2698− mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max);
2698+ mempool->items_arr = vzalloc(array_size(sizeof(void *),
2699+ mempool->items_max));
26992700 if (mempool->items_arr == NULL) {
27002701 __vxge_hw_mempool_destroy(mempool);
27012702 status = VXGE_HW_ERR_OUT_OF_MEMORY;
drivers/net/ethernet/neterion/vxge/vxge-main.c+2−2
@@ -3429,8 +3429,8 @@ static int vxge_device_register(struct __vxge_hw_device *hldev, · 3428 unmodified lines
34293429 vxge_initialize_ethtool_ops(ndev);
34303430
34313431 /* Allocate memory for vpath */
3432− vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) *
3433− no_of_vpath, GFP_KERNEL);
3432+ vdev->vpaths = kcalloc(no_of_vpath, sizeof(struct vxge_vpath),
3433+ GFP_KERNEL);
34343434 if (!vdev->vpaths) {
34353435 vxge_debug_init(VXGE_ERR,
34363436 "%s: vpath memory allocation failed",
drivers/net/ethernet/netronome/nfp/abm/main.c+1−1
@@ -590,7 +590,7 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id) · 589 unmodified lines
590590 alink->id = id;
591591 alink->parent = TC_H_ROOT;
592592 alink->total_queues = alink->vnic->max_rx_rings;
593− alink->qdiscs = kvzalloc(sizeof(*alink->qdiscs) * alink->total_queues,
593+ alink->qdiscs = kvcalloc(alink->total_queues, sizeof(*alink->qdiscs),
594594 GFP_KERNEL);
595595 if (!alink->qdiscs) {
596596 err = -ENOMEM;
drivers/net/ethernet/netronome/nfp/flower/metadata.c+2−1
@@ -417,7 +417,8 @@ int nfp_flower_metadata_init(struct nfp_app *app) · 416 unmodified lines
417417
418418 /* Init ring buffer and unallocated stats_ids. */
419419 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));
421422 if (!priv->stats_ids.free_list.buf)
422423 goto err_free_last_used;
423424
drivers/net/ethernet/ni/nixge.c+2−3
@@ -247,9 +247,8 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev) · 246 unmodified lines
247247 if (!priv->tx_bd_v)
248248 goto out;
249249
250− priv->tx_skb = devm_kzalloc(ndev->dev.parent,
251− sizeof(*priv->tx_skb) *
252− TX_BD_NUM,
250+ priv->tx_skb = devm_kcalloc(ndev->dev.parent,
251+ TX_BD_NUM, sizeof(*priv->tx_skb),
253252 GFP_KERNEL);
254253 if (!priv->tx_skb)
255254 goto out;
drivers/net/ethernet/nvidia/forcedeth.c+4−2
@@ -4630,8 +4630,10 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri · 4629 unmodified lines
46304630 ring->tx_pending),
46314631 &ring_addr, GFP_ATOMIC);
46324632 }
4633− rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL);
4634− tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL);
4633+ rx_skbuff = kmalloc_array(ring->rx_pending, sizeof(struct nv_skb_map),
4634+ GFP_KERNEL);
4635+ tx_skbuff = kmalloc_array(ring->tx_pending, sizeof(struct nv_skb_map),
4636+ GFP_KERNEL);
46354637 if (!rxtx_ring || !rx_skbuff || !tx_skbuff) {
46364638 /* fall back to old rings */
46374639 if (!nv_optimized(np)) {
drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c+1−1
@@ -2178,7 +2178,7 @@ static void pch_gbe_set_multi(struct net_device *netdev) · 2177 unmodified lines
21782178
21792179 if (mc_count >= PCH_GBE_MAR_ENTRIES)
21802180 return;
2181− mta_list = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC);
2181+ mta_list = kmalloc_array(ETH_ALEN, mc_count, GFP_ATOMIC);
21822182 if (!mta_list)
21832183 return;
21842184
drivers/net/ethernet/pasemi/pasemi_mac.c+6−4
@@ -390,8 +390,9 @@ static int pasemi_mac_setup_rx_resources(const struct net_device *dev) · 389 unmodified lines
390390 spin_lock_init(&ring->lock);
391391
392392 ring->size = RX_RING_SIZE;
393− ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
394− RX_RING_SIZE, GFP_KERNEL);
393+ ring->ring_info = kcalloc(RX_RING_SIZE,
394+ sizeof(struct pasemi_mac_buffer),
395+ GFP_KERNEL);
395396
396397 if (!ring->ring_info)
397398 goto out_ring_info;
@@ -473,8 +474,9 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev) · 75 unmodified lines
473474 spin_lock_init(&ring->lock);
474475
475476 ring->size = TX_RING_SIZE;
476− ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) *
477− TX_RING_SIZE, GFP_KERNEL);
477+ ring->ring_info = kcalloc(TX_RING_SIZE,
478+ sizeof(struct pasemi_mac_buffer),
479+ GFP_KERNEL);
478480 if (!ring->ring_info)
479481 goto out_ring_info;
480482
drivers/net/ethernet/qlogic/qed/qed_debug.c+3−2
@@ -6617,7 +6617,8 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, · 6616 unmodified lines
66176617
66186618 /* Read no. of modules and allocate memory for their pointers */
66196619 meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset);
6620− meta->modules = kzalloc(meta->modules_num * sizeof(char *), GFP_KERNEL);
6620+ meta->modules = kcalloc(meta->modules_num, sizeof(char *),
6621+ GFP_KERNEL);
66216622 if (!meta->modules)
66226623 return DBG_STATUS_VIRT_MEM_ALLOC_FAILED;
66236624
@@ -6645,7 +6646,7 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, · 21 unmodified lines
66456646
66466647 /* Read number of formats and allocate memory for all formats */
66476648 meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset);
6648− meta->formats = kzalloc(meta->formats_num *
6649+ meta->formats = kcalloc(meta->formats_num,
66496650 sizeof(struct mcp_trace_format),
66506651 GFP_KERNEL);
66516652 if (!meta->formats)
drivers/net/ethernet/qlogic/qed/qed_dev.c+8−8
@@ -814,26 +814,26 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn) · 813 unmodified lines
814814 if (rc)
815815 goto alloc_err;
816816
817− qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) *
818− qed_init_qm_get_num_pqs(p_hwfn),
817+ qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn),
818+ sizeof(*qm_info->qm_pq_params),
819819 GFP_KERNEL);
820820 if (!qm_info->qm_pq_params)
821821 goto alloc_err;
822822
823− qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) *
824− qed_init_qm_get_num_vports(p_hwfn),
823+ qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn),
824+ sizeof(*qm_info->qm_vport_params),
825825 GFP_KERNEL);
826826 if (!qm_info->qm_vport_params)
827827 goto alloc_err;
828828
829− qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) *
830− p_hwfn->cdev->num_ports_in_engine,
829+ qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine,
830+ sizeof(*qm_info->qm_port_params),
831831 GFP_KERNEL);
832832 if (!qm_info->qm_port_params)
833833 goto alloc_err;
834834
835− qm_info->wfq_data = kzalloc(sizeof(*qm_info->wfq_data) *
836− qed_init_qm_get_num_vports(p_hwfn),
835+ qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn),
836+ sizeof(*qm_info->wfq_data),
837837 GFP_KERNEL);
838838 if (!qm_info->wfq_data)
839839 goto alloc_err;
drivers/net/ethernet/qlogic/qed/qed_init_ops.c+2−2
@@ -149,12 +149,12 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) · 148 unmodified lines
149149 if (IS_VF(p_hwfn->cdev))
150150 return 0;
151151
152− rt_data->b_valid = kzalloc(sizeof(bool) * RUNTIME_ARRAY_SIZE,
152+ rt_data->b_valid = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(bool),
153153 GFP_KERNEL);
154154 if (!rt_data->b_valid)
155155 return -ENOMEM;
156156
157− rt_data->init_val = kzalloc(sizeof(u32) * RUNTIME_ARRAY_SIZE,
157+ rt_data->init_val = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(u32),
158158 GFP_KERNEL);
159159 if (!rt_data->init_val) {
160160 kfree(rt_data->b_valid);
drivers/net/ethernet/qlogic/qed/qed_l2.c+2−2
@@ -98,7 +98,7 @@ int qed_l2_alloc(struct qed_hwfn *p_hwfn) · 97 unmodified lines
9898 p_l2_info->queues = max_t(u8, rx, tx);
9999 }
100100
101− pp_qids = kzalloc(sizeof(unsigned long *) * p_l2_info->queues,
101+ pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *),
102102 GFP_KERNEL);
103103 if (!pp_qids)
104104 return -ENOMEM;
@@ -2435,7 +2435,7 @@ static int qed_update_vport(struct qed_dev *cdev, · 2330 unmodified lines
24352435 if (!cdev)
24362436 return -ENODEV;
24372437
2438− rss = vzalloc(sizeof(*rss) * cdev->num_hwfns);
2438+ rss = vzalloc(array_size(sizeof(*rss), cdev->num_hwfns));
24392439 if (!rss)
24402440 return -ENOMEM;
24412441
drivers/net/ethernet/qlogic/qed/qed_mcp.c+3−3
@@ -2578,9 +2578,9 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn) · 2577 unmodified lines
25782578 goto err0;
25792579 }
25802580
2581− nvm_info->image_att = kmalloc(nvm_info->num_images *
2582− sizeof(struct bist_nvm_image_att),
2583− GFP_KERNEL);
2581+ nvm_info->image_att = kmalloc_array(nvm_info->num_images,
2582+ sizeof(struct bist_nvm_image_att),
2583+ GFP_KERNEL);
25842584 if (!nvm_info->image_att) {
25852585 rc = -ENOMEM;
25862586 goto err0;
drivers/net/ethernet/qlogic/qede/qede_filter.c+3−2
@@ -342,8 +342,9 @@ int qede_alloc_arfs(struct qede_dev *edev) · 341 unmodified lines
342342 for (i = 0; i <= QEDE_RFS_FLW_MASK; i++)
343343 INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i));
344344
345− edev->arfs->arfs_fltr_bmap = vzalloc(BITS_TO_LONGS(QEDE_RFS_MAX_FLTR) *
346− sizeof(long));
345+ edev->arfs->arfs_fltr_bmap =
346+ vzalloc(array_size(sizeof(long),
347+ BITS_TO_LONGS(QEDE_RFS_MAX_FLTR)));
347348 if (!edev->arfs->arfs_fltr_bmap) {
348349 vfree(edev->arfs);
349350 edev->arfs = NULL;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c+3−2
@@ -386,8 +386,9 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter) · 385 unmodified lines
386386 }
387387
388388 /* setup interrupt mapping table for fw */
389− ahw->intr_tbl = vzalloc(num_msix *
390− sizeof(struct qlcnic_intrpt_config));
389+ ahw->intr_tbl =
390+ vzalloc(array_size(num_msix,
391+ sizeof(struct qlcnic_intrpt_config)));
391392 if (!ahw->intr_tbl)
392393 return -ENOMEM;
393394
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c+9−6
@@ -916,8 +916,9 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type) · 915 unmodified lines
916916 if (qlcnic_check_multi_tx(adapter) &&
917917 !ahw->diag_test &&
918918 (adapter->flags & QLCNIC_MSIX_ENABLED)) {
919− ahw->intr_tbl = vzalloc(ahw->num_msix *
920− sizeof(struct qlcnic_intrpt_config));
919+ ahw->intr_tbl =
920+ vzalloc(array_size(sizeof(struct qlcnic_intrpt_config),
921+ ahw->num_msix));
921922 if (!ahw->intr_tbl)
922923 return -ENOMEM;
923924
@@ -1025,15 +1026,17 @@ int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) · 101 unmodified lines
10251026
10261027 act_pci_func = ahw->total_nic_func;
10271028
1028− adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) *
1029− act_pci_func, GFP_KERNEL);
1029+ adapter->npars = kcalloc(act_pci_func,
1030+ sizeof(struct qlcnic_npar_info),
1031+ GFP_KERNEL);
10301032 if (!adapter->npars) {
10311033 ret = -ENOMEM;
10321034 goto err_pci_info;
10331035 }
10341036
1035− adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) *
1036− QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL);
1037+ adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS,
1038+ sizeof(struct qlcnic_eswitch),
1039+ GFP_KERNEL);
10371040 if (!adapter->eswitch) {
10381041 ret = -ENOMEM;
10391042 goto err_npars;
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c+4−4
@@ -157,8 +157,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs) · 156 unmodified lines
157157 adapter->ahw->sriov = sriov;
158158 sriov->num_vfs = num_vfs;
159159 bc = &sriov->bc;
160− sriov->vf_info = kzalloc(sizeof(struct qlcnic_vf_info) *
161− num_vfs, GFP_KERNEL);
160+ sriov->vf_info = kcalloc(num_vfs, sizeof(struct qlcnic_vf_info),
161+ GFP_KERNEL);
162162 if (!sriov->vf_info) {
163163 err = -ENOMEM;
164164 goto qlcnic_free_sriov;
@@ -450,7 +450,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter, · 285 unmodified lines
450450 return 0;
451451
452452 num_vlans = sriov->num_allowed_vlans;
453− sriov->allowed_vlans = kzalloc(sizeof(u16) * num_vlans, GFP_KERNEL);
453+ sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL);
454454 if (!sriov->allowed_vlans)
455455 return -ENOMEM;
456456
@@ -706,7 +706,7 @@ static inline int qlcnic_sriov_alloc_bc_trans(struct qlcnic_bc_trans **trans) · 249 unmodified lines
706706 static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr,
707707 u32 size)
708708 {
709− *hdr = kzalloc(sizeof(struct qlcnic_bc_hdr) * size, GFP_ATOMIC);
709+ *hdr = kcalloc(size, sizeof(struct qlcnic_bc_hdr), GFP_ATOMIC);
710710 if (!*hdr)
711711 return -ENOMEM;
712712
drivers/net/ethernet/qlogic/qlge/qlge_main.c+2−1
@@ -2810,7 +2810,8 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev, · 2809 unmodified lines
28102810 goto pci_alloc_err;
28112811
28122812 tx_ring->q =
2813− kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL);
2813+ kmalloc_array(tx_ring->wq_len, sizeof(struct tx_ring_desc),
2814+ GFP_KERNEL);
28142815 if (tx_ring->q == NULL)
28152816 goto err;
28162817
drivers/net/ethernet/sfc/ef10.c+2−1
@@ -4984,7 +4984,8 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) · 4983 unmodified lines
49844984 net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER;
49854985 }
49864986
4987− table->entry = vzalloc(HUNT_FILTER_TBL_ROWS * sizeof(*table->entry));
4987+ table->entry = vzalloc(array_size(HUNT_FILTER_TBL_ROWS,
4988+ sizeof(*table->entry)));
49884989 if (!table->entry) {
49894990 rc = -ENOMEM;
49904991 goto fail;
drivers/net/ethernet/sfc/falcon/farch.c+2−1
@@ -2755,7 +2755,8 @@ int ef4_farch_filter_table_probe(struct ef4_nic *efx) · 2754 unmodified lines
27552755 GFP_KERNEL);
27562756 if (!table->used_bitmap)
27572757 goto fail;
2758− table->spec = vzalloc(table->size * sizeof(*table->spec));
2758+ table->spec = vzalloc(array_size(sizeof(*table->spec),
2759+ table->size));
27592760 if (!table->spec)
27602761 goto fail;
27612762 }
drivers/net/ethernet/sfc/farch.c+2−1
@@ -2826,7 +2826,8 @@ int efx_farch_filter_table_probe(struct efx_nic *efx) · 2825 unmodified lines
28262826 GFP_KERNEL);
28272827 if (!table->used_bitmap)
28282828 goto fail;
2829− table->spec = vzalloc(table->size * sizeof(*table->spec));
2829+ table->spec = vzalloc(array_size(sizeof(*table->spec),
2830+ table->size));
28302831 if (!table->spec)
28312832 goto fail;
28322833 }
drivers/net/ethernet/socionext/netsec.c+1−1
@@ -973,7 +973,7 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) · 972 unmodified lines
973973 goto err;
974974 }
975975
976− dring->desc = kzalloc(DESC_NUM * sizeof(*dring->desc), GFP_KERNEL);
976+ dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL);
977977 if (!dring->desc) {
978978 ret = -ENOMEM;
979979 goto err;
drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c+2−2
@@ -277,8 +277,8 @@ static int tc_init(struct stmmac_priv *priv) · 276 unmodified lines
277277
278278 /* Reserve one last filter which lets all pass */
279279 priv->tc_entries_max = count;
280− priv->tc_entries = devm_kzalloc(priv->device,
281− sizeof(*priv->tc_entries) * count, GFP_KERNEL);
280+ priv->tc_entries = devm_kcalloc(priv->device,
281+ count, sizeof(*priv->tc_entries), GFP_KERNEL);
282282 if (!priv->tc_entries)
283283 return -ENOMEM;
284284
drivers/net/ethernet/ti/cpsw.c+5−4
@@ -2740,8 +2740,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, · 2739 unmodified lines
27402740 }
27412741 data->active_slave = prop;
27422742
2743− data->slave_data = devm_kzalloc(&pdev->dev, data->slaves
2744− * sizeof(struct cpsw_slave_data),
2743+ data->slave_data = devm_kcalloc(&pdev->dev,
2744+ data->slaves,
2745+ sizeof(struct cpsw_slave_data),
27452746 GFP_KERNEL);
27462747 if (!data->slave_data)
27472748 return -ENOMEM;
@@ -3045,8 +3046,8 @@ static int cpsw_probe(struct platform_device *pdev) · 297 unmodified lines
30453046
30463047 memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN);
30473048
3048− cpsw->slaves = devm_kzalloc(&pdev->dev,
3049− sizeof(struct cpsw_slave) * data->slaves,
3049+ cpsw->slaves = devm_kcalloc(&pdev->dev,
3050+ data->slaves, sizeof(struct cpsw_slave),
30503051 GFP_KERNEL);
30513052 if (!cpsw->slaves) {
30523053 ret = -ENOMEM;
drivers/net/ethernet/ti/netcp_ethss.c+12−12
@@ -3285,8 +3285,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, · 3284 unmodified lines
32853285 gbe_dev->et_stats = xgbe10_et_stats;
32863286 gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats);
32873287
3288− gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
3289− gbe_dev->num_et_stats * sizeof(u64),
3288+ gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
3289+ gbe_dev->num_et_stats, sizeof(u64),
32903290 GFP_KERNEL);
32913291 if (!gbe_dev->hw_stats) {
32923292 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3294,8 +3294,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, · 1 unmodified line
32943294 }
32953295
32963296 gbe_dev->hw_stats_prev =
3297− devm_kzalloc(gbe_dev->dev,
3298− gbe_dev->num_et_stats * sizeof(u32),
3297+ devm_kcalloc(gbe_dev->dev,
3298+ gbe_dev->num_et_stats, sizeof(u32),
32993299 GFP_KERNEL);
33003300 if (!gbe_dev->hw_stats_prev) {
33013301 dev_err(gbe_dev->dev,
@@ -3405,8 +3405,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, · 103 unmodified lines
34053405 gbe_dev->et_stats = gbe13_et_stats;
34063406 gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats);
34073407
3408− gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
3409− gbe_dev->num_et_stats * sizeof(u64),
3408+ gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
3409+ gbe_dev->num_et_stats, sizeof(u64),
34103410 GFP_KERNEL);
34113411 if (!gbe_dev->hw_stats) {
34123412 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3414,8 +3414,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, · 1 unmodified line
34143414 }
34153415
34163416 gbe_dev->hw_stats_prev =
3417− devm_kzalloc(gbe_dev->dev,
3418− gbe_dev->num_et_stats * sizeof(u32),
3417+ devm_kcalloc(gbe_dev->dev,
3418+ gbe_dev->num_et_stats, sizeof(u32),
34193419 GFP_KERNEL);
34203420 if (!gbe_dev->hw_stats_prev) {
34213421 dev_err(gbe_dev->dev,
@@ -3477,8 +3477,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, · 55 unmodified lines
34773477 gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE +
34783478 GBENU_ET_STATS_PORT_SIZE;
34793479
3480− gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev,
3481− gbe_dev->num_et_stats * sizeof(u64),
3480+ gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev,
3481+ gbe_dev->num_et_stats, sizeof(u64),
34823482 GFP_KERNEL);
34833483 if (!gbe_dev->hw_stats) {
34843484 dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n");
@@ -3486,8 +3486,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, · 1 unmodified line
34863486 }
34873487
34883488 gbe_dev->hw_stats_prev =
3489− devm_kzalloc(gbe_dev->dev,
3490− gbe_dev->num_et_stats * sizeof(u32),
3489+ devm_kcalloc(gbe_dev->dev,
3490+ gbe_dev->num_et_stats, sizeof(u32),
34913491 GFP_KERNEL);
34923492 if (!gbe_dev->hw_stats_prev) {
34933493 dev_err(gbe_dev->dev,
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c+3−2
@@ -2320,8 +2320,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card) · 2319 unmodified lines
23202320 pr_debug("%s: wl=%p port=%p\n", __func__, wl, port);
23212321
23222322 /* allocate scan list */
2323− wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) *
2324− GELIC_WL_BSS_MAX_ENT, GFP_KERNEL);
2323+ wl->networks = kcalloc(GELIC_WL_BSS_MAX_ENT,
2324+ sizeof(struct gelic_wl_scan_info),
2325+ GFP_KERNEL);
23252326
23262327 if (!wl->networks)
23272328 goto fail_bss;
drivers/net/gtp.c+4−2
@@ -742,11 +742,13 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) · 741 unmodified lines
742742 {
743743 int i;
744744
745− gtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);
745+ gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head),
746+ GFP_KERNEL);
746747 if (gtp->addr_hash == NULL)
747748 return -ENOMEM;
748749
749− gtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL);
750+ gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head),
751+ GFP_KERNEL);
750752 if (gtp->tid_hash == NULL)
751753 goto err1;
752754
drivers/net/hippi/rrunner.c+1−1
@@ -1583,7 +1583,7 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) · 1582 unmodified lines
15831583 return -EPERM;
15841584 }
15851585
1586− image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL);
1586+ image = kmalloc_array(EEPROM_WORDS, sizeof(u32), GFP_KERNEL);
15871587 if (!image)
15881588 return -ENOMEM;
15891589
drivers/net/phy/dp83640.c+3−2
@@ -1097,8 +1097,9 @@ static struct dp83640_clock *dp83640_clock_get_bus(struct mii_bus *bus) · 1096 unmodified lines
10971097 if (!clock)
10981098 goto out;
10991099
1100− clock->caps.pin_config = kzalloc(sizeof(struct ptp_pin_desc) *
1101− DP83640_N_PINS, GFP_KERNEL);
1100+ clock->caps.pin_config = kcalloc(DP83640_N_PINS,
1101+ sizeof(struct ptp_pin_desc),
1102+ GFP_KERNEL);
11021103 if (!clock->caps.pin_config) {
11031104 kfree(clock);
11041105 clock = NULL;
drivers/net/phy/phy_led_triggers.c+3−3
@@ -128,9 +128,9 @@ int phy_led_triggers_register(struct phy_device *phy) · 127 unmodified lines
128128 if (err)
129129 goto out_free_link;
130130
131− phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev,
132− sizeof(struct phy_led_trigger) *
133− phy->phy_num_led_triggers,
131+ phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev,
132+ phy->phy_num_led_triggers,
133+ sizeof(struct phy_led_trigger),
134134 GFP_KERNEL);
135135 if (!phy->phy_led_triggers) {
136136 err = -ENOMEM;
drivers/net/ppp/bsd_comp.c+2−2
@@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) · 405 unmodified lines
406406 * Allocate space for the dictionary. This may be more than one page in
407407 * length.
408408 */
409− db->dict = vmalloc(hsize * sizeof(struct bsd_dict));
409+ db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict)));
410410 if (!db->dict)
411411 {
412412 bsd_free (db);
@@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) · 12 unmodified lines
425425 */
426426 else
427427 {
428− db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0]));
428+ db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1)));
429429 if (!db->lens)
430430 {
431431 bsd_free (db);
drivers/net/ppp/pptp.c+1−1
@@ -648,7 +648,7 @@ static int __init pptp_init_module(void) · 647 unmodified lines
648648 int err = 0;
649649 pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n");
650650
651− callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *));
651+ callid_sock = vzalloc(array_size(sizeof(void *), (MAX_CALLID + 1)));
652652 if (!callid_sock)
653653 return -ENOMEM;
654654
drivers/net/slip/slip.c+1−1
@@ -1307,7 +1307,7 @@ static int __init slip_init(void) · 1306 unmodified lines
13071307 printk(KERN_INFO "SLIP linefill/keepalive option.\n");
13081308 #endif
13091309
1310− slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev,
1310+ slip_devs = kcalloc(slip_maxdev, sizeof(struct net_device *),
13111311 GFP_KERNEL);
13121312 if (!slip_devs)
13131313 return -ENOMEM;
drivers/net/team/team.c+3−2
@@ -280,7 +280,7 @@ static int __team_options_register(struct team *team, · 279 unmodified lines
280280 struct team_option **dst_opts;
281281 int err;
282282
283− dst_opts = kzalloc(sizeof(struct team_option *) * option_count,
283+ dst_opts = kcalloc(option_count, sizeof(struct team_option *),
284284 GFP_KERNEL);
285285 if (!dst_opts)
286286 return -ENOMEM;
@@ -791,7 +791,8 @@ static int team_queue_override_init(struct team *team) · 504 unmodified lines
791791
792792 if (!queue_cnt)
793793 return 0;
794− listarr = kmalloc(sizeof(struct list_head) * queue_cnt, GFP_KERNEL);
794+ listarr = kmalloc_array(queue_cnt, sizeof(struct list_head),
795+ GFP_KERNEL);
795796 if (!listarr)
796797 return -ENOMEM;
797798 team->qom_lists = listarr;
drivers/net/usb/asix_common.c+4−4
@@ -640,8 +640,8 @@ int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, · 639 unmodified lines
640640 first_word = eeprom->offset >> 1;
641641 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
642642
643− eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
644− GFP_KERNEL);
643+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
644+ GFP_KERNEL);
645645 if (!eeprom_buff)
646646 return -ENOMEM;
647647
@@ -680,8 +680,8 @@ int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, · 32 unmodified lines
680680 first_word = eeprom->offset >> 1;
681681 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
682682
683− eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
684− GFP_KERNEL);
683+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
684+ GFP_KERNEL);
685685 if (!eeprom_buff)
686686 return -ENOMEM;
687687
drivers/net/usb/ax88179_178a.c+2−2
@@ -599,8 +599,8 @@ ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, · 598 unmodified lines
599599
600600 first_word = eeprom->offset >> 1;
601601 last_word = (eeprom->offset + eeprom->len - 1) >> 1;
602− eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1),
603− GFP_KERNEL);
602+ eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16),
603+ GFP_KERNEL);
604604 if (!eeprom_buff)
605605 return -ENOMEM;
606606
drivers/net/usb/smsc95xx.c+1−1
@@ -1661,7 +1661,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) · 1660 unmodified lines
16611661 }
16621662
16631663 if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) {
1664− u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL);
1664+ u32 *filter_mask = kcalloc(32, sizeof(u32), GFP_KERNEL);
16651665 u32 command[2];
16661666 u32 offset[2];
16671667 u32 crc[4];
drivers/net/usb/usbnet.c+2−2
@@ -1323,8 +1323,8 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb) · 1322 unmodified lines
13231323 return 0;
13241324
13251325 /* reserve one for zero packet */
1326− urb->sg = kmalloc((num_sgs + 1) * sizeof(struct scatterlist),
1327− GFP_ATOMIC);
1326+ urb->sg = kmalloc_array(num_sgs + 1, sizeof(struct scatterlist),
1327+ GFP_ATOMIC);
13281328 if (!urb->sg)
13291329 return -ENOMEM;
13301330
drivers/net/virtio_net.c+6−6
@@ -2552,17 +2552,17 @@ static int virtnet_find_vqs(struct virtnet_info *vi) · 2551 unmodified lines
25522552 virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ);
25532553
25542554 /* Allocate space for find_vqs parameters */
2555− vqs = kzalloc(total_vqs * sizeof(*vqs), GFP_KERNEL);
2555+ vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL);
25562556 if (!vqs)
25572557 goto err_vq;
2558− callbacks = kmalloc(total_vqs * sizeof(*callbacks), GFP_KERNEL);
2558+ callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL);
25592559 if (!callbacks)
25602560 goto err_callback;
2561− names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL);
2561+ names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL);
25622562 if (!names)
25632563 goto err_names;
25642564 if (!vi->big_packets || vi->mergeable_rx_bufs) {
2565− ctx = kzalloc(total_vqs * sizeof(*ctx), GFP_KERNEL);
2565+ ctx = kcalloc(total_vqs, sizeof(*ctx), GFP_KERNEL);
25662566 if (!ctx)
25672567 goto err_ctx;
25682568 } else {
@@ -2626,10 +2626,10 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) · 57 unmodified lines
26262626 vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL);
26272627 if (!vi->ctrl)
26282628 goto err_ctrl;
2629− vi->sq = kzalloc(sizeof(*vi->sq) * vi->max_queue_pairs, GFP_KERNEL);
2629+ vi->sq = kcalloc(vi->max_queue_pairs, sizeof(*vi->sq), GFP_KERNEL);
26302630 if (!vi->sq)
26312631 goto err_sq;
2632− vi->rq = kzalloc(sizeof(*vi->rq) * vi->max_queue_pairs, GFP_KERNEL);
2632+ vi->rq = kcalloc(vi->max_queue_pairs, sizeof(*vi->rq), GFP_KERNEL);
26332633 if (!vi->rq)
26342634 goto err_rq;
26352635
drivers/net/wan/fsl_ucc_hdlc.c+4−2
@@ -198,12 +198,14 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) · 197 unmodified lines
198198 goto free_tx_bd;
199199 }
200200
201− priv->rx_skbuff = kzalloc(priv->rx_ring_size * sizeof(*priv->rx_skbuff),
201+ priv->rx_skbuff = kcalloc(priv->rx_ring_size,
202+ sizeof(*priv->rx_skbuff),
202203 GFP_KERNEL);
203204 if (!priv->rx_skbuff)
204205 goto free_ucc_pram;
205206
206− priv->tx_skbuff = kzalloc(priv->tx_ring_size * sizeof(*priv->tx_skbuff),
207+ priv->tx_skbuff = kcalloc(priv->tx_ring_size,
208+ sizeof(*priv->tx_skbuff),
207209 GFP_KERNEL);
208210 if (!priv->tx_skbuff)
209211 goto free_rx_skbuff;
drivers/net/wireless/ath/ath10k/htt_rx.c+1−1
@@ -582,7 +582,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt) · 581 unmodified lines
582582 }
583583
584584 htt->rx_ring.netbufs_ring =
585− kzalloc(htt->rx_ring.size * sizeof(struct sk_buff *),
585+ kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *),
586586 GFP_KERNEL);
587587 if (!htt->rx_ring.netbufs_ring)
588588 goto err_netbuf;
drivers/net/wireless/ath/ath10k/wmi-tlv.c+1−1
@@ -155,7 +155,7 @@ ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr, · 154 unmodified lines
155155 const void **tb;
156156 int ret;
157157
158− tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp);
158+ tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp);
159159 if (!tb)
160160 return ERR_PTR(-ENOMEM);
161161
drivers/net/wireless/ath/ath5k/debug.c+1−1
@@ -931,7 +931,7 @@ static int open_file_eeprom(struct inode *inode, struct file *file) · 930 unmodified lines
931931
932932 /* Create buffer and read in eeprom */
933933
934− buf = vmalloc(eesize * 2);
934+ buf = vmalloc(array_size(eesize, 2));
935935 if (!buf) {
936936 ret = -ENOMEM;
937937 goto err;
drivers/net/wireless/ath/ath5k/phy.c+2−1
@@ -890,7 +890,8 @@ ath5k_hw_rfregs_init(struct ath5k_hw *ah, · 889 unmodified lines
890890 * ah->ah_rf_banks based on ah->ah_rf_banks_size
891891 * we set above */
892892 if (ah->ah_rf_banks == NULL) {
893− ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size,
893+ ah->ah_rf_banks = kmalloc_array(ah->ah_rf_banks_size,
894+ sizeof(u32),
894895 GFP_KERNEL);
895896 if (ah->ah_rf_banks == NULL) {
896897 ATH5K_ERR(ah, "out of memory\n");
drivers/net/wireless/ath/ath6kl/cfg80211.c+1−1
@@ -1041,7 +1041,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, · 1040 unmodified lines
10411041
10421042 n_channels = request->n_channels;
10431043
1044− channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL);
1044+ channels = kcalloc(n_channels, sizeof(u16), GFP_KERNEL);
10451045 if (channels == NULL) {
10461046 ath6kl_warn("failed to set scan channels, scan all channels");
10471047 n_channels = 0;
drivers/net/wireless/ath/ath9k/ar9003_paprd.c+1−1
@@ -925,7 +925,7 @@ int ar9003_paprd_create_curve(struct ath_hw *ah, · 924 unmodified lines
925925
926926 memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain]));
927927
928− buf = kmalloc(2 * 48 * sizeof(u32), GFP_KERNEL);
928+ buf = kmalloc_array(2 * 48, sizeof(u32), GFP_KERNEL);
929929 if (!buf)
930930 return -ENOMEM;
931931
drivers/net/wireless/ath/ath9k/hw.c+2−2
@@ -127,13 +127,13 @@ void ath9k_hw_read_array(struct ath_hw *ah, u32 array[][2], int size) · 126 unmodified lines
127127 u32 *tmp_reg_list, *tmp_data;
128128 int i;
129129
130− tmp_reg_list = kmalloc(size * sizeof(u32), GFP_KERNEL);
130+ tmp_reg_list = kmalloc_array(size, sizeof(u32), GFP_KERNEL);
131131 if (!tmp_reg_list) {
132132 dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__);
133133 return;
134134 }
135135
136− tmp_data = kmalloc(size * sizeof(u32), GFP_KERNEL);
136+ tmp_data = kmalloc_array(size, sizeof(u32), GFP_KERNEL);
137137 if (!tmp_data) {
138138 dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__);
139139 goto error_tmp_data;
drivers/net/wireless/ath/carl9170/main.c+4−3
@@ -1958,7 +1958,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar) · 1957 unmodified lines
19581958 if (!bands)
19591959 return -EINVAL;
19601960
1961− ar->survey = kzalloc(sizeof(struct survey_info) * chans, GFP_KERNEL);
1961+ ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL);
19621962 if (!ar->survey)
19631963 return -ENOMEM;
19641964 ar->num_channels = chans;
@@ -1988,8 +1988,9 @@ int carl9170_register(struct ar9170 *ar) · 23 unmodified lines
19881988 if (WARN_ON(ar->mem_bitmap))
19891989 return -EINVAL;
19901990
1991− ar->mem_bitmap = kzalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG) *
1992− sizeof(unsigned long), GFP_KERNEL);
1991+ ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG),
1992+ sizeof(unsigned long),
1993+ GFP_KERNEL);
19931994
19941995 if (!ar->mem_bitmap)
19951996 return -ENOMEM;
drivers/net/wireless/broadcom/b43/phy_n.c+1−1
@@ -1518,7 +1518,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev, · 1517 unmodified lines
15181518 u16 i;
15191519 u32 *data;
15201520
1521− data = kzalloc(len * sizeof(u32), GFP_KERNEL);
1521+ data = kcalloc(len, sizeof(u32), GFP_KERNEL);
15221522 if (!data) {
15231523 b43err(dev->wl, "allocation for samples loading failed\n");
15241524 return -ENOMEM;
drivers/net/wireless/broadcom/b43legacy/main.c+2−2
@@ -3300,8 +3300,8 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev) · 3299 unmodified lines
33003300
33013301 if ((phy->type == B43legacy_PHYTYPE_B) ||
33023302 (phy->type == B43legacy_PHYTYPE_G)) {
3303− phy->_lo_pairs = kzalloc(sizeof(struct b43legacy_lopair)
3304− * B43legacy_LO_COUNT,
3303+ phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT,
3304+ sizeof(struct b43legacy_lopair),
33053305 GFP_KERNEL);
33063306 if (!phy->_lo_pairs)
33073307 return -ENOMEM;
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c+3−2
@@ -1486,8 +1486,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) · 1485 unmodified lines
14861486 (struct brcmf_commonring **)if_msgbuf->commonrings;
14871487 msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings;
14881488 msgbuf->max_flowrings = if_msgbuf->max_flowrings;
1489− msgbuf->flowring_dma_handle = kzalloc(msgbuf->max_flowrings *
1490− sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
1489+ msgbuf->flowring_dma_handle =
1490+ kcalloc(msgbuf->max_flowrings,
1491+ sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL);
14911492 if (!msgbuf->flowring_dma_handle)
14921493 goto fail;
14931494
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c+1−1
@@ -1058,7 +1058,7 @@ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel) · 1057 unmodified lines
10581058 channel_cnt = AF_PEER_SEARCH_CNT;
10591059 else
10601060 channel_cnt = SOCIAL_CHAN_CNT;
1061− default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list),
1061+ default_chan_list = kcalloc(channel_cnt, sizeof(*default_chan_list),
10621062 GFP_KERNEL);
10631063 if (default_chan_list == NULL) {
10641064 brcmf_err("channel list allocation failed\n");
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c+4−3
@@ -507,7 +507,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) · 506 unmodified lines
507507 wlc->hw->wlc = wlc;
508508
509509 wlc->hw->bandstate[0] =
510− kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC);
510+ kcalloc(MAXBANDS, sizeof(struct brcms_hw_band), GFP_ATOMIC);
511511 if (wlc->hw->bandstate[0] == NULL) {
512512 *err = 1006;
513513 goto fail;
@@ -521,7 +521,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) · 7 unmodified lines
521521 }
522522
523523 wlc->modulecb =
524− kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC);
524+ kcalloc(BRCMS_MAXMODULES, sizeof(struct modulecb),
525+ GFP_ATOMIC);
525526 if (wlc->modulecb == NULL) {
526527 *err = 1009;
527528 goto fail;
@@ -553,7 +554,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) · 25 unmodified lines
553554 }
554555
555556 wlc->bandstate[0] =
556− kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC);
557+ kcalloc(MAXBANDS, sizeof(struct brcms_band), GFP_ATOMIC);
557558 if (wlc->bandstate[0] == NULL) {
558559 *err = 1025;
559560 goto fail;
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c+4−4
@@ -1387,7 +1387,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, · 1386 unmodified lines
13871387 s16 *ptr;
13881388 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
13891389
1390− ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
1390+ ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC);
13911391 if (NULL == ptr)
13921392 return false;
13931393 if (module == 2) {
@@ -2670,7 +2670,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, · 1276 unmodified lines
26702670 u16 *values_to_save;
26712671 struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy;
26722672
2673− values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
2673+ values_to_save = kmalloc_array(20, sizeof(u16), GFP_ATOMIC);
26742674 if (NULL == values_to_save)
26752675 return;
26762676
@@ -3678,11 +3678,11 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, · 1001 unmodified lines
36783678 u16 *phy_c32;
36793679 phy_c21 = 0;
36803680 phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0;
3681− ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC);
3681+ ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC);
36823682 if (NULL == ptr)
36833683 return;
36843684
3685− phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC);
3685+ phy_c32 = kmalloc_array(20, sizeof(u16), GFP_ATOMIC);
36863686 if (NULL == phy_c32) {
36873687 kfree(ptr);
36883688 return;
drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c+3−2
@@ -23032,7 +23032,7 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, · 23031 unmodified lines
2303223032 u16 t;
2303323033 u32 *data_buf = NULL;
2303423034
23035− data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC);
23035+ data_buf = kmalloc_array(num_samps, sizeof(u32), GFP_ATOMIC);
2303623036 if (data_buf == NULL)
2303723037 return;
2303823038
@@ -23074,7 +23074,8 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, · 35 unmodified lines
2307423074 tbl_len = (phy_bw << 1);
2307523075 }
2307623076
23077− tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC);
23077+ tone_buf = kmalloc_array(tbl_len, sizeof(struct cordic_iq),
23078+ GFP_ATOMIC);
2307823079 if (tone_buf == NULL)
2307923080 return 0;
2308023081
drivers/net/wireless/cisco/airo.c+1−1
@@ -7127,7 +7127,7 @@ static int airo_get_aplist(struct net_device *dev, · 7126 unmodified lines
71277127 int i;
71287128 int loseSync = capable(CAP_NET_ADMIN) ? 1: -1;
71297129
7130− qual = kmalloc(IW_MAX_AP * sizeof(*qual), GFP_KERNEL);
7130+ qual = kmalloc_array(IW_MAX_AP, sizeof(*qual), GFP_KERNEL);
71317131 if (!qual)
71327132 return -ENOMEM;
71337133
drivers/net/wireless/intel/ipw2x00/ipw2100.c+6−5
@@ -3445,8 +3445,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) · 3444 unmodified lines
34453445 dma_addr_t p;
34463446
34473447 priv->msg_buffers =
3448− kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet),
3449− GFP_KERNEL);
3448+ kmalloc_array(IPW_COMMAND_POOL_SIZE,
3449+ sizeof(struct ipw2100_tx_packet),
3450+ GFP_KERNEL);
34503451 if (!priv->msg_buffers)
34513452 return -ENOMEM;
34523453
@@ -4587,9 +4588,9 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv) · 1134 unmodified lines
45874588 /*
45884589 * allocate packets
45894590 */
4590− priv->rx_buffers = kmalloc(RX_QUEUE_LENGTH *
4591− sizeof(struct ipw2100_rx_packet),
4592− GFP_KERNEL);
4591+ priv->rx_buffers = kmalloc_array(RX_QUEUE_LENGTH,
4592+ sizeof(struct ipw2100_rx_packet),
4593+ GFP_KERNEL);
45934594 if (!priv->rx_buffers) {
45944595 IPW_DEBUG_INFO("can't allocate rx packet buffer table\n");
45954596
drivers/net/wireless/intel/ipw2x00/ipw2200.c+5−5
@@ -3208,13 +3208,13 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) · 3207 unmodified lines
32083208
32093209 IPW_DEBUG_TRACE("<< :\n");
32103210
3211− virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL,
3212− GFP_KERNEL);
3211+ virts = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(void *),
3212+ GFP_KERNEL);
32133213 if (!virts)
32143214 return -ENOMEM;
32153215
3216− phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL,
3217− GFP_KERNEL);
3216+ phys = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(dma_addr_t),
3217+ GFP_KERNEL);
32183218 if (!phys) {
32193219 kfree(virts);
32203220 return -ENOMEM;
@@ -3782,7 +3782,7 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, · 561 unmodified lines
37823782 {
37833783 struct pci_dev *dev = priv->pci_dev;
37843784
3785− q->txb = kmalloc(sizeof(q->txb[0]) * count, GFP_KERNEL);
3785+ q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL);
37863786 if (!q->txb) {
37873787 IPW_ERROR("vmalloc for auxiliary BD structures failed\n");
37883788 return -ENOMEM;
drivers/net/wireless/intel/iwlegacy/common.c+7−6
@@ -922,7 +922,7 @@ il_init_channel_map(struct il_priv *il) · 921 unmodified lines
922922 D_EEPROM("Parsing data for %d channels.\n", il->channel_count);
923923
924924 il->channel_info =
925− kzalloc(sizeof(struct il_channel_info) * il->channel_count,
925+ kcalloc(il->channel_count, sizeof(struct il_channel_info),
926926 GFP_KERNEL);
927927 if (!il->channel_info) {
928928 IL_ERR("Could not allocate channel_info\n");
@@ -3041,9 +3041,9 @@ il_tx_queue_init(struct il_priv *il, u32 txq_id) · 2112 unmodified lines
30413041 }
30423042
30433043 txq->meta =
3044− kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL);
3044+ kcalloc(actual_slots, sizeof(struct il_cmd_meta), GFP_KERNEL);
30453045 txq->cmd =
3046− kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL);
3046+ kcalloc(actual_slots, sizeof(struct il_device_cmd *), GFP_KERNEL);
30473047
30483048 if (!txq->meta || !txq->cmd)
30493049 goto out_free_arrays;
@@ -3455,7 +3455,7 @@ il_init_geos(struct il_priv *il) · 405 unmodified lines
34553455 }
34563456
34573457 channels =
3458− kzalloc(sizeof(struct ieee80211_channel) * il->channel_count,
3458+ kcalloc(il->channel_count, sizeof(struct ieee80211_channel),
34593459 GFP_KERNEL);
34603460 if (!channels)
34613461 return -ENOMEM;
@@ -4654,8 +4654,9 @@ il_alloc_txq_mem(struct il_priv *il) · 1192 unmodified lines
46544654 {
46554655 if (!il->txq)
46564656 il->txq =
4657− kzalloc(sizeof(struct il_tx_queue) *
4658− il->cfg->num_of_queues, GFP_KERNEL);
4657+ kcalloc(il->cfg->num_of_queues,
4658+ sizeof(struct il_tx_queue),
4659+ GFP_KERNEL);
46594660 if (!il->txq) {
46604661 IL_ERR("Not enough memory for txq\n");
46614662 return -ENOMEM;
drivers/net/wireless/intel/iwlwifi/mvm/scan.c+1−1
@@ -564,7 +564,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm, · 563 unmodified lines
564564 else
565565 blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN;
566566
567− blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL);
567+ blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL);
568568 if (!blacklist)
569569 return -ENOMEM;
570570
drivers/net/wireless/intersil/hostap/hostap_info.c+3−2
@@ -271,8 +271,9 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf, · 270 unmodified lines
271271 left -= 4;
272272
273273 new_count = left / sizeof(struct hfa384x_scan_result);
274− results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result),
275− GFP_ATOMIC);
274+ results = kmalloc_array(new_count,
275+ sizeof(struct hfa384x_hostscan_result),
276+ GFP_ATOMIC);
276277 if (results == NULL)
277278 return;
278279
drivers/net/wireless/intersil/hostap/hostap_ioctl.c+2−2
@@ -513,8 +513,8 @@ static int prism2_ioctl_giwaplist(struct net_device *dev, · 512 unmodified lines
513513 return -EOPNOTSUPP;
514514 }
515515
516− addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL);
517− qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL);
516+ addr = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL);
517+ qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL);
518518 if (addr == NULL || qual == NULL) {
519519 kfree(addr);
520520 kfree(qual);
drivers/net/wireless/intersil/p54/eeprom.c+7−5
@@ -161,8 +161,9 @@ static int p54_generate_band(struct ieee80211_hw *dev, · 160 unmodified lines
161161 if (!tmp)
162162 goto err_out;
163163
164− tmp->channels = kzalloc(sizeof(struct ieee80211_channel) *
165− list->band_channel_num[band], GFP_KERNEL);
164+ tmp->channels = kcalloc(list->band_channel_num[band],
165+ sizeof(struct ieee80211_channel),
166+ GFP_KERNEL);
166167 if (!tmp->channels)
167168 goto err_out;
168169
@@ -344,7 +345,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) · 175 unmodified lines
344345 goto free;
345346 }
346347 priv->chan_num = max_channel_num;
347− priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num,
348+ priv->survey = kcalloc(max_channel_num, sizeof(struct survey_info),
348349 GFP_KERNEL);
349350 if (!priv->survey) {
350351 ret = -ENOMEM;
@@ -352,8 +353,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) · 1 unmodified line
352353 }
353354
354355 list->max_entries = max_channel_num;
355− list->channels = kzalloc(sizeof(struct p54_channel_entry) *
356− max_channel_num, GFP_KERNEL);
356+ list->channels = kcalloc(max_channel_num,
357+ sizeof(struct p54_channel_entry),
358+ GFP_KERNEL);
357359 if (!list->channels) {
358360 ret = -ENOMEM;
359361 goto free;
drivers/net/wireless/intersil/prism54/oid_mgt.c+1−1
@@ -244,7 +244,7 @@ mgt_init(islpci_private *priv) · 243 unmodified lines
244244 /* Alloc the cache */
245245 for (i = 0; i < OID_NUM_LAST; i++) {
246246 if (isl_oid[i].flags & OID_FLAG_CACHED) {
247− priv->mib[i] = kzalloc(isl_oid[i].size *
247+ priv->mib[i] = kcalloc(isl_oid[i].size,
248248 (isl_oid[i].range + 1),
249249 GFP_KERNEL);
250250 if (!priv->mib[i])
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c+2−2
@@ -399,8 +399,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, · 398 unmodified lines
399399
400400 new_node->win_size = win_size;
401401
402− new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size,
403− GFP_KERNEL);
402+ new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *),
403+ GFP_KERNEL);
404404 if (!new_node->rx_reorder_ptr) {
405405 kfree((u8 *) new_node);
406406 mwifiex_dbg(priv->adapter, ERROR,
drivers/net/wireless/marvell/mwifiex/cfg80211.c+2−2
@@ -4242,8 +4242,8 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter) · 4241 unmodified lines
42424242 * additional active scan request for hidden SSIDs on passive channels.
42434243 */
42444244 adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a);
4245− adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) *
4246− adapter->num_in_chan_stats);
4245+ adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats),
4246+ adapter->num_in_chan_stats));
42474247
42484248 if (!adapter->chan_stats)
42494249 return -ENOMEM;
drivers/net/wireless/marvell/mwifiex/sdio.c+5−4
@@ -2106,15 +2106,16 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) · 2105 unmodified lines
21062106 return -ENOMEM;
21072107
21082108 /* Allocate skb pointer buffers */
2109− card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) *
2110− card->mp_agg_pkt_limit, GFP_KERNEL);
2109+ card->mpa_rx.skb_arr = kcalloc(card->mp_agg_pkt_limit, sizeof(void *),
2110+ GFP_KERNEL);
21112111 if (!card->mpa_rx.skb_arr) {
21122112 kfree(card->mp_regs);
21132113 return -ENOMEM;
21142114 }
21152115
2116− card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) *
2117− card->mp_agg_pkt_limit, GFP_KERNEL);
2116+ card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit,
2117+ sizeof(*card->mpa_rx.len_arr),
2118+ GFP_KERNEL);
21182119 if (!card->mpa_rx.len_arr) {
21192120 kfree(card->mp_regs);
21202121 kfree(card->mpa_rx.skb_arr);
drivers/net/wireless/mediatek/mt76/mac80211.c+1−1
@@ -181,7 +181,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, · 180 unmodified lines
181181 if (!chanlist)
182182 return -ENOMEM;
183183
184− msband->chan = devm_kzalloc(dev->dev, n_chan * sizeof(*msband->chan),
184+ msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan),
185185 GFP_KERNEL);
186186 if (!msband->chan)
187187 return -ENOMEM;
drivers/net/wireless/quantenna/qtnfmac/commands.c+1−1
@@ -1216,7 +1216,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, · 1215 unmodified lines
12161216 return -EINVAL;
12171217 }
12181218
1219− limits = kzalloc(sizeof(*limits) * rec->n_limits,
1219+ limits = kcalloc(rec->n_limits, sizeof(*limits),
12201220 GFP_KERNEL);
12211221 if (!limits)
12221222 return -ENOMEM;
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c+1−1
@@ -397,7 +397,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file, · 396 unmodified lines
397397 if (*offset)
398398 return 0;
399399
400− data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL);
400+ data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL);
401401 if (!data)
402402 return -ENOMEM;
403403
drivers/net/wireless/realtek/rtlwifi/efuse.c+2−2
@@ -258,8 +258,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) · 257 unmodified lines
258258 }
259259
260260 /* allocate memory for efuse_tbl and efuse_word */
261− efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] *
262− sizeof(u8), GFP_ATOMIC);
261+ efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE],
262+ GFP_ATOMIC);
263263 if (!efuse_tbl)
264264 return;
265265 efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
drivers/net/wireless/realtek/rtlwifi/usb.c+1−1
@@ -1048,7 +1048,7 @@ int rtl_usb_probe(struct usb_interface *intf, · 1047 unmodified lines
10481048 }
10491049 rtlpriv = hw->priv;
10501050 rtlpriv->hw = hw;
1051− rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32),
1051+ rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32),
10521052 GFP_KERNEL);
10531053 if (!rtlpriv->usb_data)
10541054 return -ENOMEM;
drivers/net/wireless/st/cw1200/queue.c+5−5
@@ -154,7 +154,7 @@ int cw1200_queue_stats_init(struct cw1200_queue_stats *stats, · 153 unmodified lines
154154 spin_lock_init(&stats->lock);
155155 init_waitqueue_head(&stats->wait_link_id_empty);
156156
157− stats->link_map_cache = kzalloc(sizeof(int) * map_capacity,
157+ stats->link_map_cache = kcalloc(map_capacity, sizeof(int),
158158 GFP_KERNEL);
159159 if (!stats->link_map_cache)
160160 return -ENOMEM;
@@ -181,13 +181,13 @@ int cw1200_queue_init(struct cw1200_queue *queue, · 20 unmodified lines
181181 spin_lock_init(&queue->lock);
182182 timer_setup(&queue->gc, cw1200_queue_gc, 0);
183183
184− queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity,
185− GFP_KERNEL);
184+ queue->pool = kcalloc(capacity, sizeof(struct cw1200_queue_item),
185+ GFP_KERNEL);
186186 if (!queue->pool)
187187 return -ENOMEM;
188188
189− queue->link_map_cache = kzalloc(sizeof(int) * stats->map_capacity,
190− GFP_KERNEL);
189+ queue->link_map_cache = kcalloc(stats->map_capacity, sizeof(int),
190+ GFP_KERNEL);
191191 if (!queue->link_map_cache) {
192192 kfree(queue->pool);
193193 queue->pool = NULL;
drivers/net/wireless/st/cw1200/scan.c+3−3
@@ -230,9 +230,9 @@ void cw1200_scan_work(struct work_struct *work) · 229 unmodified lines
230230 scan.type = WSM_SCAN_TYPE_BACKGROUND;
231231 scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND;
232232 }
233− scan.ch = kzalloc(
234− sizeof(struct wsm_scan_ch) * (it - priv->scan.curr),
235− GFP_KERNEL);
233+ scan.ch = kcalloc(it - priv->scan.curr,
234+ sizeof(struct wsm_scan_ch),
235+ GFP_KERNEL);
236236 if (!scan.ch) {
237237 priv->scan.status = -ENOMEM;
238238 goto fail;
drivers/net/wireless/zydas/zd1211rw/zd_mac.c+2−1
@@ -732,7 +732,8 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, · 731 unmodified lines
732732
733733 /* Alloc memory for full beacon write at once. */
734734 num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len;
735− ioreqs = kmalloc(num_cmds * sizeof(struct zd_ioreq32), GFP_KERNEL);
735+ ioreqs = kmalloc_array(num_cmds, sizeof(struct zd_ioreq32),
736+ GFP_KERNEL);
736737 if (!ioreqs) {
737738 r = -ENOMEM;
738739 goto out_nofree;
drivers/net/xen-netback/xenbus.c+2−2
@@ -977,8 +977,8 @@ static void connect(struct backend_info *be) · 976 unmodified lines
977977 }
978978
979979 /* Use the number of queues requested by the frontend */
980− be->vif->queues = vzalloc(requested_num_queues *
981− sizeof(struct xenvif_queue));
980+ be->vif->queues = vzalloc(array_size(requested_num_queues,
981+ sizeof(struct xenvif_queue)));
982982 if (!be->vif->queues) {
983983 xenbus_dev_fatal(dev, -ENOMEM,
984984 "allocating queues");
drivers/nfc/fdp/i2c.c+2−2
@@ -259,8 +259,8 @@ static void fdp_nci_i2c_read_device_properties(struct device *dev, · 258 unmodified lines
259259 /* Add 1 to the length to inclue the length byte itself */
260260 len++;
261261
262− *fw_vsc_cfg = devm_kmalloc(dev,
263− len * sizeof(**fw_vsc_cfg),
262+ *fw_vsc_cfg = devm_kmalloc_array(dev,
263+ len, sizeof(**fw_vsc_cfg),
264264 GFP_KERNEL);
265265
266266 r = device_property_read_u8_array(dev, FDP_DP_FW_VSC_CFG_NAME,
drivers/ntb/hw/amd/ntb_hw_amd.c+2−2
@@ -592,12 +592,12 @@ static int ndev_init_isr(struct amd_ntb_dev *ndev, · 591 unmodified lines
592592 ndev->db_mask = ndev->db_valid_mask;
593593
594594 /* Try to set up msix irq */
595− ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
595+ ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
596596 GFP_KERNEL, node);
597597 if (!ndev->vec)
598598 goto err_msix_vec_alloc;
599599
600− ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
600+ ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
601601 GFP_KERNEL, node);
602602 if (!ndev->msix)
603603 goto err_msix_alloc;
drivers/ntb/hw/intel/ntb_hw_gen1.c+2−2
@@ -380,12 +380,12 @@ int ndev_init_isr(struct intel_ntb_dev *ndev, · 379 unmodified lines
380380
381381 /* Try to set up msix irq */
382382
383− ndev->vec = kzalloc_node(msix_max * sizeof(*ndev->vec),
383+ ndev->vec = kcalloc_node(msix_max, sizeof(*ndev->vec),
384384 GFP_KERNEL, node);
385385 if (!ndev->vec)
386386 goto err_msix_vec_alloc;
387387
388− ndev->msix = kzalloc_node(msix_max * sizeof(*ndev->msix),
388+ ndev->msix = kcalloc_node(msix_max, sizeof(*ndev->msix),
389389 GFP_KERNEL, node);
390390 if (!ndev->msix)
391391 goto err_msix_alloc;
drivers/ntb/ntb_transport.c+2−2
@@ -1102,7 +1102,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) · 1101 unmodified lines
11021102 max_mw_count_for_spads = (spad_count - MW0_SZ_HIGH) / 2;
11031103 nt->mw_count = min(mw_count, max_mw_count_for_spads);
11041104
1105− nt->mw_vec = kzalloc_node(mw_count * sizeof(*nt->mw_vec),
1105+ nt->mw_vec = kcalloc_node(mw_count, sizeof(*nt->mw_vec),
11061106 GFP_KERNEL, node);
11071107 if (!nt->mw_vec) {
11081108 rc = -ENOMEM;
@@ -1143,7 +1143,7 @@ static int ntb_transport_probe(struct ntb_client *self, struct ntb_dev *ndev) · 34 unmodified lines
11431143 nt->qp_bitmap = qp_bitmap;
11441144 nt->qp_bitmap_free = qp_bitmap;
11451145
1146− nt->qp_vec = kzalloc_node(qp_count * sizeof(*nt->qp_vec),
1146+ nt->qp_vec = kcalloc_node(qp_count, sizeof(*nt->qp_vec),
11471147 GFP_KERNEL, node);
11481148 if (!nt->qp_vec) {
11491149 rc = -ENOMEM;
drivers/nvmem/rockchip-efuse.c+4−2
@@ -122,7 +122,8 @@ static int rockchip_rk3328_efuse_read(void *context, unsigned int offset, · 121 unmodified lines
122122 addr_offset = offset % RK3399_NBYTES;
123123 addr_len = addr_end - addr_start;
124124
125− buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL);
125+ buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)),
126+ GFP_KERNEL);
126127 if (!buf) {
127128 ret = -ENOMEM;
128129 goto nomem;
@@ -174,7 +175,8 @@ static int rockchip_rk3399_efuse_read(void *context, unsigned int offset, · 45 unmodified lines
174175 addr_offset = offset % RK3399_NBYTES;
175176 addr_len = addr_end - addr_start;
176177
177− buf = kzalloc(sizeof(*buf) * addr_len * RK3399_NBYTES, GFP_KERNEL);
178+ buf = kzalloc(array3_size(addr_len, RK3399_NBYTES, sizeof(*buf)),
179+ GFP_KERNEL);
178180 if (!buf) {
179181 clk_disable_unprepare(efuse->clk);
180182 return -ENOMEM;
drivers/nvmem/sunxi_sid.c+1−1
@@ -185,7 +185,7 @@ static int sunxi_sid_probe(struct platform_device *pdev) · 184 unmodified lines
185185 if (IS_ERR(nvmem))
186186 return PTR_ERR(nvmem);
187187
188− randomness = kzalloc(sizeof(u8) * (size), GFP_KERNEL);
188+ randomness = kzalloc(size, GFP_KERNEL);
189189 if (!randomness) {
190190 ret = -EINVAL;
191191 goto err_unreg_nvmem;
drivers/of/platform.c+1−1
@@ -129,7 +129,7 @@ struct platform_device *of_device_alloc(struct device_node *np, · 128 unmodified lines
129129
130130 /* Populate the resource table */
131131 if (num_irq || num_reg) {
132− res = kzalloc(sizeof(*res) * (num_irq + num_reg), GFP_KERNEL);
132+ res = kcalloc(num_irq + num_reg, sizeof(*res), GFP_KERNEL);
133133 if (!res) {
134134 platform_device_put(dev);
135135 return NULL;
drivers/of/unittest.c+1−1
@@ -156,7 +156,7 @@ static void __init of_unittest_dynamic(void) · 155 unmodified lines
156156 }
157157
158158 /* Array of 4 properties for the purpose of testing */
159− prop = kzalloc(sizeof(*prop) * 4, GFP_KERNEL);
159+ prop = kcalloc(4, sizeof(*prop), GFP_KERNEL);
160160 if (!prop) {
161161 unittest(0, "kzalloc() failed\n");
162162 return;
drivers/opp/ti-opp-supply.c+2−2
@@ -122,8 +122,8 @@ static int _store_optimized_voltages(struct device *dev, · 121 unmodified lines
122122 goto out;
123123 }
124124
125− table = kzalloc(sizeof(*data->vdd_table) *
126− data->num_vdd_table, GFP_KERNEL);
125+ table = kcalloc(data->num_vdd_table, sizeof(*data->vdd_table),
126+ GFP_KERNEL);
127127 if (!table) {
128128 ret = -ENOMEM;
129129 goto out;
drivers/oprofile/event_buffer.c+1−1
@@ -91,7 +91,7 @@ int alloc_event_buffer(void) · 90 unmodified lines
9191 return -EINVAL;
9292
9393 buffer_pos = 0;
94− event_buffer = vmalloc(sizeof(unsigned long) * buffer_size);
94+ event_buffer = vmalloc(array_size(buffer_size, sizeof(unsigned long)));
9595 if (!event_buffer)
9696 return -ENOMEM;
9797
drivers/pci/controller/dwc/pci-dra7xx.c+2−2
@@ -639,11 +639,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) · 638 unmodified lines
639639 return phy_count;
640640 }
641641
642− phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
642+ phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
643643 if (!phy)
644644 return -ENOMEM;
645645
646− link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
646+ link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
647647 if (!link)
648648 return -ENOMEM;
649649
drivers/pci/controller/dwc/pcie-designware-ep.c+5−3
@@ -366,19 +366,21 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) · 365 unmodified lines
366366 return -EINVAL;
367367 }
368368
369− ep->ib_window_map = devm_kzalloc(dev, sizeof(long) *
369+ ep->ib_window_map = devm_kcalloc(dev,
370370 BITS_TO_LONGS(ep->num_ib_windows),
371+ sizeof(long),
371372 GFP_KERNEL);
372373 if (!ep->ib_window_map)
373374 return -ENOMEM;
374375
375− ep->ob_window_map = devm_kzalloc(dev, sizeof(long) *
376+ ep->ob_window_map = devm_kcalloc(dev,
376377 BITS_TO_LONGS(ep->num_ob_windows),
378+ sizeof(long),
377379 GFP_KERNEL);
378380 if (!ep->ob_window_map)
379381 return -ENOMEM;
380382
381− addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows,
383+ addr = devm_kcalloc(dev, ep->num_ob_windows, sizeof(phys_addr_t),
382384 GFP_KERNEL);
383385 if (!addr)
384386 return -ENOMEM;
drivers/pci/controller/pcie-cadence-ep.c+2−1
@@ -467,7 +467,8 @@ static int cdns_pcie_ep_probe(struct platform_device *pdev) · 466 unmodified lines
467467 dev_err(dev, "missing \"cdns,max-outbound-regions\"\n");
468468 return ret;
469469 }
470− ep->ob_addr = devm_kzalloc(dev, ep->max_regions * sizeof(*ep->ob_addr),
470+ ep->ob_addr = devm_kcalloc(dev,
471+ ep->max_regions, sizeof(*ep->ob_addr),
471472 GFP_KERNEL);
472473 if (!ep->ob_addr)
473474 return -ENOMEM;
drivers/pci/controller/pcie-rockchip-ep.c+1−1
@@ -593,7 +593,7 @@ static int rockchip_pcie_ep_probe(struct platform_device *pdev) · 592 unmodified lines
593593 PCIE_CLIENT_CONFIG);
594594
595595 max_regions = ep->max_regions;
596− ep->ob_addr = devm_kzalloc(dev, max_regions * sizeof(*ep->ob_addr),
596+ ep->ob_addr = devm_kcalloc(dev, max_regions, sizeof(*ep->ob_addr),
597597 GFP_KERNEL);
598598
599599 if (!ep->ob_addr) {
drivers/pci/msi.c+2−2
@@ -474,7 +474,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev) · 473 unmodified lines
474474 return 0;
475475
476476 /* Dynamically create the MSI attributes for the PCI device */
477− msi_attrs = kzalloc(sizeof(void *) * (num_msi + 1), GFP_KERNEL);
477+ msi_attrs = kcalloc(num_msi + 1, sizeof(void *), GFP_KERNEL);
478478 if (!msi_attrs)
479479 return -ENOMEM;
480480 for_each_pci_msi_entry(entry, pdev) {
@@ -501,7 +501,7 @@ static int populate_msi_sysfs(struct pci_dev *pdev) · 20 unmodified lines
501501 msi_irq_group->name = "msi_irqs";
502502 msi_irq_group->attrs = msi_attrs;
503503
504− msi_irq_groups = kzalloc(sizeof(void *) * 2, GFP_KERNEL);
504+ msi_irq_groups = kcalloc(2, sizeof(void *), GFP_KERNEL);
505505 if (!msi_irq_groups)
506506 goto error_irq_group;
507507 msi_irq_groups[0] = msi_irq_group;
drivers/pci/pci-sysfs.c+1−1
@@ -1076,7 +1076,7 @@ void pci_create_legacy_files(struct pci_bus *b) · 1075 unmodified lines
10761076 {
10771077 int error;
10781078
1079− b->legacy_io = kzalloc(sizeof(struct bin_attribute) * 2,
1079+ b->legacy_io = kcalloc(2, sizeof(struct bin_attribute),
10801080 GFP_ATOMIC);
10811081 if (!b->legacy_io)
10821082 goto kzalloc_err;
drivers/pcmcia/cistpl.c+2−2
@@ -1481,11 +1481,11 @@ static ssize_t pccard_extract_cis(struct pcmcia_socket *s, char *buf, · 1480 unmodified lines
14811481 u_char *tuplebuffer;
14821482 u_char *tempbuffer;
14831483
1484− tuplebuffer = kmalloc(sizeof(u_char) * 256, GFP_KERNEL);
1484+ tuplebuffer = kmalloc_array(256, sizeof(u_char), GFP_KERNEL);
14851485 if (!tuplebuffer)
14861486 return -ENOMEM;
14871487
1488− tempbuffer = kmalloc(sizeof(u_char) * 258, GFP_KERNEL);
1488+ tempbuffer = kmalloc_array(258, sizeof(u_char), GFP_KERNEL);
14891489 if (!tempbuffer) {
14901490 ret = -ENOMEM;
14911491 goto free_tuple;
drivers/pcmcia/pd6729.c+1−1
@@ -628,7 +628,7 @@ static int pd6729_pci_probe(struct pci_dev *dev, · 627 unmodified lines
628628 char configbyte;
629629 struct pd6729_socket *socket;
630630
631− socket = kzalloc(sizeof(struct pd6729_socket) * MAX_SOCKETS,
631+ socket = kcalloc(MAX_SOCKETS, sizeof(struct pd6729_socket),
632632 GFP_KERNEL);
633633 if (!socket) {
634634 dev_warn(&dev->dev, "failed to kzalloc socket.\n");
drivers/pinctrl/bcm/pinctrl-bcm2835.c+2−2
@@ -771,8 +771,8 @@ static int bcm2835_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, · 770 unmodified lines
771771 maps_per_pin++;
772772 if (num_pulls)
773773 maps_per_pin++;
774− cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps),
775− GFP_KERNEL);
774+ cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps),
775+ GFP_KERNEL);
776776 if (!maps)
777777 return -ENOMEM;
778778
drivers/pinctrl/berlin/berlin.c+6−4
@@ -216,8 +216,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) · 215 unmodified lines
216216 }
217217
218218 /* we will reallocate later */
219− pctrl->functions = devm_kzalloc(&pdev->dev,
220− max_functions * sizeof(*pctrl->functions),
219+ pctrl->functions = devm_kcalloc(&pdev->dev,
220+ max_functions,
221+ sizeof(*pctrl->functions),
221222 GFP_KERNEL);
222223 if (!pctrl->functions)
223224 return -ENOMEM;
@@ -261,8 +262,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) · 37 unmodified lines
261262
262263 if (!function->groups) {
263264 function->groups =
264− devm_kzalloc(&pdev->dev,
265− function->ngroups * sizeof(char *),
265+ devm_kcalloc(&pdev->dev,
266+ function->ngroups,
267+ sizeof(char *),
266268 GFP_KERNEL);
267269
268270 if (!function->groups)
drivers/pinctrl/freescale/pinctrl-imx.c+11−7
@@ -81,7 +81,8 @@ static int imx_dt_node_to_map(struct pinctrl_dev *pctldev, · 80 unmodified lines
8181 map_num++;
8282 }
8383
84− new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL);
84+ new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map),
85+ GFP_KERNEL);
8586 if (!new_map)
8687 return -ENOMEM;
8788
@@ -476,10 +477,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np, · 388 unmodified lines
476477 config = imx_pinconf_parse_generic_config(np, ipctl);
477478
478479 grp->num_pins = size / pin_size;
479− grp->data = devm_kzalloc(ipctl->dev, grp->num_pins *
480− sizeof(struct imx_pin), GFP_KERNEL);
481− grp->pins = devm_kzalloc(ipctl->dev, grp->num_pins *
482− sizeof(unsigned int), GFP_KERNEL);
480+ grp->data = devm_kcalloc(ipctl->dev,
481+ grp->num_pins, sizeof(struct imx_pin),
482+ GFP_KERNEL);
483+ grp->pins = devm_kcalloc(ipctl->dev,
484+ grp->num_pins, sizeof(unsigned int),
485+ GFP_KERNEL);
483486 if (!grp->pins || !grp->data)
484487 return -ENOMEM;
485488
@@ -697,8 +700,9 @@ int imx_pinctrl_probe(struct platform_device *pdev, · 211 unmodified lines
697700 if (!ipctl)
698701 return -ENOMEM;
699702
700− ipctl->pin_regs = devm_kmalloc(&pdev->dev, sizeof(*ipctl->pin_regs) *
701− info->npins, GFP_KERNEL);
703+ ipctl->pin_regs = devm_kmalloc_array(&pdev->dev,
704+ info->npins, sizeof(*ipctl->pin_regs),
705+ GFP_KERNEL);
702706 if (!ipctl->pin_regs)
703707 return -ENOMEM;
704708
drivers/pinctrl/freescale/pinctrl-imx1-core.c+12−11
@@ -241,7 +241,8 @@ static int imx1_dt_node_to_map(struct pinctrl_dev *pctldev, · 240 unmodified lines
241241 for (i = 0; i < grp->npins; i++)
242242 map_num++;
243243
244− new_map = kmalloc(sizeof(struct pinctrl_map) * map_num, GFP_KERNEL);
244+ new_map = kmalloc_array(map_num, sizeof(struct pinctrl_map),
245+ GFP_KERNEL);
245246 if (!new_map)
246247 return -ENOMEM;
247248
@@ -482,10 +483,10 @@ static int imx1_pinctrl_parse_groups(struct device_node *np, · 234 unmodified lines
482483 }
483484
484485 grp->npins = size / 12;
485− grp->pins = devm_kzalloc(info->dev,
486− grp->npins * sizeof(struct imx1_pin), GFP_KERNEL);
487− grp->pin_ids = devm_kzalloc(info->dev,
488− grp->npins * sizeof(unsigned int), GFP_KERNEL);
486+ grp->pins = devm_kcalloc(info->dev,
487+ grp->npins, sizeof(struct imx1_pin), GFP_KERNEL);
488+ grp->pin_ids = devm_kcalloc(info->dev,
489+ grp->npins, sizeof(unsigned int), GFP_KERNEL);
489490
490491 if (!grp->pins || !grp->pin_ids)
491492 return -ENOMEM;
@@ -522,8 +523,8 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, · 30 unmodified lines
522523 if (func->num_groups == 0)
523524 return -EINVAL;
524525
525− func->groups = devm_kzalloc(info->dev,
526− func->num_groups * sizeof(char *), GFP_KERNEL);
526+ func->groups = devm_kcalloc(info->dev,
527+ func->num_groups, sizeof(char *), GFP_KERNEL);
527528
528529 if (!func->groups)
529530 return -ENOMEM;
@@ -565,12 +566,12 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, · 35 unmodified lines
565566 }
566567
567568 info->nfunctions = nfuncs;
568− info->functions = devm_kzalloc(&pdev->dev,
569− nfuncs * sizeof(struct imx1_pmx_func), GFP_KERNEL);
569+ info->functions = devm_kcalloc(&pdev->dev,
570+ nfuncs, sizeof(struct imx1_pmx_func), GFP_KERNEL);
570571
571572 info->ngroups = ngroups;
572− info->groups = devm_kzalloc(&pdev->dev,
573− ngroups * sizeof(struct imx1_pin_group), GFP_KERNEL);
573+ info->groups = devm_kcalloc(&pdev->dev,
574+ ngroups, sizeof(struct imx1_pin_group), GFP_KERNEL);
574575
575576
576577 if (!info->functions || !info->groups)
drivers/pinctrl/freescale/pinctrl-mxs.c+12−8
@@ -89,7 +89,7 @@ static int mxs_dt_node_to_map(struct pinctrl_dev *pctldev, · 88 unmodified lines
8989 if (!purecfg && config)
9090 new_num = 2;
9191
92− new_map = kzalloc(sizeof(*new_map) * new_num, GFP_KERNEL);
92+ new_map = kcalloc(new_num, sizeof(*new_map), GFP_KERNEL);
9393 if (!new_map)
9494 return -ENOMEM;
9595
@@ -370,12 +370,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev, · 274 unmodified lines
370370 return -EINVAL;
371371 g->npins = length / sizeof(u32);
372372
373− g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins),
373+ g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins),
374374 GFP_KERNEL);
375375 if (!g->pins)
376376 return -ENOMEM;
377377
378− g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel),
378+ g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel),
379379 GFP_KERNEL);
380380 if (!g->muxsel)
381381 return -ENOMEM;
@@ -426,13 +426,16 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, · 44 unmodified lines
426426 }
427427 }
428428
429− soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions *
430− sizeof(*soc->functions), GFP_KERNEL);
429+ soc->functions = devm_kcalloc(&pdev->dev,
430+ soc->nfunctions,
431+ sizeof(*soc->functions),
432+ GFP_KERNEL);
431433 if (!soc->functions)
432434 return -ENOMEM;
433435
434− soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups *
435− sizeof(*soc->groups), GFP_KERNEL);
436+ soc->groups = devm_kcalloc(&pdev->dev,
437+ soc->ngroups, sizeof(*soc->groups),
438+ GFP_KERNEL);
436439 if (!soc->groups)
437440 return -ENOMEM;
438441
@@ -492,7 +495,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, · 53 unmodified lines
492495
493496 if (strcmp(fn, child->name)) {
494497 f = &soc->functions[idxf++];
495− f->groups = devm_kzalloc(&pdev->dev, f->ngroups *
498+ f->groups = devm_kcalloc(&pdev->dev,
499+ f->ngroups,
496500 sizeof(*f->groups),
497501 GFP_KERNEL);
498502 if (!f->groups)
drivers/pinctrl/mvebu/pinctrl-armada-37xx.c+13−8
@@ -856,9 +856,10 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) · 855 unmodified lines
856856 struct armada_37xx_pin_group *grp = &info->groups[n];
857857 int i, j, f;
858858
859− grp->pins = devm_kzalloc(info->dev,
860− (grp->npins + grp->extra_npins) *
861− sizeof(*grp->pins), GFP_KERNEL);
859+ grp->pins = devm_kcalloc(info->dev,
860+ grp->npins + grp->extra_npins,
861+ sizeof(*grp->pins),
862+ GFP_KERNEL);
862863 if (!grp->pins)
863864 return -ENOMEM;
864865
@@ -908,7 +909,8 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) · 43 unmodified lines
908909 const char **groups;
909910 int g;
910911
911− funcs[n].groups = devm_kzalloc(info->dev, funcs[n].ngroups *
912+ funcs[n].groups = devm_kcalloc(info->dev,
913+ funcs[n].ngroups,
912914 sizeof(*(funcs[n].groups)),
913915 GFP_KERNEL);
914916 if (!funcs[n].groups)
@@ -948,8 +950,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, · 33 unmodified lines
948950 ctrldesc->pmxops = &armada_37xx_pmx_ops;
949951 ctrldesc->confops = &armada_37xx_pinconf_ops;
950952
951− pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
952− pin_data->nr_pins, GFP_KERNEL);
953+ pindesc = devm_kcalloc(&pdev->dev,
954+ pin_data->nr_pins, sizeof(*pindesc),
955+ GFP_KERNEL);
953956 if (!pindesc)
954957 return -ENOMEM;
955958
@@ -968,8 +971,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, · 12 unmodified lines
968971 * we allocate functions for number of pins and hope there are
969972 * fewer unique functions than pins available
970973 */
971− info->funcs = devm_kzalloc(&pdev->dev, pin_data->nr_pins *
972− sizeof(struct armada_37xx_pmx_func), GFP_KERNEL);
974+ info->funcs = devm_kcalloc(&pdev->dev,
975+ pin_data->nr_pins,
976+ sizeof(struct armada_37xx_pmx_func),
977+ GFP_KERNEL);
973978 if (!info->funcs)
974979 return -ENOMEM;
975980
drivers/pinctrl/mvebu/pinctrl-armada-xp.c+2−2
@@ -630,8 +630,8 @@ static int armada_xp_pinctrl_probe(struct platform_device *pdev) · 629 unmodified lines
630630
631631 nregs = DIV_ROUND_UP(soc->nmodes, MVEBU_MPPS_PER_REG);
632632
633− mpp_saved_regs = devm_kmalloc(&pdev->dev, nregs * sizeof(u32),
634− GFP_KERNEL);
633+ mpp_saved_regs = devm_kmalloc_array(&pdev->dev, nregs, sizeof(u32),
634+ GFP_KERNEL);
635635 if (!mpp_saved_regs)
636636 return -ENOMEM;
637637
drivers/pinctrl/mvebu/pinctrl-mvebu.c+10−6
@@ -501,8 +501,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, · 500 unmodified lines
501501
502502 /* we allocate functions for number of pins and hope
503503 * there are fewer unique functions than pins available */
504− funcs = devm_kzalloc(&pdev->dev, funcsize *
505− sizeof(struct mvebu_pinctrl_function), GFP_KERNEL);
504+ funcs = devm_kcalloc(&pdev->dev,
505+ funcsize, sizeof(struct mvebu_pinctrl_function),
506+ GFP_KERNEL);
506507 if (!funcs)
507508 return -ENOMEM;
508509
@@ -549,8 +550,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, · 40 unmodified lines
549550
550551 /* allocate group name array if not done already */
551552 if (!f->groups) {
552− f->groups = devm_kzalloc(&pdev->dev,
553− f->num_groups * sizeof(char *),
553+ f->groups = devm_kcalloc(&pdev->dev,
554+ f->num_groups,
555+ sizeof(char *),
554556 GFP_KERNEL);
555557 if (!f->groups)
556558 return -ENOMEM;
@@ -622,8 +624,10 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) · 65 unmodified lines
622624 }
623625 }
624626
625− pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins *
626− sizeof(struct pinctrl_pin_desc), GFP_KERNEL);
627+ pdesc = devm_kcalloc(&pdev->dev,
628+ pctl->desc.npins,
629+ sizeof(struct pinctrl_pin_desc),
630+ GFP_KERNEL);
627631 if (!pdesc)
628632 return -ENOMEM;
629633
drivers/pinctrl/pinctrl-at91-pio4.c+23−16
@@ -945,27 +945,30 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) · 944 unmodified lines
945945 return PTR_ERR(atmel_pioctrl->clk);
946946 }
947947
948− atmel_pioctrl->pins = devm_kzalloc(dev, sizeof(*atmel_pioctrl->pins)
949− * atmel_pioctrl->npins, GFP_KERNEL);
948+ atmel_pioctrl->pins = devm_kcalloc(dev,
949+ atmel_pioctrl->npins,
950+ sizeof(*atmel_pioctrl->pins),
951+ GFP_KERNEL);
950952 if (!atmel_pioctrl->pins)
951953 return -ENOMEM;
952954
953− pin_desc = devm_kzalloc(dev, sizeof(*pin_desc)
954− * atmel_pioctrl->npins, GFP_KERNEL);
955+ pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc),
956+ GFP_KERNEL);
955957 if (!pin_desc)
956958 return -ENOMEM;
957959 atmel_pinctrl_desc.pins = pin_desc;
958960 atmel_pinctrl_desc.npins = atmel_pioctrl->npins;
959961
960962 /* One pin is one group since a pin can achieve all functions. */
961− group_names = devm_kzalloc(dev, sizeof(*group_names)
962− * atmel_pioctrl->npins, GFP_KERNEL);
963+ group_names = devm_kcalloc(dev,
964+ atmel_pioctrl->npins, sizeof(*group_names),
965+ GFP_KERNEL);
963966 if (!group_names)
964967 return -ENOMEM;
965968 atmel_pioctrl->group_names = group_names;
966969
967− atmel_pioctrl->groups = devm_kzalloc(&pdev->dev,
968− sizeof(*atmel_pioctrl->groups) * atmel_pioctrl->npins,
970+ atmel_pioctrl->groups = devm_kcalloc(&pdev->dev,
971+ atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups),
969972 GFP_KERNEL);
970973 if (!atmel_pioctrl->groups)
971974 return -ENOMEM;
@@ -1001,20 +1004,24 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) · 29 unmodified lines
10011004 atmel_pioctrl->gpio_chip->parent = dev;
10021005 atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names;
10031006
1004− atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev,
1005− sizeof(*atmel_pioctrl->pm_wakeup_sources)
1006− * atmel_pioctrl->nbanks, GFP_KERNEL);
1007+ atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev,
1008+ atmel_pioctrl->nbanks,
1009+ sizeof(*atmel_pioctrl->pm_wakeup_sources),
1010+ GFP_KERNEL);
10071011 if (!atmel_pioctrl->pm_wakeup_sources)
10081012 return -ENOMEM;
10091013
1010− atmel_pioctrl->pm_suspend_backup = devm_kzalloc(dev,
1011− sizeof(*atmel_pioctrl->pm_suspend_backup)
1012− * atmel_pioctrl->nbanks, GFP_KERNEL);
1014+ atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev,
1015+ atmel_pioctrl->nbanks,
1016+ sizeof(*atmel_pioctrl->pm_suspend_backup),
1017+ GFP_KERNEL);
10131018 if (!atmel_pioctrl->pm_suspend_backup)
10141019 return -ENOMEM;
10151020
1016− atmel_pioctrl->irqs = devm_kzalloc(dev, sizeof(*atmel_pioctrl->irqs)
1017− * atmel_pioctrl->nbanks, GFP_KERNEL);
1021+ atmel_pioctrl->irqs = devm_kcalloc(dev,
1022+ atmel_pioctrl->nbanks,
1023+ sizeof(*atmel_pioctrl->irqs),
1024+ GFP_KERNEL);
10181025 if (!atmel_pioctrl->irqs)
10191026 return -ENOMEM;
10201027
drivers/pinctrl/pinctrl-at91.c+22−12
@@ -269,7 +269,8 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, · 268 unmodified lines
269269 }
270270
271271 map_num += grp->npins;
272− new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL);
272+ new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
273+ GFP_KERNEL);
273274 if (!new_map)
274275 return -ENOMEM;
275276
@@ -1049,7 +1050,8 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info, · 773 unmodified lines
10491050 }
10501051 info->nmux = size / gpio_banks;
10511052
1052− info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL);
1053+ info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32),
1054+ GFP_KERNEL);
10531055 if (!info->mux_mask)
10541056 return -ENOMEM;
10551057
@@ -1087,10 +1089,12 @@ static int at91_pinctrl_parse_groups(struct device_node *np, · 31 unmodified lines
10871089 }
10881090
10891091 grp->npins = size / 4;
1090− pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin),
1091− GFP_KERNEL);
1092− grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
1093− GFP_KERNEL);
1092+ pin = grp->pins_conf = devm_kcalloc(info->dev,
1093+ grp->npins,
1094+ sizeof(struct at91_pmx_pin),
1095+ GFP_KERNEL);
1096+ grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
1097+ GFP_KERNEL);
10941098 if (!grp->pins_conf || !grp->pins)
10951099 return -ENOMEM;
10961100
@@ -1129,8 +1133,8 @@ static int at91_pinctrl_parse_functions(struct device_node *np, · 32 unmodified lines
11291133 dev_err(info->dev, "no groups defined\n");
11301134 return -EINVAL;
11311135 }
1132− func->groups = devm_kzalloc(info->dev,
1133− func->ngroups * sizeof(char *), GFP_KERNEL);
1136+ func->groups = devm_kcalloc(info->dev,
1137+ func->ngroups, sizeof(char *), GFP_KERNEL);
11341138 if (!func->groups)
11351139 return -ENOMEM;
11361140
@@ -1192,12 +1196,16 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, · 55 unmodified lines
11921196
11931197 dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
11941198 dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
1195− info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func),
1199+ info->functions = devm_kcalloc(&pdev->dev,
1200+ info->nfunctions,
1201+ sizeof(struct at91_pmx_func),
11961202 GFP_KERNEL);
11971203 if (!info->functions)
11981204 return -ENOMEM;
11991205
1200− info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group),
1206+ info->groups = devm_kcalloc(&pdev->dev,
1207+ info->ngroups,
1208+ sizeof(struct at91_pin_group),
12011209 GFP_KERNEL);
12021210 if (!info->groups)
12031211 return -ENOMEM;
@@ -1256,7 +1264,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev) · 52 unmodified lines
12561264 at91_pinctrl_desc.name = dev_name(&pdev->dev);
12571265 at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK;
12581266 at91_pinctrl_desc.pins = pdesc =
1259− devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL);
1267+ devm_kcalloc(&pdev->dev,
1268+ at91_pinctrl_desc.npins, sizeof(*pdesc),
1269+ GFP_KERNEL);
12601270
12611271 if (!at91_pinctrl_desc.pins)
12621272 return -ENOMEM;
@@ -1763,7 +1773,7 @@ static int at91_gpio_probe(struct platform_device *pdev) · 500 unmodified lines
17631773 chip->ngpio = ngpio;
17641774 }
17651775
1766− names = devm_kzalloc(&pdev->dev, sizeof(char *) * chip->ngpio,
1776+ names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *),
17671777 GFP_KERNEL);
17681778
17691779 if (!names) {
drivers/pinctrl/pinctrl-axp209.c+4−3
@@ -328,7 +328,8 @@ static void axp20x_funcs_groups_from_mask(struct device *dev, unsigned int mask, · 327 unmodified lines
328328
329329 func->ngroups = ngroups;
330330 if (func->ngroups > 0) {
331− func->groups = devm_kzalloc(dev, ngroups * sizeof(const char *),
331+ func->groups = devm_kcalloc(dev,
332+ ngroups, sizeof(const char *),
332333 GFP_KERNEL);
333334 group = func->groups;
334335 for_each_set_bit(bit, &mask_cpy, mask_len) {
@@ -358,8 +359,8 @@ static void axp20x_build_funcs_groups(struct platform_device *pdev) · 23 unmodified lines
358359 /* Every pin supports GPIO_OUT and GPIO_IN functions */
359360 for (i = 0; i <= AXP20X_FUNC_GPIO_IN; i++) {
360361 pctl->funcs[i].ngroups = npins;
361− pctl->funcs[i].groups = devm_kzalloc(&pdev->dev,
362− npins * sizeof(char *),
362+ pctl->funcs[i].groups = devm_kcalloc(&pdev->dev,
363+ npins, sizeof(char *),
363364 GFP_KERNEL);
364365 for (pin = 0; pin < npins; pin++)
365366 pctl->funcs[i].groups[pin] = pctl->desc->pins[pin].name;
drivers/pinctrl/pinctrl-digicolor.c+3−2
@@ -291,10 +291,11 @@ static int dc_pinctrl_probe(struct platform_device *pdev) · 290 unmodified lines
291291 if (IS_ERR(pmap->regs))
292292 return PTR_ERR(pmap->regs);
293293
294− pins = devm_kzalloc(&pdev->dev, sizeof(*pins)*PINS_COUNT, GFP_KERNEL);
294+ pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins),
295+ GFP_KERNEL);
295296 if (!pins)
296297 return -ENOMEM;
297− pin_names = devm_kzalloc(&pdev->dev, name_len * PINS_COUNT,
298+ pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len,
298299 GFP_KERNEL);
299300 if (!pin_names)
300301 return -ENOMEM;
drivers/pinctrl/pinctrl-ingenic.c+2−2
@@ -770,8 +770,8 @@ static int ingenic_pinctrl_probe(struct platform_device *pdev) · 769 unmodified lines
770770 pctl_desc->pmxops = &ingenic_pmxops;
771771 pctl_desc->confops = &ingenic_confops;
772772 pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP;
773− pctl_desc->pins = jzpc->pdesc = devm_kzalloc(&pdev->dev,
774− sizeof(*jzpc->pdesc) * pctl_desc->npins, GFP_KERNEL);
773+ pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev,
774+ pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL);
775775 if (!jzpc->pdesc)
776776 return -ENOMEM;
777777
drivers/pinctrl/pinctrl-lantiq.c+2−1
@@ -158,7 +158,8 @@ static int ltq_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, · 157 unmodified lines
158158
159159 for_each_child_of_node(np_config, np)
160160 max_maps += ltq_pinctrl_dt_subnode_size(np);
161− *map = kzalloc(max_maps * sizeof(struct pinctrl_map) * 2, GFP_KERNEL);
161+ *map = kzalloc(array3_size(max_maps, sizeof(struct pinctrl_map), 2),
162+ GFP_KERNEL);
162163 if (!*map)
163164 return -ENOMEM;
164165 tmp = *map;
drivers/pinctrl/pinctrl-lpc18xx.c+3−2
@@ -1308,8 +1308,9 @@ static int lpc18xx_create_group_func_map(struct device *dev, · 1307 unmodified lines
13081308 }
13091309
13101310 scu->func[func].ngroups = ngroups;
1311− scu->func[func].groups = devm_kzalloc(dev, ngroups *
1312− sizeof(char *), GFP_KERNEL);
1311+ scu->func[func].groups = devm_kcalloc(dev,
1312+ ngroups, sizeof(char *),
1313+ GFP_KERNEL);
13131314 if (!scu->func[func].groups)
13141315 return -ENOMEM;
13151316
drivers/pinctrl/pinctrl-ocelot.c+2−1
@@ -330,7 +330,8 @@ static int ocelot_create_group_func_map(struct device *dev, · 329 unmodified lines
330330 }
331331
332332 info->func[f].ngroups = npins;
333− info->func[f].groups = devm_kzalloc(dev, npins *
333+ info->func[f].groups = devm_kcalloc(dev,
334+ npins,
334335 sizeof(char *),
335336 GFP_KERNEL);
336337 if (!info->func[f].groups)
drivers/pinctrl/pinctrl-rockchip.c+14−10
@@ -507,7 +507,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, · 506 unmodified lines
507507 }
508508
509509 map_num += grp->npins;
510− new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num,
510+ new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map),
511511 GFP_KERNEL);
512512 if (!new_map)
513513 return -ENOMEM;
@@ -2473,10 +2473,11 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, · 1959 unmodified lines
24732473
24742474 grp->npins = size / 4;
24752475
2476− grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int),
2476+ grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int),
24772477 GFP_KERNEL);
2478− grp->data = devm_kzalloc(info->dev, grp->npins *
2479− sizeof(struct rockchip_pin_config),
2478+ grp->data = devm_kcalloc(info->dev,
2479+ grp->npins,
2480+ sizeof(struct rockchip_pin_config),
24802481 GFP_KERNEL);
24812482 if (!grp->pins || !grp->data)
24822483 return -ENOMEM;
@@ -2528,8 +2529,8 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, · 45 unmodified lines
25282529 if (func->ngroups <= 0)
25292530 return 0;
25302531
2531− func->groups = devm_kzalloc(info->dev,
2532− func->ngroups * sizeof(char *), GFP_KERNEL);
2532+ func->groups = devm_kcalloc(info->dev,
2533+ func->ngroups, sizeof(char *), GFP_KERNEL);
25332534 if (!func->groups)
25342535 return -ENOMEM;
25352536
@@ -2560,13 +2561,15 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, · 24 unmodified lines
25602561 dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
25612562 dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups);
25622563
2563− info->functions = devm_kzalloc(dev, info->nfunctions *
2564+ info->functions = devm_kcalloc(dev,
2565+ info->nfunctions,
25642566 sizeof(struct rockchip_pmx_func),
25652567 GFP_KERNEL);
25662568 if (!info->functions)
25672569 return -EINVAL;
25682570
2569− info->groups = devm_kzalloc(dev, info->ngroups *
2571+ info->groups = devm_kcalloc(dev,
2572+ info->ngroups,
25702573 sizeof(struct rockchip_pin_group),
25712574 GFP_KERNEL);
25722575 if (!info->groups)
@@ -2604,8 +2607,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, · 31 unmodified lines
26042607 ctrldesc->pmxops = &rockchip_pmx_ops;
26052608 ctrldesc->confops = &rockchip_pinconf_ops;
26062609
2607− pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
2608− info->ctrl->nr_pins, GFP_KERNEL);
2610+ pindesc = devm_kcalloc(&pdev->dev,
2611+ info->ctrl->nr_pins, sizeof(*pindesc),
2612+ GFP_KERNEL);
26092613 if (!pindesc)
26102614 return -ENOMEM;
26112615
drivers/pinctrl/pinctrl-single.c+14−12
@@ -712,8 +712,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) · 711 unmodified lines
712712 }
713713
714714 dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins);
715− pcs->pins.pa = devm_kzalloc(pcs->dev,
716− sizeof(*pcs->pins.pa) * nr_pins,
715+ pcs->pins.pa = devm_kcalloc(pcs->dev,
716+ nr_pins, sizeof(*pcs->pins.pa),
717717 GFP_KERNEL);
718718 if (!pcs->pins.pa)
719719 return -ENOMEM;
@@ -924,15 +924,15 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, · 204 unmodified lines
924924 if (!nconfs)
925925 return 0;
926926
927− func->conf = devm_kzalloc(pcs->dev,
928− sizeof(struct pcs_conf_vals) * nconfs,
927+ func->conf = devm_kcalloc(pcs->dev,
928+ nconfs, sizeof(struct pcs_conf_vals),
929929 GFP_KERNEL);
930930 if (!func->conf)
931931 return -ENOMEM;
932932 func->nconfs = nconfs;
933933 conf = &(func->conf[0]);
934934 m++;
935− settings = devm_kzalloc(pcs->dev, sizeof(unsigned long) * nconfs,
935+ settings = devm_kcalloc(pcs->dev, nconfs, sizeof(unsigned long),
936936 GFP_KERNEL);
937937 if (!settings)
938938 return -ENOMEM;
@@ -988,11 +988,11 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, · 49 unmodified lines
988988 return -EINVAL;
989989 }
990990
991− vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL);
991+ vals = devm_kcalloc(pcs->dev, rows, sizeof(*vals), GFP_KERNEL);
992992 if (!vals)
993993 return -ENOMEM;
994994
995− pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows, GFP_KERNEL);
995+ pins = devm_kcalloc(pcs->dev, rows, sizeof(*pins), GFP_KERNEL);
996996 if (!pins)
997997 goto free_vals;
998998
@@ -1089,13 +1089,15 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, · 90 unmodified lines
10891089
10901090 npins_in_row = pcs->width / pcs->bits_per_pin;
10911091
1092− vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row,
1093− GFP_KERNEL);
1092+ vals = devm_kzalloc(pcs->dev,
1093+ array3_size(rows, npins_in_row, sizeof(*vals)),
1094+ GFP_KERNEL);
10941095 if (!vals)
10951096 return -ENOMEM;
10961097
1097− pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows * npins_in_row,
1098− GFP_KERNEL);
1098+ pins = devm_kzalloc(pcs->dev,
1099+ array3_size(rows, npins_in_row, sizeof(*pins)),
1100+ GFP_KERNEL);
10991101 if (!pins)
11001102 goto free_vals;
11011103
@@ -1217,7 +1219,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev, · 115 unmodified lines
12171219 pcs = pinctrl_dev_get_drvdata(pctldev);
12181220
12191221 /* create 2 maps. One is for pinmux, and the other is for pinconf. */
1220− *map = devm_kzalloc(pcs->dev, sizeof(**map) * 2, GFP_KERNEL);
1222+ *map = devm_kcalloc(pcs->dev, 2, sizeof(**map), GFP_KERNEL);
12211223 if (!*map)
12221224 return -ENOMEM;
12231225
drivers/pinctrl/pinctrl-st.c+16−15
@@ -823,8 +823,8 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, · 822 unmodified lines
823823 }
824824
825825 map_num = grp->npins + 1;
826− new_map = devm_kzalloc(pctldev->dev,
827− sizeof(*new_map) * map_num, GFP_KERNEL);
826+ new_map = devm_kcalloc(pctldev->dev,
827+ map_num, sizeof(*new_map), GFP_KERNEL);
828828 if (!new_map)
829829 return -ENOMEM;
830830
@@ -1191,9 +1191,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np, · 360 unmodified lines
11911191
11921192 grp->npins = npins;
11931193 grp->name = np->name;
1194− grp->pins = devm_kzalloc(info->dev, npins * sizeof(u32), GFP_KERNEL);
1195− grp->pin_conf = devm_kzalloc(info->dev,
1196− npins * sizeof(*conf), GFP_KERNEL);
1194+ grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL);
1195+ grp->pin_conf = devm_kcalloc(info->dev,
1196+ npins, sizeof(*conf), GFP_KERNEL);
11971197
11981198 if (!grp->pins || !grp->pin_conf)
11991199 return -ENOMEM;
@@ -1249,8 +1249,8 @@ static int st_pctl_parse_functions(struct device_node *np, · 49 unmodified lines
12491249 dev_err(info->dev, "No groups defined\n");
12501250 return -EINVAL;
12511251 }
1252− func->groups = devm_kzalloc(info->dev,
1253− func->ngroups * sizeof(char *), GFP_KERNEL);
1252+ func->groups = devm_kcalloc(info->dev,
1253+ func->ngroups, sizeof(char *), GFP_KERNEL);
12541254 if (!func->groups)
12551255 return -ENOMEM;
12561256
@@ -1573,14 +1573,15 @@ static int st_pctl_probe_dt(struct platform_device *pdev, · 316 unmodified lines
15731573 dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions);
15741574 dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups);
15751575
1576− info->functions = devm_kzalloc(&pdev->dev,
1577− info->nfunctions * sizeof(*info->functions), GFP_KERNEL);
1576+ info->functions = devm_kcalloc(&pdev->dev,
1577+ info->nfunctions, sizeof(*info->functions), GFP_KERNEL);
15781578
1579− info->groups = devm_kzalloc(&pdev->dev,
1580− info->ngroups * sizeof(*info->groups) , GFP_KERNEL);
1579+ info->groups = devm_kcalloc(&pdev->dev,
1580+ info->ngroups, sizeof(*info->groups),
1581+ GFP_KERNEL);
15811582
1582− info->banks = devm_kzalloc(&pdev->dev,
1583− info->nbanks * sizeof(*info->banks), GFP_KERNEL);
1583+ info->banks = devm_kcalloc(&pdev->dev,
1584+ info->nbanks, sizeof(*info->banks), GFP_KERNEL);
15841585
15851586 if (!info->functions || !info->groups || !info->banks)
15861587 return -ENOMEM;
@@ -1608,8 +1609,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, · 21 unmodified lines
16081609 }
16091610
16101611 pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK;
1611− pdesc = devm_kzalloc(&pdev->dev,
1612− sizeof(*pdesc) * pctl_desc->npins, GFP_KERNEL);
1612+ pdesc = devm_kcalloc(&pdev->dev,
1613+ pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL);
16131614 if (!pdesc)
16141615 return -ENOMEM;
16151616
drivers/pinctrl/pinctrl-xway.c+2−2
@@ -1727,8 +1727,8 @@ static int pinmux_xway_probe(struct platform_device *pdev) · 1726 unmodified lines
17271727 xway_chip.ngpio = xway_soc->pin_count;
17281728
17291729 /* load our pad descriptors */
1730− xway_info.pads = devm_kzalloc(&pdev->dev,
1731− sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio,
1730+ xway_info.pads = devm_kcalloc(&pdev->dev,
1731+ xway_chip.ngpio, sizeof(struct pinctrl_pin_desc),
17321732 GFP_KERNEL);
17331733 if (!xway_info.pads)
17341734 return -ENOMEM;
drivers/pinctrl/samsung/pinctrl-exynos.c+3−2
@@ -491,8 +491,9 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) · 490 unmodified lines
491491 continue;
492492 }
493493
494− weint_data = devm_kzalloc(dev, bank->nr_pins
495− * sizeof(*weint_data), GFP_KERNEL);
494+ weint_data = devm_kcalloc(dev,
495+ bank->nr_pins, sizeof(*weint_data),
496+ GFP_KERNEL);
496497 if (!weint_data)
497498 return -ENOMEM;
498499
drivers/pinctrl/samsung/pinctrl-samsung.c+10−7
@@ -674,7 +674,7 @@ static struct samsung_pin_group *samsung_pinctrl_create_groups( · 673 unmodified lines
674674 const struct pinctrl_pin_desc *pdesc;
675675 int i;
676676
677− groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups),
677+ groups = devm_kcalloc(dev, ctrldesc->npins, sizeof(*groups),
678678 GFP_KERNEL);
679679 if (!groups)
680680 return ERR_PTR(-EINVAL);
@@ -711,7 +711,7 @@ static int samsung_pinctrl_create_function(struct device *dev, · 30 unmodified lines
711711
712712 func->name = func_np->full_name;
713713
714− func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL);
714+ func->groups = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL);
715715 if (!func->groups)
716716 return -ENOMEM;
717717
@@ -768,7 +768,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions( · 50 unmodified lines
768768 }
769769 }
770770
771− functions = devm_kzalloc(dev, func_cnt * sizeof(*functions),
771+ functions = devm_kcalloc(dev, func_cnt, sizeof(*functions),
772772 GFP_KERNEL);
773773 if (!functions)
774774 return ERR_PTR(-ENOMEM);
@@ -860,8 +860,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev, · 85 unmodified lines
860860 ctrldesc->pmxops = &samsung_pinmux_ops;
861861 ctrldesc->confops = &samsung_pinconf_ops;
862862
863− pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) *
864− drvdata->nr_pins, GFP_KERNEL);
863+ pindesc = devm_kcalloc(&pdev->dev,
864+ drvdata->nr_pins, sizeof(*pindesc),
865+ GFP_KERNEL);
865866 if (!pindesc)
866867 return -ENOMEM;
867868 ctrldesc->pins = pindesc;
@@ -875,8 +876,10 @@ static int samsung_pinctrl_register(struct platform_device *pdev, · 7 unmodified lines
875876 * allocate space for storing the dynamically generated names for all
876877 * the pins which belong to this pin-controller.
877878 */
878− pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH *
879− drvdata->nr_pins, GFP_KERNEL);
879+ pin_names = devm_kzalloc(&pdev->dev,
880+ array3_size(sizeof(char), PIN_NAME_LENGTH,
881+ drvdata->nr_pins),
882+ GFP_KERNEL);
880883 if (!pin_names)
881884 return -ENOMEM;
882885
drivers/pinctrl/sh-pfc/core.c+3−3
@@ -57,7 +57,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, · 56 unmodified lines
5757 return -EINVAL;
5858
5959 /* Allocate memory windows and IRQs arrays. */
60− windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows),
60+ windows = devm_kcalloc(pfc->dev, num_windows, sizeof(*windows),
6161 GFP_KERNEL);
6262 if (windows == NULL)
6363 return -ENOMEM;
@@ -66,7 +66,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, · 2 unmodified lines
6666 pfc->windows = windows;
6767
6868 if (num_irqs) {
69− irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs),
69+ irqs = devm_kcalloc(pfc->dev, num_irqs, sizeof(*irqs),
7070 GFP_KERNEL);
7171 if (irqs == NULL)
7272 return -ENOMEM;
@@ -444,7 +444,7 @@ static int sh_pfc_init_ranges(struct sh_pfc *pfc) · 371 unmodified lines
444444 }
445445
446446 pfc->nr_ranges = nr_ranges;
447− pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges,
447+ pfc->ranges = devm_kcalloc(pfc->dev, nr_ranges, sizeof(*pfc->ranges),
448448 GFP_KERNEL);
449449 if (pfc->ranges == NULL)
450450 return -ENOMEM;
drivers/pinctrl/sh-pfc/gpio.c+4−3
@@ -107,7 +107,7 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip) · 106 unmodified lines
107107 for (i = 0; pfc->info->data_regs[i].reg_width; ++i)
108108 ;
109109
110− chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs),
110+ chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs),
111111 GFP_KERNEL);
112112 if (chip->regs == NULL)
113113 return -ENOMEM;
@@ -224,8 +224,9 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip) · 110 unmodified lines
224224 struct gpio_chip *gc = &chip->gpio_chip;
225225 int ret;
226226
227− chip->pins = devm_kzalloc(pfc->dev, pfc->info->nr_pins *
228− sizeof(*chip->pins), GFP_KERNEL);
227+ chip->pins = devm_kcalloc(pfc->dev,
228+ pfc->info->nr_pins, sizeof(*chip->pins),
229+ GFP_KERNEL);
229230 if (chip->pins == NULL)
230231 return -ENOMEM;
231232
drivers/pinctrl/sh-pfc/pinctrl.c+4−4
@@ -770,14 +770,14 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) · 769 unmodified lines
770770 unsigned int i;
771771
772772 /* Allocate and initialize the pins and configs arrays. */
773− pmx->pins = devm_kzalloc(pfc->dev,
774− sizeof(*pmx->pins) * pfc->info->nr_pins,
773+ pmx->pins = devm_kcalloc(pfc->dev,
774+ pfc->info->nr_pins, sizeof(*pmx->pins),
775775 GFP_KERNEL);
776776 if (unlikely(!pmx->pins))
777777 return -ENOMEM;
778778
779− pmx->configs = devm_kzalloc(pfc->dev,
780− sizeof(*pmx->configs) * pfc->info->nr_pins,
779+ pmx->configs = devm_kcalloc(pfc->dev,
780+ pfc->info->nr_pins, sizeof(*pmx->configs),
781781 GFP_KERNEL);
782782 if (unlikely(!pmx->configs))
783783 return -ENOMEM;
drivers/pinctrl/sirf/pinctrl-sirf.c+1−1
@@ -108,7 +108,7 @@ static int sirfsoc_dt_node_to_map(struct pinctrl_dev *pctldev, · 107 unmodified lines
108108 return -ENODEV;
109109 }
110110
111− *map = kzalloc(sizeof(**map) * count, GFP_KERNEL);
111+ *map = kcalloc(count, sizeof(**map), GFP_KERNEL);
112112 if (!*map)
113113 return -ENOMEM;
114114
drivers/pinctrl/spear/pinctrl-plgpio.c+2−2
@@ -538,9 +538,9 @@ static int plgpio_probe(struct platform_device *pdev) · 537 unmodified lines
538538 dev_warn(&pdev->dev, "clk_get() failed, work without it\n");
539539
540540 #ifdef CONFIG_PM_SLEEP
541− plgpio->csave_regs = devm_kzalloc(&pdev->dev,
542− sizeof(*plgpio->csave_regs) *
541+ plgpio->csave_regs = devm_kcalloc(&pdev->dev,
543542 DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG),
543+ sizeof(*plgpio->csave_regs),
544544 GFP_KERNEL);
545545 if (!plgpio->csave_regs)
546546 return -ENOMEM;
drivers/pinctrl/spear/pinctrl-spear.c+1−1
@@ -172,7 +172,7 @@ static int spear_pinctrl_dt_node_to_map(struct pinctrl_dev *pctldev, · 171 unmodified lines
172172 return -ENODEV;
173173 }
174174
175− *map = kzalloc(sizeof(**map) * count, GFP_KERNEL);
175+ *map = kcalloc(count, sizeof(**map), GFP_KERNEL);
176176 if (!*map)
177177 return -ENOMEM;
178178
drivers/pinctrl/sprd/pinctrl-sprd.c+11−8
@@ -879,8 +879,9 @@ static int sprd_pinctrl_parse_groups(struct device_node *np, · 878 unmodified lines
879879
880880 grp->name = np->name;
881881 grp->npins = ret;
882− grp->pins = devm_kzalloc(sprd_pctl->dev, grp->npins *
883− sizeof(unsigned int), GFP_KERNEL);
882+ grp->pins = devm_kcalloc(sprd_pctl->dev,
883+ grp->npins, sizeof(unsigned int),
884+ GFP_KERNEL);
884885 if (!grp->pins)
885886 return -ENOMEM;
886887
@@ -931,14 +932,15 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl) · 44 unmodified lines
931932 if (!info->ngroups)
932933 return 0;
933934
934− info->groups = devm_kzalloc(sprd_pctl->dev, info->ngroups *
935+ info->groups = devm_kcalloc(sprd_pctl->dev,
936+ info->ngroups,
935937 sizeof(struct sprd_pin_group),
936938 GFP_KERNEL);
937939 if (!info->groups)
938940 return -ENOMEM;
939941
940− info->grp_names = devm_kzalloc(sprd_pctl->dev,
941− info->ngroups * sizeof(char *),
942+ info->grp_names = devm_kcalloc(sprd_pctl->dev,
943+ info->ngroups, sizeof(char *),
942944 GFP_KERNEL);
943945 if (!info->grp_names)
944946 return -ENOMEM;
@@ -980,8 +982,8 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl, · 35 unmodified lines
980982 int i;
981983
982984 info->npins = pins_cnt;
983− info->pins = devm_kzalloc(sprd_pctl->dev,
984− info->npins * sizeof(struct sprd_pin),
985+ info->pins = devm_kcalloc(sprd_pctl->dev,
986+ info->npins, sizeof(struct sprd_pin),
985987 GFP_KERNEL);
986988 if (!info->pins)
987989 return -ENOMEM;
@@ -1057,7 +1059,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev, · 69 unmodified lines
10571059 return ret;
10581060 }
10591061
1060− pin_desc = devm_kzalloc(&pdev->dev, pinctrl_info->npins *
1062+ pin_desc = devm_kcalloc(&pdev->dev,
1063+ pinctrl_info->npins,
10611064 sizeof(struct pinctrl_pin_desc),
10621065 GFP_KERNEL);
10631066 if (!pin_desc)
drivers/pinctrl/sunxi/pinctrl-sunxi.c+12−10
@@ -277,7 +277,7 @@ static unsigned long *sunxi_pctrl_build_pin_config(struct device_node *node, · 276 unmodified lines
277277 if (!configlen)
278278 return NULL;
279279
280− pinconfig = kzalloc(configlen * sizeof(*pinconfig), GFP_KERNEL);
280+ pinconfig = kcalloc(configlen, sizeof(*pinconfig), GFP_KERNEL);
281281 if (!pinconfig)
282282 return ERR_PTR(-ENOMEM);
283283
@@ -352,7 +352,7 @@ static int sunxi_pctrl_dt_node_to_map(struct pinctrl_dev *pctldev, · 68 unmodified lines
352352 * any configuration.
353353 */
354354 nmaps = npins * 2;
355− *map = kmalloc(nmaps * sizeof(struct pinctrl_map), GFP_KERNEL);
355+ *map = kmalloc_array(nmaps, sizeof(struct pinctrl_map), GFP_KERNEL);
356356 if (!*map)
357357 return -ENOMEM;
358358
@@ -1055,8 +1055,8 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 696 unmodified lines
10551055 * this means that the number of pins is the maximum group
10561056 * number we will ever see.
10571057 */
1058− pctl->groups = devm_kzalloc(&pdev->dev,
1059− pctl->desc->npins * sizeof(*pctl->groups),
1058+ pctl->groups = devm_kcalloc(&pdev->dev,
1059+ pctl->desc->npins, sizeof(*pctl->groups),
10601060 GFP_KERNEL);
10611061 if (!pctl->groups)
10621062 return -ENOMEM;
@@ -1079,8 +1079,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 16 unmodified lines
10791079 * We suppose that we won't have any more functions than pins,
10801080 * we'll reallocate that later anyway
10811081 */
1082− pctl->functions = devm_kzalloc(&pdev->dev,
1083− pctl->ngroups * sizeof(*pctl->functions),
1082+ pctl->functions = devm_kcalloc(&pdev->dev,
1083+ pctl->ngroups,
1084+ sizeof(*pctl->functions),
10841085 GFP_KERNEL);
10851086 if (!pctl->functions)
10861087 return -ENOMEM;
@@ -1137,8 +1138,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) · 50 unmodified lines
11371138
11381139 if (!func_item->groups) {
11391140 func_item->groups =
1140− devm_kzalloc(&pdev->dev,
1141− func_item->ngroups * sizeof(*func_item->groups),
1141+ devm_kcalloc(&pdev->dev,
1142+ func_item->ngroups,
1143+ sizeof(*func_item->groups),
11421144 GFP_KERNEL);
11431145 if (!func_item->groups)
11441146 return -ENOMEM;
@@ -1281,8 +1283,8 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, · 136 unmodified lines
12811283 return ret;
12821284 }
12831285
1284− pins = devm_kzalloc(&pdev->dev,
1285− pctl->desc->npins * sizeof(*pins),
1286+ pins = devm_kcalloc(&pdev->dev,
1287+ pctl->desc->npins, sizeof(*pins),
12861288 GFP_KERNEL);
12871289 if (!pins)
12881290 return -ENOMEM;
drivers/pinctrl/tegra/pinctrl-tegra.c+3−3
@@ -665,8 +665,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev, · 664 unmodified lines
665665 * Each mux group will appear in 4 functions' list of groups.
666666 * This over-allocates slightly, since not all groups are mux groups.
667667 */
668− pmx->group_pins = devm_kzalloc(&pdev->dev,
669− soc_data->ngroups * 4 * sizeof(*pmx->group_pins),
668+ pmx->group_pins = devm_kcalloc(&pdev->dev,
669+ soc_data->ngroups * 4, sizeof(*pmx->group_pins),
670670 GFP_KERNEL);
671671 if (!pmx->group_pins)
672672 return -ENOMEM;
@@ -708,7 +708,7 @@ int tegra_pinctrl_probe(struct platform_device *pdev, · 35 unmodified lines
708708 }
709709 pmx->nbanks = i;
710710
711− pmx->regs = devm_kzalloc(&pdev->dev, pmx->nbanks * sizeof(*pmx->regs),
711+ pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs),
712712 GFP_KERNEL);
713713 if (!pmx->regs)
714714 return -ENOMEM;
drivers/pinctrl/ti/pinctrl-ti-iodelay.c+3−3
@@ -510,11 +510,11 @@ static int ti_iodelay_dt_node_to_map(struct pinctrl_dev *pctldev, · 509 unmodified lines
510510 goto free_map;
511511 }
512512
513− pins = devm_kzalloc(iod->dev, sizeof(*pins) * rows, GFP_KERNEL);
513+ pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL);
514514 if (!pins)
515515 goto free_group;
516516
517− cfg = devm_kzalloc(iod->dev, sizeof(*cfg) * rows, GFP_KERNEL);
517+ cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL);
518518 if (!cfg) {
519519 error = -ENOMEM;
520520 goto free_pins;
@@ -749,7 +749,7 @@ static int ti_iodelay_alloc_pins(struct device *dev, · 228 unmodified lines
749749 nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register);
750750 dev_dbg(dev, "Allocating %i pins\n", nr_pins);
751751
752− iod->pa = devm_kzalloc(dev, sizeof(*iod->pa) * nr_pins, GFP_KERNEL);
752+ iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL);
753753 if (!iod->pa)
754754 return -ENOMEM;
755755
drivers/pinctrl/vt8500/pinctrl-wmt.c+1−1
@@ -352,7 +352,7 @@ static int wmt_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, · 351 unmodified lines
352352 if (num_pulls)
353353 maps_per_pin++;
354354
355− cur_map = maps = kzalloc(num_pins * maps_per_pin * sizeof(*maps),
355+ cur_map = maps = kcalloc(num_pins * maps_per_pin, sizeof(*maps),
356356 GFP_KERNEL);
357357 if (!maps)
358358 return -ENOMEM;
drivers/pinctrl/zte/pinctrl-zx.c+3−3
@@ -277,7 +277,7 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) · 276 unmodified lines
277277
278278 /* Every single pin composes a group */
279279 ngroups = info->npins;
280− groups = devm_kzalloc(&pdev->dev, ngroups * sizeof(*groups),
280+ groups = devm_kcalloc(&pdev->dev, ngroups, sizeof(*groups),
281281 GFP_KERNEL);
282282 if (!groups)
283283 return -ENOMEM;
@@ -362,8 +362,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) · 78 unmodified lines
362362
363363 func = functions + j;
364364 if (!func->group_names) {
365− func->group_names = devm_kzalloc(&pdev->dev,
366− func->num_group_names *
365+ func->group_names = devm_kcalloc(&pdev->dev,
366+ func->num_group_names,
367367 sizeof(*func->group_names),
368368 GFP_KERNEL);
369369 if (!func->group_names) {
drivers/platform/mellanox/mlxreg-hotplug.c+2−1
@@ -217,7 +217,8 @@ static int mlxreg_hotplug_attr_init(struct mlxreg_hotplug_priv_data *priv) · 216 unmodified lines
217217 }
218218 }
219219
220− priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs *
220+ priv->group.attrs = devm_kcalloc(&priv->pdev->dev,
221+ num_attrs,
221222 sizeof(struct attribute *),
222223 GFP_KERNEL);
223224 if (!priv->group.attrs)
drivers/platform/x86/alienware-wmi.c+3−3
@@ -458,19 +458,19 @@ static int alienware_zone_init(struct platform_device *dev) · 457 unmodified lines
458458 * - zone_data num_zones is for the distinct zones
459459 */
460460 zone_dev_attrs =
461− kzalloc(sizeof(struct device_attribute) * (quirks->num_zones + 1),
461+ kcalloc(quirks->num_zones + 1, sizeof(struct device_attribute),
462462 GFP_KERNEL);
463463 if (!zone_dev_attrs)
464464 return -ENOMEM;
465465
466466 zone_attrs =
467− kzalloc(sizeof(struct attribute *) * (quirks->num_zones + 2),
467+ kcalloc(quirks->num_zones + 2, sizeof(struct attribute *),
468468 GFP_KERNEL);
469469 if (!zone_attrs)
470470 return -ENOMEM;
471471
472472 zone_data =
473− kzalloc(sizeof(struct platform_zone) * (quirks->num_zones),
473+ kcalloc(quirks->num_zones, sizeof(struct platform_zone),
474474 GFP_KERNEL);
475475 if (!zone_data)
476476 return -ENOMEM;
drivers/platform/x86/intel_ips.c+6−6
@@ -964,12 +964,12 @@ static int ips_monitor(void *data) · 963 unmodified lines
964964 u16 *mcp_samples, *ctv1_samples, *ctv2_samples, *mch_samples;
965965 u8 cur_seqno, last_seqno;
966966
967− mcp_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
968− ctv1_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
969− ctv2_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
970− mch_samples = kzalloc(sizeof(u16) * IPS_SAMPLE_COUNT, GFP_KERNEL);
971− cpu_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
972− mchp_samples = kzalloc(sizeof(u32) * IPS_SAMPLE_COUNT, GFP_KERNEL);
967+ mcp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
968+ ctv1_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
969+ ctv2_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
970+ mch_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u16), GFP_KERNEL);
971+ cpu_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL);
972+ mchp_samples = kcalloc(IPS_SAMPLE_COUNT, sizeof(u32), GFP_KERNEL);
973973 if (!mcp_samples || !ctv1_samples || !ctv2_samples || !mch_samples ||
974974 !cpu_samples || !mchp_samples) {
975975 dev_err(ips->dev,
drivers/platform/x86/panasonic-laptop.c+1−1
@@ -571,7 +571,7 @@ static int acpi_pcc_hotkey_add(struct acpi_device *device) · 570 unmodified lines
571571 return -ENOMEM;
572572 }
573573
574− pcc->sinf = kzalloc(sizeof(u32) * (num_sifr + 1), GFP_KERNEL);
574+ pcc->sinf = kcalloc(num_sifr + 1, sizeof(u32), GFP_KERNEL);
575575 if (!pcc->sinf) {
576576 result = -ENOMEM;
577577 goto out_hotkey;
drivers/platform/x86/thinkpad_acpi.c+1−1
@@ -6006,7 +6006,7 @@ static int __init led_init(struct ibm_init_struct *iibm) · 6005 unmodified lines
60066006 if (led_supported == TPACPI_LED_NONE)
60076007 return 1;
60086008
6009− tpacpi_leds = kzalloc(sizeof(*tpacpi_leds) * TPACPI_LED_NUMLEDS,
6009+ tpacpi_leds = kcalloc(TPACPI_LED_NUMLEDS, sizeof(*tpacpi_leds),
60106010 GFP_KERNEL);
60116011 if (!tpacpi_leds) {
60126012 pr_err("Out of memory for LED data\n");
drivers/power/supply/charger-manager.c+17−12
@@ -1380,7 +1380,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm) · 1379 unmodified lines
13801380
13811381 snprintf(buf, 10, "charger.%d", i);
13821382 str = devm_kzalloc(cm->dev,
1383− sizeof(char) * (strlen(buf) + 1), GFP_KERNEL);
1383+ strlen(buf) + 1, GFP_KERNEL);
13841384 if (!str)
13851385 return -ENOMEM;
13861386
@@ -1522,8 +1522,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) · 135 unmodified lines
15221522 of_property_read_u32(np, "cm-num-chargers", &num_chgs);
15231523 if (num_chgs) {
15241524 /* Allocate empty bin at the tail of array */
1525− desc->psy_charger_stat = devm_kzalloc(dev, sizeof(char *)
1526− * (num_chgs + 1), GFP_KERNEL);
1525+ desc->psy_charger_stat = devm_kcalloc(dev,
1526+ num_chgs + 1,
1527+ sizeof(char *),
1528+ GFP_KERNEL);
15271529 if (desc->psy_charger_stat) {
15281530 int i;
15291531 for (i = 0; i < num_chgs; i++)
@@ -1555,8 +1557,9 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) · 25 unmodified lines
15551557 struct charger_regulator *chg_regs;
15561558 struct device_node *child;
15571559
1558− chg_regs = devm_kzalloc(dev, sizeof(*chg_regs)
1559− * desc->num_charger_regulators,
1560+ chg_regs = devm_kcalloc(dev,
1561+ desc->num_charger_regulators,
1562+ sizeof(*chg_regs),
15601563 GFP_KERNEL);
15611564 if (!chg_regs)
15621565 return ERR_PTR(-ENOMEM);
@@ -1573,9 +1576,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) · 10 unmodified lines
15731576 /* charger cables */
15741577 chg_regs->num_cables = of_get_child_count(child);
15751578 if (chg_regs->num_cables) {
1576− cables = devm_kzalloc(dev, sizeof(*cables)
1577− * chg_regs->num_cables,
1578− GFP_KERNEL);
1579+ cables = devm_kcalloc(dev,
1580+ chg_regs->num_cables,
1581+ sizeof(*cables),
1582+ GFP_KERNEL);
15791583 if (!cables) {
15801584 of_node_put(child);
15811585 return ERR_PTR(-ENOMEM);
@@ -1725,10 +1729,11 @@ static int charger_manager_probe(struct platform_device *pdev) · 143 unmodified lines
17251729 cm->charger_psy_desc.name = cm->psy_name_buf;
17261730
17271731 /* Allocate for psy properties because they may vary */
1728− cm->charger_psy_desc.properties = devm_kzalloc(&pdev->dev,
1729− sizeof(enum power_supply_property)
1730− * (ARRAY_SIZE(default_charger_props) +
1731− NUM_CHARGER_PSY_OPTIONAL), GFP_KERNEL);
1732+ cm->charger_psy_desc.properties =
1733+ devm_kcalloc(&pdev->dev,
1734+ ARRAY_SIZE(default_charger_props) +
1735+ NUM_CHARGER_PSY_OPTIONAL,
1736+ sizeof(enum power_supply_property), GFP_KERNEL);
17321737 if (!cm->charger_psy_desc.properties)
17331738 return -ENOMEM;
17341739
drivers/power/supply/power_supply_core.c+2−2
@@ -263,8 +263,8 @@ static int power_supply_check_supplies(struct power_supply *psy) · 262 unmodified lines
263263 if (!psy->supplied_from)
264264 return -ENOMEM;
265265
266− *psy->supplied_from = devm_kzalloc(&psy->dev,
267− sizeof(char *) * (cnt - 1),
266+ *psy->supplied_from = devm_kcalloc(&psy->dev,
267+ cnt - 1, sizeof(char *),
268268 GFP_KERNEL);
269269 if (!*psy->supplied_from)
270270 return -ENOMEM;
drivers/power/supply/wm97xx_battery.c+1−1
@@ -201,7 +201,7 @@ static int wm97xx_bat_probe(struct platform_device *dev) · 200 unmodified lines
201201 if (pdata->min_voltage >= 0)
202202 props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
203203
204− prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
204+ prop = kcalloc(props, sizeof(*prop), GFP_KERNEL);
205205 if (!prop) {
206206 ret = -ENOMEM;
207207 goto err3;
drivers/power/supply/z2_battery.c+1−1
@@ -146,7 +146,7 @@ static int z2_batt_ps_init(struct z2_charger *charger, int props) · 145 unmodified lines
146146 if (info->min_voltage >= 0)
147147 props++; /* POWER_SUPPLY_PROP_VOLTAGE_MIN */
148148
149− prop = kzalloc(props * sizeof(*prop), GFP_KERNEL);
149+ prop = kcalloc(props, sizeof(*prop), GFP_KERNEL);
150150 if (!prop)
151151 return -ENOMEM;
152152
drivers/powercap/powercap_sys.c+5−4
@@ -545,15 +545,16 @@ struct powercap_zone *powercap_register_zone( · 544 unmodified lines
545545 dev_set_name(&power_zone->dev, "%s:%x",
546546 dev_name(power_zone->dev.parent),
547547 power_zone->id);
548− power_zone->constraints = kzalloc(sizeof(*power_zone->constraints) *
549− nr_constraints, GFP_KERNEL);
548+ power_zone->constraints = kcalloc(nr_constraints,
549+ sizeof(*power_zone->constraints),
550+ GFP_KERNEL);
550551 if (!power_zone->constraints)
551552 goto err_const_alloc;
552553
553554 nr_attrs = nr_constraints * POWERCAP_CONSTRAINTS_ATTRS +
554555 POWERCAP_ZONE_MAX_ATTRS + 1;
555− power_zone->zone_dev_attrs = kzalloc(sizeof(void *) *
556− nr_attrs, GFP_KERNEL);
556+ power_zone->zone_dev_attrs = kcalloc(nr_attrs, sizeof(void *),
557+ GFP_KERNEL);
557558 if (!power_zone->zone_dev_attrs)
558559 goto err_attr_alloc;
559560 create_power_zone_common_attributes(power_zone);
drivers/pwm/pwm-lp3943.c+1−1
@@ -225,7 +225,7 @@ static int lp3943_pwm_parse_dt(struct device *dev, · 224 unmodified lines
225225 if (num_outputs == 0)
226226 continue;
227227
228− output = devm_kzalloc(dev, sizeof(*output) * num_outputs,
228+ output = devm_kcalloc(dev, num_outputs, sizeof(*output),
229229 GFP_KERNEL);
230230 if (!output)
231231 return -ENOMEM;
drivers/rapidio/devices/rio_mport_cdev.c+1−1
@@ -975,7 +975,7 @@ static int rio_mport_transfer_ioctl(struct file *filp, void __user *arg) · 974 unmodified lines
975975 priv->md->properties.transfer_mode) == 0)
976976 return -ENODEV;
977977
978− transfer = vmalloc(transaction.count * sizeof(*transfer));
978+ transfer = vmalloc(array_size(sizeof(*transfer), transaction.count));
979979 if (!transfer)
980980 return -ENOMEM;
981981
drivers/rapidio/rio-scan.c+3−3
@@ -425,9 +425,9 @@ static struct rio_dev *rio_setup_device(struct rio_net *net, · 424 unmodified lines
425425 rswitch = rdev->rswitch;
426426 rswitch->port_ok = 0;
427427 spin_lock_init(&rswitch->lock);
428− rswitch->route_table = kzalloc(sizeof(u8)*
429− RIO_MAX_ROUTE_ENTRIES(port->sys_size),
430− GFP_KERNEL);
428+ rswitch->route_table =
429+ kzalloc(RIO_MAX_ROUTE_ENTRIES(port->sys_size),
430+ GFP_KERNEL);
431431 if (!rswitch->route_table)
432432 goto cleanup;
433433 /* Initialize switch route table */
drivers/regulator/act8865-regulator.c+4−3
@@ -424,9 +424,10 @@ static int act8865_pdata_from_dt(struct device *dev, · 423 unmodified lines
424424 if (matched <= 0)
425425 return matched;
426426
427− pdata->regulators = devm_kzalloc(dev,
428− sizeof(struct act8865_regulator_data) *
429− num_matches, GFP_KERNEL);
427+ pdata->regulators = devm_kcalloc(dev,
428+ num_matches,
429+ sizeof(struct act8865_regulator_data),
430+ GFP_KERNEL);
430431 if (!pdata->regulators)
431432 return -ENOMEM;
432433
drivers/regulator/as3711-regulator.c+4−2
@@ -239,8 +239,10 @@ static int as3711_regulator_probe(struct platform_device *pdev) · 238 unmodified lines
239239 }
240240 }
241241
242− regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM *
243− sizeof(struct as3711_regulator), GFP_KERNEL);
242+ regs = devm_kcalloc(&pdev->dev,
243+ AS3711_REGULATOR_NUM,
244+ sizeof(struct as3711_regulator),
245+ GFP_KERNEL);
244246 if (!regs)
245247 return -ENOMEM;
246248
drivers/regulator/bcm590xx-regulator.c+4−2
@@ -383,8 +383,10 @@ static int bcm590xx_probe(struct platform_device *pdev) · 382 unmodified lines
383383
384384 platform_set_drvdata(pdev, pmu);
385385
386− pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS *
387− sizeof(struct regulator_desc), GFP_KERNEL);
386+ pmu->desc = devm_kcalloc(&pdev->dev,
387+ BCM590XX_NUM_REGS,
388+ sizeof(struct regulator_desc),
389+ GFP_KERNEL);
388390 if (!pmu->desc)
389391 return -ENOMEM;
390392
drivers/regulator/da9063-regulator.c+2−2
@@ -681,8 +681,8 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt( · 680 unmodified lines
681681 if (!pdata)
682682 return ERR_PTR(-ENOMEM);
683683
684− pdata->regulator_data = devm_kzalloc(&pdev->dev,
685− num * sizeof(*pdata->regulator_data),
684+ pdata->regulator_data = devm_kcalloc(&pdev->dev,
685+ num, sizeof(*pdata->regulator_data),
686686 GFP_KERNEL);
687687 if (!pdata->regulator_data)
688688 return ERR_PTR(-ENOMEM);
drivers/regulator/gpio-regulator.c+5−5
@@ -172,8 +172,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 171 unmodified lines
172172
173173 if (ret > 0) {
174174 config->nr_gpios = ret;
175− config->gpios = devm_kzalloc(dev,
176− sizeof(struct gpio) * config->nr_gpios,
175+ config->gpios = devm_kcalloc(dev,
176+ config->nr_gpios, sizeof(struct gpio),
177177 GFP_KERNEL);
178178 if (!config->gpios)
179179 return ERR_PTR(-ENOMEM);
@@ -214,9 +214,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, · 34 unmodified lines
214214 return ERR_PTR(-EINVAL);
215215 }
216216
217− config->states = devm_kzalloc(dev,
218− sizeof(struct gpio_regulator_state)
219− * (proplen / 2),
217+ config->states = devm_kcalloc(dev,
218+ proplen / 2,
219+ sizeof(struct gpio_regulator_state),
220220 GFP_KERNEL);
221221 if (!config->states)
222222 return ERR_PTR(-ENOMEM);
drivers/regulator/max1586.c+4−2
@@ -194,8 +194,10 @@ static int of_get_max1586_platform_data(struct device *dev, · 193 unmodified lines
194194 if (matched <= 0)
195195 return matched;
196196
197− pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) *
198− matched, GFP_KERNEL);
197+ pdata->subdevs = devm_kcalloc(dev,
198+ matched,
199+ sizeof(struct max1586_subdev_data),
200+ GFP_KERNEL);
199201 if (!pdata->subdevs)
200202 return -ENOMEM;
201203
drivers/regulator/max8660.c+4−2
@@ -351,8 +351,10 @@ static int max8660_pdata_from_dt(struct device *dev, · 350 unmodified lines
351351 if (matched <= 0)
352352 return matched;
353353
354− pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) *
355− matched, GFP_KERNEL);
354+ pdata->subdevs = devm_kcalloc(dev,
355+ matched,
356+ sizeof(struct max8660_subdev_data),
357+ GFP_KERNEL);
356358 if (!pdata->subdevs)
357359 return -ENOMEM;
358360
drivers/regulator/max8997-regulator.c+3−2
@@ -929,8 +929,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, · 928 unmodified lines
929929 /* count the number of regulators to be supported in pmic */
930930 pdata->num_regulators = of_get_child_count(regulators_np);
931931
932− rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
933− pdata->num_regulators, GFP_KERNEL);
932+ rdata = devm_kcalloc(&pdev->dev,
933+ pdata->num_regulators, sizeof(*rdata),
934+ GFP_KERNEL);
934935 if (!rdata) {
935936 of_node_put(regulators_np);
936937 return -ENOMEM;
drivers/regulator/max8998.c+3−2
@@ -670,8 +670,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, · 669 unmodified lines
670670 /* count the number of regulators to be supported in pmic */
671671 pdata->num_regulators = of_get_child_count(regulators_np);
672672
673− rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) *
674− pdata->num_regulators, GFP_KERNEL);
673+ rdata = devm_kcalloc(iodev->dev,
674+ pdata->num_regulators, sizeof(*rdata),
675+ GFP_KERNEL);
675676 if (!rdata) {
676677 of_node_put(regulators_np);
677678 return -ENOMEM;
drivers/regulator/mc13xxx-regulator-core.c+1−1
@@ -171,7 +171,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( · 170 unmodified lines
171171 if (!parent)
172172 return NULL;
173173
174− data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators,
174+ data = devm_kcalloc(&pdev->dev, priv->num_regulators, sizeof(*data),
175175 GFP_KERNEL);
176176 if (!data) {
177177 of_node_put(parent);
drivers/regulator/pbias-regulator.c+3−2
@@ -173,8 +173,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) · 172 unmodified lines
173173 if (count < 0)
174174 return count;
175175
176− drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data)
177− * count, GFP_KERNEL);
176+ drvdata = devm_kcalloc(&pdev->dev,
177+ count, sizeof(struct pbias_regulator_data),
178+ GFP_KERNEL);
178179 if (!drvdata)
179180 return -ENOMEM;
180181
drivers/regulator/rc5t583-regulator.c+4−2
@@ -132,8 +132,10 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) · 131 unmodified lines
132132 return -ENODEV;
133133 }
134134
135− regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX *
136− sizeof(struct rc5t583_regulator), GFP_KERNEL);
135+ regs = devm_kcalloc(&pdev->dev,
136+ RC5T583_REGULATOR_MAX,
137+ sizeof(struct rc5t583_regulator),
138+ GFP_KERNEL);
137139 if (!regs)
138140 return -ENOMEM;
139141
drivers/regulator/s2mps11.c+3−3
@@ -1139,8 +1139,8 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) · 1138 unmodified lines
11391139 return -EINVAL;
11401140 }
11411141
1142− s2mps11->ext_control_gpio = devm_kmalloc(&pdev->dev,
1143− sizeof(*s2mps11->ext_control_gpio) * rdev_num,
1142+ s2mps11->ext_control_gpio = devm_kmalloc_array(&pdev->dev,
1143+ rdev_num, sizeof(*s2mps11->ext_control_gpio),
11441144 GFP_KERNEL);
11451145 if (!s2mps11->ext_control_gpio)
11461146 return -ENOMEM;
@@ -1162,7 +1162,7 @@ static int s2mps11_pmic_probe(struct platform_device *pdev) · 15 unmodified lines
11621162 }
11631163 }
11641164
1165− rdata = kzalloc(sizeof(*rdata) * rdev_num, GFP_KERNEL);
1165+ rdata = kcalloc(rdev_num, sizeof(*rdata), GFP_KERNEL);
11661166 if (!rdata)
11671167 return -ENOMEM;
11681168
drivers/regulator/s5m8767.c+6−4
@@ -553,13 +553,15 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, · 552 unmodified lines
553553 /* count the number of regulators to be supported in pmic */
554554 pdata->num_regulators = of_get_child_count(regulators_np);
555555
556− rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) *
557− pdata->num_regulators, GFP_KERNEL);
556+ rdata = devm_kcalloc(&pdev->dev,
557+ pdata->num_regulators, sizeof(*rdata),
558+ GFP_KERNEL);
558559 if (!rdata)
559560 return -ENOMEM;
560561
561− rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) *
562− pdata->num_regulators, GFP_KERNEL);
562+ rmode = devm_kcalloc(&pdev->dev,
563+ pdata->num_regulators, sizeof(*rmode),
564+ GFP_KERNEL);
563565 if (!rmode)
564566 return -ENOMEM;
565567
drivers/regulator/ti-abb-regulator.c+2−2
@@ -532,13 +532,13 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, · 531 unmodified lines
532532 }
533533 num_entries /= num_values;
534534
535− info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL);
535+ info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL);
536536 if (!info)
537537 return -ENOMEM;
538538
539539 abb->info = info;
540540
541− volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries,
541+ volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int),
542542 GFP_KERNEL);
543543 if (!volt_table)
544544 return -ENOMEM;
drivers/regulator/tps65090-regulator.c+6−4
@@ -331,8 +331,9 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( · 330 unmodified lines
331331 if (!tps65090_pdata)
332332 return ERR_PTR(-ENOMEM);
333333
334− reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX *
335− sizeof(*reg_pdata), GFP_KERNEL);
334+ reg_pdata = devm_kcalloc(&pdev->dev,
335+ TPS65090_REGULATOR_MAX, sizeof(*reg_pdata),
336+ GFP_KERNEL);
336337 if (!reg_pdata)
337338 return ERR_PTR(-ENOMEM);
338339
@@ -429,8 +430,9 @@ static int tps65090_regulator_probe(struct platform_device *pdev) · 90 unmodified lines
429430 return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL;
430431 }
431432
432− pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic),
433− GFP_KERNEL);
433+ pmic = devm_kcalloc(&pdev->dev,
434+ TPS65090_REGULATOR_MAX, sizeof(*pmic),
435+ GFP_KERNEL);
434436 if (!pmic)
435437 return -ENOMEM;
436438
drivers/regulator/tps65217-regulator.c+3−2
@@ -229,8 +229,9 @@ static int tps65217_regulator_probe(struct platform_device *pdev) · 228 unmodified lines
229229 unsigned int val;
230230
231231 /* Allocate memory for strobes */
232− tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
233− TPS65217_NUM_REGULATOR, GFP_KERNEL);
232+ tps->strobes = devm_kcalloc(&pdev->dev,
233+ TPS65217_NUM_REGULATOR, sizeof(u8),
234+ GFP_KERNEL);
234235
235236 platform_set_drvdata(pdev, tps);
236237
drivers/regulator/tps65218-regulator.c+3−2
@@ -324,8 +324,9 @@ static int tps65218_regulator_probe(struct platform_device *pdev) · 323 unmodified lines
324324 config.regmap = tps->regmap;
325325
326326 /* Allocate memory for strobes */
327− tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) *
328− TPS65218_NUM_REGULATOR, GFP_KERNEL);
327+ tps->strobes = devm_kcalloc(&pdev->dev,
328+ TPS65218_NUM_REGULATOR, sizeof(u8),
329+ GFP_KERNEL);
329330 if (!tps->strobes)
330331 return -ENOMEM;
331332
drivers/regulator/tps65910-regulator.c+12−6
@@ -1131,18 +1131,24 @@ static int tps65910_probe(struct platform_device *pdev) · 1130 unmodified lines
11311131 return -ENODEV;
11321132 }
11331133
1134− pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators *
1135− sizeof(struct regulator_desc), GFP_KERNEL);
1134+ pmic->desc = devm_kcalloc(&pdev->dev,
1135+ pmic->num_regulators,
1136+ sizeof(struct regulator_desc),
1137+ GFP_KERNEL);
11361138 if (!pmic->desc)
11371139 return -ENOMEM;
11381140
1139− pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators *
1140− sizeof(struct tps_info *), GFP_KERNEL);
1141+ pmic->info = devm_kcalloc(&pdev->dev,
1142+ pmic->num_regulators,
1143+ sizeof(struct tps_info *),
1144+ GFP_KERNEL);
11411145 if (!pmic->info)
11421146 return -ENOMEM;
11431147
1144− pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators *
1145− sizeof(struct regulator_dev *), GFP_KERNEL);
1148+ pmic->rdev = devm_kcalloc(&pdev->dev,
1149+ pmic->num_regulators,
1150+ sizeof(struct regulator_dev *),
1151+ GFP_KERNEL);
11461152 if (!pmic->rdev)
11471153 return -ENOMEM;
11481154
drivers/regulator/tps80031-regulator.c+2−2
@@ -691,8 +691,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev) · 690 unmodified lines
691691 return -EINVAL;
692692 }
693693
694− pmic = devm_kzalloc(&pdev->dev,
695− TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL);
694+ pmic = devm_kcalloc(&pdev->dev,
695+ TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL);
696696 if (!pmic)
697697 return -ENOMEM;
698698
drivers/reset/reset-ti-syscon.c+2−1
@@ -189,7 +189,8 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) · 188 unmodified lines
189189 }
190190
191191 nr_controls = (size / sizeof(*list)) / 7;
192− controls = devm_kzalloc(dev, nr_controls * sizeof(*controls), GFP_KERNEL);
192+ controls = devm_kcalloc(dev, nr_controls, sizeof(*controls),
193+ GFP_KERNEL);
193194 if (!controls)
194195 return -ENOMEM;
195196
drivers/s390/block/dasd_eer.c+2−2
@@ -561,8 +561,8 @@ static int dasd_eer_open(struct inode *inp, struct file *filp) · 560 unmodified lines
561561 return -EINVAL;
562562 }
563563 eerb->buffersize = eerb->buffer_page_count * PAGE_SIZE;
564− eerb->buffer = kmalloc(eerb->buffer_page_count * sizeof(char *),
565− GFP_KERNEL);
564+ eerb->buffer = kmalloc_array(eerb->buffer_page_count, sizeof(char *),
565+ GFP_KERNEL);
566566 if (!eerb->buffer) {
567567 kfree(eerb);
568568 return -ENOMEM;
drivers/s390/block/dcssblk.c+3−3
@@ -238,9 +238,9 @@ dcssblk_is_continuous(struct dcssblk_dev_info *dev_info) · 237 unmodified lines
238238 if (dev_info->num_of_segments <= 1)
239239 return 0;
240240
241− sort_list = kzalloc(
242− sizeof(struct segment_info) * dev_info->num_of_segments,
243− GFP_KERNEL);
241+ sort_list = kcalloc(dev_info->num_of_segments,
242+ sizeof(struct segment_info),
243+ GFP_KERNEL);
244244 if (sort_list == NULL)
245245 return -ENOMEM;
246246 i = 0;
drivers/s390/char/keyboard.c+1−1
@@ -78,7 +78,7 @@ kbd_alloc(void) { · 77 unmodified lines
7878 }
7979 }
8080 kbd->fn_handler =
81− kzalloc(sizeof(fn_handler_fn *) * NR_FN_HANDLER, GFP_KERNEL);
81+ kcalloc(NR_FN_HANDLER, sizeof(fn_handler_fn *), GFP_KERNEL);
8282 if (!kbd->fn_handler)
8383 goto out_func;
8484 kbd->accent_table = kmemdup(ebc_accent_table,
drivers/s390/char/sclp_sd.c+1−1
@@ -300,7 +300,7 @@ static int sclp_sd_store_data(struct sclp_sd_data *result, u8 di) · 299 unmodified lines
300300 goto out_result;
301301
302302 /* Allocate memory */
303− data = vzalloc((size_t) dsize * PAGE_SIZE);
303+ data = vzalloc(array_size((size_t)dsize, PAGE_SIZE));
304304 if (!data) {
305305 rc = -ENOMEM;
306306 goto out;
drivers/s390/char/tty3270.c+2−1
@@ -719,7 +719,8 @@ tty3270_alloc_view(void) · 718 unmodified lines
719719 if (!tp)
720720 goto out_err;
721721 tp->freemem_pages =
722− kmalloc(sizeof(void *) * TTY3270_STRING_PAGES, GFP_KERNEL);
722+ kmalloc_array(TTY3270_STRING_PAGES, sizeof(void *),
723+ GFP_KERNEL);
723724 if (!tp->freemem_pages)
724725 goto out_tp;
725726 INIT_LIST_HEAD(&tp->freemem);
drivers/s390/char/vmur.c+1−1
@@ -242,7 +242,7 @@ static struct ccw1 *alloc_chan_prog(const char __user *ubuf, int rec_count, · 241 unmodified lines
242242 * That means we allocate room for CCWs to cover count/reclen
243243 * records plus a NOP.
244244 */
245− cpa = kzalloc((rec_count + 1) * sizeof(struct ccw1),
245+ cpa = kcalloc(rec_count + 1, sizeof(struct ccw1),
246246 GFP_KERNEL | GFP_DMA);
247247 if (!cpa)
248248 return ERR_PTR(-ENOMEM);
drivers/s390/char/zcore.c+1−1
@@ -152,7 +152,7 @@ static int zcore_memmap_open(struct inode *inode, struct file *filp) · 151 unmodified lines
152152 char *buf;
153153 int i = 0;
154154
155− buf = kzalloc(memblock.memory.cnt * CHUNK_INFO_SIZE, GFP_KERNEL);
155+ buf = kcalloc(memblock.memory.cnt, CHUNK_INFO_SIZE, GFP_KERNEL);
156156 if (!buf) {
157157 return -ENOMEM;
158158 }
drivers/s390/cio/qdio_setup.c+1−1
@@ -536,7 +536,7 @@ void qdio_print_subchannel_info(struct qdio_irq *irq_ptr, · 535 unmodified lines
536536
537537 int qdio_enable_async_operation(struct qdio_output_q *outq)
538538 {
539− outq->aobs = kzalloc(sizeof(struct qaob *) * QDIO_MAX_BUFFERS_PER_Q,
539+ outq->aobs = kcalloc(QDIO_MAX_BUFFERS_PER_Q, sizeof(struct qaob *),
540540 GFP_ATOMIC);
541541 if (!outq->aobs) {
542542 outq->use_cq = 0;
drivers/s390/cio/qdio_thinint.c+3−2
@@ -241,8 +241,9 @@ out: · 240 unmodified lines
241241 /* allocate non-shared indicators and shared indicator */
242242 int __init tiqdio_allocate_memory(void)
243243 {
244− q_indicators = kzalloc(sizeof(struct indicator_t) * TIQDIO_NR_INDICATORS,
245− GFP_KERNEL);
244+ q_indicators = kcalloc(TIQDIO_NR_INDICATORS,
245+ sizeof(struct indicator_t),
246+ GFP_KERNEL);
246247 if (!q_indicators)
247248 return -ENOMEM;
248249 return 0;
drivers/s390/crypto/pkey_api.c+4−4
@@ -121,7 +121,7 @@ static int alloc_and_prep_cprbmem(size_t paramblen, · 120 unmodified lines
121121 * allocate consecutive memory for request CPRB, request param
122122 * block, reply CPRB and reply param block
123123 */
124− cprbmem = kzalloc(2 * cprbplusparamblen, GFP_KERNEL);
124+ cprbmem = kcalloc(2, cprbplusparamblen, GFP_KERNEL);
125125 if (!cprbmem)
126126 return -ENOMEM;
127127
@@ -899,9 +899,9 @@ int pkey_findcard(const struct pkey_seckey *seckey, · 771 unmodified lines
899899 return -EINVAL;
900900
901901 /* fetch status of all crypto cards */
902− device_status = kmalloc(MAX_ZDEV_ENTRIES_EXT
903− * sizeof(struct zcrypt_device_status_ext),
904− GFP_KERNEL);
902+ device_status = kmalloc_array(MAX_ZDEV_ENTRIES_EXT,
903+ sizeof(struct zcrypt_device_status_ext),
904+ GFP_KERNEL);
905905 if (!device_status)
906906 return -ENOMEM;
907907 zcrypt_device_status_mask_ext(device_status);
drivers/s390/net/ctcm_main.c+1−1
@@ -1379,7 +1379,7 @@ static int add_channel(struct ccw_device *cdev, enum ctcm_channel_types type, · 1378 unmodified lines
13791379 } else
13801380 ccw_num = 8;
13811381
1382− ch->ccw = kzalloc(ccw_num * sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
1382+ ch->ccw = kcalloc(ccw_num, sizeof(struct ccw1), GFP_KERNEL | GFP_DMA);
13831383 if (ch->ccw == NULL)
13841384 goto nomem_return;
13851385
drivers/s390/net/qeth_core_main.c+15−12
@@ -374,9 +374,10 @@ static int qeth_alloc_cq(struct qeth_card *card) · 373 unmodified lines
374374 }
375375 card->qdio.no_in_queues = 2;
376376 card->qdio.out_bufstates =
377− kzalloc(card->qdio.no_out_queues *
378− QDIO_MAX_BUFFERS_PER_Q *
379− sizeof(struct qdio_outbuf_state), GFP_KERNEL);
377+ kcalloc(card->qdio.no_out_queues *
378+ QDIO_MAX_BUFFERS_PER_Q,
379+ sizeof(struct qdio_outbuf_state),
380+ GFP_KERNEL);
380381 outbuf_states = card->qdio.out_bufstates;
381382 if (outbuf_states == NULL) {
382383 rc = -1;
@@ -2538,8 +2539,9 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card) · 2155 unmodified lines
25382539
25392540 /* outbound */
25402541 card->qdio.out_qs =
2541− kzalloc(card->qdio.no_out_queues *
2542− sizeof(struct qeth_qdio_out_q *), GFP_KERNEL);
2542+ kcalloc(card->qdio.no_out_queues,
2543+ sizeof(struct qeth_qdio_out_q *),
2544+ GFP_KERNEL);
25432545 if (!card->qdio.out_qs)
25442546 goto out_freepool;
25452547 for (i = 0; i < card->qdio.no_out_queues; ++i) {
@@ -4963,8 +4965,8 @@ static int qeth_qdio_establish(struct qeth_card *card) · 2417 unmodified lines
49634965
49644966 QETH_DBF_TEXT(SETUP, 2, "qdioest");
49654967
4966− qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q * sizeof(char),
4967− GFP_KERNEL);
4968+ qib_param_field = kzalloc(QDIO_MAX_BUFFERS_PER_Q,
4969+ GFP_KERNEL);
49684970 if (!qib_param_field) {
49694971 rc = -ENOMEM;
49704972 goto out_free_nothing;
@@ -4973,8 +4975,8 @@ static int qeth_qdio_establish(struct qeth_card *card) · 2 unmodified lines
49734975 qeth_create_qib_param_field(card, qib_param_field);
49744976 qeth_create_qib_param_field_blkt(card, qib_param_field);
49754977
4976− in_sbal_ptrs = kzalloc(card->qdio.no_in_queues *
4977− QDIO_MAX_BUFFERS_PER_Q * sizeof(void *),
4978+ in_sbal_ptrs = kcalloc(card->qdio.no_in_queues * QDIO_MAX_BUFFERS_PER_Q,
4979+ sizeof(void *),
49784980 GFP_KERNEL);
49794981 if (!in_sbal_ptrs) {
49804982 rc = -ENOMEM;
@@ -4985,7 +4987,7 @@ static int qeth_qdio_establish(struct qeth_card *card) · 4 unmodified lines
49854987 virt_to_phys(card->qdio.in_q->bufs[i].buffer);
49864988 }
49874989
4988− queue_start_poll = kzalloc(sizeof(void *) * card->qdio.no_in_queues,
4990+ queue_start_poll = kcalloc(card->qdio.no_in_queues, sizeof(void *),
49894991 GFP_KERNEL);
49904992 if (!queue_start_poll) {
49914993 rc = -ENOMEM;
@@ -4997,8 +4999,9 @@ static int qeth_qdio_establish(struct qeth_card *card) · 5 unmodified lines
49974999 qeth_qdio_establish_cq(card, in_sbal_ptrs, queue_start_poll);
49985000
49995001 out_sbal_ptrs =
5000− kzalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q *
5001− sizeof(void *), GFP_KERNEL);
5002+ kcalloc(card->qdio.no_out_queues * QDIO_MAX_BUFFERS_PER_Q,
5003+ sizeof(void *),
5004+ GFP_KERNEL);
50025005 if (!out_sbal_ptrs) {
50035006 rc = -ENOMEM;
50045007 goto out_free_queue_start_poll;
drivers/scsi/BusLogic.c+1−1
@@ -2366,7 +2366,7 @@ static int __init blogic_init(void) · 2365 unmodified lines
23662366 if (blogic_probe_options.noprobe)
23672367 return -ENODEV;
23682368 blogic_probeinfo_list =
2369− kzalloc(BLOGIC_MAX_ADAPTERS * sizeof(struct blogic_probeinfo),
2369+ kcalloc(BLOGIC_MAX_ADAPTERS, sizeof(struct blogic_probeinfo),
23702370 GFP_KERNEL);
23712371 if (blogic_probeinfo_list == NULL) {
23722372 blogic_err("BusLogic: Unable to allocate Probe Info List\n",
drivers/scsi/aacraid/aachba.c+1−1
@@ -4132,7 +4132,7 @@ static int aac_convert_sgraw2(struct aac_raw_io2 *rio2, int pages, int nseg, int · 4131 unmodified lines
41324132 if (aac_convert_sgl == 0)
41334133 return 0;
41344134
4135− sge = kmalloc(nseg_new * sizeof(struct sge_ieee1212), GFP_ATOMIC);
4135+ sge = kmalloc_array(nseg_new, sizeof(struct sge_ieee1212), GFP_ATOMIC);
41364136 if (sge == NULL)
41374137 return -ENOMEM;
41384138
drivers/scsi/aacraid/linit.c+3−1
@@ -1681,7 +1681,9 @@ static int aac_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) · 1680 unmodified lines
16811681 if (aac_reset_devices || reset_devices)
16821682 aac->init_reset = true;
16831683
1684− aac->fibs = kzalloc(sizeof(struct fib) * (shost->can_queue + AAC_NUM_MGT_FIB), GFP_KERNEL);
1684+ aac->fibs = kcalloc(shost->can_queue + AAC_NUM_MGT_FIB,
1685+ sizeof(struct fib),
1686+ GFP_KERNEL);
16851687 if (!aac->fibs)
16861688 goto out_free_host;
16871689 spin_lock_init(&aac->fib_lock);
drivers/scsi/aha1542.c+2−1
@@ -400,7 +400,8 @@ static int aha1542_queuecommand(struct Scsi_Host *sh, struct scsi_cmnd *cmd) · 399 unmodified lines
400400 #endif
401401 if (bufflen) { /* allocate memory before taking host_lock */
402402 sg_count = scsi_sg_count(cmd);
403− cptr = kmalloc(sizeof(*cptr) * sg_count, GFP_KERNEL | GFP_DMA);
403+ cptr = kmalloc_array(sg_count, sizeof(*cptr),
404+ GFP_KERNEL | GFP_DMA);
404405 if (!cptr)
405406 return SCSI_MLQUEUE_HOST_BUSY;
406407 } else {
drivers/scsi/aic7xxx/aic79xx_core.c+2−1
@@ -7063,7 +7063,8 @@ ahd_init(struct ahd_softc *ahd) · 7062 unmodified lines
70637063 AHD_ASSERT_MODES(ahd, AHD_MODE_SCSI_MSK, AHD_MODE_SCSI_MSK);
70647064
70657065 ahd->stack_size = ahd_probe_stack_size(ahd);
7066− ahd->saved_stack = kmalloc(ahd->stack_size * sizeof(uint16_t), GFP_ATOMIC);
7066+ ahd->saved_stack = kmalloc_array(ahd->stack_size, sizeof(uint16_t),
7067+ GFP_ATOMIC);
70677068 if (ahd->saved_stack == NULL)
70687069 return (ENOMEM);
70697070
drivers/scsi/aic7xxx/aic7xxx_core.c+2−2
@@ -4779,8 +4779,8 @@ ahc_init_scbdata(struct ahc_softc *ahc) · 4778 unmodified lines
47794779 SLIST_INIT(&scb_data->sg_maps);
47804780
47814781 /* Allocate SCB resources */
4782− scb_data->scbarray = kzalloc(sizeof(struct scb) * AHC_SCB_MAX_ALLOC,
4783− GFP_ATOMIC);
4782+ scb_data->scbarray = kcalloc(AHC_SCB_MAX_ALLOC, sizeof(struct scb),
4783+ GFP_ATOMIC);
47844784 if (scb_data->scbarray == NULL)
47854785 return (ENOMEM);
47864786
drivers/scsi/aic94xx/aic94xx_hwi.c+7−5
@@ -220,8 +220,9 @@ static int asd_init_scbs(struct asd_ha_struct *asd_ha) · 219 unmodified lines
220220
221221 /* allocate the index array and bitmap */
222222 asd_ha->seq.tc_index_bitmap_bits = asd_ha->hw_prof.max_scbs;
223− asd_ha->seq.tc_index_array = kzalloc(asd_ha->seq.tc_index_bitmap_bits*
224− sizeof(void *), GFP_KERNEL);
223+ asd_ha->seq.tc_index_array = kcalloc(asd_ha->seq.tc_index_bitmap_bits,
224+ sizeof(void *),
225+ GFP_KERNEL);
225226 if (!asd_ha->seq.tc_index_array)
226227 return -ENOMEM;
227228
@@ -291,7 +292,8 @@ static int asd_alloc_edbs(struct asd_ha_struct *asd_ha, gfp_t gfp_flags) · 63 unmodified lines
291292 struct asd_seq_data *seq = &asd_ha->seq;
292293 int i;
293294
294− seq->edb_arr = kmalloc(seq->num_edbs*sizeof(*seq->edb_arr), gfp_flags);
295+ seq->edb_arr = kmalloc_array(seq->num_edbs, sizeof(*seq->edb_arr),
296+ gfp_flags);
295297 if (!seq->edb_arr)
296298 return -ENOMEM;
297299
@@ -323,8 +325,8 @@ static int asd_alloc_escbs(struct asd_ha_struct *asd_ha, · 25 unmodified lines
323325 struct asd_ascb *escb;
324326 int i, escbs;
325327
326− seq->escb_arr = kmalloc(seq->num_escbs*sizeof(*seq->escb_arr),
327− gfp_flags);
328+ seq->escb_arr = kmalloc_array(seq->num_escbs, sizeof(*seq->escb_arr),
329+ gfp_flags);
328330 if (!seq->escb_arr)
329331 return -ENOMEM;
330332
drivers/scsi/aic94xx/aic94xx_init.c+1−1
@@ -350,7 +350,7 @@ static ssize_t asd_store_update_bios(struct device *dev, · 349 unmodified lines
350350 int flash_command = FLASH_CMD_NONE;
351351 int err = 0;
352352
353− cmd_ptr = kzalloc(count*2, GFP_KERNEL);
353+ cmd_ptr = kcalloc(count, 2, GFP_KERNEL);
354354
355355 if (!cmd_ptr) {
356356 err = FAIL_OUT_MEMORY;
drivers/scsi/arm/queue.c+1−1
@@ -70,7 +70,7 @@ int queue_initialise (Queue_t *queue) · 69 unmodified lines
7070 * need to keep free lists or allocate this
7171 * memory.
7272 */
73− queue->alloc = q = kmalloc(sizeof(QE_t) * nqueues, GFP_KERNEL);
73+ queue->alloc = q = kmalloc_array(nqueues, sizeof(QE_t), GFP_KERNEL);
7474 if (q) {
7575 for (; nqueues; q++, nqueues--) {
7676 SET_MAGIC(q, QUEUE_MAGIC_FREE);
drivers/scsi/be2iscsi/be_main.c+30−24
@@ -2467,8 +2467,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) · 2466 unmodified lines
24672467
24682468 /* Allocate memory for wrb_context */
24692469 phwi_ctrlr = phba->phwi_ctrlr;
2470− phwi_ctrlr->wrb_context = kzalloc(sizeof(struct hwi_wrb_context) *
2471− phba->params.cxns_per_ctrl,
2470+ phwi_ctrlr->wrb_context = kcalloc(phba->params.cxns_per_ctrl,
2471+ sizeof(struct hwi_wrb_context),
24722472 GFP_KERNEL);
24732473 if (!phwi_ctrlr->wrb_context) {
24742474 kfree(phba->phwi_ctrlr);
@@ -2483,8 +2483,9 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) · 8 unmodified lines
24832483 return -ENOMEM;
24842484 }
24852485
2486− mem_arr_orig = kmalloc(sizeof(*mem_arr_orig) * BEISCSI_MAX_FRAGS_INIT,
2487− GFP_KERNEL);
2486+ mem_arr_orig = kmalloc_array(BEISCSI_MAX_FRAGS_INIT,
2487+ sizeof(*mem_arr_orig),
2488+ GFP_KERNEL);
24882489 if (!mem_arr_orig) {
24892490 kfree(phba->init_mem);
24902491 kfree(phwi_ctrlr->wrb_context);
@@ -2533,8 +2534,8 @@ static int beiscsi_alloc_mem(struct beiscsi_hba *phba) · 42 unmodified lines
25332534 } while (alloc_size);
25342535 mem_descr->num_elements = j;
25352536 mem_descr->size_in_bytes = phba->mem_req[i];
2536− mem_descr->mem_array = kmalloc(sizeof(*mem_arr) * j,
2537− GFP_KERNEL);
2537+ mem_descr->mem_array = kmalloc_array(j, sizeof(*mem_arr),
2538+ GFP_KERNEL);
25382539 if (!mem_descr->mem_array)
25392540 goto free_mem;
25402541
@@ -2620,8 +2621,8 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) · 79 unmodified lines
26202621
26212622 /* Allocate memory for WRBQ */
26222623 phwi_ctxt = phwi_ctrlr->phwi_ctxt;
2623− phwi_ctxt->be_wrbq = kzalloc(sizeof(struct be_queue_info) *
2624− phba->params.cxns_per_ctrl,
2624+ phwi_ctxt->be_wrbq = kcalloc(phba->params.cxns_per_ctrl,
2625+ sizeof(struct be_queue_info),
26252626 GFP_KERNEL);
26262627 if (!phwi_ctxt->be_wrbq) {
26272628 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
@@ -2632,16 +2633,18 @@ static int beiscsi_init_wrb_handle(struct beiscsi_hba *phba) · 4 unmodified lines
26322633 for (index = 0; index < phba->params.cxns_per_ctrl; index++) {
26332634 pwrb_context = &phwi_ctrlr->wrb_context[index];
26342635 pwrb_context->pwrb_handle_base =
2635− kzalloc(sizeof(struct wrb_handle *) *
2636− phba->params.wrbs_per_cxn, GFP_KERNEL);
2636+ kcalloc(phba->params.wrbs_per_cxn,
2637+ sizeof(struct wrb_handle *),
2638+ GFP_KERNEL);
26372639 if (!pwrb_context->pwrb_handle_base) {
26382640 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
26392641 "BM_%d : Mem Alloc Failed. Failing to load\n");
26402642 goto init_wrb_hndl_failed;
26412643 }
26422644 pwrb_context->pwrb_handle_basestd =
2643− kzalloc(sizeof(struct wrb_handle *) *
2644− phba->params.wrbs_per_cxn, GFP_KERNEL);
2645+ kcalloc(phba->params.wrbs_per_cxn,
2646+ sizeof(struct wrb_handle *),
2647+ GFP_KERNEL);
26452648 if (!pwrb_context->pwrb_handle_basestd) {
26462649 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
26472650 "BM_%d : Mem Alloc Failed. Failing to load\n");
@@ -3353,8 +3356,9 @@ beiscsi_create_wrb_rings(struct beiscsi_hba *phba, · 705 unmodified lines
33533356 idx = 0;
33543357 mem_descr = phba->init_mem;
33553358 mem_descr += HWI_MEM_WRB;
3356− pwrb_arr = kmalloc(sizeof(*pwrb_arr) * phba->params.cxns_per_ctrl,
3357− GFP_KERNEL);
3359+ pwrb_arr = kmalloc_array(phba->params.cxns_per_ctrl,
3360+ sizeof(*pwrb_arr),
3361+ GFP_KERNEL);
33583362 if (!pwrb_arr) {
33593363 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
33603364 "BM_%d : Memory alloc failed in create wrb ring.\n");
@@ -3894,18 +3898,18 @@ static int beiscsi_init_sgl_handle(struct beiscsi_hba *phba) · 533 unmodified lines
38943898 mem_descr_sglh = phba->init_mem;
38953899 mem_descr_sglh += HWI_MEM_SGLH;
38963900 if (1 == mem_descr_sglh->num_elements) {
3897− phba->io_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
3898− phba->params.ios_per_ctrl,
3901+ phba->io_sgl_hndl_base = kcalloc(phba->params.ios_per_ctrl,
3902+ sizeof(struct sgl_handle *),
38993903 GFP_KERNEL);
39003904 if (!phba->io_sgl_hndl_base) {
39013905 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
39023906 "BM_%d : Mem Alloc Failed. Failing to load\n");
39033907 return -ENOMEM;
39043908 }
3905− phba->eh_sgl_hndl_base = kzalloc(sizeof(struct sgl_handle *) *
3906− (phba->params.icds_per_ctrl -
3907− phba->params.ios_per_ctrl),
3908− GFP_KERNEL);
3909+ phba->eh_sgl_hndl_base =
3910+ kcalloc(phba->params.icds_per_ctrl -
3911+ phba->params.ios_per_ctrl,
3912+ sizeof(struct sgl_handle *), GFP_KERNEL);
39093913 if (!phba->eh_sgl_hndl_base) {
39103914 kfree(phba->io_sgl_hndl_base);
39113915 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
@@ -4032,8 +4036,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) · 120 unmodified lines
40324036 phba->cid_array_info[ulp_num] = ptr_cid_info;
40334037 }
40344038 }
4035− phba->ep_array = kzalloc(sizeof(struct iscsi_endpoint *) *
4036− phba->params.cxns_per_ctrl, GFP_KERNEL);
4039+ phba->ep_array = kcalloc(phba->params.cxns_per_ctrl,
4040+ sizeof(struct iscsi_endpoint *),
4041+ GFP_KERNEL);
40374042 if (!phba->ep_array) {
40384043 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
40394044 "BM_%d : Failed to allocate memory in "
@@ -4043,8 +4048,9 @@ static int hba_setup_cid_tbls(struct beiscsi_hba *phba) · 3 unmodified lines
40434048 goto free_memory;
40444049 }
40454050
4046− phba->conn_table = kzalloc(sizeof(struct beiscsi_conn *) *
4047− phba->params.cxns_per_ctrl, GFP_KERNEL);
4051+ phba->conn_table = kcalloc(phba->params.cxns_per_ctrl,
4052+ sizeof(struct beiscsi_conn *),
4053+ GFP_KERNEL);
40484054 if (!phba->conn_table) {
40494055 beiscsi_log(phba, KERN_ERR, BEISCSI_LOG_INIT,
40504056 "BM_%d : Failed to allocate memory in"
drivers/scsi/bfa/bfad_attr.c+1−1
@@ -927,7 +927,7 @@ bfad_im_num_of_discovered_ports_show(struct device *dev, · 926 unmodified lines
927927 struct bfa_rport_qualifier_s *rports = NULL;
928928 unsigned long flags;
929929
930− rports = kzalloc(sizeof(struct bfa_rport_qualifier_s) * nrports,
930+ rports = kcalloc(nrports, sizeof(struct bfa_rport_qualifier_s),
931931 GFP_ATOMIC);
932932 if (rports == NULL)
933933 return snprintf(buf, PAGE_SIZE, "Failed\n");
drivers/scsi/bfa/bfad_bsg.c+3−2
@@ -3252,8 +3252,9 @@ bfad_fcxp_map_sg(struct bfad_s *bfad, void *payload_kbuf, · 3251 unmodified lines
32523252 struct bfa_sge_s *sg_table;
32533253 int sge_num = 1;
32543254
3255− buf_base = kzalloc((sizeof(struct bfad_buf_info) +
3256− sizeof(struct bfa_sge_s)) * sge_num, GFP_KERNEL);
3255+ buf_base = kcalloc(sizeof(struct bfad_buf_info) +
3256+ sizeof(struct bfa_sge_s),
3257+ sge_num, GFP_KERNEL);
32573258 if (!buf_base)
32583259 return NULL;
32593260
drivers/scsi/bnx2fc/bnx2fc_fcoe.c+1−1
@@ -1397,7 +1397,7 @@ static struct bnx2fc_hba *bnx2fc_hba_create(struct cnic_dev *cnic) · 1396 unmodified lines
13971397 hba->next_conn_id = 0;
13981398
13991399 hba->tgt_ofld_list =
1400− kzalloc(sizeof(struct bnx2fc_rport *) * BNX2FC_NUM_MAX_SESS,
1400+ kcalloc(BNX2FC_NUM_MAX_SESS, sizeof(struct bnx2fc_rport *),
14011401 GFP_KERNEL);
14021402 if (!hba->tgt_ofld_list) {
14031403 printk(KERN_ERR PFX "Unable to allocate tgt offload list\n");
drivers/scsi/bnx2fc/bnx2fc_io.c+4−4
@@ -240,15 +240,15 @@ struct bnx2fc_cmd_mgr *bnx2fc_cmd_mgr_alloc(struct bnx2fc_hba *hba) · 239 unmodified lines
240240 return NULL;
241241 }
242242
243− cmgr->free_list = kzalloc(sizeof(*cmgr->free_list) *
244− arr_sz, GFP_KERNEL);
243+ cmgr->free_list = kcalloc(arr_sz, sizeof(*cmgr->free_list),
244+ GFP_KERNEL);
245245 if (!cmgr->free_list) {
246246 printk(KERN_ERR PFX "failed to alloc free_list\n");
247247 goto mem_err;
248248 }
249249
250− cmgr->free_list_lock = kzalloc(sizeof(*cmgr->free_list_lock) *
251− arr_sz, GFP_KERNEL);
250+ cmgr->free_list_lock = kcalloc(arr_sz, sizeof(*cmgr->free_list_lock),
251+ GFP_KERNEL);
252252 if (!cmgr->free_list_lock) {
253253 printk(KERN_ERR PFX "failed to alloc free_list_lock\n");
254254 kfree(cmgr->free_list);
drivers/scsi/csiostor/csio_wr.c+2−2
@@ -276,7 +276,7 @@ csio_wr_alloc_q(struct csio_hw *hw, uint32_t qsize, uint32_t wrsize, · 275 unmodified lines
276276 q->un.iq.flq_idx = flq_idx;
277277
278278 flq = wrm->q_arr[q->un.iq.flq_idx];
279− flq->un.fl.bufs = kzalloc(flq->credits *
279+ flq->un.fl.bufs = kcalloc(flq->credits,
280280 sizeof(struct csio_dma_buf),
281281 GFP_KERNEL);
282282 if (!flq->un.fl.bufs) {
@@ -1579,7 +1579,7 @@ csio_wrm_init(struct csio_wrm *wrm, struct csio_hw *hw) · 1296 unmodified lines
15791579 return -EINVAL;
15801580 }
15811581
1582− wrm->q_arr = kzalloc(sizeof(struct csio_q *) * wrm->num_q, GFP_KERNEL);
1582+ wrm->q_arr = kcalloc(wrm->num_q, sizeof(struct csio_q *), GFP_KERNEL);
15831583 if (!wrm->q_arr)
15841584 goto err;
15851585
drivers/scsi/esas2r/esas2r_init.c+6−5
@@ -833,7 +833,7 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, · 832 unmodified lines
833833
834834 /* allocate requests for asynchronous events */
835835 a->first_ae_req =
836− kzalloc(num_ae_requests * sizeof(struct esas2r_request),
836+ kcalloc(num_ae_requests, sizeof(struct esas2r_request),
837837 GFP_KERNEL);
838838
839839 if (a->first_ae_req == NULL) {
@@ -843,8 +843,8 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, · 3 unmodified lines
843843 }
844844
845845 /* allocate the S/G list memory descriptors */
846− a->sg_list_mds = kzalloc(
847− num_sg_lists * sizeof(struct esas2r_mem_desc), GFP_KERNEL);
846+ a->sg_list_mds = kcalloc(num_sg_lists, sizeof(struct esas2r_mem_desc),
847+ GFP_KERNEL);
848848
849849 if (a->sg_list_mds == NULL) {
850850 esas2r_log(ESAS2R_LOG_CRIT,
@@ -854,8 +854,9 @@ bool esas2r_init_adapter_struct(struct esas2r_adapter *a, · 3 unmodified lines
854854
855855 /* allocate the request table */
856856 a->req_table =
857− kzalloc((num_requests + num_ae_requests +
858− 1) * sizeof(struct esas2r_request *), GFP_KERNEL);
857+ kcalloc(num_requests + num_ae_requests + 1,
858+ sizeof(struct esas2r_request *),
859+ GFP_KERNEL);
859860
860861 if (a->req_table == NULL) {
861862 esas2r_log(ESAS2R_LOG_CRIT,
drivers/scsi/fcoe/fcoe_ctlr.c+2−2
@@ -1390,8 +1390,8 @@ static void fcoe_ctlr_recv_clr_vlink(struct fcoe_ctlr *fip, · 1389 unmodified lines
13901390 */
13911391 num_vlink_desc = rlen / sizeof(*vp);
13921392 if (num_vlink_desc)
1393− vlink_desc_arr = kmalloc(sizeof(vp) * num_vlink_desc,
1394− GFP_ATOMIC);
1393+ vlink_desc_arr = kmalloc_array(num_vlink_desc, sizeof(vp),
1394+ GFP_ATOMIC);
13951395 if (!vlink_desc_arr)
13961396 return;
13971397 num_vlink_desc = 0;
drivers/scsi/fnic/fnic_debugfs.c+4−3
@@ -233,8 +233,8 @@ static int fnic_trace_debugfs_open(struct inode *inode, · 232 unmodified lines
233233 return -ENOMEM;
234234
235235 if (*rdata_ptr == fc_trc_flag->fnic_trace) {
236− fnic_dbg_prt->buffer = vmalloc(3 *
237− (trace_max_pages * PAGE_SIZE));
236+ fnic_dbg_prt->buffer = vmalloc(array3_size(3, trace_max_pages,
237+ PAGE_SIZE));
238238 if (!fnic_dbg_prt->buffer) {
239239 kfree(fnic_dbg_prt);
240240 return -ENOMEM;
@@ -244,7 +244,8 @@ static int fnic_trace_debugfs_open(struct inode *inode, · 3 unmodified lines
244244 fnic_dbg_prt->buffer_len = fnic_get_trace_data(fnic_dbg_prt);
245245 } else {
246246 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));
248249 if (!fnic_dbg_prt->buffer) {
249250 kfree(fnic_dbg_prt);
250251 return -ENOMEM;
drivers/scsi/fnic/fnic_trace.c+9−6
@@ -477,8 +477,9 @@ int fnic_trace_buf_init(void) · 476 unmodified lines
477477 }
478478 memset((void *)fnic_trace_buf_p, 0, (trace_max_pages * PAGE_SIZE));
479479
480− fnic_trace_entries.page_offset = vmalloc(fnic_max_trace_entries *
481− sizeof(unsigned long));
480+ fnic_trace_entries.page_offset =
481+ vmalloc(array_size(fnic_max_trace_entries,
482+ sizeof(unsigned long)));
482483 if (!fnic_trace_entries.page_offset) {
483484 printk(KERN_ERR PFX "Failed to allocate memory for"
484485 " page_offset\n");
@@ -555,8 +556,9 @@ int fnic_fc_trace_init(void) · 70 unmodified lines
555556
556557 fc_trace_max_entries = (fnic_fc_trace_max_pages * PAGE_SIZE)/
557558 FC_TRC_SIZE_BYTES;
558− fnic_fc_ctlr_trace_buf_p = (unsigned long)vmalloc(
559− fnic_fc_trace_max_pages * PAGE_SIZE);
559+ fnic_fc_ctlr_trace_buf_p =
560+ (unsigned long)vmalloc(array_size(PAGE_SIZE,
561+ fnic_fc_trace_max_pages));
560562 if (!fnic_fc_ctlr_trace_buf_p) {
561563 pr_err("fnic: Failed to allocate memory for "
562564 "FC Control Trace Buf\n");
@@ -568,8 +570,9 @@ int fnic_fc_trace_init(void) · 5 unmodified lines
568570 fnic_fc_trace_max_pages * PAGE_SIZE);
569571
570572 /* Allocate memory for page offset */
571− fc_trace_entries.page_offset = vmalloc(fc_trace_max_entries *
572− sizeof(unsigned long));
573+ fc_trace_entries.page_offset =
574+ vmalloc(array_size(fc_trace_max_entries,
575+ sizeof(unsigned long)));
573576 if (!fc_trace_entries.page_offset) {
574577 pr_err("fnic:Failed to allocate memory for page_offset\n");
575578 if (fnic_fc_ctlr_trace_buf_p) {
drivers/scsi/hpsa.c+19−17
@@ -1923,8 +1923,8 @@ static void adjust_hpsa_scsi_table(struct ctlr_info *h, · 1922 unmodified lines
19231923 }
19241924 spin_unlock_irqrestore(&h->reset_lock, flags);
19251925
1926− added = kzalloc(sizeof(*added) * HPSA_MAX_DEVICES, GFP_KERNEL);
1927− removed = kzalloc(sizeof(*removed) * HPSA_MAX_DEVICES, GFP_KERNEL);
1926+ added = kcalloc(HPSA_MAX_DEVICES, sizeof(*added), GFP_KERNEL);
1927+ removed = kcalloc(HPSA_MAX_DEVICES, sizeof(*removed), GFP_KERNEL);
19281928
19291929 if (!added || !removed) {
19301930 dev_warn(&h->pdev->dev, "out of memory in "
@@ -2171,14 +2171,15 @@ static int hpsa_allocate_ioaccel2_sg_chain_blocks(struct ctlr_info *h) · 240 unmodified lines
21712171 return 0;
21722172
21732173 h->ioaccel2_cmd_sg_list =
2174− kzalloc(sizeof(*h->ioaccel2_cmd_sg_list) * h->nr_cmds,
2174+ kcalloc(h->nr_cmds, sizeof(*h->ioaccel2_cmd_sg_list),
21752175 GFP_KERNEL);
21762176 if (!h->ioaccel2_cmd_sg_list)
21772177 return -ENOMEM;
21782178 for (i = 0; i < h->nr_cmds; i++) {
21792179 h->ioaccel2_cmd_sg_list[i] =
2180− kmalloc(sizeof(*h->ioaccel2_cmd_sg_list[i]) *
2181− h->maxsgentries, GFP_KERNEL);
2180+ kmalloc_array(h->maxsgentries,
2181+ sizeof(*h->ioaccel2_cmd_sg_list[i]),
2182+ GFP_KERNEL);
21822183 if (!h->ioaccel2_cmd_sg_list[i])
21832184 goto clean;
21842185 }
@@ -2210,14 +2211,15 @@ static int hpsa_alloc_sg_chain_blocks(struct ctlr_info *h) · 25 unmodified lines
22102211 if (h->chainsize <= 0)
22112212 return 0;
22122213
2213− h->cmd_sg_list = kzalloc(sizeof(*h->cmd_sg_list) * h->nr_cmds,
2214− GFP_KERNEL);
2214+ h->cmd_sg_list = kcalloc(h->nr_cmds, sizeof(*h->cmd_sg_list),
2215+ GFP_KERNEL);
22152216 if (!h->cmd_sg_list)
22162217 return -ENOMEM;
22172218
22182219 for (i = 0; i < h->nr_cmds; i++) {
2219− h->cmd_sg_list[i] = kmalloc(sizeof(*h->cmd_sg_list[i]) *
2220− h->chainsize, GFP_KERNEL);
2220+ h->cmd_sg_list[i] = kmalloc_array(h->chainsize,
2221+ sizeof(*h->cmd_sg_list[i]),
2222+ GFP_KERNEL);
22212223 if (!h->cmd_sg_list[i])
22222224 goto clean;
22232225
@@ -4319,7 +4321,7 @@ static void hpsa_update_scsi_devices(struct ctlr_info *h) · 2095 unmodified lines
43194321 bool physical_device;
43204322 DECLARE_BITMAP(lunzerobits, MAX_EXT_TARGETS);
43214323
4322− currentsd = kzalloc(sizeof(*currentsd) * HPSA_MAX_DEVICES, GFP_KERNEL);
4324+ currentsd = kcalloc(HPSA_MAX_DEVICES, sizeof(*currentsd), GFP_KERNEL);
43234325 physdev_list = kzalloc(sizeof(*physdev_list), GFP_KERNEL);
43244326 logdev_list = kzalloc(sizeof(*logdev_list), GFP_KERNEL);
43254327 tmpdevice = kzalloc(sizeof(*tmpdevice), GFP_KERNEL);
@@ -6402,12 +6404,12 @@ static int hpsa_big_passthru_ioctl(struct ctlr_info *h, void __user *argp) · 2076 unmodified lines
64026404 status = -EINVAL;
64036405 goto cleanup1;
64046406 }
6405− buff = kzalloc(SG_ENTRIES_IN_CMD * sizeof(char *), GFP_KERNEL);
6407+ buff = kcalloc(SG_ENTRIES_IN_CMD, sizeof(char *), GFP_KERNEL);
64066408 if (!buff) {
64076409 status = -ENOMEM;
64086410 goto cleanup1;
64096411 }
6410− buff_size = kmalloc(SG_ENTRIES_IN_CMD * sizeof(int), GFP_KERNEL);
6412+ buff_size = kmalloc_array(SG_ENTRIES_IN_CMD, sizeof(int), GFP_KERNEL);
64116413 if (!buff_size) {
64126414 status = -ENOMEM;
64136415 goto cleanup1;
@@ -7151,7 +7153,7 @@ static int controller_reset_failed(struct CfgTable __iomem *cfgtable) · 737 unmodified lines
71517153 char *driver_ver, *old_driver_ver;
71527154 int rc, size = sizeof(cfgtable->driver_version);
71537155
7154− old_driver_ver = kmalloc(2 * size, GFP_KERNEL);
7156+ old_driver_ver = kmalloc_array(2, size, GFP_KERNEL);
71557157 if (!old_driver_ver)
71567158 return -ENOMEM;
71577159 driver_ver = old_driver_ver + size;
@@ -7931,9 +7933,9 @@ static void hpsa_free_cmd_pool(struct ctlr_info *h) · 773 unmodified lines
79317933
79327934 static int hpsa_alloc_cmd_pool(struct ctlr_info *h)
79337935 {
7934− h->cmd_pool_bits = kzalloc(
7935− DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG) *
7936− sizeof(unsigned long), GFP_KERNEL);
7936+ h->cmd_pool_bits = kcalloc(DIV_ROUND_UP(h->nr_cmds, BITS_PER_LONG),
7937+ sizeof(unsigned long),
7938+ GFP_KERNEL);
79377939 h->cmd_pool = pci_alloc_consistent(h->pdev,
79387940 h->nr_cmds * sizeof(*h->cmd_pool),
79397941 &(h->cmd_pool_dhandle));
@@ -8507,7 +8509,7 @@ static struct ctlr_info *hpda_alloc_ctlr_info(void) · 567 unmodified lines
85078509 if (!h)
85088510 return NULL;
85098511
8510− h->reply_map = kzalloc(sizeof(*h->reply_map) * nr_cpu_ids, GFP_KERNEL);
8512+ h->reply_map = kcalloc(nr_cpu_ids, sizeof(*h->reply_map), GFP_KERNEL);
85118513 if (!h->reply_map) {
85128514 kfree(h);
85138515 return NULL;
drivers/scsi/ipr.c+10−6
@@ -4331,9 +4331,11 @@ static int ipr_alloc_dump(struct ipr_ioa_cfg *ioa_cfg) · 4330 unmodified lines
43314331 }
43324332
43334333 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 *)));
43354336 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 *)));
43374339
43384340 if (!ioa_data) {
43394341 ipr_err("Dump memory allocation failed\n");
@@ -9713,8 +9715,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) · 5373 unmodified lines
97139715 int i, rc = -ENOMEM;
97149716
97159717 ENTER;
9716− ioa_cfg->res_entries = kzalloc(sizeof(struct ipr_resource_entry) *
9717− ioa_cfg->max_devs_supported, GFP_KERNEL);
9718+ ioa_cfg->res_entries = kcalloc(ioa_cfg->max_devs_supported,
9719+ sizeof(struct ipr_resource_entry),
9720+ GFP_KERNEL);
97189721
97199722 if (!ioa_cfg->res_entries)
97209723 goto out;
@@ -9775,8 +9778,9 @@ static int ipr_alloc_mem(struct ipr_ioa_cfg *ioa_cfg) · 54 unmodified lines
97759778 list_add_tail(&ioa_cfg->hostrcb[i]->queue, &ioa_cfg->hostrcb_free_q);
97769779 }
97779780
9778− ioa_cfg->trace = kzalloc(sizeof(struct ipr_trace_entry) *
9779− IPR_NUM_TRACE_ENTRIES, GFP_KERNEL);
9781+ ioa_cfg->trace = kcalloc(IPR_NUM_TRACE_ENTRIES,
9782+ sizeof(struct ipr_trace_entry),
9783+ GFP_KERNEL);
97809784
97819785 if (!ioa_cfg->trace)
97829786 goto out_free_hostrcb_dma;
drivers/scsi/isci/init.c+4−4
@@ -232,14 +232,14 @@ static int isci_register_sas_ha(struct isci_host *isci_host) · 231 unmodified lines
232232 struct asd_sas_phy **sas_phys;
233233 struct asd_sas_port **sas_ports;
234234
235− sas_phys = devm_kzalloc(&isci_host->pdev->dev,
236− SCI_MAX_PHYS * sizeof(void *),
235+ sas_phys = devm_kcalloc(&isci_host->pdev->dev,
236+ SCI_MAX_PHYS, sizeof(void *),
237237 GFP_KERNEL);
238238 if (!sas_phys)
239239 return -ENOMEM;
240240
241− sas_ports = devm_kzalloc(&isci_host->pdev->dev,
242− SCI_MAX_PORTS * sizeof(void *),
241+ sas_ports = devm_kcalloc(&isci_host->pdev->dev,
242+ SCI_MAX_PORTS, sizeof(void *),
243243 GFP_KERNEL);
244244 if (!sas_ports)
245245 return -ENOMEM;
drivers/scsi/libiscsi.c+1−1
@@ -2576,7 +2576,7 @@ iscsi_pool_init(struct iscsi_pool *q, int max, void ***items, int item_size) · 2575 unmodified lines
25762576 * the array. */
25772577 if (items)
25782578 num_arrays++;
2579− q->pool = kvzalloc(num_arrays * max * sizeof(void*), GFP_KERNEL);
2579+ q->pool = kvcalloc(num_arrays * max, sizeof(void *), GFP_KERNEL);
25802580 if (q->pool == NULL)
25812581 return -ENOMEM;
25822582
drivers/scsi/libsas/sas_expander.c+1−1
@@ -443,7 +443,7 @@ static int sas_expander_discover(struct domain_device *dev) · 442 unmodified lines
443443 struct expander_device *ex = &dev->ex_dev;
444444 int res = -ENOMEM;
445445
446− ex->ex_phy = kzalloc(sizeof(*ex->ex_phy)*ex->num_phys, GFP_KERNEL);
446+ ex->ex_phy = kcalloc(ex->num_phys, sizeof(*ex->ex_phy), GFP_KERNEL);
447447 if (!ex->ex_phy)
448448 return -ENOMEM;
449449
drivers/scsi/lpfc/lpfc_init.c+4−3
@@ -5723,8 +5723,9 @@ lpfc_sli_driver_resource_setup(struct lpfc_hba *phba) · 5722 unmodified lines
57235723 }
57245724
57255725 if (!phba->sli.sli3_ring)
5726− phba->sli.sli3_ring = kzalloc(LPFC_SLI3_MAX_RING *
5727− sizeof(struct lpfc_sli_ring), GFP_KERNEL);
5726+ phba->sli.sli3_ring = kcalloc(LPFC_SLI3_MAX_RING,
5727+ sizeof(struct lpfc_sli_ring),
5728+ GFP_KERNEL);
57285729 if (!phba->sli.sli3_ring)
57295730 return -ENOMEM;
57305731
@@ -6233,7 +6234,7 @@ lpfc_sli4_driver_resource_setup(struct lpfc_hba *phba) · 502 unmodified lines
62336234
62346235 /* Allocate eligible FCF bmask memory for FCF roundrobin failover */
62356236 longs = (LPFC_SLI4_FCF_TBL_INDX_MAX + BITS_PER_LONG - 1)/BITS_PER_LONG;
6236− phba->fcf.fcf_rr_bmask = kzalloc(longs * sizeof(unsigned long),
6237+ phba->fcf.fcf_rr_bmask = kcalloc(longs, sizeof(unsigned long),
62376238 GFP_KERNEL);
62386239 if (!phba->fcf.fcf_rr_bmask) {
62396240 lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
drivers/scsi/lpfc/lpfc_mem.c+3−2
@@ -120,8 +120,9 @@ lpfc_mem_alloc(struct lpfc_hba *phba, int align) · 119 unmodified lines
120120 if (!phba->lpfc_mbuf_pool)
121121 goto fail_free_dma_buf_pool;
122122
123− pool->elements = kmalloc(sizeof(struct lpfc_dmabuf) *
124− LPFC_MBUF_POOL_SIZE, GFP_KERNEL);
123+ pool->elements = kmalloc_array(LPFC_MBUF_POOL_SIZE,
124+ sizeof(struct lpfc_dmabuf),
125+ GFP_KERNEL);
125126 if (!pool->elements)
126127 goto fail_free_lpfc_mbuf_pool;
127128
drivers/scsi/lpfc/lpfc_sli.c+22−28
@@ -1720,7 +1720,7 @@ lpfc_sli_next_iotag(struct lpfc_hba *phba, struct lpfc_iocbq *iocbq) · 1719 unmodified lines
17201720 - LPFC_IOCBQ_LOOKUP_INCREMENT)) {
17211721 new_len = psli->iocbq_lookup_len + LPFC_IOCBQ_LOOKUP_INCREMENT;
17221722 spin_unlock_irq(&phba->hbalock);
1723− new_arr = kzalloc(new_len * sizeof (struct lpfc_iocbq *),
1723+ new_arr = kcalloc(new_len, sizeof(struct lpfc_iocbq *),
17241724 GFP_KERNEL);
17251725 if (new_arr) {
17261726 spin_lock_irq(&phba->hbalock);
@@ -5142,16 +5142,17 @@ lpfc_sli_hba_setup(struct lpfc_hba *phba) · 3415 unmodified lines
51425142 */
51435143 if ((phba->vpi_bmask == NULL) && (phba->vpi_ids == NULL)) {
51445144 longs = (phba->max_vpi + BITS_PER_LONG) / BITS_PER_LONG;
5145− phba->vpi_bmask = kzalloc(longs * sizeof(unsigned long),
5145+ phba->vpi_bmask = kcalloc(longs,
5146+ sizeof(unsigned long),
51465147 GFP_KERNEL);
51475148 if (!phba->vpi_bmask) {
51485149 rc = -ENOMEM;
51495150 goto lpfc_sli_hba_setup_error;
51505151 }
51515152
5152− phba->vpi_ids = kzalloc(
5153− (phba->max_vpi+1) * sizeof(uint16_t),
5154− GFP_KERNEL);
5153+ phba->vpi_ids = kcalloc(phba->max_vpi + 1,
5154+ sizeof(uint16_t),
5155+ GFP_KERNEL);
51555156 if (!phba->vpi_ids) {
51565157 kfree(phba->vpi_bmask);
51575158 rc = -ENOMEM;
@@ -5836,14 +5837,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) · 678 unmodified lines
58365837 length = sizeof(struct lpfc_rsrc_blks);
58375838 switch (type) {
58385839 case LPFC_RSC_TYPE_FCOE_RPI:
5839− phba->sli4_hba.rpi_bmask = kzalloc(longs *
5840+ phba->sli4_hba.rpi_bmask = kcalloc(longs,
58405841 sizeof(unsigned long),
58415842 GFP_KERNEL);
58425843 if (unlikely(!phba->sli4_hba.rpi_bmask)) {
58435844 rc = -ENOMEM;
58445845 goto err_exit;
58455846 }
5846− phba->sli4_hba.rpi_ids = kzalloc(rsrc_id_cnt *
5847+ phba->sli4_hba.rpi_ids = kcalloc(rsrc_id_cnt,
58475848 sizeof(uint16_t),
58485849 GFP_KERNEL);
58495850 if (unlikely(!phba->sli4_hba.rpi_ids)) {
@@ -5865,15 +5866,13 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) · 15 unmodified lines
58655866 ext_blk_list = &phba->sli4_hba.lpfc_rpi_blk_list;
58665867 break;
58675868 case LPFC_RSC_TYPE_FCOE_VPI:
5868− phba->vpi_bmask = kzalloc(longs *
5869− sizeof(unsigned long),
5869+ phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long),
58705870 GFP_KERNEL);
58715871 if (unlikely(!phba->vpi_bmask)) {
58725872 rc = -ENOMEM;
58735873 goto err_exit;
58745874 }
5875− phba->vpi_ids = kzalloc(rsrc_id_cnt *
5876− sizeof(uint16_t),
5875+ phba->vpi_ids = kcalloc(rsrc_id_cnt, sizeof(uint16_t),
58775876 GFP_KERNEL);
58785877 if (unlikely(!phba->vpi_ids)) {
58795878 kfree(phba->vpi_bmask);
@@ -5887,7 +5886,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) · 7 unmodified lines
58875886 ext_blk_list = &phba->lpfc_vpi_blk_list;
58885887 break;
58895888 case LPFC_RSC_TYPE_FCOE_XRI:
5890− phba->sli4_hba.xri_bmask = kzalloc(longs *
5889+ phba->sli4_hba.xri_bmask = kcalloc(longs,
58915890 sizeof(unsigned long),
58925891 GFP_KERNEL);
58935892 if (unlikely(!phba->sli4_hba.xri_bmask)) {
@@ -5895,7 +5894,7 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) · 1 unmodified line
58955894 goto err_exit;
58965895 }
58975896 phba->sli4_hba.max_cfg_param.xri_used = 0;
5898− phba->sli4_hba.xri_ids = kzalloc(rsrc_id_cnt *
5897+ phba->sli4_hba.xri_ids = kcalloc(rsrc_id_cnt,
58995898 sizeof(uint16_t),
59005899 GFP_KERNEL);
59015900 if (unlikely(!phba->sli4_hba.xri_ids)) {
@@ -5910,14 +5909,14 @@ lpfc_sli4_alloc_extent(struct lpfc_hba *phba, uint16_t type) · 8 unmodified lines
59105909 ext_blk_list = &phba->sli4_hba.lpfc_xri_blk_list;
59115910 break;
59125911 case LPFC_RSC_TYPE_FCOE_VFI:
5913− phba->sli4_hba.vfi_bmask = kzalloc(longs *
5912+ phba->sli4_hba.vfi_bmask = kcalloc(longs,
59145913 sizeof(unsigned long),
59155914 GFP_KERNEL);
59165915 if (unlikely(!phba->sli4_hba.vfi_bmask)) {
59175916 rc = -ENOMEM;
59185917 goto err_exit;
59195918 }
5920− phba->sli4_hba.vfi_ids = kzalloc(rsrc_id_cnt *
5919+ phba->sli4_hba.vfi_ids = kcalloc(rsrc_id_cnt,
59215920 sizeof(uint16_t),
59225921 GFP_KERNEL);
59235922 if (unlikely(!phba->sli4_hba.vfi_ids)) {
@@ -6250,15 +6249,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) · 326 unmodified lines
62506249 }
62516250 base = phba->sli4_hba.max_cfg_param.rpi_base;
62526251 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
6253− phba->sli4_hba.rpi_bmask = kzalloc(longs *
6252+ phba->sli4_hba.rpi_bmask = kcalloc(longs,
62546253 sizeof(unsigned long),
62556254 GFP_KERNEL);
62566255 if (unlikely(!phba->sli4_hba.rpi_bmask)) {
62576256 rc = -ENOMEM;
62586257 goto err_exit;
62596258 }
6260− phba->sli4_hba.rpi_ids = kzalloc(count *
6261− sizeof(uint16_t),
6259+ phba->sli4_hba.rpi_ids = kcalloc(count, sizeof(uint16_t),
62626260 GFP_KERNEL);
62636261 if (unlikely(!phba->sli4_hba.rpi_ids)) {
62646262 rc = -ENOMEM;
@@ -6279,15 +6277,13 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) · 14 unmodified lines
62796277 }
62806278 base = phba->sli4_hba.max_cfg_param.vpi_base;
62816279 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
6282− phba->vpi_bmask = kzalloc(longs *
6283− sizeof(unsigned long),
6280+ phba->vpi_bmask = kcalloc(longs, sizeof(unsigned long),
62846281 GFP_KERNEL);
62856282 if (unlikely(!phba->vpi_bmask)) {
62866283 rc = -ENOMEM;
62876284 goto free_rpi_ids;
62886285 }
6289− phba->vpi_ids = kzalloc(count *
6290− sizeof(uint16_t),
6286+ phba->vpi_ids = kcalloc(count, sizeof(uint16_t),
62916287 GFP_KERNEL);
62926288 if (unlikely(!phba->vpi_ids)) {
62936289 rc = -ENOMEM;
@@ -6308,7 +6304,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) · 14 unmodified lines
63086304 }
63096305 base = phba->sli4_hba.max_cfg_param.xri_base;
63106306 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
6311− phba->sli4_hba.xri_bmask = kzalloc(longs *
6307+ phba->sli4_hba.xri_bmask = kcalloc(longs,
63126308 sizeof(unsigned long),
63136309 GFP_KERNEL);
63146310 if (unlikely(!phba->sli4_hba.xri_bmask)) {
@@ -6316,8 +6312,7 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) · 1 unmodified line
63166312 goto free_vpi_ids;
63176313 }
63186314 phba->sli4_hba.max_cfg_param.xri_used = 0;
6319− phba->sli4_hba.xri_ids = kzalloc(count *
6320− sizeof(uint16_t),
6315+ phba->sli4_hba.xri_ids = kcalloc(count, sizeof(uint16_t),
63216316 GFP_KERNEL);
63226317 if (unlikely(!phba->sli4_hba.xri_ids)) {
63236318 rc = -ENOMEM;
@@ -6338,15 +6333,14 @@ lpfc_sli4_alloc_resource_identifiers(struct lpfc_hba *phba) · 14 unmodified lines
63386333 }
63396334 base = phba->sli4_hba.max_cfg_param.vfi_base;
63406335 longs = (count + BITS_PER_LONG - 1) / BITS_PER_LONG;
6341− phba->sli4_hba.vfi_bmask = kzalloc(longs *
6336+ phba->sli4_hba.vfi_bmask = kcalloc(longs,
63426337 sizeof(unsigned long),
63436338 GFP_KERNEL);
63446339 if (unlikely(!phba->sli4_hba.vfi_bmask)) {
63456340 rc = -ENOMEM;
63466341 goto free_xri_ids;
63476342 }
6348− phba->sli4_hba.vfi_ids = kzalloc(count *
6349− sizeof(uint16_t),
6343+ phba->sli4_hba.vfi_ids = kcalloc(count, sizeof(uint16_t),
63506344 GFP_KERNEL);
63516345 if (unlikely(!phba->sli4_hba.vfi_ids)) {
63526346 rc = -ENOMEM;
drivers/scsi/lpfc/lpfc_vport.c+1−1
@@ -840,7 +840,7 @@ lpfc_create_vport_work_array(struct lpfc_hba *phba) · 839 unmodified lines
840840 struct lpfc_vport *port_iterator;
841841 struct lpfc_vport **vports;
842842 int index = 0;
843− vports = kzalloc((phba->max_vports + 1) * sizeof(struct lpfc_vport *),
843+ vports = kcalloc(phba->max_vports + 1, sizeof(struct lpfc_vport *),
844844 GFP_KERNEL);
845845 if (vports == NULL)
846846 return NULL;
drivers/scsi/mac53c94.c+3−2
@@ -464,8 +464,9 @@ static int mac53c94_probe(struct macio_dev *mdev, const struct of_device_id *mat · 463 unmodified lines
464464 * +1 to allow for aligning.
465465 * XXX FIXME: Use DMA consistent routines
466466 */
467− dma_cmd_space = kmalloc((host->sg_tablesize + 2) *
468− sizeof(struct dbdma_cmd), GFP_KERNEL);
467+ dma_cmd_space = kmalloc_array(host->sg_tablesize + 2,
468+ sizeof(struct dbdma_cmd),
469+ GFP_KERNEL);
469470 if (dma_cmd_space == 0) {
470471 printk(KERN_ERR "mac53c94: couldn't allocate dma "
471472 "command space for %pOF\n", node);
drivers/scsi/megaraid.c+2−1
@@ -4292,7 +4292,8 @@ megaraid_probe_one(struct pci_dev *pdev, const struct pci_device_id *id) · 4291 unmodified lines
42924292 goto out_host_put;
42934293 }
42944294
4295− adapter->scb_list = kmalloc(sizeof(scb_t) * MAX_COMMANDS, GFP_KERNEL);
4295+ adapter->scb_list = kmalloc_array(MAX_COMMANDS, sizeof(scb_t),
4296+ GFP_KERNEL);
42964297 if (!adapter->scb_list) {
42974298 dev_warn(&pdev->dev, "out of RAM\n");
42984299 goto out_free_cmd_buffer;
drivers/scsi/megaraid/megaraid_mm.c+6−4
@@ -935,10 +935,12 @@ mraid_mm_register_adp(mraid_mmadp_t *lld_adp) · 934 unmodified lines
935935 * Allocate single blocks of memory for all required kiocs,
936936 * mailboxes and passthru structures.
937937 */
938− adapter->kioc_list = kmalloc(sizeof(uioc_t) * lld_adp->max_kioc,
939− GFP_KERNEL);
940− adapter->mbox_list = kmalloc(sizeof(mbox64_t) * lld_adp->max_kioc,
941− GFP_KERNEL);
938+ adapter->kioc_list = kmalloc_array(lld_adp->max_kioc,
939+ sizeof(uioc_t),
940+ GFP_KERNEL);
941+ adapter->mbox_list = kmalloc_array(lld_adp->max_kioc,
942+ sizeof(mbox64_t),
943+ GFP_KERNEL);
942944 adapter->pthru_dma_pool = dma_pool_create("megaraid mm pthru pool",
943945 &adapter->pdev->dev,
944946 sizeof(mraid_passthru_t),
drivers/scsi/megaraid/megaraid_sas_base.c+4−4
@@ -5419,9 +5419,9 @@ static int megasas_init_fw(struct megasas_instance *instance) · 5418 unmodified lines
54195419 /* stream detection initialization */
54205420 if (instance->adapter_type == VENTURA_SERIES) {
54215421 fusion->stream_detect_by_ld =
5422− kzalloc(sizeof(struct LD_STREAM_DETECT *)
5423− * MAX_LOGICAL_DRIVES_EXT,
5424− GFP_KERNEL);
5422+ kcalloc(MAX_LOGICAL_DRIVES_EXT,
5423+ sizeof(struct LD_STREAM_DETECT *),
5424+ GFP_KERNEL);
54255425 if (!fusion->stream_detect_by_ld) {
54265426 dev_err(&instance->pdev->dev,
54275427 "unable to allocate stream detection for pool of LDs\n");
@@ -6139,7 +6139,7 @@ static inline int megasas_alloc_mfi_ctrl_mem(struct megasas_instance *instance) · 711 unmodified lines
61396139 */
61406140 static int megasas_alloc_ctrl_mem(struct megasas_instance *instance)
61416141 {
6142− instance->reply_map = kzalloc(sizeof(unsigned int) * nr_cpu_ids,
6142+ instance->reply_map = kcalloc(nr_cpu_ids, sizeof(unsigned int),
61436143 GFP_KERNEL);
61446144 if (!instance->reply_map)
61456145 return -ENOMEM;
drivers/scsi/megaraid/megaraid_sas_fusion.c+7−5
@@ -487,7 +487,7 @@ megasas_alloc_cmdlist_fusion(struct megasas_instance *instance) · 486 unmodified lines
487487 * commands.
488488 */
489489 fusion->cmd_list =
490− kzalloc(sizeof(struct megasas_cmd_fusion *) * max_mpt_cmd,
490+ kcalloc(max_mpt_cmd, sizeof(struct megasas_cmd_fusion *),
491491 GFP_KERNEL);
492492 if (!fusion->cmd_list) {
493493 dev_err(&instance->pdev->dev,
@@ -4829,8 +4829,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) · 4335 unmodified lines
48294829 (PLD_SPAN_INFO)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
48304830 fusion->log_to_span_pages);
48314831 if (!fusion->log_to_span) {
4832− fusion->log_to_span = vzalloc(MAX_LOGICAL_DRIVES_EXT *
4833− sizeof(LD_SPAN_INFO));
4832+ fusion->log_to_span =
4833+ vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
4834+ sizeof(LD_SPAN_INFO)));
48344835 if (!fusion->log_to_span) {
48354836 dev_err(&instance->pdev->dev, "Failed from %s %d\n",
48364837 __func__, __LINE__);
@@ -4844,8 +4845,9 @@ megasas_alloc_fusion_context(struct megasas_instance *instance) · 7 unmodified lines
48444845 (struct LD_LOAD_BALANCE_INFO *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
48454846 fusion->load_balance_info_pages);
48464847 if (!fusion->load_balance_info) {
4847− fusion->load_balance_info = vzalloc(MAX_LOGICAL_DRIVES_EXT *
4848− sizeof(struct LD_LOAD_BALANCE_INFO));
4848+ fusion->load_balance_info =
4849+ vzalloc(array_size(MAX_LOGICAL_DRIVES_EXT,
4850+ sizeof(struct LD_LOAD_BALANCE_INFO)));
48494851 if (!fusion->load_balance_info)
48504852 dev_err(&instance->pdev->dev, "Failed to allocate load_balance_info, "
48514853 "continuing without Load Balance support\n");
drivers/scsi/osst.c+5−3
@@ -381,7 +381,7 @@ static int osst_execute(struct osst_request *SRpnt, const unsigned char *cmd, · 380 unmodified lines
381381 struct scatterlist *sg, *sgl = (struct scatterlist *)buffer;
382382 int i;
383383
384− pages = kzalloc(use_sg * sizeof(struct page *), GFP_KERNEL);
384+ pages = kcalloc(use_sg, sizeof(struct page *), GFP_KERNEL);
385385 if (!pages)
386386 goto free_req;
387387
@@ -1488,7 +1488,7 @@ static int osst_read_back_buffer_and_rewrite(struct osst_tape * STp, struct osst · 1100 unmodified lines
14881488 int dbg = debugging;
14891489 #endif
14901490
1491− if ((buffer = vmalloc((nframes + 1) * OS_DATA_SIZE)) == NULL)
1491+ if ((buffer = vmalloc(array_size((nframes + 1), OS_DATA_SIZE))) == NULL)
14921492 return (-EIO);
14931493
14941494 printk(KERN_INFO "%s:I: Reading back %d frames from drive buffer%s\n",
@@ -5856,7 +5856,9 @@ static int osst_probe(struct device *dev) · 4361 unmodified lines
58565856 /* if this is the first attach, build the infrastructure */
58575857 write_lock(&os_scsi_tapes_lock);
58585858 if (os_scsi_tapes == NULL) {
5859− os_scsi_tapes = kmalloc(osst_max_dev * sizeof(struct osst_tape *), GFP_ATOMIC);
5859+ os_scsi_tapes = kmalloc_array(osst_max_dev,
5860+ sizeof(struct osst_tape *),
5861+ GFP_ATOMIC);
58605862 if (os_scsi_tapes == NULL) {
58615863 write_unlock(&os_scsi_tapes_lock);
58625864 printk(KERN_ERR "osst :E: Unable to allocate array for OnStream SCSI tapes.\n");
drivers/scsi/pm8001/pm8001_ctl.c+1−1
@@ -705,7 +705,7 @@ static ssize_t pm8001_store_update_fw(struct device *cdev, · 704 unmodified lines
705705 return -EINPROGRESS;
706706 pm8001_ha->fw_status = FLASH_IN_PROGRESS;
707707
708− cmd_ptr = kzalloc(count*2, GFP_KERNEL);
708+ cmd_ptr = kcalloc(count, 2, GFP_KERNEL);
709709 if (!cmd_ptr) {
710710 pm8001_ha->fw_status = FAIL_OUT_MEMORY;
711711 return -ENOMEM;
drivers/scsi/pmcraid.c+3−2
@@ -4873,8 +4873,9 @@ static int pmcraid_allocate_config_buffers(struct pmcraid_instance *pinstance) · 4872 unmodified lines
48734873 int i;
48744874
48754875 pinstance->res_entries =
4876− kzalloc(sizeof(struct pmcraid_resource_entry) *
4877− PMCRAID_MAX_RESOURCES, GFP_KERNEL);
4876+ kcalloc(PMCRAID_MAX_RESOURCES,
4877+ sizeof(struct pmcraid_resource_entry),
4878+ GFP_KERNEL);
48784879
48794880 if (NULL == pinstance->res_entries) {
48804881 pmcraid_err("failed to allocate memory for resource table\n");
drivers/scsi/qedi/qedi_main.c+1−1
@@ -524,7 +524,7 @@ static int qedi_init_id_tbl(struct qedi_portid_tbl *id_tbl, u16 size, · 523 unmodified lines
524524 id_tbl->max = size;
525525 id_tbl->next = next;
526526 spin_lock_init(&id_tbl->lock);
527− id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL);
527+ id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL);
528528 if (!id_tbl->table)
529529 return -ENOMEM;
530530
drivers/scsi/qla2xxx/qla_init.c+6−4
@@ -3089,8 +3089,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) · 3088 unmodified lines
30893089 req->num_outstanding_cmds = ha->cur_fw_iocb_count;
30903090 }
30913091
3092− req->outstanding_cmds = kzalloc(sizeof(srb_t *) *
3093− req->num_outstanding_cmds, GFP_KERNEL);
3092+ req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
3093+ sizeof(srb_t *),
3094+ GFP_KERNEL);
30943095
30953096 if (!req->outstanding_cmds) {
30963097 /*
@@ -3098,8 +3099,9 @@ qla2x00_alloc_outstanding_cmds(struct qla_hw_data *ha, struct req_que *req) · 1 unmodified line
30983099 * initialization.
30993100 */
31003101 req->num_outstanding_cmds = MIN_OUTSTANDING_COMMANDS;
3101− req->outstanding_cmds = kzalloc(sizeof(srb_t *) *
3102− req->num_outstanding_cmds, GFP_KERNEL);
3102+ req->outstanding_cmds = kcalloc(req->num_outstanding_cmds,
3103+ sizeof(srb_t *),
3104+ GFP_KERNEL);
31033105
31043106 if (!req->outstanding_cmds) {
31053107 ql_log(ql_log_fatal, NULL, 0x0126,
drivers/scsi/qla2xxx/qla_isr.c+3−2
@@ -3434,8 +3434,9 @@ qla24xx_enable_msix(struct qla_hw_data *ha, struct rsp_que *rsp) · 3433 unmodified lines
34343434 "Adjusted Max no of queues pairs: %d.\n", ha->max_qpairs);
34353435 }
34363436 }
3437− ha->msix_entries = kzalloc(sizeof(struct qla_msix_entry) *
3438− ha->msix_count, GFP_KERNEL);
3437+ ha->msix_entries = kcalloc(ha->msix_count,
3438+ sizeof(struct qla_msix_entry),
3439+ GFP_KERNEL);
34393440 if (!ha->msix_entries) {
34403441 ql_log(ql_log_fatal, vha, 0x00c8,
34413442 "Failed to allocate memory for ha->msix_entries.\n");
drivers/scsi/qla2xxx/qla_nx.c+1−1
@@ -1230,7 +1230,7 @@ qla82xx_pinit_from_rom(scsi_qla_host_t *vha) · 1229 unmodified lines
12301230 ql_log(ql_log_info, vha, 0x0072,
12311231 "%d CRB init values found in ROM.\n", n);
12321232
1233− buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL);
1233+ buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
12341234 if (buf == NULL) {
12351235 ql_log(ql_log_fatal, vha, 0x010c,
12361236 "Unable to allocate memory.\n");
drivers/scsi/qla2xxx/qla_os.c+8−6
@@ -410,7 +410,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, · 409 unmodified lines
410410 struct rsp_que *rsp)
411411 {
412412 scsi_qla_host_t *vha = pci_get_drvdata(ha->pdev);
413− ha->req_q_map = kzalloc(sizeof(struct req_que *) * ha->max_req_queues,
413+ ha->req_q_map = kcalloc(ha->max_req_queues, sizeof(struct req_que *),
414414 GFP_KERNEL);
415415 if (!ha->req_q_map) {
416416 ql_log(ql_log_fatal, vha, 0x003b,
@@ -418,7 +418,7 @@ static int qla2x00_alloc_queues(struct qla_hw_data *ha, struct req_que *req, · 1 unmodified line
418418 goto fail_req_map;
419419 }
420420
421− ha->rsp_q_map = kzalloc(sizeof(struct rsp_que *) * ha->max_rsp_queues,
421+ ha->rsp_q_map = kcalloc(ha->max_rsp_queues, sizeof(struct rsp_que *),
422422 GFP_KERNEL);
423423 if (!ha->rsp_q_map) {
424424 ql_log(ql_log_fatal, vha, 0x003c,
@@ -4045,8 +4045,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, · 3620 unmodified lines
40454045 (*rsp)->ring);
40464046 /* Allocate memory for NVRAM data for vports */
40474047 if (ha->nvram_npiv_size) {
4048− ha->npiv_info = kzalloc(sizeof(struct qla_npiv_entry) *
4049− ha->nvram_npiv_size, GFP_KERNEL);
4048+ ha->npiv_info = kcalloc(ha->nvram_npiv_size,
4049+ sizeof(struct qla_npiv_entry),
4050+ GFP_KERNEL);
40504051 if (!ha->npiv_info) {
40514052 ql_log_pci(ql_log_fatal, ha->pdev, 0x002d,
40524053 "Failed to allocate memory for npiv_info.\n");
@@ -4080,8 +4081,9 @@ qla2x00_mem_alloc(struct qla_hw_data *ha, uint16_t req_len, uint16_t rsp_len, · 27 unmodified lines
40804081 INIT_LIST_HEAD(&ha->vp_list);
40814082
40824083 /* Allocate memory for our loop_id bitmap */
4083− ha->loop_id_map = kzalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE) * sizeof(long),
4084− GFP_KERNEL);
4084+ ha->loop_id_map = kcalloc(BITS_TO_LONGS(LOOPID_MAP_SIZE),
4085+ sizeof(long),
4086+ GFP_KERNEL);
40854087 if (!ha->loop_id_map)
40864088 goto fail_loop_id_map;
40874089 else {
drivers/scsi/qla2xxx/qla_target.c+6−4
@@ -6248,8 +6248,9 @@ int qlt_add_target(struct qla_hw_data *ha, struct scsi_qla_host *base_vha) · 6247 unmodified lines
62486248 return -ENOMEM;
62496249 }
62506250
6251− tgt->qphints = kzalloc((ha->max_qpairs + 1) *
6252− sizeof(struct qla_qpair_hint), GFP_KERNEL);
6251+ tgt->qphints = kcalloc(ha->max_qpairs + 1,
6252+ sizeof(struct qla_qpair_hint),
6253+ GFP_KERNEL);
62536254 if (!tgt->qphints) {
62546255 kfree(tgt);
62556256 ql_log(ql_log_warn, base_vha, 0x0197,
@@ -7089,8 +7090,9 @@ qlt_mem_alloc(struct qla_hw_data *ha) · 833 unmodified lines
70897090 if (!QLA_TGT_MODE_ENABLED())
70907091 return 0;
70917092
7092− ha->tgt.tgt_vp_map = kzalloc(sizeof(struct qla_tgt_vp_map) *
7093− MAX_MULTI_ID_FABRIC, GFP_KERNEL);
7093+ ha->tgt.tgt_vp_map = kcalloc(MAX_MULTI_ID_FABRIC,
7094+ sizeof(struct qla_tgt_vp_map),
7095+ GFP_KERNEL);
70947096 if (!ha->tgt.tgt_vp_map)
70957097 return -ENOMEM;
70967098
drivers/scsi/qla2xxx/tcm_qla2xxx.c+3−1
@@ -1661,7 +1661,9 @@ static int tcm_qla2xxx_init_lport(struct tcm_qla2xxx_lport *lport) · 1660 unmodified lines
16611661 return rc;
16621662 }
16631663
1664− lport->lport_loopid_map = vzalloc(sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
1664+ lport->lport_loopid_map =
1665+ vzalloc(array_size(65536,
1666+ sizeof(struct tcm_qla2xxx_fc_loopid)));
16651667 if (!lport->lport_loopid_map) {
16661668 pr_err("Unable to allocate lport->lport_loopid_map of %zu bytes\n",
16671669 sizeof(struct tcm_qla2xxx_fc_loopid) * 65536);
drivers/scsi/qla4xxx/ql4_nx.c+1−1
@@ -1077,7 +1077,7 @@ qla4_82xx_pinit_from_rom(struct scsi_qla_host *ha, int verbose) · 1076 unmodified lines
10771077 ql4_printk(KERN_INFO, ha,
10781078 "%s: %d CRB init values found in ROM.\n", DRIVER_NAME, n);
10791079
1080− buf = kmalloc(n * sizeof(struct crb_addr_pair), GFP_KERNEL);
1080+ buf = kmalloc_array(n, sizeof(struct crb_addr_pair), GFP_KERNEL);
10811081 if (buf == NULL) {
10821082 ql4_printk(KERN_WARNING, ha,
10831083 "%s: [ERROR] Unable to malloc memory.\n", DRIVER_NAME);
drivers/scsi/scsi_debug.c+3−2
@@ -3450,7 +3450,7 @@ static int resp_comp_write(struct scsi_cmnd *scp, · 3449 unmodified lines
34503450 return check_condition_result;
34513451 }
34523452 dnum = 2 * num;
3453− arr = kzalloc(dnum * lb_size, GFP_ATOMIC);
3453+ arr = kcalloc(lb_size, dnum, GFP_ATOMIC);
34543454 if (NULL == arr) {
34553455 mk_sense_buffer(scp, ILLEGAL_REQUEST, INSUFF_RES_ASC,
34563456 INSUFF_RES_ASCQ);
@@ -5439,7 +5439,8 @@ static int __init scsi_debug_init(void) · 1982 unmodified lines
54395439 }
54405440
54415441 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)));
54435444
54445445 pr_info("%lu provisioning blocks\n", map_size);
54455446
drivers/scsi/sd_zbc.c+1−1
@@ -494,7 +494,7 @@ out_free: · 493 unmodified lines
494494 static inline unsigned long *
495495 sd_zbc_alloc_zone_bitmap(u32 nr_zones, int numa_node)
496496 {
497− return kzalloc_node(BITS_TO_LONGS(nr_zones) * sizeof(unsigned long),
497+ return kcalloc_node(BITS_TO_LONGS(nr_zones), sizeof(unsigned long),
498498 GFP_KERNEL, numa_node);
499499 }
500500
drivers/scsi/ses.c+1−1
@@ -747,7 +747,7 @@ static int ses_intf_add(struct device *cdev, · 746 unmodified lines
747747 buf = NULL;
748748 }
749749 page2_not_supported:
750− scomp = kzalloc(sizeof(struct ses_component) * components, GFP_KERNEL);
750+ scomp = kcalloc(components, sizeof(struct ses_component), GFP_KERNEL);
751751 if (!scomp)
752752 goto err_free;
753753
drivers/scsi/sg.c+1−1
@@ -1045,7 +1045,7 @@ sg_ioctl(struct file *filp, unsigned int cmd_in, unsigned long arg) · 1044 unmodified lines
10451045 else {
10461046 sg_req_info_t *rinfo;
10471047
1048− rinfo = kzalloc(SZ_SG_REQ_INFO * SG_MAX_QUEUE,
1048+ rinfo = kcalloc(SG_MAX_QUEUE, SZ_SG_REQ_INFO,
10491049 GFP_KERNEL);
10501050 if (!rinfo)
10511051 return -ENOMEM;
drivers/scsi/smartpqi/smartpqi_init.c+6−4
@@ -1820,8 +1820,9 @@ static int pqi_update_scsi_devices(struct pqi_ctrl_info *ctrl_info) · 1819 unmodified lines
18201820
18211821 num_new_devices = num_physicals + num_logicals;
18221822
1823− new_device_list = kmalloc(sizeof(*new_device_list) *
1824− num_new_devices, GFP_KERNEL);
1823+ new_device_list = kmalloc_array(num_new_devices,
1824+ sizeof(*new_device_list),
1825+ GFP_KERNEL);
18251826 if (!new_device_list) {
18261827 dev_warn(&ctrl_info->pci_dev->dev, "%s\n", out_of_memory_msg);
18271828 rc = -ENOMEM;
@@ -4251,8 +4252,9 @@ static int pqi_alloc_io_resources(struct pqi_ctrl_info *ctrl_info) · 2423 unmodified lines
42514252 struct device *dev;
42524253 struct pqi_io_request *io_request;
42534254
4254− ctrl_info->io_request_pool = kzalloc(ctrl_info->max_io_slots *
4255− sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL);
4255+ ctrl_info->io_request_pool =
4256+ kcalloc(ctrl_info->max_io_slots,
4257+ sizeof(ctrl_info->io_request_pool[0]), GFP_KERNEL);
42564258
42574259 if (!ctrl_info->io_request_pool) {
42584260 dev_err(&ctrl_info->pci_dev->dev,
drivers/scsi/st.c+3−2
@@ -3888,7 +3888,7 @@ static struct st_buffer *new_tape_buffer(int need_dma, int max_sg) · 3887 unmodified lines
38883888 tb->dma = need_dma;
38893889 tb->buffer_size = 0;
38903890
3891− tb->reserved_pages = kzalloc(max_sg * sizeof(struct page *),
3891+ tb->reserved_pages = kcalloc(max_sg, sizeof(struct page *),
38923892 GFP_KERNEL);
38933893 if (!tb->reserved_pages) {
38943894 kfree(tb);
@@ -4915,7 +4915,8 @@ static int sgl_map_user_pages(struct st_buffer *STbp, · 1020 unmodified lines
49154915 if (count == 0)
49164916 return 0;
49174917
4918− if ((pages = kmalloc(max_pages * sizeof(*pages), GFP_KERNEL)) == NULL)
4918+ pages = kmalloc_array(max_pages, sizeof(*pages), GFP_KERNEL);
4919+ if (pages == NULL)
49194920 return -ENOMEM;
49204921
49214922 /* Try to fault in all of the necessary pages */
drivers/scsi/ufs/ufshcd-pltfrm.c+2−2
@@ -86,8 +86,8 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) · 85 unmodified lines
8686 goto out;
8787 }
8888
89− clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq),
90− GFP_KERNEL);
89+ clkfreq = devm_kcalloc(dev, sz, sizeof(*clkfreq),
90+ GFP_KERNEL);
9191 if (!clkfreq) {
9292 ret = -ENOMEM;
9393 goto out;
drivers/scsi/ufs/ufshcd.c+2−2
@@ -3357,8 +3357,8 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba) · 3356 unmodified lines
33573357 }
33583358
33593359 /* Allocate memory for local reference block */
3360− hba->lrb = devm_kzalloc(hba->dev,
3361− hba->nutrs * sizeof(struct ufshcd_lrb),
3360+ hba->lrb = devm_kcalloc(hba->dev,
3361+ hba->nutrs, sizeof(struct ufshcd_lrb),
33623362 GFP_KERNEL);
33633363 if (!hba->lrb) {
33643364 dev_err(hba->dev, "LRB Memory allocation failed\n");
drivers/scsi/virtio_scsi.c+4−3
@@ -794,9 +794,10 @@ static int virtscsi_init(struct virtio_device *vdev, · 793 unmodified lines
794794 struct irq_affinity desc = { .pre_vectors = 2 };
795795
796796 num_vqs = vscsi->num_queues + VIRTIO_SCSI_VQ_BASE;
797− vqs = kmalloc(num_vqs * sizeof(struct virtqueue *), GFP_KERNEL);
798− callbacks = kmalloc(num_vqs * sizeof(vq_callback_t *), GFP_KERNEL);
799− names = kmalloc(num_vqs * sizeof(char *), GFP_KERNEL);
797+ vqs = kmalloc_array(num_vqs, sizeof(struct virtqueue *), GFP_KERNEL);
798+ callbacks = kmalloc_array(num_vqs, sizeof(vq_callback_t *),
799+ GFP_KERNEL);
800+ names = kmalloc_array(num_vqs, sizeof(char *), GFP_KERNEL);
800801
801802 if (!callbacks || !vqs || !names) {
802803 err = -ENOMEM;
drivers/sh/clk/cpg.c+1−1
@@ -249,7 +249,7 @@ static int __init sh_clk_div_register_ops(struct clk *clks, int nr, · 248 unmodified lines
249249 int k;
250250
251251 freq_table_size *= (nr_divs + 1);
252− freq_table = kzalloc(freq_table_size * nr, GFP_KERNEL);
252+ freq_table = kcalloc(nr, freq_table_size, GFP_KERNEL);
253253 if (!freq_table) {
254254 pr_err("%s: unable to alloc memory\n", __func__);
255255 return -ENOMEM;
drivers/sh/intc/core.c+5−5
@@ -203,7 +203,7 @@ int __init register_intc_controller(struct intc_desc *desc) · 202 unmodified lines
203203
204204 if (desc->num_resources) {
205205 d->nr_windows = desc->num_resources;
206− d->window = kzalloc(d->nr_windows * sizeof(*d->window),
206+ d->window = kcalloc(d->nr_windows, sizeof(*d->window),
207207 GFP_NOWAIT);
208208 if (!d->window)
209209 goto err1;
@@ -230,12 +230,12 @@ int __init register_intc_controller(struct intc_desc *desc) · 20 unmodified lines
230230 d->nr_reg += hw->ack_regs ? hw->nr_ack_regs : 0;
231231 d->nr_reg += hw->subgroups ? hw->nr_subgroups : 0;
232232
233− d->reg = kzalloc(d->nr_reg * sizeof(*d->reg), GFP_NOWAIT);
233+ d->reg = kcalloc(d->nr_reg, sizeof(*d->reg), GFP_NOWAIT);
234234 if (!d->reg)
235235 goto err2;
236236
237237 #ifdef CONFIG_SMP
238− d->smp = kzalloc(d->nr_reg * sizeof(*d->smp), GFP_NOWAIT);
238+ d->smp = kcalloc(d->nr_reg, sizeof(*d->smp), GFP_NOWAIT);
239239 if (!d->smp)
240240 goto err3;
241241 #endif
@@ -253,7 +253,7 @@ int __init register_intc_controller(struct intc_desc *desc) · 11 unmodified lines
253253 }
254254
255255 if (hw->prio_regs) {
256− d->prio = kzalloc(hw->nr_vectors * sizeof(*d->prio),
256+ d->prio = kcalloc(hw->nr_vectors, sizeof(*d->prio),
257257 GFP_NOWAIT);
258258 if (!d->prio)
259259 goto err4;
@@ -269,7 +269,7 @@ int __init register_intc_controller(struct intc_desc *desc) · 9 unmodified lines
269269 }
270270
271271 if (hw->sense_regs) {
272− d->sense = kzalloc(hw->nr_vectors * sizeof(*d->sense),
272+ d->sense = kcalloc(hw->nr_vectors, sizeof(*d->sense),
273273 GFP_NOWAIT);
274274 if (!d->sense)
275275 goto err5;
drivers/sh/maple/maple.c+1−1
@@ -161,7 +161,7 @@ int maple_add_packet(struct maple_device *mdev, u32 function, u32 command, · 160 unmodified lines
161161 void *sendbuf = NULL;
162162
163163 if (length) {
164− sendbuf = kzalloc(length * 4, GFP_KERNEL);
164+ sendbuf = kcalloc(length, 4, GFP_KERNEL);
165165 if (!sendbuf) {
166166 ret = -ENOMEM;
167167 goto out;
drivers/slimbus/qcom-ctrl.c+1−1
@@ -540,7 +540,7 @@ static int qcom_slim_probe(struct platform_device *pdev) · 539 unmodified lines
540540 ctrl->tx.sl_sz = SLIM_MSGQ_BUF_LEN;
541541 ctrl->rx.n = QCOM_RX_MSGS;
542542 ctrl->rx.sl_sz = SLIM_MSGQ_BUF_LEN;
543− ctrl->wr_comp = kzalloc(sizeof(struct completion *) * QCOM_TX_MSGS,
543+ ctrl->wr_comp = kcalloc(QCOM_TX_MSGS, sizeof(struct completion *),
544544 GFP_KERNEL);
545545 if (!ctrl->wr_comp)
546546 return -ENOMEM;
drivers/soc/bcm/raspberrypi-power.c+4−2
@@ -165,8 +165,10 @@ static int rpi_power_probe(struct platform_device *pdev) · 164 unmodified lines
165165 return -ENOMEM;
166166
167167 rpi_domains->xlate.domains =
168− devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) *
169− RPI_POWER_DOMAIN_COUNT, GFP_KERNEL);
168+ devm_kcalloc(dev,
169+ RPI_POWER_DOMAIN_COUNT,
170+ sizeof(*rpi_domains->xlate.domains),
171+ GFP_KERNEL);
170172 if (!rpi_domains->xlate.domains)
171173 return -ENOMEM;
172174
drivers/soc/fsl/qbman/qman.c+3−2
@@ -1021,7 +1021,8 @@ int qman_alloc_fq_table(u32 _num_fqids) · 1020 unmodified lines
10211021 {
10221022 num_fqids = _num_fqids;
10231023
1024− fq_table = vzalloc(num_fqids * 2 * sizeof(struct qman_fq *));
1024+ fq_table = vzalloc(array3_size(sizeof(struct qman_fq *),
1025+ num_fqids, 2));
10251026 if (!fq_table)
10261027 return -ENOMEM;
10271028
@@ -1181,7 +1182,7 @@ static int qman_create_portal(struct qman_portal *portal, · 153 unmodified lines
11811182 qm_dqrr_set_ithresh(p, QMAN_PIRQ_DQRR_ITHRESH);
11821183 qm_mr_set_ithresh(p, QMAN_PIRQ_MR_ITHRESH);
11831184 qm_out(p, QM_REG_ITPR, QMAN_PIRQ_IPERIOD);
1184− portal->cgrs = kmalloc(2 * sizeof(*cgrs), GFP_KERNEL);
1185+ portal->cgrs = kmalloc_array(2, sizeof(*cgrs), GFP_KERNEL);
11851186 if (!portal->cgrs)
11861187 goto fail_cgrs;
11871188 /* initial snapshot is no-depletion */
drivers/soc/mediatek/mtk-scpsys.c+4−4
@@ -376,15 +376,15 @@ static struct scp *init_scp(struct platform_device *pdev, · 375 unmodified lines
376376 if (IS_ERR(scp->base))
377377 return ERR_CAST(scp->base);
378378
379− scp->domains = devm_kzalloc(&pdev->dev,
380− sizeof(*scp->domains) * num, GFP_KERNEL);
379+ scp->domains = devm_kcalloc(&pdev->dev,
380+ num, sizeof(*scp->domains), GFP_KERNEL);
381381 if (!scp->domains)
382382 return ERR_PTR(-ENOMEM);
383383
384384 pd_data = &scp->pd_data;
385385
386− pd_data->domains = devm_kzalloc(&pdev->dev,
387− sizeof(*pd_data->domains) * num, GFP_KERNEL);
386+ pd_data->domains = devm_kcalloc(&pdev->dev,
387+ num, sizeof(*pd_data->domains), GFP_KERNEL);
388388 if (!pd_data->domains)
389389 return ERR_PTR(-ENOMEM);
390390
drivers/soc/ti/knav_qmss_acc.c+3−3
@@ -405,8 +405,8 @@ static int knav_acc_init_queue(struct knav_range_info *range, · 404 unmodified lines
405405 {
406406 unsigned id = kq->id - range->queue_base;
407407
408− kq->descs = devm_kzalloc(range->kdev->dev,
409− ACC_DESCS_MAX * sizeof(u32), GFP_KERNEL);
408+ kq->descs = devm_kcalloc(range->kdev->dev,
409+ ACC_DESCS_MAX, sizeof(u32), GFP_KERNEL);
410410 if (!kq->descs)
411411 return -ENOMEM;
412412
@@ -552,7 +552,7 @@ int knav_init_acc_range(struct knav_device *kdev, · 139 unmodified lines
552552 info->list_size = list_size;
553553 mem_size = PAGE_ALIGN(list_size * 2);
554554 info->mem_size = mem_size;
555− range->acc = devm_kzalloc(kdev->dev, channels * sizeof(*range->acc),
555+ range->acc = devm_kcalloc(kdev->dev, channels, sizeof(*range->acc),
556556 GFP_KERNEL);
557557 if (!range->acc)
558558 return -ENOMEM;
drivers/spi/spi-davinci.c+4−3
@@ -923,9 +923,10 @@ static int davinci_spi_probe(struct platform_device *pdev) · 922 unmodified lines
923923 /* pdata in dspi is now updated and point pdata to that */
924924 pdata = &dspi->pdata;
925925
926− dspi->bytes_per_word = devm_kzalloc(&pdev->dev,
927− sizeof(*dspi->bytes_per_word) *
928− pdata->num_chipselect, GFP_KERNEL);
926+ dspi->bytes_per_word = devm_kcalloc(&pdev->dev,
927+ pdata->num_chipselect,
928+ sizeof(*dspi->bytes_per_word),
929+ GFP_KERNEL);
929930 if (dspi->bytes_per_word == NULL) {
930931 ret = -ENOMEM;
931932 goto free_master;
drivers/spi/spi-ep93xx.c+2−2
@@ -671,8 +671,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) · 670 unmodified lines
671671 master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16);
672672
673673 master->num_chipselect = info->num_chipselect;
674− master->cs_gpios = devm_kzalloc(&master->dev,
675− sizeof(int) * master->num_chipselect,
674+ master->cs_gpios = devm_kcalloc(&master->dev,
675+ master->num_chipselect, sizeof(int),
676676 GFP_KERNEL);
677677 if (!master->cs_gpios) {
678678 error = -ENOMEM;
drivers/spi/spi-gpio.c+3−2
@@ -373,8 +373,9 @@ static int spi_gpio_probe(struct platform_device *pdev) · 372 unmodified lines
373373
374374 spi_gpio = spi_master_get_devdata(master);
375375
376− spi_gpio->cs_gpios = devm_kzalloc(&pdev->dev,
377− pdata->num_chipselect * sizeof(*spi_gpio->cs_gpios),
376+ spi_gpio->cs_gpios = devm_kcalloc(&pdev->dev,
377+ pdata->num_chipselect,
378+ sizeof(*spi_gpio->cs_gpios),
378379 GFP_KERNEL);
379380 if (!spi_gpio->cs_gpios)
380381 return -ENOMEM;
drivers/spi/spi-imx.c+3−2
@@ -1511,8 +1511,9 @@ static int spi_imx_probe(struct platform_device *pdev) · 1510 unmodified lines
15111511 if (mxc_platform_info) {
15121512 master->num_chipselect = mxc_platform_info->num_chipselect;
15131513 if (mxc_platform_info->chipselect) {
1514− master->cs_gpios = devm_kzalloc(&master->dev,
1515− sizeof(int) * master->num_chipselect, GFP_KERNEL);
1514+ master->cs_gpios = devm_kcalloc(&master->dev,
1515+ master->num_chipselect, sizeof(int),
1516+ GFP_KERNEL);
15161517 if (!master->cs_gpios)
15171518 return -ENOMEM;
15181519
drivers/spi/spi-oc-tiny.c+2−2
@@ -213,8 +213,8 @@ static int tiny_spi_of_probe(struct platform_device *pdev) · 212 unmodified lines
213213 return 0;
214214 hw->gpio_cs_count = of_gpio_count(np);
215215 if (hw->gpio_cs_count > 0) {
216− hw->gpio_cs = devm_kzalloc(&pdev->dev,
217− hw->gpio_cs_count * sizeof(unsigned int),
216+ hw->gpio_cs = devm_kcalloc(&pdev->dev,
217+ hw->gpio_cs_count, sizeof(unsigned int),
218218 GFP_KERNEL);
219219 if (!hw->gpio_cs)
220220 return -ENOMEM;
drivers/spi/spi-pl022.c+1−1
@@ -2135,7 +2135,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) · 2134 unmodified lines
21352135 pl022->master_info = platform_info;
21362136 pl022->adev = adev;
21372137 pl022->vendor = id->data;
2138− pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int),
2138+ pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int),
21392139 GFP_KERNEL);
21402140 if (!pl022->chipselects) {
21412141 status = -ENOMEM;
drivers/spi/spi.c+1−1
@@ -2049,7 +2049,7 @@ static int of_spi_register_master(struct spi_controller *ctlr) · 2048 unmodified lines
20492049 else if (nb < 0)
20502050 return nb;
20512051
2052− cs = devm_kzalloc(&ctlr->dev, sizeof(int) * ctlr->num_chipselect,
2052+ cs = devm_kcalloc(&ctlr->dev, ctlr->num_chipselect, sizeof(int),
20532053 GFP_KERNEL);
20542054 ctlr->cs_gpios = cs;
20552055
drivers/staging/android/ion/ion_heap.c+2−1
@@ -25,7 +25,8 @@ void *ion_heap_map_kernel(struct ion_heap *heap, · 24 unmodified lines
2525 pgprot_t pgprot;
2626 struct sg_table *table = buffer->sg_table;
2727 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 *)));
2930 struct page **tmp = pages;
3031
3132 if (!pages)
drivers/staging/greybus/audio_topology.c+1−1
@@ -144,7 +144,7 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb, · 143 unmodified lines
144144 __u8 *data;
145145
146146 items = le32_to_cpu(gbenum->items);
147− strings = devm_kzalloc(gb->dev, sizeof(char *) * items, GFP_KERNEL);
147+ strings = devm_kcalloc(gb->dev, items, sizeof(char *), GFP_KERNEL);
148148 data = gbenum->names;
149149
150150 for (i = 0; i < items; i++) {
drivers/staging/greybus/camera.c+3−2
@@ -1175,8 +1175,9 @@ static int gb_camera_debugfs_init(struct gb_camera *gcam) · 1174 unmodified lines
11751175
11761176 gcam->debugfs.root = debugfs_create_dir(dirname, gb_debugfs_get());
11771177
1178− gcam->debugfs.buffers = vmalloc(sizeof(*gcam->debugfs.buffers) *
1179− GB_CAMERA_DEBUGFS_BUFFER_MAX);
1178+ gcam->debugfs.buffers =
1179+ vmalloc(array_size(GB_CAMERA_DEBUGFS_BUFFER_MAX,
1180+ sizeof(*gcam->debugfs.buffers)));
11801181 if (!gcam->debugfs.buffers)
11811182 return -ENOMEM;
11821183
drivers/staging/media/imx/imx-media-dev.c+3−3
@@ -303,9 +303,9 @@ static int imx_media_alloc_pad_vdev_lists(struct imx_media_dev *imxmd) · 302 unmodified lines
303303
304304 list_for_each_entry(sd, &imxmd->v4l2_dev.subdevs, list) {
305305 entity = &sd->entity;
306− vdev_lists = devm_kzalloc(
306+ vdev_lists = devm_kcalloc(
307307 imxmd->md.dev,
308− entity->num_pads * sizeof(*vdev_lists),
308+ entity->num_pads, sizeof(*vdev_lists),
309309 GFP_KERNEL);
310310 if (!vdev_lists)
311311 return -ENOMEM;
@@ -544,7 +544,7 @@ static int imx_media_probe(struct platform_device *pdev) · 232 unmodified lines
544544 goto unreg_dev;
545545 }
546546
547− subdevs = devm_kzalloc(imxmd->md.dev, sizeof(*subdevs) * num_subdevs,
547+ subdevs = devm_kcalloc(imxmd->md.dev, num_subdevs, sizeof(*subdevs),
548548 GFP_KERNEL);
549549 if (!subdevs) {
550550 ret = -ENOMEM;
drivers/staging/media/zoran/zoran_driver.c+3−2
@@ -941,7 +941,7 @@ static int zoran_open(struct file *file) · 940 unmodified lines
941941 /* used to be BUZ_MAX_WIDTH/HEIGHT, but that gives overflows
942942 * on norm-change! */
943943 fh->overlay_mask =
944− kmalloc(((768 + 31) / 32) * 576 * 4, GFP_KERNEL);
944+ kmalloc(array3_size((768 + 31) / 32, 576, 4), GFP_KERNEL);
945945 if (!fh->overlay_mask) {
946946 dprintk(1,
947947 KERN_ERR
@@ -1220,7 +1220,8 @@ static int setup_window(struct zoran_fh *fh, · 272 unmodified lines
12201220 }
12211221 } else if (clipcount) {
12221222 /* 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));
12241225 if (vcp == NULL) {
12251226 dprintk(1,
12261227 KERN_ERR
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c+17−9
@@ -143,7 +143,7 @@ static int rt2880_pinctrl_dt_node_to_map(struct pinctrl_dev *pctrldev, · 142 unmodified lines
143143 if (!max_maps)
144144 return max_maps;
145145
146− *map = kzalloc(max_maps * sizeof(struct pinctrl_map), GFP_KERNEL);
146+ *map = kcalloc(max_maps, sizeof(struct pinctrl_map), GFP_KERNEL);
147147 if (!*map)
148148 return -ENOMEM;
149149
@@ -287,7 +287,8 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) · 137 unmodified lines
287287 }
288288
289289 /* allocate the group names array needed by the gpio function */
290− p->group_names = devm_kzalloc(p->dev, sizeof(char *) * p->group_count, GFP_KERNEL);
290+ p->group_names = devm_kcalloc(p->dev, p->group_count, sizeof(char *),
291+ GFP_KERNEL);
291292 if (!p->group_names)
292293 return -1;
293294
@@ -300,8 +301,12 @@ static int rt2880_pinmux_index(struct rt2880_priv *p) · 6 unmodified lines
300301 p->func_count++;
301302
302303 /* allocate our function and group mapping index buffers */
303− f = p->func = devm_kzalloc(p->dev, sizeof(struct rt2880_pmx_func) * p->func_count, GFP_KERNEL);
304− gpio_func.groups = devm_kzalloc(p->dev, sizeof(int) * p->group_count, GFP_KERNEL);
304+ f = p->func = devm_kcalloc(p->dev,
305+ p->func_count,
306+ sizeof(struct rt2880_pmx_func),
307+ GFP_KERNEL);
308+ gpio_func.groups = devm_kcalloc(p->dev, p->group_count, sizeof(int),
309+ GFP_KERNEL);
305310 if (!f || !gpio_func.groups)
306311 return -1;
307312
@@ -337,7 +342,10 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) · 29 unmodified lines
337342 if (!p->func[i]->pin_count)
338343 continue;
339344
340− p->func[i]->pins = devm_kzalloc(p->dev, sizeof(int) * p->func[i]->pin_count, GFP_KERNEL);
345+ p->func[i]->pins = devm_kcalloc(p->dev,
346+ p->func[i]->pin_count,
347+ sizeof(int),
348+ GFP_KERNEL);
341349 for (j = 0; j < p->func[i]->pin_count; j++)
342350 p->func[i]->pins[j] = p->func[i]->pin_first + j;
343351
@@ -347,11 +355,11 @@ static int rt2880_pinmux_pins(struct rt2880_priv *p) · 3 unmodified lines
347355 }
348356
349357 /* the buffer that tells us which pins are gpio */
350− p->gpio = devm_kzalloc(p->dev,sizeof(uint8_t) * p->max_pins,
351− GFP_KERNEL);
358+ p->gpio = devm_kcalloc(p->dev,p->max_pins, sizeof(uint8_t),
359+ GFP_KERNEL);
352360 /* the pads needed to tell pinctrl about our pins */
353− p->pads = devm_kzalloc(p->dev,
354− sizeof(struct pinctrl_pin_desc) * p->max_pins,
361+ p->pads = devm_kcalloc(p->dev,
362+ p->max_pins, sizeof(struct pinctrl_pin_desc),
355363 GFP_KERNEL);
356364 if (!p->pads || !p->gpio ) {
357365 dev_err(p->dev, "Failed to allocate gpio data\n");
drivers/staging/rtl8188eu/core/rtw_mlme.c+1−1
@@ -53,7 +53,7 @@ int rtw_init_mlme_priv(struct adapter *padapter) · 52 unmodified lines
5353
5454 memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
5555
56− pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
56+ pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
5757
5858 if (!pbuf) {
5959 res = _FAIL;
drivers/staging/rtl8192u/ieee80211/ieee80211_rx.c+3−2
@@ -597,8 +597,9 @@ static void RxReorderIndicatePacket(struct ieee80211_device *ieee, · 596 unmodified lines
597597 bool bMatchWinStart = false, bPktInBuf = false;
598598 IEEE80211_DEBUG(IEEE80211_DL_REORDER,"%s(): Seq is %d,pTS->RxIndicateSeq is %d, WinSize is %d\n",__func__,SeqNum,pTS->RxIndicateSeq,WinSize);
599599
600− prxbIndicateArray = kmalloc(sizeof(struct ieee80211_rxb *) *
601− REORDER_WIN_SIZE, GFP_KERNEL);
600+ prxbIndicateArray = kmalloc_array(REORDER_WIN_SIZE,
601+ sizeof(struct ieee80211_rxb *),
602+ GFP_KERNEL);
602603 if (!prxbIndicateArray)
603604 return;
604605
drivers/staging/rtl8192u/r8192U_core.c+2−2
@@ -1640,8 +1640,8 @@ static short rtl8192_usb_initendpoints(struct net_device *dev) · 1639 unmodified lines
16401640 {
16411641 struct r8192_priv *priv = ieee80211_priv(dev);
16421642
1643− priv->rx_urb = kmalloc(sizeof(struct urb *) * (MAX_RX_URB + 1),
1644− GFP_KERNEL);
1643+ priv->rx_urb = kmalloc_array(MAX_RX_URB + 1, sizeof(struct urb *),
1644+ GFP_KERNEL);
16451645 if (!priv->rx_urb)
16461646 return -ENOMEM;
16471647
drivers/staging/rtl8723bs/core/rtw_mlme.c+1−1
@@ -37,7 +37,7 @@ sint _rtw_init_mlme_priv(struct adapter *padapter) · 36 unmodified lines
3737
3838 memset(&pmlmepriv->assoc_ssid, 0, sizeof(struct ndis_802_11_ssid));
3939
40− pbuf = vzalloc(MAX_BSS_CNT * (sizeof(struct wlan_network)));
40+ pbuf = vzalloc(array_size(MAX_BSS_CNT, sizeof(struct wlan_network)));
4141
4242 if (pbuf == NULL) {
4343 res = _FAIL;
drivers/staging/rtlwifi/efuse.c+2−2
@@ -237,8 +237,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) · 236 unmodified lines
237237 }
238238
239239 /* allocate memory for efuse_tbl and efuse_word */
240− efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] *
241− sizeof(u8), GFP_ATOMIC);
240+ efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE],
241+ GFP_ATOMIC);
242242 if (!efuse_tbl)
243243 return;
244244 efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC);
drivers/staging/rts5208/ms.c+1−1
@@ -2618,7 +2618,7 @@ static int ms_build_l2p_tbl(struct rtsx_chip *chip, int seg_no) · 2617 unmodified lines
26182618 segment = &ms_card->segment[seg_no];
26192619
26202620 if (!segment->l2p_table) {
2621− segment->l2p_table = vmalloc(table_size * 2);
2621+ segment->l2p_table = vmalloc(array_size(table_size, 2));
26222622 if (!segment->l2p_table) {
26232623 rtsx_trace(chip);
26242624 goto BUILD_FAIL;
drivers/staging/rts5208/rtsx_chip.c+3−3
@@ -1660,13 +1660,13 @@ int rtsx_write_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, · 1659 unmodified lines
16601660
16611661 dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
16621662
1663− data = vzalloc(dw_len * 4);
1663+ data = vzalloc(array_size(dw_len, 4));
16641664 if (!data) {
16651665 rtsx_trace(chip);
16661666 return STATUS_NOMEM;
16671667 }
16681668
1669− mask = vzalloc(dw_len * 4);
1669+ mask = vzalloc(array_size(dw_len, 4));
16701670 if (!mask) {
16711671 vfree(data);
16721672 rtsx_trace(chip);
@@ -1721,7 +1721,7 @@ int rtsx_read_cfg_seq(struct rtsx_chip *chip, u8 func, u16 addr, u8 *buf, · 48 unmodified lines
17211721
17221722 dev_dbg(rtsx_dev(chip), "dw_len = %d\n", dw_len);
17231723
1724− data = vmalloc(dw_len * 4);
1724+ data = vmalloc(array_size(dw_len, 4));
17251725 if (!data) {
17261726 rtsx_trace(chip);
17271727 return STATUS_NOMEM;
drivers/staging/unisys/visorhba/visorhba_main.c+1−1
@@ -865,7 +865,7 @@ static void do_scsi_nolinuxstat(struct uiscmdrsp *cmdrsp, · 864 unmodified lines
865865 if (cmdrsp->scsi.no_disk_result == 0)
866866 return;
867867
868− buf = kzalloc(sizeof(char) * 36, GFP_KERNEL);
868+ buf = kzalloc(36, GFP_KERNEL);
869869 if (!buf)
870870 return;
871871
drivers/target/target_core_transport.c+2−2
@@ -250,10 +250,10 @@ int transport_alloc_session_tags(struct se_session *se_sess, · 249 unmodified lines
250250 {
251251 int rc;
252252
253− se_sess->sess_cmd_map = kzalloc(tag_num * tag_size,
253+ se_sess->sess_cmd_map = kcalloc(tag_size, tag_num,
254254 GFP_KERNEL | __GFP_NOWARN | __GFP_RETRY_MAYFAIL);
255255 if (!se_sess->sess_cmd_map) {
256− se_sess->sess_cmd_map = vzalloc(tag_num * tag_size);
256+ se_sess->sess_cmd_map = vzalloc(array_size(tag_size, tag_num));
257257 if (!se_sess->sess_cmd_map) {
258258 pr_err("Unable to allocate se_sess->sess_cmd_map\n");
259259 return -ENOMEM;
drivers/target/target_core_user.c+3−2
@@ -1717,8 +1717,9 @@ static int tcmu_configure_device(struct se_device *dev) · 1716 unmodified lines
17171717
17181718 info = &udev->uio_info;
17191719
1720− udev->data_bitmap = kzalloc(BITS_TO_LONGS(udev->max_blocks) *
1721− sizeof(unsigned long), GFP_KERNEL);
1720+ udev->data_bitmap = kcalloc(BITS_TO_LONGS(udev->max_blocks),
1721+ sizeof(unsigned long),
1722+ GFP_KERNEL);
17221723 if (!udev->data_bitmap) {
17231724 ret = -ENOMEM;
17241725 goto err_bitmap_alloc;
drivers/thermal/int340x_thermal/acpi_thermal_rel.c+2−2
@@ -96,7 +96,7 @@ int acpi_parse_trt(acpi_handle handle, int *trt_count, struct trt **trtp, · 95 unmodified lines
9696 }
9797
9898 *trt_count = p->package.count;
99− trts = kzalloc(*trt_count * sizeof(struct trt), GFP_KERNEL);
99+ trts = kcalloc(*trt_count, sizeof(struct trt), GFP_KERNEL);
100100 if (!trts) {
101101 result = -ENOMEM;
102102 goto end;
@@ -178,7 +178,7 @@ int acpi_parse_art(acpi_handle handle, int *art_count, struct art **artp, · 75 unmodified lines
178178
179179 /* ignore p->package.elements[0], as this is _ART Revision field */
180180 *art_count = p->package.count - 1;
181− arts = kzalloc(*art_count * sizeof(struct art), GFP_KERNEL);
181+ arts = kcalloc(*art_count, sizeof(struct art), GFP_KERNEL);
182182 if (!arts) {
183183 result = -ENOMEM;
184184 goto end;
drivers/thermal/int340x_thermal/int340x_thermal_zone.c+4−3
@@ -239,9 +239,10 @@ struct int34x_thermal_zone *int340x_thermal_zone_add(struct acpi_device *adev, · 238 unmodified lines
239239 if (ACPI_FAILURE(status))
240240 trip_cnt = 0;
241241 else {
242− int34x_thermal_zone->aux_trips = kzalloc(
243− sizeof(*int34x_thermal_zone->aux_trips) *
244− trip_cnt, GFP_KERNEL);
242+ int34x_thermal_zone->aux_trips =
243+ kcalloc(trip_cnt,
244+ sizeof(*int34x_thermal_zone->aux_trips),
245+ GFP_KERNEL);
245246 if (!int34x_thermal_zone->aux_trips) {
246247 ret = -ENOMEM;
247248 goto err_trip_alloc;
drivers/thermal/of-thermal.c+2−2
@@ -853,7 +853,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) · 852 unmodified lines
853853 if (tz->ntrips == 0) /* must have at least one child */
854854 goto finish;
855855
856− tz->trips = kzalloc(tz->ntrips * sizeof(*tz->trips), GFP_KERNEL);
856+ tz->trips = kcalloc(tz->ntrips, sizeof(*tz->trips), GFP_KERNEL);
857857 if (!tz->trips) {
858858 ret = -ENOMEM;
859859 goto free_tz;
@@ -879,7 +879,7 @@ __init *thermal_of_build_thermal_zone(struct device_node *np) · 19 unmodified lines
879879 if (tz->num_tbps == 0)
880880 goto finish;
881881
882− tz->tbps = kzalloc(tz->num_tbps * sizeof(*tz->tbps), GFP_KERNEL);
882+ tz->tbps = kcalloc(tz->num_tbps, sizeof(*tz->tbps), GFP_KERNEL);
883883 if (!tz->tbps) {
884884 ret = -ENOMEM;
885885 goto free_trips;
drivers/thermal/tegra/soctherm.c+4−4
@@ -1318,8 +1318,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) · 1317 unmodified lines
13181318 return PTR_ERR(tegra->clock_soctherm);
13191319 }
13201320
1321− tegra->calib = devm_kzalloc(&pdev->dev,
1322− sizeof(u32) * soc->num_tsensors,
1321+ tegra->calib = devm_kcalloc(&pdev->dev,
1322+ soc->num_tsensors, sizeof(u32),
13231323 GFP_KERNEL);
13241324 if (!tegra->calib)
13251325 return -ENOMEM;
@@ -1338,8 +1338,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) · 12 unmodified lines
13381338 return err;
13391339 }
13401340
1341− tegra->thermctl_tzs = devm_kzalloc(&pdev->dev,
1342− sizeof(*z) * soc->num_ttgs,
1341+ tegra->thermctl_tzs = devm_kcalloc(&pdev->dev,
1342+ soc->num_ttgs, sizeof(*z),
13431343 GFP_KERNEL);
13441344 if (!tegra->thermctl_tzs)
13451345 return -ENOMEM;
drivers/thermal/thermal-generic-adc.c+3−2
@@ -87,8 +87,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev, · 86 unmodified lines
8787 return -EINVAL;
8888 }
8989
90− gti->lookup_table = devm_kzalloc(dev, sizeof(*gti->lookup_table) *
91− ntable, GFP_KERNEL);
90+ gti->lookup_table = devm_kcalloc(dev,
91+ ntable, sizeof(*gti->lookup_table),
92+ GFP_KERNEL);
9293 if (!gti->lookup_table)
9394 return -ENOMEM;
9495
drivers/thermal/x86_pkg_temp_thermal.c+2−1
@@ -516,7 +516,8 @@ static int __init pkg_temp_thermal_init(void) · 515 unmodified lines
516516 return -ENODEV;
517517
518518 max_packages = topology_max_packages();
519− packages = kzalloc(max_packages * sizeof(struct pkg_device *), GFP_KERNEL);
519+ packages = kcalloc(max_packages, sizeof(struct pkg_device *),
520+ GFP_KERNEL);
520521 if (!packages)
521522 return -ENOMEM;
522523
drivers/tty/ehv_bytechan.c+1−1
@@ -754,7 +754,7 @@ static int __init ehv_bc_init(void) · 753 unmodified lines
754754 * array, then you can use pointer math (e.g. "bc - bcs") to get its
755755 * tty index.
756756 */
757− bcs = kzalloc(count * sizeof(struct ehv_bc_data), GFP_KERNEL);
757+ bcs = kcalloc(count, sizeof(struct ehv_bc_data), GFP_KERNEL);
758758 if (!bcs)
759759 return -ENOMEM;
760760
drivers/tty/goldfish.c+3−2
@@ -245,8 +245,9 @@ static int goldfish_tty_create_driver(void) · 244 unmodified lines
245245 int ret;
246246 struct tty_driver *tty;
247247
248− goldfish_ttys = kzalloc(sizeof(*goldfish_ttys) *
249− goldfish_tty_line_count, GFP_KERNEL);
248+ goldfish_ttys = kcalloc(goldfish_tty_line_count,
249+ sizeof(*goldfish_ttys),
250+ GFP_KERNEL);
250251 if (goldfish_ttys == NULL) {
251252 ret = -ENOMEM;
252253 goto err_alloc_goldfish_ttys_failed;
drivers/tty/hvc/hvc_iucv.c+1−1
@@ -1252,7 +1252,7 @@ static int hvc_iucv_setup_filter(const char *val) · 1251 unmodified lines
12521252 if (size > MAX_VMID_FILTER)
12531253 return -ENOSPC;
12541254
1255− array = kzalloc(size * 8, GFP_KERNEL);
1255+ array = kcalloc(size, 8, GFP_KERNEL);
12561256 if (!array)
12571257 return -ENOMEM;
12581258
drivers/tty/hvc/hvcs.c+2−1
@@ -1441,7 +1441,8 @@ static int hvcs_alloc_index_list(int n) · 1440 unmodified lines
14411441 {
14421442 int i;
14431443
1444− hvcs_index_list = kmalloc(n * sizeof(hvcs_index_count),GFP_KERNEL);
1444+ hvcs_index_list = kmalloc_array(n, sizeof(hvcs_index_count),
1445+ GFP_KERNEL);
14451446 if (!hvcs_index_list)
14461447 return -ENOMEM;
14471448 hvcs_index_count = n;
drivers/tty/isicom.c+1−1
@@ -1477,7 +1477,7 @@ static int load_firmware(struct pci_dev *pdev, · 1476 unmodified lines
14771477 goto errrelfw;
14781478 }
14791479
1480− data = kmalloc(word_count * 2, GFP_KERNEL);
1480+ data = kmalloc_array(word_count, 2, GFP_KERNEL);
14811481 if (data == NULL) {
14821482 dev_err(&pdev->dev, "Card%d, firmware upload "
14831483 "failed, not enough memory\n", index + 1);
drivers/tty/serial/atmel_serial.c+3−2
@@ -2738,8 +2738,9 @@ static int atmel_serial_probe(struct platform_device *pdev) · 2737 unmodified lines
27382738
27392739 if (!atmel_use_pdc_rx(&atmel_port->uart)) {
27402740 ret = -ENOMEM;
2741− data = kmalloc(sizeof(struct atmel_uart_char)
2742− * ATMEL_SERIAL_RINGSIZE, GFP_KERNEL);
2741+ data = kmalloc_array(ATMEL_SERIAL_RINGSIZE,
2742+ sizeof(struct atmel_uart_char),
2743+ GFP_KERNEL);
27432744 if (!data)
27442745 goto err_alloc_ring;
27452746 atmel_port->rx_ring.buf = data;
drivers/tty/serial/pch_uart.c+1−1
@@ -991,7 +991,7 @@ static unsigned int dma_handle_tx(struct eg20t_port *priv) · 990 unmodified lines
991991
992992 priv->tx_dma_use = 1;
993993
994− priv->sg_tx_p = kzalloc(sizeof(struct scatterlist)*num, GFP_ATOMIC);
994+ priv->sg_tx_p = kcalloc(num, sizeof(struct scatterlist), GFP_ATOMIC);
995995 if (!priv->sg_tx_p) {
996996 dev_err(priv->port.dev, "%s:kzalloc Failed\n", __func__);
997997 return 0;
drivers/tty/serial/rp2.c+1−1
@@ -774,7 +774,7 @@ static int rp2_probe(struct pci_dev *pdev, · 773 unmodified lines
774774
775775 rp2_init_card(card);
776776
777− ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports,
777+ ports = devm_kcalloc(&pdev->dev, card->n_ports, sizeof(*ports),
778778 GFP_KERNEL);
779779 if (!ports)
780780 return -ENOMEM;
drivers/tty/serial/serial_core.c+1−1
@@ -2445,7 +2445,7 @@ int uart_register_driver(struct uart_driver *drv) · 2444 unmodified lines
24452445 * Maybe we should be using a slab cache for this, especially if
24462446 * we have a large number of ports to handle.
24472447 */
2448− drv->state = kzalloc(sizeof(struct uart_state) * drv->nr, GFP_KERNEL);
2448+ drv->state = kcalloc(drv->nr, sizeof(struct uart_state), GFP_KERNEL);
24492449 if (!drv->state)
24502450 goto out;
24512451
drivers/tty/serial/sunsab.c+3−2
@@ -1125,8 +1125,9 @@ static int __init sunsab_init(void) · 1124 unmodified lines
11251125 }
11261126
11271127 if (num_channels) {
1128− sunsab_ports = kzalloc(sizeof(struct uart_sunsab_port) *
1129− num_channels, GFP_KERNEL);
1128+ sunsab_ports = kcalloc(num_channels,
1129+ sizeof(struct uart_sunsab_port),
1130+ GFP_KERNEL);
11301131 if (!sunsab_ports)
11311132 return -ENOMEM;
11321133
drivers/tty/vt/consolemap.c+4−3
@@ -231,7 +231,7 @@ static void set_inverse_trans_unicode(struct vc_data *conp, · 230 unmodified lines
231231 q = p->inverse_trans_unicode;
232232 if (!q) {
233233 q = p->inverse_trans_unicode =
234− kmalloc(MAX_GLYPH * sizeof(u16), GFP_KERNEL);
234+ kmalloc_array(MAX_GLYPH, sizeof(u16), GFP_KERNEL);
235235 if (!q)
236236 return;
237237 }
@@ -479,7 +479,8 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) · 241 unmodified lines
479479
480480 p1 = p->uni_pgdir[n = unicode >> 11];
481481 if (!p1) {
482− p1 = p->uni_pgdir[n] = kmalloc(32*sizeof(u16 *), GFP_KERNEL);
482+ p1 = p->uni_pgdir[n] = kmalloc_array(32, sizeof(u16 *),
483+ GFP_KERNEL);
483484 if (!p1) return -ENOMEM;
484485 for (i = 0; i < 32; i++)
485486 p1[i] = NULL;
@@ -487,7 +488,7 @@ con_insert_unipair(struct uni_pagedir *p, u_short unicode, u_short fontpos) · 1 unmodified line
487488
488489 p2 = p1[n = (unicode >> 6) & 0x1f];
489490 if (!p2) {
490− p2 = p1[n] = kmalloc(64*sizeof(u16), GFP_KERNEL);
491+ p2 = p1[n] = kmalloc_array(64, sizeof(u16), GFP_KERNEL);
491492 if (!p2) return -ENOMEM;
492493 memset(p2, 0xff, 64*sizeof(u16)); /* No glyphs for the characters (yet) */
493494 }
drivers/tty/vt/keyboard.c+2−2
@@ -1624,7 +1624,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) · 1623 unmodified lines
16241624 struct kbdiacr *dia;
16251625 int i;
16261626
1627− dia = kmalloc(MAX_DIACR * sizeof(struct kbdiacr),
1627+ dia = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacr),
16281628 GFP_KERNEL);
16291629 if (!dia)
16301630 return -ENOMEM;
@@ -1657,7 +1657,7 @@ int vt_do_diacrit(unsigned int cmd, void __user *udp, int perm) · 26 unmodified lines
16571657 struct kbdiacrsuc __user *a = udp;
16581658 void *buf;
16591659
1660− buf = kmalloc(MAX_DIACR * sizeof(struct kbdiacruc),
1660+ buf = kmalloc_array(MAX_DIACR, sizeof(struct kbdiacruc),
16611661 GFP_KERNEL);
16621662 if (buf == NULL)
16631663 return -ENOMEM;
drivers/tty/vt/selection.c+2−1
@@ -280,7 +280,8 @@ int set_selection(const struct tiocl_selection __user *sel, struct tty_struct *t · 279 unmodified lines
280280
281281 /* Allocate a new buffer before freeing the old one ... */
282282 multiplier = use_unicode ? 3 : 1; /* chars can take up to 3 bytes */
283− bp = kmalloc(((sel_end-sel_start)/2+1)*multiplier, GFP_KERNEL);
283+ bp = kmalloc_array((sel_end - sel_start) / 2 + 1, multiplier,
284+ GFP_KERNEL);
284285 if (!bp) {
285286 printk(KERN_WARNING "selection: kmalloc() failed\n");
286287 clear_selection();
drivers/uio/uio_pruss.c+1−1
@@ -129,7 +129,7 @@ static int pruss_probe(struct platform_device *pdev) · 128 unmodified lines
129129 if (!gdev)
130130 return -ENOMEM;
131131
132− gdev->info = kzalloc(sizeof(*p) * MAX_PRUSS_EVT, GFP_KERNEL);
132+ gdev->info = kcalloc(MAX_PRUSS_EVT, sizeof(*p), GFP_KERNEL);
133133 if (!gdev->info) {
134134 kfree(gdev);
135135 return -ENOMEM;
drivers/usb/core/devio.c+4−3
@@ -897,7 +897,7 @@ static int parse_usbdevfs_streams(struct usb_dev_state *ps, · 896 unmodified lines
897897 if (num_streams_ret && (num_streams < 2 || num_streams > 65536))
898898 return -EINVAL;
899899
900− eps = kmalloc(num_eps * sizeof(*eps), GFP_KERNEL);
900+ eps = kmalloc_array(num_eps, sizeof(*eps), GFP_KERNEL);
901901 if (!eps)
902902 return -ENOMEM;
903903
@@ -1602,8 +1602,9 @@ static int proc_do_submiturb(struct usb_dev_state *ps, struct usbdevfs_urb *uurb · 698 unmodified lines
16021602 as->mem_usage = u;
16031603
16041604 if (num_sgs) {
1605− as->urb->sg = kmalloc(num_sgs * sizeof(struct scatterlist),
1606− GFP_KERNEL);
1605+ as->urb->sg = kmalloc_array(num_sgs,
1606+ sizeof(struct scatterlist),
1607+ GFP_KERNEL);
16071608 if (!as->urb->sg) {
16081609 ret = -ENOMEM;
16091610 goto error;
drivers/usb/core/hub.c+1−1
@@ -1376,7 +1376,7 @@ static int hub_configure(struct usb_hub *hub, · 1375 unmodified lines
13761376 dev_info(hub_dev, "%d port%s detected\n", maxchild,
13771377 (maxchild == 1) ? "" : "s");
13781378
1379− hub->ports = kzalloc(maxchild * sizeof(struct usb_port *), GFP_KERNEL);
1379+ hub->ports = kcalloc(maxchild, sizeof(struct usb_port *), GFP_KERNEL);
13801380 if (!hub->ports) {
13811381 ret = -ENOMEM;
13821382 goto fail;
drivers/usb/core/message.c+3−3
@@ -390,7 +390,7 @@ int usb_sg_init(struct usb_sg_request *io, struct usb_device *dev, · 389 unmodified lines
390390 }
391391
392392 /* initialize all the urbs we'll use */
393− io->urbs = kmalloc(io->entries * sizeof(*io->urbs), mem_flags);
393+ io->urbs = kmalloc_array(io->entries, sizeof(*io->urbs), mem_flags);
394394 if (!io->urbs)
395395 goto nomem;
396396
@@ -1824,8 +1824,8 @@ int usb_set_configuration(struct usb_device *dev, int configuration) · 1427 unmodified lines
18241824 n = nintf = 0;
18251825 if (cp) {
18261826 nintf = cp->desc.bNumInterfaces;
1827− new_interfaces = kmalloc(nintf * sizeof(*new_interfaces),
1828− GFP_NOIO);
1827+ new_interfaces = kmalloc_array(nintf, sizeof(*new_interfaces),
1828+ GFP_NOIO);
18291829 if (!new_interfaces)
18301830 return -ENOMEM;
18311831
drivers/usb/dwc2/hcd.c+6−5
@@ -5079,13 +5079,14 @@ int dwc2_hcd_init(struct dwc2_hsotg *hsotg) · 5078 unmodified lines
50795079 dev_dbg(hsotg->dev, "hcfg=%08x\n", hcfg);
50805080
50815081 #ifdef CONFIG_USB_DWC2_TRACK_MISSED_SOFS
5082− hsotg->frame_num_array = kzalloc(sizeof(*hsotg->frame_num_array) *
5083− FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
5082+ hsotg->frame_num_array = kcalloc(FRAME_NUM_ARRAY_SIZE,
5083+ sizeof(*hsotg->frame_num_array),
5084+ GFP_KERNEL);
50845085 if (!hsotg->frame_num_array)
50855086 goto error1;
5086− hsotg->last_frame_num_array = kzalloc(
5087− sizeof(*hsotg->last_frame_num_array) *
5088− FRAME_NUM_ARRAY_SIZE, GFP_KERNEL);
5087+ hsotg->last_frame_num_array =
5088+ kcalloc(FRAME_NUM_ARRAY_SIZE,
5089+ sizeof(*hsotg->last_frame_num_array), GFP_KERNEL);
50895090 if (!hsotg->last_frame_num_array)
50905091 goto error1;
50915092 #endif
drivers/usb/gadget/udc/atmel_usba_udc.c+1−1
@@ -2036,7 +2036,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, · 2035 unmodified lines
20362036 udc->num_ep = usba_config_fifo_table(udc);
20372037 }
20382038
2039− eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * udc->num_ep,
2039+ eps = devm_kcalloc(&pdev->dev, udc->num_ep, sizeof(struct usba_ep),
20402040 GFP_KERNEL);
20412041 if (!eps)
20422042 return ERR_PTR(-ENOMEM);
drivers/usb/gadget/udc/bdc/bdc_ep.c+3−3
@@ -138,9 +138,9 @@ static int ep_bd_list_alloc(struct bdc_ep *ep) · 137 unmodified lines
138138 __func__, ep, num_tabs);
139139
140140 /* Allocate memory for table array */
141− ep->bd_list.bd_table_array = kzalloc(
142− num_tabs * sizeof(struct bd_table *),
143− GFP_ATOMIC);
141+ ep->bd_list.bd_table_array = kcalloc(num_tabs,
142+ sizeof(struct bd_table *),
143+ GFP_ATOMIC);
144144 if (!ep->bd_list.bd_table_array)
145145 return -ENOMEM;
146146
drivers/usb/gadget/udc/fsl_udc_core.c+1−1
@@ -2246,7 +2246,7 @@ static int struct_udc_setup(struct fsl_udc *udc, · 2245 unmodified lines
22462246 pdata = dev_get_platdata(&pdev->dev);
22472247 udc->phy_mode = pdata->phy_mode;
22482248
2249− udc->eps = kzalloc(sizeof(struct fsl_ep) * udc->max_ep, GFP_KERNEL);
2249+ udc->eps = kcalloc(udc->max_ep, sizeof(struct fsl_ep), GFP_KERNEL);
22502250 if (!udc->eps)
22512251 return -1;
22522252
drivers/usb/gadget/udc/renesas_usb3.c+2−1
@@ -2427,7 +2427,8 @@ static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev, · 2426 unmodified lines
24272427 if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES)
24282428 usb3->num_usb3_eps = USB3_MAX_NUM_PIPES;
24292429
2430− usb3->usb3_ep = devm_kzalloc(dev, sizeof(*usb3_ep) * usb3->num_usb3_eps,
2430+ usb3->usb3_ep = devm_kcalloc(dev,
2431+ usb3->num_usb3_eps, sizeof(*usb3_ep),
24312432 GFP_KERNEL);
24322433 if (!usb3->usb3_ep)
24332434 return -ENOMEM;
drivers/usb/host/ehci-sched.c+3−2
@@ -117,8 +117,9 @@ static struct ehci_tt *find_tt(struct usb_device *udev) · 116 unmodified lines
117117 if (utt->multi) {
118118 tt_index = utt->hcpriv;
119119 if (!tt_index) { /* Create the index array */
120− tt_index = kzalloc(utt->hub->maxchild *
121− sizeof(*tt_index), GFP_ATOMIC);
120+ tt_index = kcalloc(utt->hub->maxchild,
121+ sizeof(*tt_index),
122+ GFP_ATOMIC);
122123 if (!tt_index)
123124 return ERR_PTR(-ENOMEM);
124125 utt->hcpriv = tt_index;
drivers/usb/host/fhci-tds.c+1−1
@@ -189,7 +189,7 @@ u32 fhci_create_ep(struct fhci_usb *usb, enum fhci_mem_alloc data_mem, · 188 unmodified lines
189189 goto err;
190190 }
191191
192− buff = kmalloc(1028 * sizeof(*buff), GFP_KERNEL);
192+ buff = kmalloc_array(1028, sizeof(*buff), GFP_KERNEL);
193193 if (!buff) {
194194 kfree(pkt);
195195 err_for = "buffer";
drivers/usb/host/imx21-hcd.c+2−2
@@ -741,8 +741,8 @@ static int imx21_hc_urb_enqueue_isoc(struct usb_hcd *hcd, · 740 unmodified lines
741741 if (urb_priv == NULL)
742742 return -ENOMEM;
743743
744− urb_priv->isoc_td = kzalloc(
745− sizeof(struct td) * urb->number_of_packets, mem_flags);
744+ urb_priv->isoc_td = kcalloc(urb->number_of_packets, sizeof(struct td),
745+ mem_flags);
746746 if (urb_priv->isoc_td == NULL) {
747747 ret = -ENOMEM;
748748 goto alloc_td_failed;
drivers/usb/host/ohci-dbg.c+1−1
@@ -492,7 +492,7 @@ static ssize_t fill_periodic_buffer(struct debug_buffer *buf) · 491 unmodified lines
492492 char *next;
493493 unsigned i;
494494
495− seen = kmalloc(DBG_SCHED_LIMIT * sizeof *seen, GFP_ATOMIC);
495+ seen = kmalloc_array(DBG_SCHED_LIMIT, sizeof(*seen), GFP_ATOMIC);
496496 if (!seen)
497497 return 0;
498498 seen_count = 0;
drivers/usb/host/xhci-mem.c+2−2
@@ -2274,8 +2274,8 @@ static int xhci_setup_port_arrays(struct xhci_hcd *xhci, gfp_t flags) · 2273 unmodified lines
22742274 xhci->hw_ports[i].hw_portnum = i;
22752275 }
22762276
2277− xhci->rh_bw = kzalloc_node(sizeof(*xhci->rh_bw)*num_ports, flags,
2278− dev_to_node(dev));
2277+ xhci->rh_bw = kcalloc_node(num_ports, sizeof(*xhci->rh_bw), flags,
2278+ dev_to_node(dev));
22792279 if (!xhci->rh_bw)
22802280 return -ENOMEM;
22812281 for (i = 0; i < num_ports; i++) {
drivers/usb/misc/ldusb.c+7−2
@@ -695,7 +695,10 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * · 694 unmodified lines
695695 dev_warn(&intf->dev, "Interrupt out endpoint not found (using control endpoint instead)\n");
696696
697697 dev->interrupt_in_endpoint_size = usb_endpoint_maxp(dev->interrupt_in_endpoint);
698− dev->ring_buffer = kmalloc(ring_buffer_size*(sizeof(size_t)+dev->interrupt_in_endpoint_size), GFP_KERNEL);
698+ dev->ring_buffer =
699+ kmalloc_array(ring_buffer_size,
700+ sizeof(size_t) + dev->interrupt_in_endpoint_size,
701+ GFP_KERNEL);
699702 if (!dev->ring_buffer)
700703 goto error;
701704 dev->interrupt_in_buffer = kmalloc(dev->interrupt_in_endpoint_size, GFP_KERNEL);
@@ -706,7 +709,9 @@ static int ld_usb_probe(struct usb_interface *intf, const struct usb_device_id * · 4 unmodified lines
706709 goto error;
707710 dev->interrupt_out_endpoint_size = dev->interrupt_out_endpoint ? usb_endpoint_maxp(dev->interrupt_out_endpoint) :
708711 udev->descriptor.bMaxPacketSize0;
709− dev->interrupt_out_buffer = kmalloc(write_buffer_size*dev->interrupt_out_endpoint_size, GFP_KERNEL);
712+ dev->interrupt_out_buffer =
713+ kmalloc_array(write_buffer_size,
714+ dev->interrupt_out_endpoint_size, GFP_KERNEL);
710715 if (!dev->interrupt_out_buffer)
711716 goto error;
712717 dev->interrupt_out_urb = usb_alloc_urb(0, GFP_KERNEL);
drivers/usb/misc/sisusbvga/sisusb_con.c+1−1
@@ -1243,7 +1243,7 @@ sisusbcon_font_set(struct vc_data *c, struct console_font *font, · 1242 unmodified lines
12431243 }
12441244
12451245 if (!sisusb->font_backup)
1246− sisusb->font_backup = vmalloc(charcount * 32);
1246+ sisusb->font_backup = vmalloc(array_size(charcount, 32));
12471247
12481248 if (sisusb->font_backup) {
12491249 memcpy(sisusb->font_backup, font->data, charcount * 32);
drivers/usb/mon/mon_bin.c+2−1
@@ -1024,7 +1024,8 @@ static long mon_bin_ioctl(struct file *file, unsigned int cmd, unsigned long arg · 1023 unmodified lines
10241024 return -EINVAL;
10251025
10261026 size = CHUNK_ALIGN(arg);
1027− vec = kzalloc(sizeof(struct mon_pgmap) * (size / CHUNK_SIZE), GFP_KERNEL);
1027+ vec = kcalloc(size / CHUNK_SIZE, sizeof(struct mon_pgmap),
1028+ GFP_KERNEL);
10281029 if (vec == NULL) {
10291030 ret = -ENOMEM;
10301031 break;
drivers/usb/renesas_usbhs/mod_gadget.c+1−1
@@ -1068,7 +1068,7 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) · 1067 unmodified lines
10681068 if (!gpriv)
10691069 return -ENOMEM;
10701070
1071− uep = kzalloc(sizeof(struct usbhsg_uep) * pipe_size, GFP_KERNEL);
1071+ uep = kcalloc(pipe_size, sizeof(struct usbhsg_uep), GFP_KERNEL);
10721072 if (!uep) {
10731073 ret = -ENOMEM;
10741074 goto usbhs_mod_gadget_probe_err_gpriv;
drivers/usb/renesas_usbhs/pipe.c+2−1
@@ -803,7 +803,8 @@ int usbhs_pipe_probe(struct usbhs_priv *priv) · 802 unmodified lines
803803 return -EINVAL;
804804 }
805805
806− info->pipe = kzalloc(sizeof(struct usbhs_pipe) * pipe_size, GFP_KERNEL);
806+ info->pipe = kcalloc(pipe_size, sizeof(struct usbhs_pipe),
807+ GFP_KERNEL);
807808 if (!info->pipe)
808809 return -ENOMEM;
809810
drivers/usb/serial/iuu_phoenix.c+2−2
@@ -736,7 +736,7 @@ static int iuu_uart_on(struct usb_serial_port *port) · 735 unmodified lines
736736 int status;
737737 u8 *buf;
738738
739− buf = kmalloc(sizeof(u8) * 4, GFP_KERNEL);
739+ buf = kmalloc(4, GFP_KERNEL);
740740
741741 if (!buf)
742742 return -ENOMEM;
@@ -790,7 +790,7 @@ static int iuu_uart_baud(struct usb_serial_port *port, u32 baud_base, · 47 unmodified lines
790790 unsigned int T1FrekvensHZ = 0;
791791
792792 dev_dbg(&port->dev, "%s - enter baud_base=%d\n", __func__, baud_base);
793− dataout = kmalloc(sizeof(u8) * 5, GFP_KERNEL);
793+ dataout = kmalloc(5, GFP_KERNEL);
794794
795795 if (!dataout)
796796 return -ENOMEM;
drivers/usb/storage/alauda.c+1−1
@@ -1025,7 +1025,7 @@ static int alauda_write_data(struct us_data *us, unsigned long address, · 1024 unmodified lines
10251025 * We also need a temporary block buffer, where we read in the old data,
10261026 * overwrite parts with the new data, and manipulate the redundancy data
10271027 */
1028− blockbuffer = kmalloc((pagesize + 64) * blocksize, GFP_NOIO);
1028+ blockbuffer = kmalloc_array(pagesize + 64, blocksize, GFP_NOIO);
10291029 if (!blockbuffer) {
10301030 kfree(buffer);
10311031 return USB_STOR_TRANSPORT_ERROR;
drivers/usb/storage/ene_ub6250.c+12−4
@@ -807,8 +807,12 @@ static int ms_lib_alloc_logicalmap(struct us_data *us) · 806 unmodified lines
807807 u32 i;
808808 struct ene_ub6250_info *info = (struct ene_ub6250_info *) us->extra;
809809
810− info->MS_Lib.Phy2LogMap = kmalloc(info->MS_Lib.NumberOfPhyBlock * sizeof(u16), GFP_KERNEL);
811− info->MS_Lib.Log2PhyMap = kmalloc(info->MS_Lib.NumberOfLogBlock * sizeof(u16), GFP_KERNEL);
810+ info->MS_Lib.Phy2LogMap = kmalloc_array(info->MS_Lib.NumberOfPhyBlock,
811+ sizeof(u16),
812+ GFP_KERNEL);
813+ info->MS_Lib.Log2PhyMap = kmalloc_array(info->MS_Lib.NumberOfLogBlock,
814+ sizeof(u16),
815+ GFP_KERNEL);
812816
813817 if ((info->MS_Lib.Phy2LogMap == NULL) || (info->MS_Lib.Log2PhyMap == NULL)) {
814818 ms_lib_free_logicalmap(us);
@@ -1113,8 +1117,12 @@ static int ms_lib_alloc_writebuf(struct us_data *us) · 298 unmodified lines
11131117
11141118 info->MS_Lib.wrtblk = (u16)-1;
11151119
1116− info->MS_Lib.blkpag = kmalloc(info->MS_Lib.PagesPerBlock * info->MS_Lib.BytesPerSector, GFP_KERNEL);
1117− info->MS_Lib.blkext = kmalloc(info->MS_Lib.PagesPerBlock * sizeof(struct ms_lib_type_extdat), GFP_KERNEL);
1120+ info->MS_Lib.blkpag = kmalloc_array(info->MS_Lib.PagesPerBlock,
1121+ info->MS_Lib.BytesPerSector,
1122+ GFP_KERNEL);
1123+ info->MS_Lib.blkext = kmalloc_array(info->MS_Lib.PagesPerBlock,
1124+ sizeof(struct ms_lib_type_extdat),
1125+ GFP_KERNEL);
11181126
11191127 if ((info->MS_Lib.blkpag == NULL) || (info->MS_Lib.blkext == NULL)) {
11201128 ms_lib_free_writebuf(us);
drivers/usb/storage/sddr09.c+2−2
@@ -1231,8 +1231,8 @@ sddr09_read_map(struct us_data *us) { · 1230 unmodified lines
12311231
12321232 kfree(info->lba_to_pba);
12331233 kfree(info->pba_to_lba);
1234− info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
1235− info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
1234+ info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
1235+ info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
12361236
12371237 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
12381238 printk(KERN_WARNING "sddr09_read_map: out of memory\n");
drivers/usb/storage/sddr55.c+3−3
@@ -651,7 +651,7 @@ static int sddr55_read_map(struct us_data *us) { · 650 unmodified lines
651651
652652 numblocks = info->capacity >> (info->blockshift + info->pageshift);
653653
654− buffer = kmalloc( numblocks * 2, GFP_NOIO );
654+ buffer = kmalloc_array(numblocks, 2, GFP_NOIO );
655655
656656 if (!buffer)
657657 return -1;
@@ -684,8 +684,8 @@ static int sddr55_read_map(struct us_data *us) { · 26 unmodified lines
684684
685685 kfree(info->lba_to_pba);
686686 kfree(info->pba_to_lba);
687− info->lba_to_pba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
688− info->pba_to_lba = kmalloc(numblocks*sizeof(int), GFP_NOIO);
687+ info->lba_to_pba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
688+ info->pba_to_lba = kmalloc_array(numblocks, sizeof(int), GFP_NOIO);
689689
690690 if (info->lba_to_pba == NULL || info->pba_to_lba == NULL) {
691691 kfree(info->lba_to_pba);
drivers/usb/wusbcore/wa-rpipe.c+2−1
@@ -470,7 +470,8 @@ error: · 469 unmodified lines
470470 int wa_rpipes_create(struct wahc *wa)
471471 {
472472 wa->rpipes = le16_to_cpu(wa->wa_descr->wNumRPipes);
473− wa->rpipe_bm = kzalloc(BITS_TO_LONGS(wa->rpipes)*sizeof(unsigned long),
473+ wa->rpipe_bm = kcalloc(BITS_TO_LONGS(wa->rpipes),
474+ sizeof(unsigned long),
474475 GFP_KERNEL);
475476 if (wa->rpipe_bm == NULL)
476477 return -ENOMEM;
drivers/uwb/est.c+1−1
@@ -217,7 +217,7 @@ static · 216 unmodified lines
217217 int uwb_est_grow(void)
218218 {
219219 size_t actual_size = uwb_est_size * sizeof(uwb_est[0]);
220− void *new = kmalloc(2 * actual_size, GFP_ATOMIC);
220+ void *new = kmalloc_array(2, actual_size, GFP_ATOMIC);
221221 if (new == NULL)
222222 return -ENOMEM;
223223 memcpy(new, uwb_est, actual_size);
drivers/uwb/i1480/dfu/usb.c+1−1
@@ -376,7 +376,7 @@ int i1480_usb_probe(struct usb_interface *iface, const struct usb_device_id *id) · 375 unmodified lines
376376
377377 i1480 = &i1480_usb->i1480;
378378 i1480->buf_size = 512;
379− i1480->cmd_buf = kmalloc(2 * i1480->buf_size, GFP_KERNEL);
379+ i1480->cmd_buf = kmalloc_array(2, i1480->buf_size, GFP_KERNEL);
380380 if (i1480->cmd_buf == NULL) {
381381 dev_err(dev, "Cannot allocate transfer buffers\n");
382382 result = -ENOMEM;
drivers/vhost/net.c+5−3
@@ -274,8 +274,10 @@ static int vhost_net_set_ubuf_info(struct vhost_net *n) · 273 unmodified lines
274274 zcopy = vhost_net_zcopy_mask & (0x1 << i);
275275 if (!zcopy)
276276 continue;
277− n->vqs[i].ubuf_info = kmalloc(sizeof(*n->vqs[i].ubuf_info) *
278− UIO_MAXIOV, GFP_KERNEL);
277+ n->vqs[i].ubuf_info =
278+ kmalloc_array(UIO_MAXIOV,
279+ sizeof(*n->vqs[i].ubuf_info),
280+ GFP_KERNEL);
279281 if (!n->vqs[i].ubuf_info)
280282 goto err;
281283 }
@@ -943,7 +945,7 @@ static int vhost_net_open(struct inode *inode, struct file *f) · 661 unmodified lines
943945 n = kvmalloc(sizeof *n, GFP_KERNEL | __GFP_RETRY_MAYFAIL);
944946 if (!n)
945947 return -ENOMEM;
946− vqs = kmalloc(VHOST_NET_VQ_MAX * sizeof(*vqs), GFP_KERNEL);
948+ vqs = kmalloc_array(VHOST_NET_VQ_MAX, sizeof(*vqs), GFP_KERNEL);
947949 if (!vqs) {
948950 kvfree(n);
949951 return -ENOMEM;
drivers/vhost/scsi.c+10−7
@@ -1378,7 +1378,7 @@ static int vhost_scsi_open(struct inode *inode, struct file *f) · 1377 unmodified lines
13781378 goto err_vs;
13791379 }
13801380
1381− vqs = kmalloc(VHOST_SCSI_MAX_VQ * sizeof(*vqs), GFP_KERNEL);
1381+ vqs = kmalloc_array(VHOST_SCSI_MAX_VQ, sizeof(*vqs), GFP_KERNEL);
13821382 if (!vqs)
13831383 goto err_vqs;
13841384
@@ -1685,22 +1685,25 @@ static int vhost_scsi_nexus_cb(struct se_portal_group *se_tpg, · 300 unmodified lines
16851685 for (i = 0; i < VHOST_SCSI_DEFAULT_TAGS; i++) {
16861686 tv_cmd = &((struct vhost_scsi_cmd *)se_sess->sess_cmd_map)[i];
16871687
1688− tv_cmd->tvc_sgl = kzalloc(sizeof(struct scatterlist) *
1689− VHOST_SCSI_PREALLOC_SGLS, GFP_KERNEL);
1688+ tv_cmd->tvc_sgl = kcalloc(VHOST_SCSI_PREALLOC_SGLS,
1689+ sizeof(struct scatterlist),
1690+ GFP_KERNEL);
16901691 if (!tv_cmd->tvc_sgl) {
16911692 pr_err("Unable to allocate tv_cmd->tvc_sgl\n");
16921693 goto out;
16931694 }
16941695
1695− tv_cmd->tvc_upages = kzalloc(sizeof(struct page *) *
1696− VHOST_SCSI_PREALLOC_UPAGES, GFP_KERNEL);
1696+ tv_cmd->tvc_upages = kcalloc(VHOST_SCSI_PREALLOC_UPAGES,
1697+ sizeof(struct page *),
1698+ GFP_KERNEL);
16971699 if (!tv_cmd->tvc_upages) {
16981700 pr_err("Unable to allocate tv_cmd->tvc_upages\n");
16991701 goto out;
17001702 }
17011703
1702− tv_cmd->tvc_prot_sgl = kzalloc(sizeof(struct scatterlist) *
1703− VHOST_SCSI_PREALLOC_PROT_SGLS, GFP_KERNEL);
1704+ tv_cmd->tvc_prot_sgl = kcalloc(VHOST_SCSI_PREALLOC_PROT_SGLS,
1705+ sizeof(struct scatterlist),
1706+ GFP_KERNEL);
17041707 if (!tv_cmd->tvc_prot_sgl) {
17051708 pr_err("Unable to allocate tv_cmd->tvc_prot_sgl\n");
17061709 goto out;
drivers/vhost/test.c+1−1
@@ -107,7 +107,7 @@ static int vhost_test_open(struct inode *inode, struct file *f) · 106 unmodified lines
107107
108108 if (!n)
109109 return -ENOMEM;
110− vqs = kmalloc(VHOST_TEST_VQ_MAX * sizeof(*vqs), GFP_KERNEL);
110+ vqs = kmalloc_array(VHOST_TEST_VQ_MAX, sizeof(*vqs), GFP_KERNEL);
111111 if (!vqs) {
112112 kfree(n);
113113 return -ENOMEM;
drivers/vhost/vhost.c+9−5
@@ -385,10 +385,13 @@ static long vhost_dev_alloc_iovecs(struct vhost_dev *dev) · 384 unmodified lines
385385
386386 for (i = 0; i < dev->nvqs; ++i) {
387387 vq = dev->vqs[i];
388− vq->indirect = kmalloc(sizeof *vq->indirect * UIO_MAXIOV,
389− GFP_KERNEL);
390− vq->log = kmalloc(sizeof *vq->log * UIO_MAXIOV, GFP_KERNEL);
391− vq->heads = kmalloc(sizeof *vq->heads * UIO_MAXIOV, GFP_KERNEL);
388+ vq->indirect = kmalloc_array(UIO_MAXIOV,
389+ sizeof(*vq->indirect),
390+ GFP_KERNEL);
391+ vq->log = kmalloc_array(UIO_MAXIOV, sizeof(*vq->log),
392+ GFP_KERNEL);
393+ vq->heads = kmalloc_array(UIO_MAXIOV, sizeof(*vq->heads),
394+ GFP_KERNEL);
392395 if (!vq->indirect || !vq->log || !vq->heads)
393396 goto err_nomem;
394397 }
@@ -1286,7 +1289,8 @@ static long vhost_set_memory(struct vhost_dev *d, struct vhost_memory __user *m) · 891 unmodified lines
12861289 return -EOPNOTSUPP;
12871290 if (mem.nregions > max_mem_regions)
12881291 return -E2BIG;
1289− newmem = kvzalloc(size + mem.nregions * sizeof(*m->regions), GFP_KERNEL);
1292+ newmem = kvzalloc(struct_size(newmem, regions, mem.nregions),
1293+ GFP_KERNEL);
12901294 if (!newmem)
12911295 return -ENOMEM;
12921296
drivers/vhost/vringh.c+1−1
@@ -191,7 +191,7 @@ static int resize_iovec(struct vringh_kiov *iov, gfp_t gfp) · 190 unmodified lines
191191 if (flag)
192192 new = krealloc(iov->iov, new_num * sizeof(struct iovec), gfp);
193193 else {
194− new = kmalloc(new_num * sizeof(struct iovec), gfp);
194+ new = kmalloc_array(new_num, sizeof(struct iovec), gfp);
195195 if (new) {
196196 memcpy(new, iov->iov,
197197 iov->max_num * sizeof(struct iovec));
drivers/video/backlight/adp8860_bl.c+1−1
@@ -223,7 +223,7 @@ static int adp8860_led_probe(struct i2c_client *client) · 222 unmodified lines
223223 struct led_info *cur_led;
224224 int ret, i;
225225
226− led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds,
226+ led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led),
227227 GFP_KERNEL);
228228 if (led == NULL)
229229 return -ENOMEM;
drivers/video/backlight/adp8870_bl.c+1−1
@@ -246,7 +246,7 @@ static int adp8870_led_probe(struct i2c_client *client) · 245 unmodified lines
246246 struct led_info *cur_led;
247247 int ret, i;
248248
249− led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led),
249+ led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led),
250250 GFP_KERNEL);
251251 if (led == NULL)
252252 return -ENOMEM;
drivers/video/backlight/lp855x_bl.c+1−1
@@ -374,7 +374,7 @@ static int lp855x_parse_dt(struct lp855x *lp) · 373 unmodified lines
374374 struct device_node *child;
375375 int i = 0;
376376
377− rom = devm_kzalloc(dev, sizeof(*rom) * rom_length, GFP_KERNEL);
377+ rom = devm_kcalloc(dev, rom_length, sizeof(*rom), GFP_KERNEL);
378378 if (!rom)
379379 return -ENOMEM;
380380
drivers/video/console/sticore.c+1−1
@@ -649,7 +649,7 @@ static void *sti_bmode_font_raw(struct sti_cooked_font *f) · 648 unmodified lines
649649 unsigned char *n, *p, *q;
650650 int size = f->raw->bytes_per_char*256+sizeof(struct sti_rom_font);
651651
652− n = kzalloc(4*size, STI_LOWMEM);
652+ n = kcalloc(4, size, STI_LOWMEM);
653653 if (!n)
654654 return NULL;
655655 p = n + 3;
drivers/video/fbdev/au1100fb.c+1−1
@@ -501,7 +501,7 @@ static int au1100fb_drv_probe(struct platform_device *dev) · 500 unmodified lines
501501 fbdev->info.fix = au1100fb_fix;
502502
503503 fbdev->info.pseudo_palette =
504− devm_kzalloc(&dev->dev, sizeof(u32) * 16, GFP_KERNEL);
504+ devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL);
505505 if (!fbdev->info.pseudo_palette)
506506 return -ENOMEM;
507507
drivers/video/fbdev/broadsheetfb.c+1−1
@@ -617,7 +617,7 @@ static int broadsheet_spiflash_rewrite_sector(struct broadsheetfb_par *par, · 616 unmodified lines
617617 int tail_start_addr;
618618 int start_sector_addr;
619619
620− sector_buffer = kzalloc(sizeof(char)*sector_size, GFP_KERNEL);
620+ sector_buffer = kzalloc(sector_size, GFP_KERNEL);
621621 if (!sector_buffer)
622622 return -ENOMEM;
623623
drivers/video/fbdev/core/bitblit.c+2−2
@@ -269,7 +269,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 268 unmodified lines
269269 if (attribute) {
270270 u8 *dst;
271271
272− dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
272+ dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
273273 if (!dst)
274274 return;
275275 kfree(ops->cursor_data);
@@ -312,7 +312,7 @@ static void bit_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 36 unmodified lines
312312 vc->vc_cursor_type != ops->p->cursor_shape ||
313313 ops->cursor_state.mask == NULL ||
314314 ops->cursor_reset) {
315− char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
315+ char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
316316 int cur_height, size, i = 0;
317317 u8 msk = 0xff;
318318
drivers/video/fbdev/core/fbcon.c+2−1
@@ -591,7 +591,8 @@ static void fbcon_prepare_logo(struct vc_data *vc, struct fb_info *info, · 590 unmodified lines
591591 if (scr_readw(r) != vc->vc_video_erase_char)
592592 break;
593593 if (r != q && new_rows >= rows + logo_lines) {
594− save = kmalloc(logo_lines * new_cols * 2, GFP_KERNEL);
594+ save = kmalloc(array3_size(logo_lines, new_cols, 2),
595+ GFP_KERNEL);
595596 if (save) {
596597 int i = cols < new_cols ? cols : new_cols;
597598 scr_memsetw(save, erase, logo_lines * new_cols * 2);
drivers/video/fbdev/core/fbcon_ccw.c+4−3
@@ -258,7 +258,7 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 257 unmodified lines
258258 if (attribute) {
259259 u8 *dst;
260260
261− dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC);
261+ dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC);
262262 if (!dst)
263263 return;
264264 kfree(ops->cursor_data);
@@ -304,14 +304,15 @@ static void ccw_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 39 unmodified lines
304304 vc->vc_cursor_type != ops->p->cursor_shape ||
305305 ops->cursor_state.mask == NULL ||
306306 ops->cursor_reset) {
307− char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC);
307+ char *tmp, *mask = kmalloc_array(w, vc->vc_font.width,
308+ GFP_ATOMIC);
308309 int cur_height, size, i = 0;
309310 int width = (vc->vc_font.width + 7)/8;
310311
311312 if (!mask)
312313 return;
313314
314− tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC);
315+ tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC);
315316
316317 if (!tmp) {
317318 kfree(mask);
drivers/video/fbdev/core/fbcon_cw.c+4−3
@@ -241,7 +241,7 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 240 unmodified lines
241241 if (attribute) {
242242 u8 *dst;
243243
244− dst = kmalloc(w * vc->vc_font.width, GFP_ATOMIC);
244+ dst = kmalloc_array(w, vc->vc_font.width, GFP_ATOMIC);
245245 if (!dst)
246246 return;
247247 kfree(ops->cursor_data);
@@ -287,14 +287,15 @@ static void cw_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 39 unmodified lines
287287 vc->vc_cursor_type != ops->p->cursor_shape ||
288288 ops->cursor_state.mask == NULL ||
289289 ops->cursor_reset) {
290− char *tmp, *mask = kmalloc(w*vc->vc_font.width, GFP_ATOMIC);
290+ char *tmp, *mask = kmalloc_array(w, vc->vc_font.width,
291+ GFP_ATOMIC);
291292 int cur_height, size, i = 0;
292293 int width = (vc->vc_font.width + 7)/8;
293294
294295 if (!mask)
295296 return;
296297
297− tmp = kmalloc(width * vc->vc_font.height, GFP_ATOMIC);
298+ tmp = kmalloc_array(width, vc->vc_font.height, GFP_ATOMIC);
298299
299300 if (!tmp) {
300301 kfree(mask);
drivers/video/fbdev/core/fbcon_rotate.c+1−1
@@ -46,7 +46,7 @@ static int fbcon_rotate_font(struct fb_info *info, struct vc_data *vc) · 45 unmodified lines
4646 info->fbops->fb_sync(info);
4747
4848 if (ops->fd_size < d_cellsize * len) {
49− dst = kmalloc(d_cellsize * len, GFP_KERNEL);
49+ dst = kmalloc_array(len, d_cellsize, GFP_KERNEL);
5050
5151 if (dst == NULL) {
5252 err = -ENOMEM;
drivers/video/fbdev/core/fbcon_ud.c+2−2
@@ -289,7 +289,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 288 unmodified lines
289289 if (attribute) {
290290 u8 *dst;
291291
292− dst = kmalloc(w * vc->vc_font.height, GFP_ATOMIC);
292+ dst = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
293293 if (!dst)
294294 return;
295295 kfree(ops->cursor_data);
@@ -335,7 +335,7 @@ static void ud_cursor(struct vc_data *vc, struct fb_info *info, int mode, · 39 unmodified lines
335335 vc->vc_cursor_type != ops->p->cursor_shape ||
336336 ops->cursor_state.mask == NULL ||
337337 ops->cursor_reset) {
338− char *mask = kmalloc(w*vc->vc_font.height, GFP_ATOMIC);
338+ char *mask = kmalloc_array(w, vc->vc_font.height, GFP_ATOMIC);
339339 int cur_height, size, i = 0;
340340 u8 msk = 0xff;
341341
drivers/video/fbdev/core/fbmem.c+4−3
@@ -489,7 +489,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, · 488 unmodified lines
489489 }
490490
491491 if (fb_logo.depth <= 4) {
492− logo_new = kmalloc(logo->width * logo->height, GFP_KERNEL);
492+ logo_new = kmalloc_array(logo->width, logo->height,
493+ GFP_KERNEL);
493494 if (logo_new == NULL) {
494495 kfree(palette);
495496 if (saved_pseudo_palette)
@@ -506,8 +507,8 @@ static int fb_show_logo_line(struct fb_info *info, int rotate, · 10 unmodified lines
506507 image.height = logo->height;
507508
508509 if (rotate) {
509− logo_rotate = kmalloc(logo->width *
510− logo->height, GFP_KERNEL);
510+ logo_rotate = kmalloc_array(logo->width, logo->height,
511+ GFP_KERNEL);
511512 if (logo_rotate)
512513 fb_rotate_logo(info, logo_rotate, &image, rotate);
513514 }
drivers/video/fbdev/core/fbmon.c+5−4
@@ -620,7 +620,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, · 619 unmodified lines
620620 int num = 0, i, first = 1;
621621 int ver, rev;
622622
623− mode = kzalloc(50 * sizeof(struct fb_videomode), GFP_KERNEL);
623+ mode = kcalloc(50, sizeof(struct fb_videomode), GFP_KERNEL);
624624 if (mode == NULL)
625625 return NULL;
626626
@@ -671,7 +671,7 @@ static struct fb_videomode *fb_create_modedb(unsigned char *edid, int *dbsize, · 44 unmodified lines
671671 }
672672
673673 *dbsize = num;
674− m = kmalloc(num * sizeof(struct fb_videomode), GFP_KERNEL);
674+ m = kmalloc_array(num, sizeof(struct fb_videomode), GFP_KERNEL);
675675 if (!m)
676676 return mode;
677677 memmove(m, mode, num * sizeof(struct fb_videomode));
@@ -1055,8 +1055,9 @@ void fb_edid_add_monspecs(unsigned char *edid, struct fb_monspecs *specs) · 377 unmodified lines
10551055 if (!(num + svd_n))
10561056 return;
10571057
1058− m = kzalloc((specs->modedb_len + num + svd_n) *
1059− sizeof(struct fb_videomode), GFP_KERNEL);
1058+ m = kcalloc(specs->modedb_len + num + svd_n,
1059+ sizeof(struct fb_videomode),
1060+ GFP_KERNEL);
10601061
10611062 if (!m)
10621063 return;
drivers/video/fbdev/imxfb.c+1−1
@@ -662,7 +662,7 @@ static int imxfb_init_fbinfo(struct platform_device *pdev) · 661 unmodified lines
662662
663663 pr_debug("%s\n",__func__);
664664
665− info->pseudo_palette = kmalloc(sizeof(u32) * 16, GFP_KERNEL);
665+ info->pseudo_palette = kmalloc_array(16, sizeof(u32), GFP_KERNEL);
666666 if (!info->pseudo_palette)
667667 return -ENOMEM;
668668
drivers/video/fbdev/mb862xx/mb862xxfb_accel.c+1−1
@@ -245,7 +245,7 @@ static void mb86290fb_imageblit(struct fb_info *info, · 244 unmodified lines
245245 return;
246246 }
247247
248− cmd = kmalloc(cmdlen * 4, GFP_DMA);
248+ cmd = kmalloc_array(cmdlen, 4, GFP_DMA);
249249 if (!cmd)
250250 return cfb_imageblit(info, image);
251251 cmdfn(cmd, step, dx, dy, width, height, fgcolor, bgcolor, image, info);
drivers/video/fbdev/mmp/fb/mmpfb.c+2−2
@@ -493,8 +493,8 @@ static int modes_setup(struct mmpfb_info *fbi) · 492 unmodified lines
493493 return 0;
494494 }
495495 /* put videomode list to info structure */
496− videomodes = kzalloc(sizeof(struct fb_videomode) * videomode_num,
497− GFP_KERNEL);
496+ videomodes = kcalloc(videomode_num, sizeof(struct fb_videomode),
497+ GFP_KERNEL);
498498 if (!videomodes) {
499499 dev_err(fbi->dev, "can't malloc video modes\n");
500500 return -ENOMEM;
drivers/video/fbdev/mxsfb.c+1−1
@@ -931,7 +931,7 @@ static int mxsfb_probe(struct platform_device *pdev) · 930 unmodified lines
931931 if (IS_ERR(host->reg_lcd))
932932 host->reg_lcd = NULL;
933933
934− fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16,
934+ fb_info->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32),
935935 GFP_KERNEL);
936936 if (!fb_info->pseudo_palette) {
937937 ret = -ENOMEM;
drivers/video/fbdev/nvidia/nvidia.c+1−1
@@ -566,7 +566,7 @@ static int nvidiafb_cursor(struct fb_info *info, struct fb_cursor *cursor) · 565 unmodified lines
566566 u8 *msk = (u8 *) cursor->mask;
567567 u8 *src;
568568
569− src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
569+ src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC);
570570
571571 if (src) {
572572 switch (cursor->rop) {
drivers/video/fbdev/omap2/omapfb/dss/manager.c+2−2
@@ -42,8 +42,8 @@ int dss_init_overlay_managers(void) · 41 unmodified lines
4242
4343 num_managers = dss_feat_get_num_mgrs();
4444
45− managers = kzalloc(sizeof(struct omap_overlay_manager) * num_managers,
46− GFP_KERNEL);
45+ managers = kcalloc(num_managers, sizeof(struct omap_overlay_manager),
46+ GFP_KERNEL);
4747
4848 BUG_ON(managers == NULL);
4949
drivers/video/fbdev/omap2/omapfb/dss/overlay.c+2−2
@@ -59,8 +59,8 @@ void dss_init_overlays(struct platform_device *pdev) · 58 unmodified lines
5959
6060 num_overlays = dss_feat_get_num_ovls();
6161
62− overlays = kzalloc(sizeof(struct omap_overlay) * num_overlays,
63− GFP_KERNEL);
62+ overlays = kcalloc(num_overlays, sizeof(struct omap_overlay),
63+ GFP_KERNEL);
6464
6565 BUG_ON(overlays == NULL);
6666
drivers/video/fbdev/omap2/omapfb/vrfb.c+2−2
@@ -359,8 +359,8 @@ static int __init vrfb_probe(struct platform_device *pdev) · 358 unmodified lines
359359
360360 num_ctxs = pdev->num_resources - 1;
361361
362− ctxs = devm_kzalloc(&pdev->dev,
363− sizeof(struct vrfb_ctx) * num_ctxs,
362+ ctxs = devm_kcalloc(&pdev->dev,
363+ num_ctxs, sizeof(struct vrfb_ctx),
364364 GFP_KERNEL);
365365
366366 if (!ctxs)
drivers/video/fbdev/pvr2fb.c+1−1
@@ -682,7 +682,7 @@ static ssize_t pvr2fb_write(struct fb_info *info, const char *buf, · 681 unmodified lines
682682
683683 nr_pages = (count + PAGE_SIZE - 1) >> PAGE_SHIFT;
684684
685− pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
685+ pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
686686 if (!pages)
687687 return -ENOMEM;
688688
drivers/video/fbdev/riva/fbdev.c+1−1
@@ -1615,7 +1615,7 @@ static int rivafb_cursor(struct fb_info *info, struct fb_cursor *cursor) · 1614 unmodified lines
16151615 u8 *msk = (u8 *) cursor->mask;
16161616 u8 *src;
16171617
1618− src = kmalloc(s_pitch * cursor->image.height, GFP_ATOMIC);
1618+ src = kmalloc_array(s_pitch, cursor->image.height, GFP_ATOMIC);
16191619
16201620 if (src) {
16211621 switch (cursor->rop) {
drivers/video/fbdev/uvesafb.c+6−4
@@ -486,8 +486,9 @@ static int uvesafb_vbe_getmodes(struct uvesafb_ktask *task, · 485 unmodified lines
486486 mode++;
487487 }
488488
489− par->vbe_modes = kzalloc(sizeof(struct vbe_mode_ib) *
490− par->vbe_modes_cnt, GFP_KERNEL);
489+ par->vbe_modes = kcalloc(par->vbe_modes_cnt,
490+ sizeof(struct vbe_mode_ib),
491+ GFP_KERNEL);
491492 if (!par->vbe_modes)
492493 return -ENOMEM;
493494
@@ -858,7 +859,7 @@ static int uvesafb_vbe_init_mode(struct fb_info *info) · 364 unmodified lines
858859 * Convert the modelist into a modedb so that we can use it with
859860 * fb_find_mode().
860861 */
861− mode = kzalloc(i * sizeof(*mode), GFP_KERNEL);
862+ mode = kcalloc(i, sizeof(*mode), GFP_KERNEL);
862863 if (mode) {
863864 i = 0;
864865 list_for_each(pos, &info->modelist) {
@@ -1044,7 +1045,8 @@ static int uvesafb_setcmap(struct fb_cmap *cmap, struct fb_info *info) · 179 unmodified lines
10441045 info->cmap.len || cmap->start < info->cmap.start)
10451046 return -EINVAL;
10461047
1047− entries = kmalloc(sizeof(*entries) * cmap->len, GFP_KERNEL);
1048+ entries = kmalloc_array(cmap->len, sizeof(*entries),
1049+ GFP_KERNEL);
10481050 if (!entries)
10491051 return -ENOMEM;
10501052
drivers/video/fbdev/via/viafbdev.c+2−1
@@ -596,7 +596,8 @@ static int viafb_ioctl(struct fb_info *info, u_int cmd, u_long arg) · 595 unmodified lines
596596 break;
597597
598598 case VIAFB_GET_GAMMA_LUT:
599− viafb_gamma_table = kmalloc(256 * sizeof(u32), GFP_KERNEL);
599+ viafb_gamma_table = kmalloc_array(256, sizeof(u32),
600+ GFP_KERNEL);
600601 if (!viafb_gamma_table)
601602 return -ENOMEM;
602603 viafb_get_gamma_table(viafb_gamma_table);
drivers/video/fbdev/w100fb.c+2−1
@@ -693,7 +693,8 @@ int w100fb_probe(struct platform_device *pdev) · 692 unmodified lines
693693 goto out;
694694 }
695695
696− info->pseudo_palette = kmalloc(sizeof (u32) * MAX_PALETTES, GFP_KERNEL);
696+ info->pseudo_palette = kmalloc_array(MAX_PALETTES, sizeof(u32),
697+ GFP_KERNEL);
697698 if (!info->pseudo_palette) {
698699 err = -ENOMEM;
699700 goto out;
drivers/video/fbdev/xen-fbfront.c+1−1
@@ -412,7 +412,7 @@ static int xenfb_probe(struct xenbus_device *dev, · 411 unmodified lines
412412
413413 info->nr_pages = (fb_size + PAGE_SIZE - 1) >> PAGE_SHIFT;
414414
415− info->gfns = vmalloc(sizeof(unsigned long) * info->nr_pages);
415+ info->gfns = vmalloc(array_size(sizeof(unsigned long), info->nr_pages));
416416 if (!info->gfns)
417417 goto error_nomem;
418418
drivers/video/of_display_timing.c+3−2
@@ -181,8 +181,9 @@ struct display_timings *of_get_display_timings(const struct device_node *np) · 180 unmodified lines
181181 goto entryfail;
182182 }
183183
184− disp->timings = kzalloc(sizeof(struct display_timing *) *
185− disp->num_timings, GFP_KERNEL);
184+ disp->timings = kcalloc(disp->num_timings,
185+ sizeof(struct display_timing *),
186+ GFP_KERNEL);
186187 if (!disp->timings) {
187188 pr_err("%pOF: could not allocate timings array\n", np);
188189 goto entryfail;
drivers/virt/fsl_hypervisor.c+1−1
@@ -223,7 +223,7 @@ static long ioctl_memcpy(struct fsl_hv_ioctl_memcpy __user *p) · 222 unmodified lines
223223 * 'pages' is an array of struct page pointers that's initialized by
224224 * get_user_pages().
225225 */
226− pages = kzalloc(num_pages * sizeof(struct page *), GFP_KERNEL);
226+ pages = kcalloc(num_pages, sizeof(struct page *), GFP_KERNEL);
227227 if (!pages) {
228228 pr_debug("fsl-hv: could not allocate page list\n");
229229 return -ENOMEM;
drivers/virt/vboxguest/vboxguest_core.c+4−3
@@ -69,7 +69,7 @@ static void vbg_guest_mappings_init(struct vbg_dev *gdev) · 68 unmodified lines
6969 /* Add 4M so that we can align the vmap to 4MiB as the host requires. */
7070 size = PAGE_ALIGN(req->hypervisor_size) + SZ_4M;
7171
72− pages = kmalloc(sizeof(*pages) * (size >> PAGE_SHIFT), GFP_KERNEL);
72+ pages = kmalloc_array(size >> PAGE_SHIFT, sizeof(*pages), GFP_KERNEL);
7373 if (!pages)
7474 goto out;
7575
@@ -262,8 +262,9 @@ static int vbg_balloon_inflate(struct vbg_dev *gdev, u32 chunk_idx) · 186 unmodified lines
262262 struct page **pages;
263263 int i, rc, ret;
264264
265− pages = kmalloc(sizeof(*pages) * VMMDEV_MEMORY_BALLOON_CHUNK_PAGES,
266− GFP_KERNEL | __GFP_NOWARN);
265+ pages = kmalloc_array(VMMDEV_MEMORY_BALLOON_CHUNK_PAGES,
266+ sizeof(*pages),
267+ GFP_KERNEL | __GFP_NOWARN);
267268 if (!pages)
268269 return -ENOMEM;
269270
drivers/virtio/virtio_pci_common.c+4−3
@@ -113,12 +113,13 @@ static int vp_request_msix_vectors(struct virtio_device *vdev, int nvectors, · 112 unmodified lines
113113
114114 vp_dev->msix_vectors = nvectors;
115115
116− vp_dev->msix_names = kmalloc(nvectors * sizeof *vp_dev->msix_names,
117− GFP_KERNEL);
116+ vp_dev->msix_names = kmalloc_array(nvectors,
117+ sizeof(*vp_dev->msix_names),
118+ GFP_KERNEL);
118119 if (!vp_dev->msix_names)
119120 goto error;
120121 vp_dev->msix_affinity_masks
121− = kzalloc(nvectors * sizeof *vp_dev->msix_affinity_masks,
122+ = kcalloc(nvectors, sizeof(*vp_dev->msix_affinity_masks),
122123 GFP_KERNEL);
123124 if (!vp_dev->msix_affinity_masks)
124125 goto error;
drivers/virtio/virtio_ring.c+1−1
@@ -247,7 +247,7 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq, · 246 unmodified lines
247247 */
248248 gfp &= ~__GFP_HIGHMEM;
249249
250− desc = kmalloc(total_sg * sizeof(struct vring_desc), gfp);
250+ desc = kmalloc_array(total_sg, sizeof(struct vring_desc), gfp);
251251 if (!desc)
252252 return NULL;
253253
drivers/xen/arm-device.c+3−3
@@ -70,9 +70,9 @@ static int xen_map_device_mmio(const struct resource *resources, · 69 unmodified lines
7070 if ((resource_type(r) != IORESOURCE_MEM) || (nr == 0))
7171 continue;
7272
73− gpfns = kzalloc(sizeof(xen_pfn_t) * nr, GFP_KERNEL);
74− idxs = kzalloc(sizeof(xen_ulong_t) * nr, GFP_KERNEL);
75− errs = kzalloc(sizeof(int) * nr, GFP_KERNEL);
73+ gpfns = kcalloc(nr, sizeof(xen_pfn_t), GFP_KERNEL);
74+ idxs = kcalloc(nr, sizeof(xen_ulong_t), GFP_KERNEL);
75+ errs = kcalloc(nr, sizeof(int), GFP_KERNEL);
7676 if (!gpfns || !idxs || !errs) {
7777 kfree(gpfns);
7878 kfree(idxs);
drivers/xen/evtchn.c+1−1
@@ -322,7 +322,7 @@ static int evtchn_resize_ring(struct per_user_data *u) · 321 unmodified lines
322322 else
323323 new_size = 2 * u->ring_size;
324324
325− new_ring = kvmalloc(new_size * sizeof(*new_ring), GFP_KERNEL);
325+ new_ring = kvmalloc_array(new_size, sizeof(*new_ring), GFP_KERNEL);
326326 if (!new_ring)
327327 return -ENOMEM;
328328
drivers/xen/grant-table.c+4−3
@@ -1137,7 +1137,7 @@ static int gnttab_map(unsigned int start_idx, unsigned int end_idx) · 1136 unmodified lines
11371137 /* No need for kzalloc as it is initialized in following hypercall
11381138 * GNTTABOP_setup_table.
11391139 */
1140− frames = kmalloc(nr_gframes * sizeof(unsigned long), GFP_ATOMIC);
1140+ frames = kmalloc_array(nr_gframes, sizeof(unsigned long), GFP_ATOMIC);
11411141 if (!frames)
11421142 return -ENOMEM;
11431143
@@ -1300,8 +1300,9 @@ int gnttab_init(void) · 156 unmodified lines
13001300 max_nr_glist_frames = (max_nr_grant_frames *
13011301 gnttab_interface->grefs_per_grant_frame / RPP);
13021302
1303− gnttab_list = kmalloc(max_nr_glist_frames * sizeof(grant_ref_t *),
1304− GFP_KERNEL);
1303+ gnttab_list = kmalloc_array(max_nr_glist_frames,
1304+ sizeof(grant_ref_t *),
1305+ GFP_KERNEL);
13051306 if (gnttab_list == NULL)
13061307 return -ENOMEM;
13071308
drivers/xen/xen-pciback/pciback_ops.c+1−1
@@ -234,7 +234,7 @@ int xen_pcibk_enable_msix(struct xen_pcibk_device *pdev, · 233 unmodified lines
234234 if (dev->msi_enabled || !(cmd & PCI_COMMAND_MEMORY))
235235 return -ENXIO;
236236
237− entries = kmalloc(op->value * sizeof(*entries), GFP_KERNEL);
237+ entries = kmalloc_array(op->value, sizeof(*entries), GFP_KERNEL);
238238 if (entries == NULL)
239239 return -ENOMEM;
240240
fs/9p/fid.c+1−1
@@ -100,7 +100,7 @@ static int build_path_from_dentry(struct v9fs_session_info *v9ses, · 99 unmodified lines
100100 for (ds = dentry; !IS_ROOT(ds); ds = ds->d_parent)
101101 n++;
102102
103− wnames = kmalloc(sizeof(char *) * n, GFP_KERNEL);
103+ wnames = kmalloc_array(n, sizeof(char *), GFP_KERNEL);
104104 if (!wnames)
105105 goto err_out;
106106
fs/adfs/super.c+1−1
@@ -313,7 +313,7 @@ static struct adfs_discmap *adfs_read_map(struct super_block *sb, struct adfs_di · 312 unmodified lines
313313
314314 asb->s_ids_per_zone = zone_size / (asb->s_idlen + 1);
315315
316− dm = kmalloc(nzones * sizeof(*dm), GFP_KERNEL);
316+ dm = kmalloc_array(nzones, sizeof(*dm), GFP_KERNEL);
317317 if (dm == NULL) {
318318 adfs_error(sb, "not enough memory");
319319 return ERR_PTR(-ENOMEM);
fs/afs/cmservice.c+4−3
@@ -191,7 +191,8 @@ static int afs_deliver_cb_callback(struct afs_call *call) · 190 unmodified lines
191191 if (call->count > AFSCBMAX)
192192 return afs_protocol_error(call, -EBADMSG);
193193
194− call->buffer = kmalloc(call->count * 3 * 4, GFP_KERNEL);
194+ call->buffer = kmalloc(array3_size(call->count, 3, 4),
195+ GFP_KERNEL);
195196 if (!call->buffer)
196197 return -ENOMEM;
197198 call->offset = 0;
@@ -330,7 +331,7 @@ static int afs_deliver_cb_init_call_back_state3(struct afs_call *call) · 132 unmodified lines
330331 switch (call->unmarshall) {
331332 case 0:
332333 call->offset = 0;
333− call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL);
334+ call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
334335 if (!call->buffer)
335336 return -ENOMEM;
336337 call->unmarshall++;
@@ -453,7 +454,7 @@ static int afs_deliver_cb_probe_uuid(struct afs_call *call) · 116 unmodified lines
453454 switch (call->unmarshall) {
454455 case 0:
455456 call->offset = 0;
456− call->buffer = kmalloc(11 * sizeof(__be32), GFP_KERNEL);
457+ call->buffer = kmalloc_array(11, sizeof(__be32), GFP_KERNEL);
457458 if (!call->buffer)
458459 return -ENOMEM;
459460 call->unmarshall++;
fs/binfmt_elf.c+2−2
@@ -2010,7 +2010,7 @@ static int elf_note_info_init(struct elf_note_info *info) · 2009 unmodified lines
20102010 INIT_LIST_HEAD(&info->thread_list);
20112011
20122012 /* Allocate space for ELF notes */
2013− info->notes = kmalloc(8 * sizeof(struct memelfnote), GFP_KERNEL);
2013+ info->notes = kmalloc_array(8, sizeof(struct memelfnote), GFP_KERNEL);
20142014 if (!info->notes)
20152015 return 0;
20162016 info->psinfo = kmalloc(sizeof(*info->psinfo), GFP_KERNEL);
@@ -2294,7 +2294,7 @@ static int elf_core_dump(struct coredump_params *cprm) · 277 unmodified lines
22942294
22952295 if (segs - 1 > ULONG_MAX / sizeof(*vma_filesz))
22962296 goto end_coredump;
2297− vma_filesz = vmalloc((segs - 1) * sizeof(*vma_filesz));
2297+ vma_filesz = vmalloc(array_size(sizeof(*vma_filesz), (segs - 1)));
22982298 if (!vma_filesz)
22992299 goto end_coredump;
23002300
fs/binfmt_elf_fdpic.c+2−1
@@ -1600,7 +1600,8 @@ static int elf_fdpic_core_dump(struct coredump_params *cprm) · 1599 unmodified lines
16001600 psinfo = kmalloc(sizeof(*psinfo), GFP_KERNEL);
16011601 if (!psinfo)
16021602 goto cleanup;
1603− notes = kmalloc(NUM_NOTES * sizeof(struct memelfnote), GFP_KERNEL);
1603+ notes = kmalloc_array(NUM_NOTES, sizeof(struct memelfnote),
1604+ GFP_KERNEL);
16041605 if (!notes)
16051606 goto cleanup;
16061607 fpu = kmalloc(sizeof(*fpu), GFP_KERNEL);
fs/block_dev.c+2−1
@@ -205,7 +205,8 @@ __blkdev_direct_IO_simple(struct kiocb *iocb, struct iov_iter *iter, · 204 unmodified lines
205205 if (nr_pages <= DIO_INLINE_BIO_VECS)
206206 vecs = inline_vecs;
207207 else {
208− vecs = kmalloc(nr_pages * sizeof(struct bio_vec), GFP_KERNEL);
208+ vecs = kmalloc_array(nr_pages, sizeof(struct bio_vec),
209+ GFP_KERNEL);
209210 if (!vecs)
210211 return -ENOMEM;
211212 }
fs/btrfs/check-integrity.c+2−2
@@ -1603,8 +1603,8 @@ static int btrfsic_read_block(struct btrfsic_state *state, · 1602 unmodified lines
16031603
16041604 num_pages = (block_ctx->len + (u64)PAGE_SIZE - 1) >>
16051605 PAGE_SHIFT;
1606− block_ctx->mem_to_free = kzalloc((sizeof(*block_ctx->datav) +
1607− sizeof(*block_ctx->pagev)) *
1606+ block_ctx->mem_to_free = kcalloc(sizeof(*block_ctx->datav) +
1607+ sizeof(*block_ctx->pagev),
16081608 num_pages, GFP_NOFS);
16091609 if (!block_ctx->mem_to_free)
16101610 return -ENOMEM;
fs/ceph/addr.c+6−5
@@ -370,7 +370,7 @@ static int start_read(struct inode *inode, struct ceph_rw_context *rw_ctx, · 369 unmodified lines
370370
371371 /* build page vector */
372372 nr_pages = calc_pages_for(0, len);
373− pages = kmalloc(sizeof(*pages) * nr_pages, GFP_KERNEL);
373+ pages = kmalloc_array(nr_pages, sizeof(*pages), GFP_KERNEL);
374374 if (!pages) {
375375 ret = -ENOMEM;
376376 goto out_put;
@@ -966,8 +966,9 @@ get_more_pages: · 589 unmodified lines
966966
967967 BUG_ON(pages);
968968 max_pages = calc_pages_for(0, (u64)len);
969− pages = kmalloc(max_pages * sizeof (*pages),
970− GFP_NOFS);
969+ pages = kmalloc_array(max_pages,
970+ sizeof(*pages),
971+ GFP_NOFS);
971972 if (!pages) {
972973 pool = fsc->wb_pagevec_pool;
973974 pages = mempool_alloc(pool, GFP_NOFS);
@@ -1113,8 +1114,8 @@ new_request: · 139 unmodified lines
11131114
11141115 /* allocate new pages array for next request */
11151116 data_pages = pages;
1116− pages = kmalloc(locked_pages * sizeof (*pages),
1117− GFP_NOFS);
1117+ pages = kmalloc_array(locked_pages, sizeof(*pages),
1118+ GFP_NOFS);
11181119 if (!pages) {
11191120 pool = fsc->wb_pagevec_pool;
11201121 pages = mempool_alloc(pool, GFP_NOFS);
fs/ceph/mds_client.c+3−2
@@ -2992,8 +2992,9 @@ encode_again: · 2991 unmodified lines
29922992 num_flock_locks = 0;
29932993 }
29942994 if (num_fcntl_locks + num_flock_locks > 0) {
2995− flocks = kmalloc((num_fcntl_locks + num_flock_locks) *
2996− sizeof(struct ceph_filelock), GFP_NOFS);
2995+ flocks = kmalloc_array(num_fcntl_locks + num_flock_locks,
2996+ sizeof(struct ceph_filelock),
2997+ GFP_NOFS);
29972998 if (!flocks) {
29982999 err = -ENOMEM;
29993000 goto out_free;
fs/cifs/asn1.c+1−1
@@ -428,7 +428,7 @@ asn1_oid_decode(struct asn1_ctx *ctx, · 427 unmodified lines
428428 if (size < 2 || size > UINT_MAX/sizeof(unsigned long))
429429 return 0;
430430
431− *oid = kmalloc(size * sizeof(unsigned long), GFP_ATOMIC);
431+ *oid = kmalloc_array(size, sizeof(unsigned long), GFP_ATOMIC);
432432 if (*oid == NULL)
433433 return 0;
434434
fs/cifs/cifsacl.c+2−2
@@ -747,8 +747,8 @@ static void parse_dacl(struct cifs_acl *pdacl, char *end_of_acl, · 746 unmodified lines
747747
748748 if (num_aces > ULONG_MAX / sizeof(struct cifs_ace *))
749749 return;
750− ppace = kmalloc(num_aces * sizeof(struct cifs_ace *),
751− GFP_KERNEL);
750+ ppace = kmalloc_array(num_aces, sizeof(struct cifs_ace *),
751+ GFP_KERNEL);
752752 if (!ppace)
753753 return;
754754
fs/cifs/cifssmb.c+1−1
@@ -2077,7 +2077,7 @@ struct cifs_writedata * · 2076 unmodified lines
20772077 cifs_writedata_alloc(unsigned int nr_pages, work_func_t complete)
20782078 {
20792079 struct page **pages =
2080− kzalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
2080+ kcalloc(nr_pages, sizeof(struct page *), GFP_NOFS);
20812081 if (pages)
20822082 return cifs_writedata_direct_alloc(pages, complete);
20832083
fs/cifs/file.c+1−1
@@ -2900,7 +2900,7 @@ static struct cifs_readdata * · 2899 unmodified lines
29002900 cifs_readdata_alloc(unsigned int nr_pages, work_func_t complete)
29012901 {
29022902 struct page **pages =
2903− kzalloc(sizeof(struct page *) * nr_pages, GFP_KERNEL);
2903+ kcalloc(nr_pages, sizeof(struct page *), GFP_KERNEL);
29042904 struct cifs_readdata *ret = NULL;
29052905
29062906 if (pages) {
fs/cifs/inode.c+1−1
@@ -1792,7 +1792,7 @@ cifs_rename2(struct inode *source_dir, struct dentry *source_dentry, · 1791 unmodified lines
17921792 * with unix extensions enabled.
17931793 */
17941794 info_buf_source =
1795− kmalloc(2 * sizeof(FILE_UNIX_BASIC_INFO),
1795+ kmalloc_array(2, sizeof(FILE_UNIX_BASIC_INFO),
17961796 GFP_KERNEL);
17971797 if (info_buf_source == NULL) {
17981798 rc = -ENOMEM;
fs/cifs/misc.c+2−2
@@ -789,7 +789,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) · 788 unmodified lines
789789 GFP_KERNEL);
790790
791791 if (!bv) {
792− bv = vmalloc(max_pages * sizeof(struct bio_vec));
792+ bv = vmalloc(array_size(max_pages, sizeof(struct bio_vec)));
793793 if (!bv)
794794 return -ENOMEM;
795795 }
@@ -799,7 +799,7 @@ setup_aio_ctx_iter(struct cifs_aio_ctx *ctx, struct iov_iter *iter, int rw) · 3 unmodified lines
799799 GFP_KERNEL);
800800
801801 if (!pages) {
802− pages = vmalloc(max_pages * sizeof(struct page *));
802+ pages = vmalloc(array_size(max_pages, sizeof(struct page *)));
803803 if (!pages) {
804804 kvfree(bv);
805805 return -ENOMEM;
fs/cifs/smb2pdu.c+3−3
@@ -3471,7 +3471,7 @@ send_set_info(const unsigned int xid, struct cifs_tcon *tcon, · 3470 unmodified lines
34713471 if (!num)
34723472 return -EINVAL;
34733473
3474− iov = kmalloc(sizeof(struct kvec) * num, GFP_KERNEL);
3474+ iov = kmalloc_array(num, sizeof(struct kvec), GFP_KERNEL);
34753475 if (!iov)
34763476 return -ENOMEM;
34773477
@@ -3535,7 +3535,7 @@ SMB2_rename(const unsigned int xid, struct cifs_tcon *tcon, · 57 unmodified lines
35353535 int rc;
35363536 int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX));
35373537
3538− data = kmalloc(sizeof(void *) * 2, GFP_KERNEL);
3538+ data = kmalloc_array(2, sizeof(void *), GFP_KERNEL);
35393539 if (!data)
35403540 return -ENOMEM;
35413541
@@ -3583,7 +3583,7 @@ SMB2_set_hardlink(const unsigned int xid, struct cifs_tcon *tcon, · 41 unmodified lines
35833583 int rc;
35843584 int len = (2 * UniStrnlen((wchar_t *)target_file, PATH_MAX));
35853585
3586− data = kmalloc(sizeof(void *) * 2, GFP_KERNEL);
3586+ data = kmalloc_array(2, sizeof(void *), GFP_KERNEL);
35873587 if (!data)
35883588 return -ENOMEM;
35893589
fs/cifs/transport.c+4−4
@@ -844,8 +844,8 @@ SendReceive2(const unsigned int xid, struct cifs_ses *ses, · 843 unmodified lines
844844 int rc;
845845
846846 if (n_vec + 1 > CIFS_MAX_IOV_SIZE) {
847− new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1),
848− GFP_KERNEL);
847+ new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec),
848+ GFP_KERNEL);
849849 if (!new_iov) {
850850 /* otherwise cifs_send_recv below sets resp_buf_type */
851851 *resp_buf_type = CIFS_NO_BUFFER;
@@ -886,8 +886,8 @@ smb2_send_recv(const unsigned int xid, struct cifs_ses *ses, · 34 unmodified lines
886886 __be32 rfc1002_marker;
887887
888888 if (n_vec + 1 > CIFS_MAX_IOV_SIZE) {
889− new_iov = kmalloc(sizeof(struct kvec) * (n_vec + 1),
890− GFP_KERNEL);
889+ new_iov = kmalloc_array(n_vec + 1, sizeof(struct kvec),
890+ GFP_KERNEL);
891891 if (!new_iov)
892892 return -ENOMEM;
893893 } else
fs/dlm/lockspace.c+1−1
@@ -517,7 +517,7 @@ static int new_lockspace(const char *name, const char *cluster, · 516 unmodified lines
517517 size = dlm_config.ci_rsbtbl_size;
518518 ls->ls_rsbtbl_size = size;
519519
520− ls->ls_rsbtbl = vmalloc(sizeof(struct dlm_rsbtable) * size);
520+ ls->ls_rsbtbl = vmalloc(array_size(size, sizeof(struct dlm_rsbtable)));
521521 if (!ls->ls_rsbtbl)
522522 goto out_lsfree;
523523 for (i = 0; i < size; i++) {
fs/exofs/inode.c+2−2
@@ -110,8 +110,8 @@ static int pcol_try_alloc(struct page_collect *pcol) · 109 unmodified lines
110110 pages = exofs_max_io_pages(&pcol->sbi->layout, pcol->expected_pages);
111111
112112 for (; pages; pages >>= 1) {
113− pcol->pages = kmalloc(pages * sizeof(struct page *),
114− GFP_KERNEL);
113+ pcol->pages = kmalloc_array(pages, sizeof(struct page *),
114+ GFP_KERNEL);
115115 if (likely(pcol->pages)) {
116116 pcol->alloc_pages = pages;
117117 return 0;
fs/ext2/super.c+3−1
@@ -1082,7 +1082,9 @@ static int ext2_fill_super(struct super_block *sb, void *data, int silent) · 1081 unmodified lines
10821082 / EXT2_BLOCKS_PER_GROUP(sb)) + 1;
10831083 db_count = (sbi->s_groups_count + EXT2_DESC_PER_BLOCK(sb) - 1) /
10841084 EXT2_DESC_PER_BLOCK(sb);
1085− sbi->s_group_desc = kmalloc (db_count * sizeof (struct buffer_head *), GFP_KERNEL);
1085+ sbi->s_group_desc = kmalloc_array (db_count,
1086+ sizeof(struct buffer_head *),
1087+ GFP_KERNEL);
10861088 if (sbi->s_group_desc == NULL) {
10871089 ext2_msg(sb, KERN_ERR, "error: not enough memory");
10881090 goto failed_mount;
fs/ext4/extents.c+4−4
@@ -577,7 +577,7 @@ int ext4_ext_precache(struct inode *inode) · 576 unmodified lines
577577 down_read(&ei->i_data_sem);
578578 depth = ext_depth(inode);
579579
580− path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
580+ path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
581581 GFP_NOFS);
582582 if (path == NULL) {
583583 up_read(&ei->i_data_sem);
@@ -879,7 +879,7 @@ ext4_find_extent(struct inode *inode, ext4_lblk_t block, · 295 unmodified lines
879879 }
880880 if (!path) {
881881 /* account possible depth increase */
882− path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 2),
882+ path = kcalloc(depth + 2, sizeof(struct ext4_ext_path),
883883 GFP_NOFS);
884884 if (unlikely(!path))
885885 return ERR_PTR(-ENOMEM);
@@ -1063,7 +1063,7 @@ static int ext4_ext_split(handle_t *handle, struct inode *inode, · 177 unmodified lines
10631063 * We need this to handle errors and free blocks
10641064 * upon them.
10651065 */
1066− ablocks = kzalloc(sizeof(ext4_fsblk_t) * depth, GFP_NOFS);
1066+ ablocks = kcalloc(depth, sizeof(ext4_fsblk_t), GFP_NOFS);
10671067 if (!ablocks)
10681068 return -ENOMEM;
10691069
@@ -2921,7 +2921,7 @@ again: · 1851 unmodified lines
29212921 path[k].p_block =
29222922 le16_to_cpu(path[k].p_hdr->eh_entries)+1;
29232923 } else {
2924− path = kzalloc(sizeof(struct ext4_ext_path) * (depth + 1),
2924+ path = kcalloc(depth + 1, sizeof(struct ext4_ext_path),
29252925 GFP_NOFS);
29262926 if (path == NULL) {
29272927 ext4_journal_stop(handle);
fs/ext4/resize.c+6−4
@@ -204,12 +204,14 @@ static struct ext4_new_flex_group_data *alloc_flex_gd(unsigned long flexbg_size) · 203 unmodified lines
204204 goto out2;
205205 flex_gd->count = flexbg_size;
206206
207− flex_gd->groups = kmalloc(sizeof(struct ext4_new_group_data) *
208− flexbg_size, GFP_NOFS);
207+ flex_gd->groups = kmalloc_array(flexbg_size,
208+ sizeof(struct ext4_new_group_data),
209+ GFP_NOFS);
209210 if (flex_gd->groups == NULL)
210211 goto out2;
211212
212− flex_gd->bg_flags = kmalloc(flexbg_size * sizeof(__u16), GFP_NOFS);
213+ flex_gd->bg_flags = kmalloc_array(flexbg_size, sizeof(__u16),
214+ GFP_NOFS);
213215 if (flex_gd->bg_flags == NULL)
214216 goto out1;
215217
@@ -969,7 +971,7 @@ static int reserve_backup_gdb(handle_t *handle, struct inode *inode, · 753 unmodified lines
969971 int res, i;
970972 int err;
971973
972− primary = kmalloc(reserved_gdb * sizeof(*primary), GFP_NOFS);
974+ primary = kmalloc_array(reserved_gdb, sizeof(*primary), GFP_NOFS);
973975 if (!primary)
974976 return -ENOMEM;
975977
fs/ext4/super.c+3−3
@@ -3993,9 +3993,9 @@ static int ext4_fill_super(struct super_block *sb, void *data, int silent) · 3992 unmodified lines
39933993 goto failed_mount;
39943994 }
39953995 }
3996− sbi->s_group_desc = kvmalloc(db_count *
3997− sizeof(struct buffer_head *),
3998− GFP_KERNEL);
3996+ sbi->s_group_desc = kvmalloc_array(db_count,
3997+ sizeof(struct buffer_head *),
3998+ GFP_KERNEL);
39993999 if (sbi->s_group_desc == NULL) {
40004000 ext4_msg(sb, KERN_ERR, "not enough memory");
40014001 ret = -ENOMEM;
fs/f2fs/checkpoint.c+2−1
@@ -806,7 +806,8 @@ int f2fs_get_valid_checkpoint(struct f2fs_sb_info *sbi) · 805 unmodified lines
806806 block_t cp_blk_no;
807807 int i;
808808
809− sbi->ckpt = f2fs_kzalloc(sbi, cp_blks * blk_size, GFP_KERNEL);
809+ sbi->ckpt = f2fs_kzalloc(sbi, array_size(blk_size, cp_blks),
810+ GFP_KERNEL);
810811 if (!sbi->ckpt)
811812 return -ENOMEM;
812813 /*
fs/f2fs/file.c+4−2
@@ -1122,12 +1122,14 @@ static int __exchange_data_block(struct inode *src_inode, · 1121 unmodified lines
11221122 olen = min((pgoff_t)4 * ADDRS_PER_BLOCK, len);
11231123
11241124 src_blkaddr = f2fs_kvzalloc(F2FS_I_SB(src_inode),
1125− sizeof(block_t) * olen, GFP_KERNEL);
1125+ array_size(olen, sizeof(block_t)),
1126+ GFP_KERNEL);
11261127 if (!src_blkaddr)
11271128 return -ENOMEM;
11281129
11291130 do_replace = f2fs_kvzalloc(F2FS_I_SB(src_inode),
1130− sizeof(int) * olen, GFP_KERNEL);
1131+ array_size(olen, sizeof(int)),
1132+ GFP_KERNEL);
11311133 if (!do_replace) {
11321134 kvfree(src_blkaddr);
11331135 return -ENOMEM;
fs/f2fs/node.c+8−4
@@ -2753,8 +2753,10 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi) · 2752 unmodified lines
27532753 struct f2fs_nm_info *nm_i = NM_I(sbi);
27542754 int i;
27552755
2756− nm_i->free_nid_bitmap = f2fs_kzalloc(sbi, nm_i->nat_blocks *
2757− sizeof(unsigned char *), GFP_KERNEL);
2756+ nm_i->free_nid_bitmap =
2757+ f2fs_kzalloc(sbi, array_size(sizeof(unsigned char *),
2758+ nm_i->nat_blocks),
2759+ GFP_KERNEL);
27582760 if (!nm_i->free_nid_bitmap)
27592761 return -ENOMEM;
27602762
@@ -2770,8 +2772,10 @@ static int init_free_nid_cache(struct f2fs_sb_info *sbi) · 9 unmodified lines
27702772 if (!nm_i->nat_block_bitmap)
27712773 return -ENOMEM;
27722774
2773− nm_i->free_nid_count = f2fs_kvzalloc(sbi, nm_i->nat_blocks *
2774− sizeof(unsigned short), GFP_KERNEL);
2775+ nm_i->free_nid_count =
2776+ f2fs_kvzalloc(sbi, array_size(sizeof(unsigned short),
2777+ nm_i->nat_blocks),
2778+ GFP_KERNEL);
27752779 if (!nm_i->free_nid_count)
27762780 return -ENOMEM;
27772781 return 0;
fs/f2fs/segment.c+10−5
@@ -3517,8 +3517,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi) · 3516 unmodified lines
35173517
35183518 SM_I(sbi)->sit_info = sit_i;
35193519
3520− sit_i->sentries = f2fs_kvzalloc(sbi, MAIN_SEGS(sbi) *
3521− sizeof(struct seg_entry), GFP_KERNEL);
3520+ sit_i->sentries =
3521+ f2fs_kvzalloc(sbi, array_size(sizeof(struct seg_entry),
3522+ MAIN_SEGS(sbi)),
3523+ GFP_KERNEL);
35223524 if (!sit_i->sentries)
35233525 return -ENOMEM;
35243526
@@ -3558,8 +3560,10 @@ static int build_sit_info(struct f2fs_sb_info *sbi) · 33 unmodified lines
35583560 return -ENOMEM;
35593561
35603562 if (sbi->segs_per_sec > 1) {
3561− sit_i->sec_entries = f2fs_kvzalloc(sbi, MAIN_SECS(sbi) *
3562− sizeof(struct sec_entry), GFP_KERNEL);
3563+ sit_i->sec_entries =
3564+ f2fs_kvzalloc(sbi, array_size(sizeof(struct sec_entry),
3565+ MAIN_SECS(sbi)),
3566+ GFP_KERNEL);
35633567 if (!sit_i->sec_entries)
35643568 return -ENOMEM;
35653569 }
@@ -3635,7 +3639,8 @@ static int build_curseg(struct f2fs_sb_info *sbi) · 69 unmodified lines
36353639 struct curseg_info *array;
36363640 int i;
36373641
3638− array = f2fs_kzalloc(sbi, sizeof(*array) * NR_CURSEG_TYPE, GFP_KERNEL);
3642+ array = f2fs_kzalloc(sbi, array_size(NR_CURSEG_TYPE, sizeof(*array)),
3643+ GFP_KERNEL);
36393644 if (!array)
36403645 return -ENOMEM;
36413646
fs/f2fs/super.c+13−7
@@ -2419,8 +2419,10 @@ static int init_blkz_info(struct f2fs_sb_info *sbi, int devi) · 2418 unmodified lines
24192419
24202420 #define F2FS_REPORT_NR_ZONES 4096
24212421
2422− zones = f2fs_kzalloc(sbi, sizeof(struct blk_zone) *
2423− F2FS_REPORT_NR_ZONES, GFP_KERNEL);
2422+ zones = f2fs_kzalloc(sbi,
2423+ array_size(F2FS_REPORT_NR_ZONES,
2424+ sizeof(struct blk_zone)),
2425+ GFP_KERNEL);
24242426 if (!zones)
24252427 return -ENOMEM;
24262428
@@ -2560,8 +2562,10 @@ static int f2fs_scan_devices(struct f2fs_sb_info *sbi) · 133 unmodified lines
25602562 * Initialize multiple devices information, or single
25612563 * zoned block device information.
25622564 */
2563− sbi->devs = f2fs_kzalloc(sbi, sizeof(struct f2fs_dev_info) *
2564− max_devices, GFP_KERNEL);
2565+ sbi->devs = f2fs_kzalloc(sbi,
2566+ array_size(max_devices,
2567+ sizeof(struct f2fs_dev_info)),
2568+ GFP_KERNEL);
25652569 if (!sbi->devs)
25662570 return -ENOMEM;
25672571
@@ -2783,9 +2787,11 @@ try_onemore: · 215 unmodified lines
27832787 int n = (i == META) ? 1: NR_TEMP_TYPE;
27842788 int j;
27852789
2786− sbi->write_io[i] = f2fs_kmalloc(sbi,
2787− n * sizeof(struct f2fs_bio_info),
2788− GFP_KERNEL);
2790+ sbi->write_io[i] =
2791+ f2fs_kmalloc(sbi,
2792+ array_size(n,
2793+ sizeof(struct f2fs_bio_info)),
2794+ GFP_KERNEL);
27892795 if (!sbi->write_io[i]) {
27902796 err = -ENOMEM;
27912797 goto free_options;
fs/fat/namei_vfat.c+1−1
@@ -664,7 +664,7 @@ static int vfat_add_entry(struct inode *dir, const struct qstr *qname, · 663 unmodified lines
664664 if (len == 0)
665665 return -ENOENT;
666666
667− slots = kmalloc(sizeof(*slots) * MSDOS_SLOTS, GFP_NOFS);
667+ slots = kmalloc_array(MSDOS_SLOTS, sizeof(*slots), GFP_NOFS);
668668 if (slots == NULL)
669669 return -ENOMEM;
670670
fs/fuse/dev.c+10−5
@@ -64,9 +64,12 @@ static struct fuse_req *__fuse_request_alloc(unsigned npages, gfp_t flags) · 63 unmodified lines
6464 pages = req->inline_pages;
6565 page_descs = req->inline_page_descs;
6666 } else {
67− pages = kmalloc(sizeof(struct page *) * npages, flags);
68− page_descs = kmalloc(sizeof(struct fuse_page_desc) *
69− npages, flags);
67+ pages = kmalloc_array(npages, sizeof(struct page *),
68+ flags);
69+ page_descs =
70+ kmalloc_array(npages,
71+ sizeof(struct fuse_page_desc),
72+ flags);
7073 }
7174
7275 if (!pages || !page_descs) {
@@ -1359,7 +1362,8 @@ static ssize_t fuse_dev_splice_read(struct file *in, loff_t *ppos, · 1286 unmodified lines
13591362 if (!fud)
13601363 return -EPERM;
13611364
1362− bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL);
1365+ bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer),
1366+ GFP_KERNEL);
13631367 if (!bufs)
13641368 return -ENOMEM;
13651369
@@ -1940,7 +1944,8 @@ static ssize_t fuse_dev_splice_write(struct pipe_inode_info *pipe, · 574 unmodified lines
19401944 if (!fud)
19411945 return -EPERM;
19421946
1943− bufs = kmalloc(pipe->buffers * sizeof(struct pipe_buffer), GFP_KERNEL);
1947+ bufs = kmalloc_array(pipe->buffers, sizeof(struct pipe_buffer),
1948+ GFP_KERNEL);
19441949 if (!bufs)
19451950 return -ENOMEM;
19461951
fs/gfs2/dir.c+3−3
@@ -1055,7 +1055,7 @@ static int dir_split_leaf(struct inode *inode, const struct qstr *name) · 1054 unmodified lines
10551055 /* Change the pointers.
10561056 Don't bother distinguishing stuffed from non-stuffed.
10571057 This code is complicated enough already. */
1058− lp = kmalloc(half_len * sizeof(__be64), GFP_NOFS);
1058+ lp = kmalloc_array(half_len, sizeof(__be64), GFP_NOFS);
10591059 if (!lp) {
10601060 error = -ENOMEM;
10611061 goto fail_brelse;
@@ -1169,7 +1169,7 @@ static int dir_double_exhash(struct gfs2_inode *dip) · 107 unmodified lines
11691169 if (IS_ERR(hc))
11701170 return PTR_ERR(hc);
11711171
1172− hc2 = kmalloc(hsize_bytes * 2, GFP_NOFS | __GFP_NOWARN);
1172+ hc2 = kmalloc_array(hsize_bytes, 2, GFP_NOFS | __GFP_NOWARN);
11731173 if (hc2 == NULL)
11741174 hc2 = __vmalloc(hsize_bytes * 2, GFP_NOFS, PAGE_KERNEL);
11751175
@@ -1596,7 +1596,7 @@ int gfs2_dir_read(struct inode *inode, struct dir_context *ctx, · 420 unmodified lines
15961596
15971597 error = -ENOMEM;
15981598 /* 96 is max number of dirents which can be stuffed into an inode */
1599− darr = kmalloc(96 * sizeof(struct gfs2_dirent *), GFP_NOFS);
1599+ darr = kmalloc_array(96, sizeof(struct gfs2_dirent *), GFP_NOFS);
16001600 if (darr) {
16011601 g.pdent = (const struct gfs2_dirent **)darr;
16021602 g.offset = 0;
fs/gfs2/glock.c+2−1
@@ -1303,7 +1303,8 @@ int gfs2_glock_nq_m(unsigned int num_gh, struct gfs2_holder *ghs) · 1302 unmodified lines
13031303 default:
13041304 if (num_gh <= 4)
13051305 break;
1306− pph = kmalloc(num_gh * sizeof(struct gfs2_holder *), GFP_NOFS);
1306+ pph = kmalloc_array(num_gh, sizeof(struct gfs2_holder *),
1307+ GFP_NOFS);
13071308 if (!pph)
13081309 return -ENOMEM;
13091310 }
fs/gfs2/quota.c+1−1
@@ -886,7 +886,7 @@ static int do_sync(unsigned int num_qd, struct gfs2_quota_data **qda) · 885 unmodified lines
886886 gfs2_write_calc_reserv(ip, sizeof(struct gfs2_quota),
887887 &data_blocks, &ind_blocks);
888888
889− ghs = kmalloc(num_qd * sizeof(struct gfs2_holder), GFP_NOFS);
889+ ghs = kmalloc_array(num_qd, sizeof(struct gfs2_holder), GFP_NOFS);
890890 if (!ghs)
891891 return -ENOMEM;
892892
fs/gfs2/rgrp.c+3−2
@@ -2605,8 +2605,9 @@ void gfs2_rlist_alloc(struct gfs2_rgrp_list *rlist, unsigned int state) · 2604 unmodified lines
26052605 {
26062606 unsigned int x;
26072607
2608− rlist->rl_ghs = kmalloc(rlist->rl_rgrps * sizeof(struct gfs2_holder),
2609− GFP_NOFS | __GFP_NOFAIL);
2608+ rlist->rl_ghs = kmalloc_array(rlist->rl_rgrps,
2609+ sizeof(struct gfs2_holder),
2610+ GFP_NOFS | __GFP_NOFAIL);
26102611 for (x = 0; x < rlist->rl_rgrps; x++)
26112612 gfs2_holder_init(rlist->rl_rgd[x]->rd_gl,
26122613 state, 0,
fs/gfs2/super.c+1−1
@@ -1097,7 +1097,7 @@ static int gfs2_statfs_slow(struct gfs2_sbd *sdp, struct gfs2_statfs_change_host · 1096 unmodified lines
10971097 int error = 0, err;
10981098
10991099 memset(sc, 0, sizeof(struct gfs2_statfs_change_host));
1100− gha = kmalloc(slots * sizeof(struct gfs2_holder), GFP_KERNEL);
1100+ gha = kmalloc_array(slots, sizeof(struct gfs2_holder), GFP_KERNEL);
11011101 if (!gha)
11021102 return -ENOMEM;
11031103 for (x = 0; x < slots; x++)
fs/hpfs/dnode.c+2−1
@@ -33,7 +33,8 @@ int hpfs_add_pos(struct inode *inode, loff_t *pos) · 32 unmodified lines
3333 if (hpfs_inode->i_rddir_off[i] == pos)
3434 return 0;
3535 if (!(i&0x0f)) {
36− if (!(ppos = kmalloc((i+0x11) * sizeof(loff_t*), GFP_NOFS))) {
36+ ppos = kmalloc_array(i + 0x11, sizeof(loff_t *), GFP_NOFS);
37+ if (!ppos) {
3738 pr_err("out of memory for position list\n");
3839 return -ENOMEM;
3940 }
fs/hpfs/map.c+1−1
@@ -115,7 +115,7 @@ __le32 *hpfs_load_bitmap_directory(struct super_block *s, secno bmp) · 114 unmodified lines
115115 int n = (hpfs_sb(s)->sb_fs_size + 0x200000 - 1) >> 21;
116116 int i;
117117 __le32 *b;
118− if (!(b = kmalloc(n * 512, GFP_KERNEL))) {
118+ if (!(b = kmalloc_array(n, 512, GFP_KERNEL))) {
119119 pr_err("can't allocate memory for bitmap directory\n");
120120 return NULL;
121121 }
fs/jbd2/revoke.c+1−1
@@ -223,7 +223,7 @@ static struct jbd2_revoke_table_s *jbd2_journal_init_revoke_table(int hash_size) · 222 unmodified lines
223223 table->hash_size = hash_size;
224224 table->hash_shift = shift;
225225 table->hash_table =
226− kmalloc(hash_size * sizeof(struct list_head), GFP_KERNEL);
226+ kmalloc_array(hash_size, sizeof(struct list_head), GFP_KERNEL);
227227 if (!table->hash_table) {
228228 kmem_cache_free(jbd2_revoke_table_cache, table);
229229 table = NULL;
fs/jffs2/acl.c+2−1
@@ -133,7 +133,8 @@ static void *jffs2_acl_to_medium(const struct posix_acl *acl, size_t *size) · 132 unmodified lines
133133 size_t i;
134134
135135 *size = jffs2_acl_size(acl->a_count);
136− header = kmalloc(sizeof(*header) + acl->a_count * sizeof(*entry), GFP_KERNEL);
136+ header = kmalloc(struct_size(header, a_entries, acl->a_count),
137+ GFP_KERNEL);
137138 if (!header)
138139 return ERR_PTR(-ENOMEM);
139140 header->a_version = cpu_to_je32(JFFS2_ACL_VERSION);
fs/jffs2/acl.h+1−0
@@ -22,6 +22,7 @@ struct jffs2_acl_entry_short { · 21 unmodified lines
2222
2323 struct jffs2_acl_header {
2424 jint32_t a_version;
25+ struct jffs2_acl_entry a_entries[];
2526 };
2627
2728 #ifdef CONFIG_JFFS2_FS_POSIX_ACL
fs/jffs2/wbuf.c+1−1
@@ -1208,7 +1208,7 @@ int jffs2_nand_flash_setup(struct jffs2_sb_info *c) · 1207 unmodified lines
12081208 if (!c->wbuf)
12091209 return -ENOMEM;
12101210
1211− c->oobbuf = kmalloc(NR_OOB_SCAN_PAGES * c->oobavail, GFP_KERNEL);
1211+ c->oobbuf = kmalloc_array(NR_OOB_SCAN_PAGES, c->oobavail, GFP_KERNEL);
12121212 if (!c->oobbuf) {
12131213 kfree(c->wbuf);
12141214 return -ENOMEM;
fs/jfs/jfs_dmap.c+1−1
@@ -1641,7 +1641,7 @@ s64 dbDiscardAG(struct inode *ip, int agno, s64 minlen) · 1640 unmodified lines
16411641 max_ranges = nblocks;
16421642 do_div(max_ranges, minlen);
16431643 range_cnt = min_t(u64, max_ranges + 1, 32 * 1024);
1644− totrim = kmalloc(sizeof(struct range2trim) * range_cnt, GFP_NOFS);
1644+ totrim = kmalloc_array(range_cnt, sizeof(struct range2trim), GFP_NOFS);
16451645 if (totrim == NULL) {
16461646 jfs_error(bmp->db_ipbmap->i_sb, "no memory for trim array\n");
16471647 IWRITE_UNLOCK(ipbmap);
fs/jfs/jfs_dtree.c+5−4
@@ -594,7 +594,8 @@ int dtSearch(struct inode *ip, struct component_name * key, ino_t * data, · 593 unmodified lines
594594 struct component_name ciKey;
595595 struct super_block *sb = ip->i_sb;
596596
597− ciKey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t), GFP_NOFS);
597+ ciKey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
598+ GFP_NOFS);
598599 if (!ciKey.name) {
599600 rc = -ENOMEM;
600601 goto dtSearch_Exit2;
@@ -957,7 +958,7 @@ static int dtSplitUp(tid_t tid, · 356 unmodified lines
957958 smp = split->mp;
958959 sp = DT_PAGE(ip, smp);
959960
960− key.name = kmalloc((JFS_NAME_MAX + 2) * sizeof(wchar_t), GFP_NOFS);
961+ key.name = kmalloc_array(JFS_NAME_MAX + 2, sizeof(wchar_t), GFP_NOFS);
961962 if (!key.name) {
962963 DT_PUTPAGE(smp);
963964 rc = -ENOMEM;
@@ -3779,12 +3780,12 @@ static int ciGetLeafPrefixKey(dtpage_t * lp, int li, dtpage_t * rp, · 2815 unmodified lines
37793780 struct component_name lkey;
37803781 struct component_name rkey;
37813782
3782− lkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
3783+ lkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
37833784 GFP_KERNEL);
37843785 if (lkey.name == NULL)
37853786 return -ENOMEM;
37863787
3787− rkey.name = kmalloc((JFS_NAME_MAX + 1) * sizeof(wchar_t),
3788+ rkey.name = kmalloc_array(JFS_NAME_MAX + 1, sizeof(wchar_t),
37883789 GFP_KERNEL);
37893790 if (rkey.name == NULL) {
37903791 kfree(lkey.name);
fs/jfs/jfs_unicode.c+1−1
@@ -121,7 +121,7 @@ int get_UCSname(struct component_name * uniName, struct dentry *dentry) · 120 unmodified lines
121121 return -ENAMETOOLONG;
122122
123123 uniName->name =
124− kmalloc((length + 1) * sizeof(wchar_t), GFP_NOFS);
124+ kmalloc_array(length + 1, sizeof(wchar_t), GFP_NOFS);
125125
126126 if (uniName->name == NULL)
127127 return -ENOMEM;
fs/mbcache.c+3−2
@@ -353,8 +353,9 @@ struct mb_cache *mb_cache_create(int bucket_bits) · 352 unmodified lines
353353 cache->c_max_entries = bucket_count << 4;
354354 INIT_LIST_HEAD(&cache->c_list);
355355 spin_lock_init(&cache->c_list_lock);
356− cache->c_hash = kmalloc(bucket_count * sizeof(struct hlist_bl_head),
357− GFP_KERNEL);
356+ cache->c_hash = kmalloc_array(bucket_count,
357+ sizeof(struct hlist_bl_head),
358+ GFP_KERNEL);
358359 if (!cache->c_hash) {
359360 kfree(cache);
360361 goto err_out;
fs/namei.c+2−2
@@ -537,12 +537,12 @@ static int __nd_alloc_stack(struct nameidata *nd) · 536 unmodified lines
537537 struct saved *p;
538538
539539 if (nd->flags & LOOKUP_RCU) {
540− p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
540+ p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved),
541541 GFP_ATOMIC);
542542 if (unlikely(!p))
543543 return -ECHILD;
544544 } else {
545− p= kmalloc(MAXSYMLINKS * sizeof(struct saved),
545+ p= kmalloc_array(MAXSYMLINKS, sizeof(struct saved),
546546 GFP_KERNEL);
547547 if (unlikely(!p))
548548 return -ENOMEM;
fs/nfs/flexfilelayout/flexfilelayout.c+1−1
@@ -461,7 +461,7 @@ ff_layout_alloc_lseg(struct pnfs_layout_hdr *lh, · 460 unmodified lines
461461 fh_count = be32_to_cpup(p);
462462
463463 fls->mirror_array[i]->fh_versions =
464− kzalloc(fh_count * sizeof(struct nfs_fh),
464+ kcalloc(fh_count, sizeof(struct nfs_fh),
465465 gfp_flags);
466466 if (fls->mirror_array[i]->fh_versions == NULL) {
467467 rc = -ENOMEM;
fs/nfs/flexfilelayout/flexfilelayoutdev.c+2−1
@@ -99,7 +99,8 @@ nfs4_ff_alloc_deviceid_node(struct nfs_server *server, struct pnfs_device *pdev, · 98 unmodified lines
9999 version_count = be32_to_cpup(p);
100100 dprintk("%s: version count %d\n", __func__, version_count);
101101
102− ds_versions = kzalloc(version_count * sizeof(struct nfs4_ff_ds_version),
102+ ds_versions = kcalloc(version_count,
103+ sizeof(struct nfs4_ff_ds_version),
103104 gfp_flags);
104105 if (!ds_versions)
105106 goto out_scratch;
fs/nfsd/export.c+3−2
@@ -404,8 +404,9 @@ fsloc_parse(char **mesg, char *buf, struct nfsd4_fs_locations *fsloc) · 403 unmodified lines
404404 if (fsloc->locations_count == 0)
405405 return 0;
406406
407− fsloc->locations = kzalloc(fsloc->locations_count
408− * sizeof(struct nfsd4_fs_location), GFP_KERNEL);
407+ fsloc->locations = kcalloc(fsloc->locations_count,
408+ sizeof(struct nfsd4_fs_location),
409+ GFP_KERNEL);
409410 if (!fsloc->locations)
410411 return -ENOMEM;
411412 for (i=0; i < fsloc->locations_count; i++) {
fs/nfsd/nfs4recover.c+3−2
@@ -510,8 +510,9 @@ nfs4_legacy_state_init(struct net *net) · 509 unmodified lines
510510 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
511511 int i;
512512
513− nn->reclaim_str_hashtbl = kmalloc(sizeof(struct list_head) *
514− CLIENT_HASH_SIZE, GFP_KERNEL);
513+ nn->reclaim_str_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
514+ sizeof(struct list_head),
515+ GFP_KERNEL);
515516 if (!nn->reclaim_str_hashtbl)
516517 return -ENOMEM;
517518
fs/nfsd/nfs4state.c+12−8
@@ -1807,8 +1807,9 @@ static struct nfs4_client *alloc_client(struct xdr_netobj name) · 1806 unmodified lines
18071807 clp->cl_name.data = kmemdup(name.data, name.len, GFP_KERNEL);
18081808 if (clp->cl_name.data == NULL)
18091809 goto err_no_name;
1810− clp->cl_ownerstr_hashtbl = kmalloc(sizeof(struct list_head) *
1811− OWNER_HASH_SIZE, GFP_KERNEL);
1810+ clp->cl_ownerstr_hashtbl = kmalloc_array(OWNER_HASH_SIZE,
1811+ sizeof(struct list_head),
1812+ GFP_KERNEL);
18121813 if (!clp->cl_ownerstr_hashtbl)
18131814 goto err_no_hashtbl;
18141815 for (i = 0; i < OWNER_HASH_SIZE; i++)
@@ -7096,16 +7097,19 @@ static int nfs4_state_create_net(struct net *net) · 5281 unmodified lines
70967097 struct nfsd_net *nn = net_generic(net, nfsd_net_id);
70977098 int i;
70987099
7099− nn->conf_id_hashtbl = kmalloc(sizeof(struct list_head) *
7100− CLIENT_HASH_SIZE, GFP_KERNEL);
7100+ nn->conf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
7101+ sizeof(struct list_head),
7102+ GFP_KERNEL);
71017103 if (!nn->conf_id_hashtbl)
71027104 goto err;
7103− nn->unconf_id_hashtbl = kmalloc(sizeof(struct list_head) *
7104− CLIENT_HASH_SIZE, GFP_KERNEL);
7105+ nn->unconf_id_hashtbl = kmalloc_array(CLIENT_HASH_SIZE,
7106+ sizeof(struct list_head),
7107+ GFP_KERNEL);
71057108 if (!nn->unconf_id_hashtbl)
71067109 goto err_unconf_id;
7107− nn->sessionid_hashtbl = kmalloc(sizeof(struct list_head) *
7108− SESSION_HASH_SIZE, GFP_KERNEL);
7110+ nn->sessionid_hashtbl = kmalloc_array(SESSION_HASH_SIZE,
7111+ sizeof(struct list_head),
7112+ GFP_KERNEL);
71097113 if (!nn->sessionid_hashtbl)
71107114 goto err_sessionid;
71117115
fs/nfsd/nfscache.c+2−1
@@ -177,7 +177,8 @@ int nfsd_reply_cache_init(void) · 176 unmodified lines
177177
178178 drc_hashtbl = kcalloc(hashsize, sizeof(*drc_hashtbl), GFP_KERNEL);
179179 if (!drc_hashtbl) {
180− drc_hashtbl = vzalloc(hashsize * sizeof(*drc_hashtbl));
180+ drc_hashtbl = vzalloc(array_size(hashsize,
181+ sizeof(*drc_hashtbl)));
181182 if (!drc_hashtbl)
182183 goto out_nomem;
183184 }
fs/ntfs/compress.c+1−1
@@ -527,7 +527,7 @@ int ntfs_read_compressed_block(struct page *page) · 526 unmodified lines
527527 BUG_ON(ni->type != AT_DATA);
528528 BUG_ON(ni->name_len);
529529
530− pages = kmalloc(nr_pages * sizeof(struct page *), GFP_NOFS);
530+ pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_NOFS);
531531
532532 /* Allocate memory to store the buffer heads we need. */
533533 bhs_size = cb_size / block_size * sizeof(struct buffer_head *);
fs/ocfs2/cluster/tcp.c+1−1
@@ -1078,7 +1078,7 @@ int o2net_send_message_vec(u32 msg_type, u32 key, struct kvec *caller_vec, · 1077 unmodified lines
10781078 o2net_set_nst_sock_container(&nst, sc);
10791079
10801080 veclen = caller_veclen + 1;
1081− vec = kmalloc(sizeof(struct kvec) * veclen, GFP_ATOMIC);
1081+ vec = kmalloc_array(veclen, sizeof(struct kvec), GFP_ATOMIC);
10821082 if (vec == NULL) {
10831083 mlog(0, "failed to %zu element kvec!\n", veclen);
10841084 ret = -ENOMEM;
fs/ocfs2/dlm/dlmdomain.c+1−1
@@ -86,7 +86,7 @@ static void dlm_free_pagevec(void **vec, int pages) · 85 unmodified lines
8686
8787 static void **dlm_alloc_pagevec(int pages)
8888 {
89− void **vec = kmalloc(pages * sizeof(void *), GFP_KERNEL);
89+ void **vec = kmalloc_array(pages, sizeof(void *), GFP_KERNEL);
9090 int i;
9191
9292 if (!vec)
fs/ocfs2/journal.c+1−1
@@ -1383,7 +1383,7 @@ static int __ocfs2_recovery_thread(void *arg) · 1382 unmodified lines
13831383 goto bail;
13841384 }
13851385
1386− rm_quota = kzalloc(osb->max_slots * sizeof(int), GFP_NOFS);
1386+ rm_quota = kcalloc(osb->max_slots, sizeof(int), GFP_NOFS);
13871387 if (!rm_quota) {
13881388 status = -ENOMEM;
13891389 goto bail;
fs/ocfs2/sysfile.c+5−4
@@ -69,10 +69,11 @@ static struct inode **get_local_system_inode(struct ocfs2_super *osb, · 68 unmodified lines
6969 spin_unlock(&osb->osb_lock);
7070
7171 if (unlikely(!local_system_inodes)) {
72− local_system_inodes = kzalloc(sizeof(struct inode *) *
73− NUM_LOCAL_SYSTEM_INODES *
74− osb->max_slots,
75− GFP_NOFS);
72+ local_system_inodes =
73+ kzalloc(array3_size(sizeof(struct inode *),
74+ NUM_LOCAL_SYSTEM_INODES,
75+ osb->max_slots),
76+ GFP_NOFS);
7677 if (!local_system_inodes) {
7778 mlog_errno(-ENOMEM);
7879 /*
fs/overlayfs/namei.c+1−1
@@ -612,7 +612,7 @@ static int ovl_get_index_name_fh(struct ovl_fh *fh, struct qstr *name) · 611 unmodified lines
612612 {
613613 char *n, *s;
614614
615− n = kzalloc(fh->len * 2, GFP_KERNEL);
615+ n = kcalloc(fh->len, 2, GFP_KERNEL);
616616 if (!n)
617617 return -ENOMEM;
618618
fs/proc/base.c+2−1
@@ -389,7 +389,8 @@ static int proc_pid_stack(struct seq_file *m, struct pid_namespace *ns, · 388 unmodified lines
389389 unsigned long *entries;
390390 int err;
391391
392− entries = kmalloc(MAX_STACK_TRACE_DEPTH * sizeof(*entries), GFP_KERNEL);
392+ entries = kmalloc_array(MAX_STACK_TRACE_DEPTH, sizeof(*entries),
393+ GFP_KERNEL);
393394 if (!entries)
394395 return -ENOMEM;
395396
fs/proc/proc_sysctl.c+1−1
@@ -1426,7 +1426,7 @@ static int register_leaf_sysctl_tables(const char *path, char *pos, · 1425 unmodified lines
14261426 /* If there are mixed files and directories we need a new table */
14271427 if (nr_dirs && nr_files) {
14281428 struct ctl_table *new;
1429− files = kzalloc(sizeof(struct ctl_table) * (nr_files + 1),
1429+ files = kcalloc(nr_files + 1, sizeof(struct ctl_table),
14301430 GFP_KERNEL);
14311431 if (!files)
14321432 goto out;
fs/proc/task_mmu.c+1−1
@@ -1473,7 +1473,7 @@ static ssize_t pagemap_read(struct file *file, char __user *buf, · 1472 unmodified lines
14731473 pm.show_pfn = file_ns_capable(file, &init_user_ns, CAP_SYS_ADMIN);
14741474
14751475 pm.len = (PAGEMAP_WALK_SIZE >> PAGE_SHIFT);
1476− pm.buffer = kmalloc(pm.len * PM_ENTRY_BYTES, GFP_KERNEL);
1476+ pm.buffer = kmalloc_array(pm.len, PM_ENTRY_BYTES, GFP_KERNEL);
14771477 ret = -ENOMEM;
14781478 if (!pm.buffer)
14791479 goto out_mm;
fs/read_write.c+2−2
@@ -778,7 +778,7 @@ ssize_t rw_copy_check_uvector(int type, const struct iovec __user * uvector, · 777 unmodified lines
778778 goto out;
779779 }
780780 if (nr_segs > fast_segs) {
781− iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
781+ iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);
782782 if (iov == NULL) {
783783 ret = -ENOMEM;
784784 goto out;
@@ -849,7 +849,7 @@ ssize_t compat_rw_copy_check_uvector(int type, · 64 unmodified lines
849849 goto out;
850850 if (nr_segs > fast_segs) {
851851 ret = -ENOMEM;
852− iov = kmalloc(nr_segs*sizeof(struct iovec), GFP_KERNEL);
852+ iov = kmalloc_array(nr_segs, sizeof(struct iovec), GFP_KERNEL);
853853 if (iov == NULL)
854854 goto out;
855855 }
fs/reiserfs/bitmap.c+1−1
@@ -1456,7 +1456,7 @@ int reiserfs_init_bitmap_cache(struct super_block *sb) · 1455 unmodified lines
14561456 struct reiserfs_bitmap_info *bitmap;
14571457 unsigned int bmap_nr = reiserfs_bmap_count(sb);
14581458
1459− bitmap = vmalloc(sizeof(*bitmap) * bmap_nr);
1459+ bitmap = vmalloc(array_size(bmap_nr, sizeof(*bitmap)));
14601460 if (bitmap == NULL)
14611461 return -ENOMEM;
14621462
fs/reiserfs/inode.c+2−1
@@ -1044,7 +1044,8 @@ research: · 1043 unmodified lines
10441044 if (blocks_needed == 1) {
10451045 un = &unf_single;
10461046 } else {
1047− un = kzalloc(min(blocks_needed, max_to_insert) * UNFM_P_SIZE, GFP_NOFS);
1047+ un = kcalloc(min(blocks_needed, max_to_insert),
1048+ UNFM_P_SIZE, GFP_NOFS);
10481049 if (!un) {
10491050 un = &unf_single;
10501051 blocks_needed = 1;
fs/reiserfs/journal.c+8−5
@@ -350,7 +350,8 @@ static struct reiserfs_journal_cnode *allocate_cnodes(int num_cnodes) · 349 unmodified lines
350350 if (num_cnodes <= 0) {
351351 return NULL;
352352 }
353− head = vzalloc(num_cnodes * sizeof(struct reiserfs_journal_cnode));
353+ head = vzalloc(array_size(num_cnodes,
354+ sizeof(struct reiserfs_journal_cnode)));
354355 if (!head) {
355356 return NULL;
356357 }
@@ -2192,10 +2193,12 @@ static int journal_read_transaction(struct super_block *sb, · 1835 unmodified lines
21922193 * now we know we've got a good transaction, and it was
21932194 * inside the valid time ranges
21942195 */
2195− log_blocks = kmalloc(get_desc_trans_len(desc) *
2196− sizeof(struct buffer_head *), GFP_NOFS);
2197− real_blocks = kmalloc(get_desc_trans_len(desc) *
2198− sizeof(struct buffer_head *), GFP_NOFS);
2196+ log_blocks = kmalloc_array(get_desc_trans_len(desc),
2197+ sizeof(struct buffer_head *),
2198+ GFP_NOFS);
2199+ real_blocks = kmalloc_array(get_desc_trans_len(desc),
2200+ sizeof(struct buffer_head *),
2201+ GFP_NOFS);
21992202 if (!log_blocks || !real_blocks) {
22002203 brelse(c_bh);
22012204 brelse(d_bh);
fs/reiserfs/resize.c+2−1
@@ -120,7 +120,8 @@ int reiserfs_resize(struct super_block *s, unsigned long block_count_new) · 119 unmodified lines
120120 * array of bitmap block pointers
121121 */
122122 bitmap =
123− vzalloc(sizeof(struct reiserfs_bitmap_info) * bmap_nr_new);
123+ vzalloc(array_size(bmap_nr_new,
124+ sizeof(struct reiserfs_bitmap_info)));
124125 if (!bitmap) {
125126 /*
126127 * Journal bitmaps are still supersized, but the
fs/select.c+1−1
@@ -1236,7 +1236,7 @@ static int compat_core_sys_select(int n, compat_ulong_t __user *inp, · 1235 unmodified lines
12361236 size = FDS_BYTES(n);
12371237 bits = stack_fds;
12381238 if (size > sizeof(stack_fds) / 6) {
1239− bits = kmalloc(6 * size, GFP_KERNEL);
1239+ bits = kmalloc_array(6, size, GFP_KERNEL);
12401240 ret = -ENOMEM;
12411241 if (!bits)
12421242 goto out_nofds;
fs/splice.c+4−3
@@ -259,8 +259,9 @@ int splice_grow_spd(const struct pipe_inode_info *pipe, struct splice_pipe_desc · 258 unmodified lines
259259 if (buffers <= PIPE_DEF_BUFFERS)
260260 return 0;
261261
262− spd->pages = kmalloc(buffers * sizeof(struct page *), GFP_KERNEL);
263− spd->partial = kmalloc(buffers * sizeof(struct partial_page), GFP_KERNEL);
262+ spd->pages = kmalloc_array(buffers, sizeof(struct page *), GFP_KERNEL);
263+ spd->partial = kmalloc_array(buffers, sizeof(struct partial_page),
264+ GFP_KERNEL);
264265
265266 if (spd->pages && spd->partial)
266267 return 0;
@@ -395,7 +396,7 @@ static ssize_t default_file_splice_read(struct file *in, loff_t *ppos, · 128 unmodified lines
395396
396397 vec = __vec;
397398 if (nr_pages > PIPE_DEF_BUFFERS) {
398− vec = kmalloc(nr_pages * sizeof(struct kvec), GFP_KERNEL);
399+ vec = kmalloc_array(nr_pages, sizeof(struct kvec), GFP_KERNEL);
399400 if (unlikely(!vec)) {
400401 res = -ENOMEM;
401402 goto out;
fs/ubifs/journal.c+3−2
@@ -1282,10 +1282,11 @@ static int truncate_data_node(const struct ubifs_info *c, const struct inode *in · 1281 unmodified lines
12821282 int *new_len)
12831283 {
12841284 void *buf;
1285− int err, dlen, compr_type, out_len, old_dlen;
1285+ int err, compr_type;
1286+ u32 dlen, out_len, old_dlen;
12861287
12871288 out_len = le32_to_cpu(dn->size);
1288− buf = kmalloc(out_len * WORST_COMPR_FACTOR, GFP_NOFS);
1289+ buf = kmalloc_array(out_len, WORST_COMPR_FACTOR, GFP_NOFS);
12891290 if (!buf)
12901291 return -ENOMEM;
12911292
fs/ubifs/lpt.c+15−10
@@ -628,11 +628,12 @@ int ubifs_create_dflt_lpt(struct ubifs_info *c, int *main_lebs, int lpt_first, · 627 unmodified lines
628628 /* Needed by 'ubifs_pack_lsave()' */
629629 c->main_first = c->leb_cnt - *main_lebs;
630630
631− lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_KERNEL);
631+ lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_KERNEL);
632632 pnode = kzalloc(sizeof(struct ubifs_pnode), GFP_KERNEL);
633633 nnode = kzalloc(sizeof(struct ubifs_nnode), GFP_KERNEL);
634634 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));
636637 if (!pnode || !nnode || !buf || !ltab || !lsave) {
637638 err = -ENOMEM;
638639 goto out;
@@ -1626,7 +1627,8 @@ static int lpt_init_rd(struct ubifs_info *c) · 987 unmodified lines
16261627 {
16271628 int err, i;
16281629
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));
16301632 if (!c->ltab)
16311633 return -ENOMEM;
16321634
@@ -1636,15 +1638,17 @@ static int lpt_init_rd(struct ubifs_info *c) · 3 unmodified lines
16361638 return -ENOMEM;
16371639
16381640 for (i = 0; i < LPROPS_HEAP_CNT; i++) {
1639− c->lpt_heap[i].arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ,
1640− GFP_KERNEL);
1641+ c->lpt_heap[i].arr = kmalloc_array(LPT_HEAP_SZ,
1642+ sizeof(void *),
1643+ GFP_KERNEL);
16411644 if (!c->lpt_heap[i].arr)
16421645 return -ENOMEM;
16431646 c->lpt_heap[i].cnt = 0;
16441647 c->lpt_heap[i].max_cnt = LPT_HEAP_SZ;
16451648 }
16461649
1647− c->dirty_idx.arr = kmalloc(sizeof(void *) * LPT_HEAP_SZ, GFP_KERNEL);
1650+ c->dirty_idx.arr = kmalloc_array(LPT_HEAP_SZ, sizeof(void *),
1651+ GFP_KERNEL);
16481652 if (!c->dirty_idx.arr)
16491653 return -ENOMEM;
16501654 c->dirty_idx.cnt = 0;
@@ -1688,7 +1692,8 @@ static int lpt_init_wr(struct ubifs_info *c) · 37 unmodified lines
16881692 {
16891693 int err, i;
16901694
1691− c->ltab_cmt = vmalloc(sizeof(struct ubifs_lpt_lprops) * c->lpt_lebs);
1695+ c->ltab_cmt = vmalloc(array_size(sizeof(struct ubifs_lpt_lprops),
1696+ c->lpt_lebs));
16921697 if (!c->ltab_cmt)
16931698 return -ENOMEM;
16941699
@@ -1697,7 +1702,7 @@ static int lpt_init_wr(struct ubifs_info *c) · 2 unmodified lines
16971702 return -ENOMEM;
16981703
16991704 if (c->big_lpt) {
1700− c->lsave = kmalloc(sizeof(int) * c->lsave_cnt, GFP_NOFS);
1705+ c->lsave = kmalloc_array(c->lsave_cnt, sizeof(int), GFP_NOFS);
17011706 if (!c->lsave)
17021707 return -ENOMEM;
17031708 err = read_lsave(c);
@@ -1939,8 +1944,8 @@ int ubifs_lpt_scan_nolock(struct ubifs_info *c, int start_lnum, int end_lnum, · 235 unmodified lines
19391944 return err;
19401945 }
19411946
1942− path = kmalloc(sizeof(struct lpt_scan_node) * (c->lpt_hght + 1),
1943− GFP_NOFS);
1947+ path = kmalloc_array(c->lpt_hght + 1, sizeof(struct lpt_scan_node),
1948+ GFP_NOFS);
19441949 if (!path)
19451950 return -ENOMEM;
19461951
fs/ubifs/super.c+2−1
@@ -1196,7 +1196,8 @@ static int mount_ubifs(struct ubifs_info *c) · 1195 unmodified lines
11961196 * never exceed 64.
11971197 */
11981198 err = -ENOMEM;
1199− c->bottom_up_buf = kmalloc(BOTTOM_UP_HEIGHT * sizeof(int), GFP_KERNEL);
1199+ c->bottom_up_buf = kmalloc_array(BOTTOM_UP_HEIGHT, sizeof(int),
1200+ GFP_KERNEL);
12001201 if (!c->bottom_up_buf)
12011202 goto out_free;
12021203
fs/ubifs/tnc.c+3−2
@@ -1104,8 +1104,9 @@ static struct ubifs_znode *dirty_cow_bottom_up(struct ubifs_info *c, · 1103 unmodified lines
11041104 ubifs_assert(znode);
11051105 if (c->zroot.znode->level > BOTTOM_UP_HEIGHT) {
11061106 kfree(c->bottom_up_buf);
1107− c->bottom_up_buf = kmalloc(c->zroot.znode->level * sizeof(int),
1108− GFP_NOFS);
1107+ c->bottom_up_buf = kmalloc_array(c->zroot.znode->level,
1108+ sizeof(int),
1109+ GFP_NOFS);
11091110 if (!c->bottom_up_buf)
11101111 return ERR_PTR(-ENOMEM);
11111112 path = c->bottom_up_buf;
fs/ubifs/tnc_commit.c+3−2
@@ -366,7 +366,8 @@ static int layout_in_gaps(struct ubifs_info *c, int cnt) · 365 unmodified lines
366366
367367 dbg_gc("%d znodes to write", cnt);
368368
369− c->gap_lebs = kmalloc(sizeof(int) * (c->lst.idx_lebs + 1), GFP_NOFS);
369+ c->gap_lebs = kmalloc_array(c->lst.idx_lebs + 1, sizeof(int),
370+ GFP_NOFS);
370371 if (!c->gap_lebs)
371372 return -ENOMEM;
372373
@@ -674,7 +675,7 @@ static int alloc_idx_lebs(struct ubifs_info *c, int cnt) · 301 unmodified lines
674675 dbg_cmt("need about %d empty LEBS for TNC commit", leb_cnt);
675676 if (!leb_cnt)
676677 return 0;
677− c->ilebs = kmalloc(leb_cnt * sizeof(int), GFP_NOFS);
678+ c->ilebs = kmalloc_array(leb_cnt, sizeof(int), GFP_NOFS);
678679 if (!c->ilebs)
679680 return -ENOMEM;
680681 for (i = 0; i < leb_cnt; i++) {
fs/udf/super.c+4−3
@@ -1585,7 +1585,7 @@ static struct udf_vds_record *handle_partition_descriptor( · 1584 unmodified lines
15851585 struct udf_vds_record *new_loc;
15861586 unsigned int new_size = ALIGN(partnum, PART_DESC_ALLOC_STEP);
15871587
1588− new_loc = kzalloc(sizeof(*new_loc) * new_size, GFP_KERNEL);
1588+ new_loc = kcalloc(new_size, sizeof(*new_loc), GFP_KERNEL);
15891589 if (!new_loc)
15901590 return ERR_PTR(-ENOMEM);
15911591 memcpy(new_loc, data->part_descs_loc,
@@ -1644,8 +1644,9 @@ static noinline int udf_process_sequence( · 52 unmodified lines
16441644
16451645 memset(data.vds, 0, sizeof(struct udf_vds_record) * VDS_POS_LENGTH);
16461646 data.size_part_descs = PART_DESC_ALLOC_STEP;
1647− data.part_descs_loc = kzalloc(sizeof(*data.part_descs_loc) *
1648− data.size_part_descs, GFP_KERNEL);
1647+ data.part_descs_loc = kcalloc(data.size_part_descs,
1648+ sizeof(*data.part_descs_loc),
1649+ GFP_KERNEL);
16491650 if (!data.part_descs_loc)
16501651 return -ENOMEM;
16511652
fs/ufs/super.c+3−1
@@ -541,7 +541,9 @@ static int ufs_read_cylinder_structures(struct super_block *sb) · 540 unmodified lines
541541 * Read cylinder group (we read only first fragment from block
542542 * at this time) and prepare internal data structures for cg caching.
543543 */
544− if (!(sbi->s_ucg = kmalloc (sizeof(struct buffer_head *) * uspi->s_ncg, GFP_NOFS)))
544+ sbi->s_ucg = kmalloc_array(uspi->s_ncg, sizeof(struct buffer_head *),
545+ GFP_NOFS);
546+ if (!sbi->s_ucg)
545547 goto failed;
546548 for (i = 0; i < uspi->s_ncg; i++)
547549 sbi->s_ucg[i] = NULL;
include/linux/mm.h+5−0
@@ -575,6 +575,11 @@ static inline void *kvmalloc_array(size_t n, size_t size, gfp_t flags) · 574 unmodified lines
575575 return kvmalloc(bytes, flags);
576576 }
577577
578+static inline void *kvcalloc(size_t n, size_t size, gfp_t flags)
579+{
580+ return kvmalloc_array(n, size, flags | __GFP_ZERO);
581+}
582+
578583 extern void kvfree(const void *addr);
579584
580585 static inline atomic_t *compound_mapcount_ptr(struct page *page)
include/rdma/ib_verbs.h+1−4
@@ -2093,10 +2093,7 @@ struct ib_flow_attr { · 2092 unmodified lines
20932093 u32 flags;
20942094 u8 num_of_specs;
20952095 u8 port;
2096− /* Following are the optional layers according to user request
2097− * struct ib_flow_spec_xxx
2098− * struct ib_flow_spec_yyy
2099− */
2096+ union ib_flow_spec flows[];
21002097 };
21012098
21022099 struct ib_flow {
ipc/sem.c+1−1
@@ -1945,7 +1945,7 @@ static long do_semtimedop(int semid, struct sembuf __user *tsops, · 1944 unmodified lines
19451945 if (nsops > ns->sc_semopm)
19461946 return -E2BIG;
19471947 if (nsops > SEMOPM_FAST) {
1948− sops = kvmalloc(sizeof(*sops)*nsops, GFP_KERNEL);
1948+ sops = kvmalloc_array(nsops, sizeof(*sops), GFP_KERNEL);
19491949 if (sops == NULL)
19501950 return -ENOMEM;
19511951 }
kernel/bpf/btf.c+4−4
@@ -608,7 +608,7 @@ static int btf_add_type(struct btf_verifier_env *env, struct btf_type *t) · 607 unmodified lines
608608 new_size = min_t(u32, BTF_MAX_TYPE,
609609 btf->types_size + expand_by);
610610
611− new_types = kvzalloc(new_size * sizeof(*new_types),
611+ new_types = kvcalloc(new_size, sizeof(*new_types),
612612 GFP_KERNEL | __GFP_NOWARN);
613613 if (!new_types)
614614 return -ENOMEM;
@@ -698,17 +698,17 @@ static int env_resolve_init(struct btf_verifier_env *env) · 83 unmodified lines
698698 u8 *visit_states = NULL;
699699
700700 /* +1 for btf_void */
701− resolved_sizes = kvzalloc((nr_types + 1) * sizeof(*resolved_sizes),
701+ resolved_sizes = kvcalloc(nr_types + 1, sizeof(*resolved_sizes),
702702 GFP_KERNEL | __GFP_NOWARN);
703703 if (!resolved_sizes)
704704 goto nomem;
705705
706− resolved_ids = kvzalloc((nr_types + 1) * sizeof(*resolved_ids),
706+ resolved_ids = kvcalloc(nr_types + 1, sizeof(*resolved_ids),
707707 GFP_KERNEL | __GFP_NOWARN);
708708 if (!resolved_ids)
709709 goto nomem;
710710
711− visit_states = kvzalloc((nr_types + 1) * sizeof(*visit_states),
711+ visit_states = kvcalloc(nr_types + 1, sizeof(*visit_states),
712712 GFP_KERNEL | __GFP_NOWARN);
713713 if (!visit_states)
714714 goto nomem;
kernel/bpf/lpm_trie.c+3−2
@@ -623,8 +623,9 @@ static int trie_get_next_key(struct bpf_map *map, void *_key, void *_next_key) · 622 unmodified lines
623623 if (!key || key->prefixlen > trie->max_prefixlen)
624624 goto find_leftmost;
625625
626− node_stack = kmalloc(trie->max_prefixlen * sizeof(struct lpm_trie_node *),
627− GFP_ATOMIC | __GFP_NOWARN);
626+ node_stack = kmalloc_array(trie->max_prefixlen,
627+ sizeof(struct lpm_trie_node *),
628+ GFP_ATOMIC | __GFP_NOWARN);
628629 if (!node_stack)
629630 return -ENOMEM;
630631
kernel/bpf/verifier.c+6−4
@@ -5206,7 +5206,8 @@ static int adjust_insn_aux_data(struct bpf_verifier_env *env, u32 prog_len, · 5205 unmodified lines
52065206
52075207 if (cnt == 1)
52085208 return 0;
5209− new_data = vzalloc(sizeof(struct bpf_insn_aux_data) * prog_len);
5209+ new_data = vzalloc(array_size(prog_len,
5210+ sizeof(struct bpf_insn_aux_data)));
52105211 if (!new_data)
52115212 return -ENOMEM;
52125213 memcpy(new_data, old_data, sizeof(struct bpf_insn_aux_data) * off);
@@ -5447,7 +5448,7 @@ static int jit_subprogs(struct bpf_verifier_env *env) · 234 unmodified lines
54475448 insn->imm = 1;
54485449 }
54495450
5450− func = kzalloc(sizeof(prog) * env->subprog_cnt, GFP_KERNEL);
5451+ func = kcalloc(env->subprog_cnt, sizeof(prog), GFP_KERNEL);
54515452 if (!func)
54525453 return -ENOMEM;
54535454
@@ -5870,8 +5871,9 @@ int bpf_check(struct bpf_prog **prog, union bpf_attr *attr) · 416 unmodified lines
58705871 return -ENOMEM;
58715872 log = &env->log;
58725873
5873− env->insn_aux_data = vzalloc(sizeof(struct bpf_insn_aux_data) *
5874− (*prog)->len);
5874+ env->insn_aux_data =
5875+ vzalloc(array_size(sizeof(struct bpf_insn_aux_data),
5876+ (*prog)->len));
58755877 ret = -ENOMEM;
58765878 if (!env->insn_aux_data)
58775879 goto err_free_env;
kernel/cgroup/cgroup-v1.c+2−2
@@ -195,9 +195,9 @@ struct cgroup_pidlist { · 194 unmodified lines
195195 static void *pidlist_allocate(int count)
196196 {
197197 if (PIDLIST_TOO_LARGE(count))
198− return vmalloc(count * sizeof(pid_t));
198+ return vmalloc(array_size(count, sizeof(pid_t)));
199199 else
200− return kmalloc(count * sizeof(pid_t), GFP_KERNEL);
200+ return kmalloc_array(count, sizeof(pid_t), GFP_KERNEL);
201201 }
202202
203203 static void pidlist_free(void *p)
kernel/cgroup/cpuset.c+3−2
@@ -683,7 +683,7 @@ static int generate_sched_domains(cpumask_var_t **domains, · 682 unmodified lines
683683 goto done;
684684 }
685685
686− csa = kmalloc(nr_cpusets() * sizeof(cp), GFP_KERNEL);
686+ csa = kmalloc_array(nr_cpusets(), sizeof(cp), GFP_KERNEL);
687687 if (!csa)
688688 goto done;
689689 csn = 0;
@@ -753,7 +753,8 @@ restart: · 63 unmodified lines
753753 * The rest of the code, including the scheduler, can deal with
754754 * dattr==NULL case. No need to abort if alloc fails.
755755 */
756− dattr = kmalloc(ndoms * sizeof(struct sched_domain_attr), GFP_KERNEL);
756+ dattr = kmalloc_array(ndoms, sizeof(struct sched_domain_attr),
757+ GFP_KERNEL);
757758
758759 for (nslot = 0, i = 0; i < csn; i++) {
759760 struct cpuset *a = csa[i];
kernel/debug/kdb/kdb_main.c+8−5
@@ -691,7 +691,7 @@ static int kdb_defcmd2(const char *cmdstr, const char *argv0) · 690 unmodified lines
691691 }
692692 if (!s->usable)
693693 return KDB_NOTIMP;
694− s->command = kzalloc((s->count + 1) * sizeof(*(s->command)), GFP_KDB);
694+ s->command = kcalloc(s->count + 1, sizeof(*(s->command)), GFP_KDB);
695695 if (!s->command) {
696696 kdb_printf("Could not allocate new kdb_defcmd table for %s\n",
697697 cmdstr);
@@ -729,8 +729,8 @@ static int kdb_defcmd(int argc, const char **argv) · 31 unmodified lines
729729 kdb_printf("Command only available during kdb_init()\n");
730730 return KDB_NOTIMP;
731731 }
732− defcmd_set = kmalloc((defcmd_set_count + 1) * sizeof(*defcmd_set),
733− GFP_KDB);
732+ defcmd_set = kmalloc_array(defcmd_set_count + 1, sizeof(*defcmd_set),
733+ GFP_KDB);
734734 if (!defcmd_set)
735735 goto fail_defcmd;
736736 memcpy(defcmd_set, save_defcmd_set,
@@ -2706,8 +2706,11 @@ int kdb_register_flags(char *cmd, · 1969 unmodified lines
27062706 }
27072707
27082708 if (i >= kdb_max_commands) {
2709− kdbtab_t *new = kmalloc((kdb_max_commands - KDB_BASE_CMD_MAX +
2710− kdb_command_extend) * sizeof(*new), GFP_KDB);
2709+ kdbtab_t *new = kmalloc_array(kdb_max_commands -
2710+ KDB_BASE_CMD_MAX +
2711+ kdb_command_extend,
2712+ sizeof(*new),
2713+ GFP_KDB);
27112714 if (!new) {
27122715 kdb_printf("Could not allocate new kdb_command "
27132716 "table\n");
kernel/events/ring_buffer.c+2−1
@@ -614,7 +614,8 @@ int rb_alloc_aux(struct ring_buffer *rb, struct perf_event *event, · 613 unmodified lines
614614 }
615615 }
616616
617− rb->aux_pages = kzalloc_node(nr_pages * sizeof(void *), GFP_KERNEL, node);
617+ rb->aux_pages = kcalloc_node(nr_pages, sizeof(void *), GFP_KERNEL,
618+ node);
618619 if (!rb->aux_pages)
619620 return -ENOMEM;
620621
kernel/events/uprobes.c+2−1
@@ -1184,7 +1184,8 @@ static struct xol_area *__create_xol_area(unsigned long vaddr) · 1183 unmodified lines
11841184 if (unlikely(!area))
11851185 goto out;
11861186
1187− area->bitmap = kzalloc(BITS_TO_LONGS(UINSNS_PER_PAGE) * sizeof(long), GFP_KERNEL);
1187+ area->bitmap = kcalloc(BITS_TO_LONGS(UINSNS_PER_PAGE), sizeof(long),
1188+ GFP_KERNEL);
11881189 if (!area->bitmap)
11891190 goto free_area;
11901191
kernel/fail_function.c+1−1
@@ -258,7 +258,7 @@ static ssize_t fei_write(struct file *file, const char __user *buffer, · 257 unmodified lines
258258 /* cut off if it is too long */
259259 if (count > KSYM_NAME_LEN)
260260 count = KSYM_NAME_LEN;
261− buf = kmalloc(sizeof(char) * (count + 1), GFP_KERNEL);
261+ buf = kmalloc(count + 1, GFP_KERNEL);
262262 if (!buf)
263263 return -ENOMEM;
264264
kernel/kexec_file.c+1−1
@@ -793,7 +793,7 @@ static int kexec_purgatory_setup_sechdrs(struct purgatory_info *pi, · 792 unmodified lines
793793 * The section headers in kexec_purgatory are read-only. In order to
794794 * have them modifiable make a temporary copy.
795795 */
796− sechdrs = vzalloc(pi->ehdr->e_shnum * sizeof(Elf_Shdr));
796+ sechdrs = vzalloc(array_size(sizeof(Elf_Shdr), pi->ehdr->e_shnum));
797797 if (!sechdrs)
798798 return -ENOMEM;
799799 memcpy(sechdrs, (void *)pi->ehdr + pi->ehdr->e_shoff,
kernel/locking/locktorture.c+10−4
@@ -913,7 +913,9 @@ static int __init lock_torture_init(void) · 912 unmodified lines
913913 /* Initialize the statistics so that each run gets its own numbers. */
914914 if (nwriters_stress) {
915915 lock_is_write_held = 0;
916− cxt.lwsa = kmalloc(sizeof(*cxt.lwsa) * cxt.nrealwriters_stress, GFP_KERNEL);
916+ cxt.lwsa = kmalloc_array(cxt.nrealwriters_stress,
917+ sizeof(*cxt.lwsa),
918+ GFP_KERNEL);
917919 if (cxt.lwsa == NULL) {
918920 VERBOSE_TOROUT_STRING("cxt.lwsa: Out of memory");
919921 firsterr = -ENOMEM;
@@ -942,7 +944,9 @@ static int __init lock_torture_init(void) · 22 unmodified lines
942944
943945 if (nreaders_stress) {
944946 lock_is_read_held = 0;
945− cxt.lrsa = kmalloc(sizeof(*cxt.lrsa) * cxt.nrealreaders_stress, GFP_KERNEL);
947+ cxt.lrsa = kmalloc_array(cxt.nrealreaders_stress,
948+ sizeof(*cxt.lrsa),
949+ GFP_KERNEL);
946950 if (cxt.lrsa == NULL) {
947951 VERBOSE_TOROUT_STRING("cxt.lrsa: Out of memory");
948952 firsterr = -ENOMEM;
@@ -985,7 +989,8 @@ static int __init lock_torture_init(void) · 36 unmodified lines
985989 }
986990
987991 if (nwriters_stress) {
988− writer_tasks = kzalloc(cxt.nrealwriters_stress * sizeof(writer_tasks[0]),
992+ writer_tasks = kcalloc(cxt.nrealwriters_stress,
993+ sizeof(writer_tasks[0]),
989994 GFP_KERNEL);
990995 if (writer_tasks == NULL) {
991996 VERBOSE_TOROUT_ERRSTRING("writer_tasks: Out of memory");
@@ -995,7 +1000,8 @@ static int __init lock_torture_init(void) · 3 unmodified lines
9951000 }
9961001
9971002 if (cxt.cur_ops->readlock) {
998− reader_tasks = kzalloc(cxt.nrealreaders_stress * sizeof(reader_tasks[0]),
1003+ reader_tasks = kcalloc(cxt.nrealreaders_stress,
1004+ sizeof(reader_tasks[0]),
9991005 GFP_KERNEL);
10001006 if (reader_tasks == NULL) {
10011007 VERBOSE_TOROUT_ERRSTRING("reader_tasks: Out of memory");
kernel/power/swap.c+3−3
@@ -698,7 +698,7 @@ static int save_image_lzo(struct swap_map_handle *handle, · 697 unmodified lines
698698 goto out_clean;
699699 }
700700
701− data = vmalloc(sizeof(*data) * nr_threads);
701+ data = vmalloc(array_size(nr_threads, sizeof(*data)));
702702 if (!data) {
703703 pr_err("Failed to allocate LZO data\n");
704704 ret = -ENOMEM;
@@ -1183,14 +1183,14 @@ static int load_image_lzo(struct swap_map_handle *handle, · 478 unmodified lines
11831183 nr_threads = num_online_cpus() - 1;
11841184 nr_threads = clamp_val(nr_threads, 1, LZO_THREADS);
11851185
1186− page = vmalloc(sizeof(*page) * LZO_MAX_RD_PAGES);
1186+ page = vmalloc(array_size(LZO_MAX_RD_PAGES, sizeof(*page)));
11871187 if (!page) {
11881188 pr_err("Failed to allocate LZO page\n");
11891189 ret = -ENOMEM;
11901190 goto out_clean;
11911191 }
11921192
1193− data = vmalloc(sizeof(*data) * nr_threads);
1193+ data = vmalloc(array_size(nr_threads, sizeof(*data)));
11941194 if (!data) {
11951195 pr_err("Failed to allocate LZO data\n");
11961196 ret = -ENOMEM;
kernel/rcu/rcutorture.c+3−2
@@ -831,8 +831,9 @@ rcu_torture_cbflood(void *arg) · 830 unmodified lines
831831 cbflood_intra_holdoff > 0 &&
832832 cur_ops->call &&
833833 cur_ops->cb_barrier) {
834− rhp = vmalloc(sizeof(*rhp) *
835− cbflood_n_burst * cbflood_n_per_burst);
834+ rhp = vmalloc(array3_size(cbflood_n_burst,
835+ cbflood_n_per_burst,
836+ sizeof(*rhp)));
836837 err = !rhp;
837838 }
838839 if (err) {
kernel/relay.c+2−1
@@ -169,7 +169,8 @@ static struct rchan_buf *relay_create_buf(struct rchan *chan) · 168 unmodified lines
169169 buf = kzalloc(sizeof(struct rchan_buf), GFP_KERNEL);
170170 if (!buf)
171171 return NULL;
172− buf->padding = kmalloc(chan->n_subbufs * sizeof(size_t *), GFP_KERNEL);
172+ buf->padding = kmalloc_array(chan->n_subbufs, sizeof(size_t *),
173+ GFP_KERNEL);
173174 if (!buf->padding)
174175 goto free_buf;
175176
kernel/sched/fair.c+2−2
@@ -10215,10 +10215,10 @@ int alloc_fair_sched_group(struct task_group *tg, struct task_group *parent) · 10214 unmodified lines
1021510215 struct cfs_rq *cfs_rq;
1021610216 int i;
1021710217
10218− tg->cfs_rq = kzalloc(sizeof(cfs_rq) * nr_cpu_ids, GFP_KERNEL);
10218+ tg->cfs_rq = kcalloc(nr_cpu_ids, sizeof(cfs_rq), GFP_KERNEL);
1021910219 if (!tg->cfs_rq)
1022010220 goto err;
10221− tg->se = kzalloc(sizeof(se) * nr_cpu_ids, GFP_KERNEL);
10221+ tg->se = kcalloc(nr_cpu_ids, sizeof(se), GFP_KERNEL);
1022210222 if (!tg->se)
1022310223 goto err;
1022410224
kernel/sched/rt.c+2−2
@@ -183,10 +183,10 @@ int alloc_rt_sched_group(struct task_group *tg, struct task_group *parent) · 182 unmodified lines
183183 struct sched_rt_entity *rt_se;
184184 int i;
185185
186− tg->rt_rq = kzalloc(sizeof(rt_rq) * nr_cpu_ids, GFP_KERNEL);
186+ tg->rt_rq = kcalloc(nr_cpu_ids, sizeof(rt_rq), GFP_KERNEL);
187187 if (!tg->rt_rq)
188188 goto err;
189− tg->rt_se = kzalloc(sizeof(rt_se) * nr_cpu_ids, GFP_KERNEL);
189+ tg->rt_se = kcalloc(nr_cpu_ids, sizeof(rt_se), GFP_KERNEL);
190190 if (!tg->rt_se)
191191 goto err;
192192
kernel/sched/topology.c+1−1
@@ -1750,7 +1750,7 @@ cpumask_var_t *alloc_sched_domains(unsigned int ndoms) · 1749 unmodified lines
17501750 int i;
17511751 cpumask_var_t *doms;
17521752
1753− doms = kmalloc(sizeof(*doms) * ndoms, GFP_KERNEL);
1753+ doms = kmalloc_array(ndoms, sizeof(*doms), GFP_KERNEL);
17541754 if (!doms)
17551755 return NULL;
17561756 for (i = 0; i < ndoms; i++) {
kernel/sysctl.c+2−1
@@ -3047,7 +3047,8 @@ int proc_do_large_bitmap(struct ctl_table *table, int write, · 3046 unmodified lines
30473047 if (IS_ERR(kbuf))
30483048 return PTR_ERR(kbuf);
30493049
3050− tmp_bitmap = kzalloc(BITS_TO_LONGS(bitmap_len) * sizeof(unsigned long),
3050+ tmp_bitmap = kcalloc(BITS_TO_LONGS(bitmap_len),
3051+ sizeof(unsigned long),
30513052 GFP_KERNEL);
30523053 if (!tmp_bitmap) {
30533054 kfree(kbuf);
kernel/trace/ftrace.c+15−13
@@ -728,7 +728,7 @@ static int ftrace_profile_init_cpu(int cpu) · 727 unmodified lines
728728 */
729729 size = FTRACE_PROFILE_HASH_SIZE;
730730
731− stat->hash = kzalloc(sizeof(struct hlist_head) * size, GFP_KERNEL);
731+ stat->hash = kcalloc(size, sizeof(struct hlist_head), GFP_KERNEL);
732732
733733 if (!stat->hash)
734734 return -ENOMEM;
@@ -6830,9 +6830,10 @@ static int alloc_retstack_tasklist(struct ftrace_ret_stack **ret_stack_list) · 6095 unmodified lines
68306830 struct task_struct *g, *t;
68316831
68326832 for (i = 0; i < FTRACE_RETSTACK_ALLOC_SIZE; i++) {
6833− ret_stack_list[i] = kmalloc(FTRACE_RETFUNC_DEPTH
6834− * sizeof(struct ftrace_ret_stack),
6835− GFP_KERNEL);
6833+ ret_stack_list[i] =
6834+ kmalloc_array(FTRACE_RETFUNC_DEPTH,
6835+ sizeof(struct ftrace_ret_stack),
6836+ GFP_KERNEL);
68366837 if (!ret_stack_list[i]) {
68376838 start = 0;
68386839 end = i;
@@ -6904,9 +6905,9 @@ static int start_graph_tracing(void) · 65 unmodified lines
69046905 struct ftrace_ret_stack **ret_stack_list;
69056906 int ret, cpu;
69066907
6907− ret_stack_list = kmalloc(FTRACE_RETSTACK_ALLOC_SIZE *
6908− sizeof(struct ftrace_ret_stack *),
6909− GFP_KERNEL);
6908+ ret_stack_list = kmalloc_array(FTRACE_RETSTACK_ALLOC_SIZE,
6909+ sizeof(struct ftrace_ret_stack *),
6910+ GFP_KERNEL);
69106911
69116912 if (!ret_stack_list)
69126913 return -ENOMEM;
@@ -7088,9 +7089,10 @@ void ftrace_graph_init_idle_task(struct task_struct *t, int cpu) · 175 unmodified lines
70887089
70897090 ret_stack = per_cpu(idle_ret_stack, cpu);
70907091 if (!ret_stack) {
7091− ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH
7092− * sizeof(struct ftrace_ret_stack),
7093− GFP_KERNEL);
7092+ ret_stack =
7093+ kmalloc_array(FTRACE_RETFUNC_DEPTH,
7094+ sizeof(struct ftrace_ret_stack),
7095+ GFP_KERNEL);
70947096 if (!ret_stack)
70957097 return;
70967098 per_cpu(idle_ret_stack, cpu) = ret_stack;
@@ -7109,9 +7111,9 @@ void ftrace_graph_init_task(struct task_struct *t) · 12 unmodified lines
71097111 if (ftrace_graph_active) {
71107112 struct ftrace_ret_stack *ret_stack;
71117113
7112− ret_stack = kmalloc(FTRACE_RETFUNC_DEPTH
7113− * sizeof(struct ftrace_ret_stack),
7114− GFP_KERNEL);
7114+ ret_stack = kmalloc_array(FTRACE_RETFUNC_DEPTH,
7115+ sizeof(struct ftrace_ret_stack),
7116+ GFP_KERNEL);
71157117 if (!ret_stack)
71167118 return;
71177119 graph_init_task(t, ret_stack);
kernel/trace/trace.c+7−5
@@ -1751,12 +1751,13 @@ static inline void set_cmdline(int idx, const char *cmdline) · 1750 unmodified lines
17511751 static int allocate_cmdlines_buffer(unsigned int val,
17521752 struct saved_cmdlines_buffer *s)
17531753 {
1754− s->map_cmdline_to_pid = kmalloc(val * sizeof(*s->map_cmdline_to_pid),
1755− GFP_KERNEL);
1754+ s->map_cmdline_to_pid = kmalloc_array(val,
1755+ sizeof(*s->map_cmdline_to_pid),
1756+ GFP_KERNEL);
17561757 if (!s->map_cmdline_to_pid)
17571758 return -ENOMEM;
17581759
1759− s->saved_cmdlines = kmalloc(val * TASK_COMM_LEN, GFP_KERNEL);
1760+ s->saved_cmdlines = kmalloc_array(TASK_COMM_LEN, val, GFP_KERNEL);
17601761 if (!s->saved_cmdlines) {
17611762 kfree(s->map_cmdline_to_pid);
17621763 return -ENOMEM;
@@ -4360,7 +4361,8 @@ int set_tracer_flag(struct trace_array *tr, unsigned int mask, int enabled) · 2597 unmodified lines
43604361
43614362 if (mask == TRACE_ITER_RECORD_TGID) {
43624363 if (!tgid_map)
4363− tgid_map = kzalloc((PID_MAX_DEFAULT + 1) * sizeof(*tgid_map),
4364+ tgid_map = kcalloc(PID_MAX_DEFAULT + 1,
4365+ sizeof(*tgid_map),
43644366 GFP_KERNEL);
43654367 if (!tgid_map) {
43664368 tr->trace_flags &= ~TRACE_ITER_RECORD_TGID;
@@ -5063,7 +5065,7 @@ trace_insert_eval_map_file(struct module *mod, struct trace_eval_map **start, · 696 unmodified lines
50635065 * where the head holds the module and length of array, and the
50645066 * tail holds a pointer to the next list.
50655067 */
5066− map_array = kmalloc(sizeof(*map_array) * (len + 2), GFP_KERNEL);
5068+ map_array = kmalloc_array(len + 2, sizeof(*map_array), GFP_KERNEL);
50675069 if (!map_array) {
50685070 pr_warn("Unable to allocate trace eval mapping\n");
50695071 return;
kernel/trace/trace_events_filter.c+3−3
@@ -436,15 +436,15 @@ predicate_parse(const char *str, int nr_parens, int nr_preds, · 435 unmodified lines
436436
437437 nr_preds += 2; /* For TRUE and FALSE */
438438
439− op_stack = kmalloc(sizeof(*op_stack) * nr_parens, GFP_KERNEL);
439+ op_stack = kmalloc_array(nr_parens, sizeof(*op_stack), GFP_KERNEL);
440440 if (!op_stack)
441441 return ERR_PTR(-ENOMEM);
442− prog_stack = kmalloc(sizeof(*prog_stack) * nr_preds, GFP_KERNEL);
442+ prog_stack = kmalloc_array(nr_preds, sizeof(*prog_stack), GFP_KERNEL);
443443 if (!prog_stack) {
444444 parse_error(pe, -ENOMEM, 0);
445445 goto out_free;
446446 }
447− inverts = kmalloc(sizeof(*inverts) * nr_preds, GFP_KERNEL);
447+ inverts = kmalloc_array(nr_preds, sizeof(*inverts), GFP_KERNEL);
448448 if (!inverts) {
449449 parse_error(pe, -ENOMEM, 0);
450450 goto out_free;
kernel/trace/tracing_map.c+1−1
@@ -1075,7 +1075,7 @@ int tracing_map_sort_entries(struct tracing_map *map, · 1074 unmodified lines
10751075 struct tracing_map_sort_entry *sort_entry, **entries;
10761076 int i, n_entries, ret;
10771077
1078− entries = vmalloc(map->max_elts * sizeof(sort_entry));
1078+ entries = vmalloc(array_size(sizeof(sort_entry), map->max_elts));
10791079 if (!entries)
10801080 return -ENOMEM;
10811081
kernel/user_namespace.c+3−2
@@ -764,8 +764,9 @@ static int insert_extent(struct uid_gid_map *map, struct uid_gid_extent *extent) · 763 unmodified lines
764764 struct uid_gid_extent *forward;
765765
766766 /* Allocate memory for 340 mappings. */
767− forward = kmalloc(sizeof(struct uid_gid_extent) *
768− UID_GID_MAP_MAX_EXTENTS, GFP_KERNEL);
767+ forward = kmalloc_array(UID_GID_MAP_MAX_EXTENTS,
768+ sizeof(struct uid_gid_extent),
769+ GFP_KERNEL);
769770 if (!forward)
770771 return -ENOMEM;
771772
kernel/workqueue.c+1−1
@@ -5638,7 +5638,7 @@ static void __init wq_numa_init(void) · 5637 unmodified lines
56385638 * available. Build one from cpu_to_node() which should have been
56395639 * fully initialized by now.
56405640 */
5641− tbl = kzalloc(nr_node_ids * sizeof(tbl[0]), GFP_KERNEL);
5641+ tbl = kcalloc(nr_node_ids, sizeof(tbl[0]), GFP_KERNEL);
56425642 BUG_ON(!tbl);
56435643
56445644 for_each_node(node)
lib/argv_split.c+1−1
@@ -69,7 +69,7 @@ char **argv_split(gfp_t gfp, const char *str, int *argcp) · 68 unmodified lines
6969 return NULL;
7070
7171 argc = count_argc(argv_str);
72− argv = kmalloc(sizeof(*argv) * (argc + 2), gfp);
72+ argv = kmalloc_array(argc + 2, sizeof(*argv), gfp);
7373 if (!argv) {
7474 kfree(argv_str);
7575 return NULL;
lib/interval_tree_test.c+3−2
@@ -64,11 +64,12 @@ static int interval_tree_test_init(void) · 63 unmodified lines
6464 unsigned long results;
6565 cycles_t time1, time2, time;
6666
67− nodes = kmalloc(nnodes * sizeof(struct interval_tree_node), GFP_KERNEL);
67+ nodes = kmalloc_array(nnodes, sizeof(struct interval_tree_node),
68+ GFP_KERNEL);
6869 if (!nodes)
6970 return -ENOMEM;
7071
71− queries = kmalloc(nsearches * sizeof(int), GFP_KERNEL);
72+ queries = kmalloc_array(nsearches, sizeof(int), GFP_KERNEL);
7273 if (!queries) {
7374 kfree(nodes);
7475 return -ENOMEM;
lib/kfifo.c+1−1
@@ -54,7 +54,7 @@ int __kfifo_alloc(struct __kfifo *fifo, unsigned int size, · 53 unmodified lines
5454 return -EINVAL;
5555 }
5656
57− fifo->data = kmalloc(size * esize, gfp_mask);
57+ fifo->data = kmalloc_array(esize, size, gfp_mask);
5858
5959 if (!fifo->data) {
6060 fifo->mask = 0;
lib/lru_cache.c+1−1
@@ -119,7 +119,7 @@ struct lru_cache *lc_create(const char *name, struct kmem_cache *cache, · 118 unmodified lines
119119 slot = kcalloc(e_count, sizeof(struct hlist_head), GFP_KERNEL);
120120 if (!slot)
121121 goto out_fail;
122− element = kzalloc(e_count * sizeof(struct lc_element *), GFP_KERNEL);
122+ element = kcalloc(e_count, sizeof(struct lc_element *), GFP_KERNEL);
123123 if (!element)
124124 goto out_fail;
125125
lib/mpi/mpiutil.c+2−2
@@ -91,14 +91,14 @@ int mpi_resize(MPI a, unsigned nlimbs) · 90 unmodified lines
9191 return 0; /* no need to do it */
9292
9393 if (a->d) {
94− p = kmalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
94+ p = kmalloc_array(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL);
9595 if (!p)
9696 return -ENOMEM;
9797 memcpy(p, a->d, a->alloced * sizeof(mpi_limb_t));
9898 kzfree(a->d);
9999 a->d = p;
100100 } else {
101− a->d = kzalloc(nlimbs * sizeof(mpi_limb_t), GFP_KERNEL);
101+ a->d = kcalloc(nlimbs, sizeof(mpi_limb_t), GFP_KERNEL);
102102 if (!a->d)
103103 return -ENOMEM;
104104 }
lib/rbtree_test.c+1−1
@@ -247,7 +247,7 @@ static int __init rbtree_test_init(void) · 246 unmodified lines
247247 cycles_t time1, time2, time;
248248 struct rb_node *node;
249249
250− nodes = kmalloc(nnodes * sizeof(*nodes), GFP_KERNEL);
250+ nodes = kmalloc_array(nnodes, sizeof(*nodes), GFP_KERNEL);
251251 if (!nodes)
252252 return -ENOMEM;
253253
lib/reed_solomon/reed_solomon.c+3−3
@@ -88,15 +88,15 @@ static struct rs_codec *codec_init(int symsize, int gfpoly, int (*gffunc)(int), · 87 unmodified lines
8888 rs->gffunc = gffunc;
8989
9090 /* Allocate the arrays */
91− rs->alpha_to = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp);
91+ rs->alpha_to = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
9292 if (rs->alpha_to == NULL)
9393 goto err;
9494
95− rs->index_of = kmalloc(sizeof(uint16_t) * (rs->nn + 1), gfp);
95+ rs->index_of = kmalloc_array(rs->nn + 1, sizeof(uint16_t), gfp);
9696 if (rs->index_of == NULL)
9797 goto err;
9898
99− rs->genpoly = kmalloc(sizeof(uint16_t) * (rs->nroots + 1), gfp);
99+ rs->genpoly = kmalloc_array(rs->nroots + 1, sizeof(uint16_t), gfp);
100100 if(rs->genpoly == NULL)
101101 goto err;
102102
lib/sbitmap.c+1−1
@@ -52,7 +52,7 @@ int sbitmap_init_node(struct sbitmap *sb, unsigned int depth, int shift, · 51 unmodified lines
5252 return 0;
5353 }
5454
55− sb->map = kzalloc_node(sb->map_nr * sizeof(*sb->map), flags, node);
55+ sb->map = kcalloc_node(sb->map_nr, sizeof(*sb->map), flags, node);
5656 if (!sb->map)
5757 return -ENOMEM;
5858
lib/scatterlist.c+2−1
@@ -170,7 +170,8 @@ static struct scatterlist *sg_kmalloc(unsigned int nents, gfp_t gfp_mask) · 169 unmodified lines
170170 kmemleak_alloc(ptr, PAGE_SIZE, 1, gfp_mask);
171171 return ptr;
172172 } else
173− return kmalloc(nents * sizeof(struct scatterlist), gfp_mask);
173+ return kmalloc_array(nents, sizeof(struct scatterlist),
174+ gfp_mask);
174175 }
175176
176177 static void sg_kfree(struct scatterlist *sg, unsigned int nents)
lib/test_firmware.c+6−4
@@ -618,8 +618,9 @@ static ssize_t trigger_batched_requests_store(struct device *dev, · 617 unmodified lines
618618
619619 mutex_lock(&test_fw_mutex);
620620
621− test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) *
622− test_fw_config->num_requests * 2);
621+ test_fw_config->reqs =
622+ vzalloc(array3_size(sizeof(struct test_batched_req),
623+ test_fw_config->num_requests, 2));
623624 if (!test_fw_config->reqs) {
624625 rc = -ENOMEM;
625626 goto out_unlock;
@@ -720,8 +721,9 @@ ssize_t trigger_batched_requests_async_store(struct device *dev, · 94 unmodified lines
720721
721722 mutex_lock(&test_fw_mutex);
722723
723− test_fw_config->reqs = vzalloc(sizeof(struct test_batched_req) *
724− test_fw_config->num_requests * 2);
724+ test_fw_config->reqs =
725+ vzalloc(array3_size(sizeof(struct test_batched_req),
726+ test_fw_config->num_requests, 2));
725727 if (!test_fw_config->reqs) {
726728 rc = -ENOMEM;
727729 goto out;
lib/test_kmod.c+3−2
@@ -779,8 +779,9 @@ static int kmod_config_sync_info(struct kmod_test_device *test_dev) · 778 unmodified lines
779779 struct test_config *config = &test_dev->config;
780780
781781 free_test_dev_info(test_dev);
782− test_dev->info = vzalloc(config->num_threads *
783− sizeof(struct kmod_test_device_info));
782+ test_dev->info =
783+ vzalloc(array_size(sizeof(struct kmod_test_device_info),
784+ config->num_threads));
784785 if (!test_dev->info)
785786 return -ENOMEM;
786787
lib/test_overflow.c+1−1
@@ -367,7 +367,7 @@ static int __init test_overflow_allocation(void) · 366 unmodified lines
367367
368368 /* Create dummy device for devm_kmalloc()-family tests. */
369369 dev = root_device_register(device_name);
370− if (!dev) {
370+ if (IS_ERR(dev)) {
371371 pr_warn("Cannot register test device\n");
372372 return 1;
373373 }
lib/test_rhashtable.c+8−5
@@ -285,12 +285,14 @@ static int __init test_rhltable(unsigned int entries) · 284 unmodified lines
285285 if (entries == 0)
286286 entries = 1;
287287
288− rhl_test_objects = vzalloc(sizeof(*rhl_test_objects) * entries);
288+ rhl_test_objects = vzalloc(array_size(entries,
289+ sizeof(*rhl_test_objects)));
289290 if (!rhl_test_objects)
290291 return -ENOMEM;
291292
292293 ret = -ENOMEM;
293− obj_in_table = vzalloc(BITS_TO_LONGS(entries) * sizeof(unsigned long));
294+ obj_in_table = vzalloc(array_size(sizeof(unsigned long),
295+ BITS_TO_LONGS(entries)));
294296 if (!obj_in_table)
295297 goto out_free;
296298
@@ -706,7 +708,8 @@ static int __init test_rht_init(void) · 409 unmodified lines
706708 test_rht_params.max_size = max_size ? : roundup_pow_of_two(entries);
707709 test_rht_params.nelem_hint = size;
708710
709− objs = vzalloc((test_rht_params.max_size + 1) * sizeof(struct test_obj));
711+ objs = vzalloc(array_size(sizeof(struct test_obj),
712+ test_rht_params.max_size + 1));
710713 if (!objs)
711714 return -ENOMEM;
712715
@@ -753,10 +756,10 @@ static int __init test_rht_init(void) · 40 unmodified lines
753756 pr_info("Testing concurrent rhashtable access from %d threads\n",
754757 tcount);
755758 sema_init(&prestart_sem, 1 - tcount);
756− tdata = vzalloc(tcount * sizeof(struct thread_data));
759+ tdata = vzalloc(array_size(tcount, sizeof(struct thread_data)));
757760 if (!tdata)
758761 return -ENOMEM;
759− objs = vzalloc(tcount * entries * sizeof(struct test_obj));
762+ objs = vzalloc(array3_size(sizeof(struct test_obj), tcount, entries));
760763 if (!objs) {
761764 vfree(tdata);
762765 return -ENOMEM;
mm/gup_benchmark.c+1−1
@@ -23,7 +23,7 @@ static int __gup_benchmark_ioctl(unsigned int cmd, · 22 unmodified lines
2323 struct page **pages;
2424
2525 nr_pages = gup->size / PAGE_SIZE;
26− pages = kvzalloc(sizeof(void *) * nr_pages, GFP_KERNEL);
26+ pages = kvcalloc(nr_pages, sizeof(void *), GFP_KERNEL);
2727 if (!pages)
2828 return -ENOMEM;
2929
mm/huge_memory.c+2−2
@@ -1131,8 +1131,8 @@ static int do_huge_pmd_wp_page_fallback(struct vm_fault *vmf, pmd_t orig_pmd, · 1130 unmodified lines
11311131 unsigned long mmun_start; /* For mmu_notifiers */
11321132 unsigned long mmun_end; /* For mmu_notifiers */
11331133
1134− pages = kmalloc(sizeof(struct page *) * HPAGE_PMD_NR,
1135− GFP_KERNEL);
1134+ pages = kmalloc_array(HPAGE_PMD_NR, sizeof(struct page *),
1135+ GFP_KERNEL);
11361136 if (unlikely(!pages)) {
11371137 ret |= VM_FAULT_OOM;
11381138 goto out;
mm/hugetlb.c+2−1
@@ -2798,7 +2798,8 @@ static int __init hugetlb_init(void) · 2797 unmodified lines
27982798 num_fault_mutexes = 1;
27992799 #endif
28002800 hugetlb_fault_mutex_table =
2801− kmalloc(sizeof(struct mutex) * num_fault_mutexes, GFP_KERNEL);
2801+ kmalloc_array(num_fault_mutexes, sizeof(struct mutex),
2802+ GFP_KERNEL);
28022803 BUG_ON(!hugetlb_fault_mutex_table);
28032804
28042805 for (i = 0; i < num_fault_mutexes; i++)
mm/percpu-stats.c+1−1
@@ -144,7 +144,7 @@ alloc_buffer: · 143 unmodified lines
144144 spin_unlock_irq(&pcpu_lock);
145145
146146 /* 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)));
148148 if (!buffer)
149149 return -ENOMEM;
150150
mm/slab.c+2−1
@@ -4338,7 +4338,8 @@ static int leaks_show(struct seq_file *m, void *p) · 4337 unmodified lines
43384338 if (x[0] == x[1]) {
43394339 /* Increase the buffer size */
43404340 mutex_unlock(&slab_mutex);
4341− m->private = kzalloc(x[0] * 4 * sizeof(unsigned long), GFP_KERNEL);
4341+ m->private = kcalloc(x[0] * 4, sizeof(unsigned long),
4342+ GFP_KERNEL);
43424343 if (!m->private) {
43434344 /* Too bad, we are really out */
43444345 m->private = x;
mm/slub.c+11−8
@@ -3623,8 +3623,9 @@ static void list_slab_objects(struct kmem_cache *s, struct page *page, · 3622 unmodified lines
36233623 #ifdef CONFIG_SLUB_DEBUG
36243624 void *addr = page_address(page);
36253625 void *p;
3626− unsigned long *map = kzalloc(BITS_TO_LONGS(page->objects) *
3627− sizeof(long), GFP_ATOMIC);
3626+ unsigned long *map = kcalloc(BITS_TO_LONGS(page->objects),
3627+ sizeof(long),
3628+ GFP_ATOMIC);
36283629 if (!map)
36293630 return;
36303631 slab_err(s, page, text, s->name);
@@ -4412,8 +4413,9 @@ static long validate_slab_cache(struct kmem_cache *s) · 781 unmodified lines
44124413 {
44134414 int node;
44144415 unsigned long count = 0;
4415− unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) *
4416− sizeof(unsigned long), GFP_KERNEL);
4416+ unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
4417+ sizeof(unsigned long),
4418+ GFP_KERNEL);
44174419 struct kmem_cache_node *n;
44184420
44194421 if (!map)
@@ -4573,8 +4575,9 @@ static int list_locations(struct kmem_cache *s, char *buf, · 153 unmodified lines
45734575 unsigned long i;
45744576 struct loc_track t = { 0, 0, NULL };
45754577 int node;
4576− unsigned long *map = kmalloc(BITS_TO_LONGS(oo_objects(s->max)) *
4577− sizeof(unsigned long), GFP_KERNEL);
4578+ unsigned long *map = kmalloc_array(BITS_TO_LONGS(oo_objects(s->max)),
4579+ sizeof(unsigned long),
4580+ GFP_KERNEL);
45784581 struct kmem_cache_node *n;
45794582
45804583 if (!map || !alloc_loc_track(&t, PAGE_SIZE / sizeof(struct location),
@@ -4750,7 +4753,7 @@ static ssize_t show_slab_objects(struct kmem_cache *s, · 169 unmodified lines
47504753 int x;
47514754 unsigned long *nodes;
47524755
4753− nodes = kzalloc(sizeof(unsigned long) * nr_node_ids, GFP_KERNEL);
4756+ nodes = kcalloc(nr_node_ids, sizeof(unsigned long), GFP_KERNEL);
47544757 if (!nodes)
47554758 return -ENOMEM;
47564759
@@ -5293,7 +5296,7 @@ static int show_stat(struct kmem_cache *s, char *buf, enum stat_item si) · 536 unmodified lines
52935296 unsigned long sum = 0;
52945297 int cpu;
52955298 int len;
5296− int *data = kmalloc(nr_cpu_ids * sizeof(int), GFP_KERNEL);
5299+ int *data = kmalloc_array(nr_cpu_ids, sizeof(int), GFP_KERNEL);
52975300
52985301 if (!data)
52995302 return -ENOMEM;
mm/swap_slots.c+2−2
@@ -122,12 +122,12 @@ static int alloc_swap_slot_cache(unsigned int cpu) · 121 unmodified lines
122122 * as kvzalloc could trigger reclaim and get_swap_page,
123123 * which can lock swap_slots_cache_mutex.
124124 */
125− slots = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE,
125+ slots = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t),
126126 GFP_KERNEL);
127127 if (!slots)
128128 return -ENOMEM;
129129
130− slots_ret = kvzalloc(sizeof(swp_entry_t) * SWAP_SLOTS_CACHE_SIZE,
130+ slots_ret = kvcalloc(SWAP_SLOTS_CACHE_SIZE, sizeof(swp_entry_t),
131131 GFP_KERNEL);
132132 if (!slots_ret) {
133133 kvfree(slots);
mm/swap_state.c+1−1
@@ -620,7 +620,7 @@ int init_swap_address_space(unsigned int type, unsigned long nr_pages) · 619 unmodified lines
620620 unsigned int i, nr;
621621
622622 nr = DIV_ROUND_UP(nr_pages, SWAP_ADDRESS_SPACE_PAGES);
623− spaces = kvzalloc(sizeof(struct address_space) * nr, GFP_KERNEL);
623+ spaces = kvcalloc(nr, sizeof(struct address_space), GFP_KERNEL);
624624 if (!spaces)
625625 return -ENOMEM;
626626 for (i = 0; i < nr; i++) {
mm/swapfile.c+3−2
@@ -3196,7 +3196,7 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · 3195 unmodified lines
31963196 p->cluster_next = 1 + (prandom_u32() % p->highest_bit);
31973197 nr_cluster = DIV_ROUND_UP(maxpages, SWAPFILE_CLUSTER);
31983198
3199− cluster_info = kvzalloc(nr_cluster * sizeof(*cluster_info),
3199+ cluster_info = kvcalloc(nr_cluster, sizeof(*cluster_info),
32003200 GFP_KERNEL);
32013201 if (!cluster_info) {
32023202 error = -ENOMEM;
@@ -3233,7 +3233,8 @@ SYSCALL_DEFINE2(swapon, const char __user *, specialfile, int, swap_flags) · 30 unmodified lines
32333233 }
32343234 /* frontswap enabled? set up bit-per-page map for frontswap */
32353235 if (IS_ENABLED(CONFIG_FRONTSWAP))
3236− frontswap_map = kvzalloc(BITS_TO_LONGS(maxpages) * sizeof(long),
3236+ frontswap_map = kvcalloc(BITS_TO_LONGS(maxpages),
3237+ sizeof(long),
32373238 GFP_KERNEL);
32383239
32393240 if (p->bdev &&(swap_flags & SWAP_FLAG_DISCARD) && swap_discardable(p)) {
net/9p/protocol.c+6−5
@@ -242,8 +242,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, · 241 unmodified lines
242242 "w", nwname);
243243 if (!errcode) {
244244 *wnames =
245− kmalloc(sizeof(char *) * *nwname,
246− GFP_NOFS);
245+ kmalloc_array(*nwname,
246+ sizeof(char *),
247+ GFP_NOFS);
247248 if (!*wnames)
248249 errcode = -ENOMEM;
249250 }
@@ -285,9 +286,9 @@ p9pdu_vreadf(struct p9_fcall *pdu, int proto_version, const char *fmt, · 35 unmodified lines
285286 p9pdu_readf(pdu, proto_version, "w", nwqid);
286287 if (!errcode) {
287288 *wqids =
288− kmalloc(*nwqid *
289− sizeof(struct p9_qid),
290− GFP_NOFS);
289+ kmalloc_array(*nwqid,
290+ sizeof(struct p9_qid),
291+ GFP_NOFS);
291292 if (*wqids == NULL)
292293 errcode = -ENOMEM;
293294 }
net/9p/trans_virtio.c+2−1
@@ -360,7 +360,8 @@ static int p9_get_mapped_pages(struct virtio_chan *chan, · 359 unmodified lines
360360 nr_pages = DIV_ROUND_UP((unsigned long)p + len, PAGE_SIZE) -
361361 (unsigned long)p / PAGE_SIZE;
362362
363− *pages = kmalloc(sizeof(struct page *) * nr_pages, GFP_NOFS);
363+ *pages = kmalloc_array(nr_pages, sizeof(struct page *),
364+ GFP_NOFS);
364365 if (!*pages)
365366 return -ENOMEM;
366367
net/atm/mpc.c+1−1
@@ -472,7 +472,7 @@ static const uint8_t *copy_macs(struct mpoa_client *mpc, · 471 unmodified lines
472472 if (mpc->number_of_mps_macs != 0)
473473 kfree(mpc->mps_macs);
474474 mpc->number_of_mps_macs = 0;
475− mpc->mps_macs = kmalloc(num_macs * ETH_ALEN, GFP_KERNEL);
475+ mpc->mps_macs = kmalloc_array(ETH_ALEN, num_macs, GFP_KERNEL);
476476 if (mpc->mps_macs == NULL) {
477477 pr_info("(%s) out of mem\n", mpc->dev->name);
478478 return NULL;
net/bluetooth/hci_core.c+1−1
@@ -1281,7 +1281,7 @@ int hci_inquiry(void __user *arg) · 1280 unmodified lines
12811281 /* cache_dump can't sleep. Therefore we allocate temp buffer and then
12821282 * copy it to the user space.
12831283 */
1284− buf = kmalloc(sizeof(struct inquiry_info) * max_rsp, GFP_KERNEL);
1284+ buf = kmalloc_array(max_rsp, sizeof(struct inquiry_info), GFP_KERNEL);
12851285 if (!buf) {
12861286 err = -ENOMEM;
12871287 goto done;
net/bluetooth/l2cap_core.c+1−1
@@ -331,7 +331,7 @@ static int l2cap_seq_list_init(struct l2cap_seq_list *seq_list, u16 size) · 330 unmodified lines
331331 */
332332 alloc_size = roundup_pow_of_two(size);
333333
334− seq_list->list = kmalloc(sizeof(u16) * alloc_size, GFP_KERNEL);
334+ seq_list->list = kmalloc_array(alloc_size, sizeof(u16), GFP_KERNEL);
335335 if (!seq_list->list)
336336 return -ENOMEM;
337337
net/bridge/br_multicast.c+1−1
@@ -333,7 +333,7 @@ static int br_mdb_rehash(struct net_bridge_mdb_htable __rcu **mdbp, int max, · 332 unmodified lines
333333 mdb->max = max;
334334 mdb->old = old;
335335
336− mdb->mhash = kzalloc(max * sizeof(*mdb->mhash), GFP_ATOMIC);
336+ mdb->mhash = kcalloc(max, sizeof(*mdb->mhash), GFP_ATOMIC);
337337 if (!mdb->mhash) {
338338 kfree(mdb);
339339 return -ENOMEM;
net/bridge/netfilter/ebtables.c+6−5
@@ -903,12 +903,13 @@ static int translate_table(struct net *net, const char *name, · 902 unmodified lines
903903 * if an error occurs
904904 */
905905 newinfo->chainstack =
906− vmalloc(nr_cpu_ids * sizeof(*(newinfo->chainstack)));
906+ vmalloc(array_size(nr_cpu_ids,
907+ sizeof(*(newinfo->chainstack))));
907908 if (!newinfo->chainstack)
908909 return -ENOMEM;
909910 for_each_possible_cpu(i) {
910911 newinfo->chainstack[i] =
911− vmalloc(udc_cnt * sizeof(*(newinfo->chainstack[0])));
912+ vmalloc(array_size(udc_cnt, sizeof(*(newinfo->chainstack[0]))));
912913 if (!newinfo->chainstack[i]) {
913914 while (i)
914915 vfree(newinfo->chainstack[--i]);
@@ -918,7 +919,7 @@ static int translate_table(struct net *net, const char *name, · 3 unmodified lines
918919 }
919920 }
920921
921− cl_s = vmalloc(udc_cnt * sizeof(*cl_s));
922+ cl_s = vmalloc(array_size(udc_cnt, sizeof(*cl_s)));
922923 if (!cl_s)
923924 return -ENOMEM;
924925 i = 0; /* the i'th udc */
@@ -1293,7 +1294,7 @@ static int do_update_counters(struct net *net, const char *name, · 368 unmodified lines
12931294 if (num_counters == 0)
12941295 return -EINVAL;
12951296
1296− tmp = vmalloc(num_counters * sizeof(*tmp));
1297+ tmp = vmalloc(array_size(num_counters, sizeof(*tmp)));
12971298 if (!tmp)
12981299 return -ENOMEM;
12991300
@@ -1434,7 +1435,7 @@ static int copy_counters_to_user(struct ebt_table *t, · 134 unmodified lines
14341435 return -EINVAL;
14351436 }
14361437
1437− counterstmp = vmalloc(nentries * sizeof(*counterstmp));
1438+ counterstmp = vmalloc(array_size(nentries, sizeof(*counterstmp)));
14381439 if (!counterstmp)
14391440 return -ENOMEM;
14401441
net/can/bcm.c+8−5
@@ -923,8 +923,9 @@ static int bcm_tx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, · 922 unmodified lines
923923
924924 /* create array for CAN frames and copy the data */
925925 if (msg_head->nframes > 1) {
926− op->frames = kmalloc(msg_head->nframes * op->cfsiz,
927− GFP_KERNEL);
926+ op->frames = kmalloc_array(msg_head->nframes,
927+ op->cfsiz,
928+ GFP_KERNEL);
928929 if (!op->frames) {
929930 kfree(op);
930931 return -ENOMEM;
@@ -1095,15 +1096,17 @@ static int bcm_rx_setup(struct bcm_msg_head *msg_head, struct msghdr *msg, · 164 unmodified lines
10951096
10961097 if (msg_head->nframes > 1) {
10971098 /* create array for CAN frames and copy the data */
1098− op->frames = kmalloc(msg_head->nframes * op->cfsiz,
1099− GFP_KERNEL);
1099+ op->frames = kmalloc_array(msg_head->nframes,
1100+ op->cfsiz,
1101+ GFP_KERNEL);
11001102 if (!op->frames) {
11011103 kfree(op);
11021104 return -ENOMEM;
11031105 }
11041106
11051107 /* create and init array for received CAN frames */
1106− op->last_frames = kzalloc(msg_head->nframes * op->cfsiz,
1108+ op->last_frames = kcalloc(msg_head->nframes,
1109+ op->cfsiz,
11071110 GFP_KERNEL);
11081111 if (!op->last_frames) {
11091112 kfree(op->frames);
net/ceph/osdmap.c+3−2
@@ -1299,8 +1299,9 @@ static int set_primary_affinity(struct ceph_osdmap *map, int osd, u32 aff) · 1298 unmodified lines
12991299 if (!map->osd_primary_affinity) {
13001300 int i;
13011301
1302− map->osd_primary_affinity = kmalloc(map->max_osd*sizeof(u32),
1303− GFP_NOFS);
1302+ map->osd_primary_affinity = kmalloc_array(map->max_osd,
1303+ sizeof(u32),
1304+ GFP_NOFS);
13041305 if (!map->osd_primary_affinity)
13051306 return -ENOMEM;
13061307
net/ceph/pagevec.c+2−2
@@ -20,7 +20,7 @@ struct page **ceph_get_direct_page_vector(const void __user *data, · 19 unmodified lines
2020 int got = 0;
2121 int rc = 0;
2222
23− pages = kmalloc(sizeof(*pages) * num_pages, GFP_NOFS);
23+ pages = kmalloc_array(num_pages, sizeof(*pages), GFP_NOFS);
2424 if (!pages)
2525 return ERR_PTR(-ENOMEM);
2626
@@ -74,7 +74,7 @@ struct page **ceph_alloc_page_vector(int num_pages, gfp_t flags) · 47 unmodified lines
7474 struct page **pages;
7575 int i;
7676
77− pages = kmalloc(sizeof(*pages) * num_pages, flags);
77+ pages = kmalloc_array(num_pages, sizeof(*pages), flags);
7878 if (!pages)
7979 return ERR_PTR(-ENOMEM);
8080 for (i = 0; i < num_pages; i++) {
net/core/dev.c+1−1
@@ -8823,7 +8823,7 @@ static struct hlist_head * __net_init netdev_create_hash(void) · 8822 unmodified lines
88238823 int i;
88248824 struct hlist_head *hash;
88258825
8826− hash = kmalloc(sizeof(*hash) * NETDEV_HASHENTRIES, GFP_KERNEL);
8826+ hash = kmalloc_array(NETDEV_HASHENTRIES, sizeof(*hash), GFP_KERNEL);
88278827 if (hash != NULL)
88288828 for (i = 0; i < NETDEV_HASHENTRIES; i++)
88298829 INIT_HLIST_HEAD(&hash[i]);
net/core/ethtool.c+6−6
@@ -911,7 +911,7 @@ static noinline_for_stack int ethtool_get_sset_info(struct net_device *dev, · 910 unmodified lines
911911 memset(&info, 0, sizeof(info));
912912 info.cmd = ETHTOOL_GSSET_INFO;
913913
914− info_buf = kzalloc(n_bits * sizeof(u32), GFP_USER);
914+ info_buf = kcalloc(n_bits, sizeof(u32), GFP_USER);
915915 if (!info_buf)
916916 return -ENOMEM;
917917
@@ -1017,7 +1017,7 @@ static noinline_for_stack int ethtool_get_rxnfc(struct net_device *dev, · 99 unmodified lines
10171017 if (info.cmd == ETHTOOL_GRXCLSRLALL) {
10181018 if (info.rule_cnt > 0) {
10191019 if (info.rule_cnt <= KMALLOC_MAX_SIZE / sizeof(u32))
1020− rule_buf = kzalloc(info.rule_cnt * sizeof(u32),
1020+ rule_buf = kcalloc(info.rule_cnt, sizeof(u32),
10211021 GFP_USER);
10221022 if (!rule_buf)
10231023 return -ENOMEM;
@@ -1816,7 +1816,7 @@ static int ethtool_self_test(struct net_device *dev, char __user *useraddr) · 792 unmodified lines
18161816 return -EFAULT;
18171817
18181818 test.len = test_len;
1819− data = kmalloc(test_len * sizeof(u64), GFP_USER);
1819+ data = kmalloc_array(test_len, sizeof(u64), GFP_USER);
18201820 if (!data)
18211821 return -ENOMEM;
18221822
@@ -1852,7 +1852,7 @@ static int ethtool_get_strings(struct net_device *dev, void __user *useraddr) · 29 unmodified lines
18521852 WARN_ON_ONCE(!ret);
18531853
18541854 gstrings.len = ret;
1855− data = vzalloc(gstrings.len * ETH_GSTRING_LEN);
1855+ data = vzalloc(array_size(gstrings.len, ETH_GSTRING_LEN));
18561856 if (gstrings.len && !data)
18571857 return -ENOMEM;
18581858
@@ -1952,7 +1952,7 @@ static int ethtool_get_stats(struct net_device *dev, void __user *useraddr) · 93 unmodified lines
19521952 return -EFAULT;
19531953
19541954 stats.n_stats = n_stats;
1955− data = vzalloc(n_stats * sizeof(u64));
1955+ data = vzalloc(array_size(n_stats, sizeof(u64)));
19561956 if (n_stats && !data)
19571957 return -ENOMEM;
19581958
@@ -1996,7 +1996,7 @@ static int ethtool_get_phy_stats(struct net_device *dev, void __user *useraddr) · 37 unmodified lines
19961996 return -EFAULT;
19971997
19981998 stats.n_stats = n_stats;
1999− data = vzalloc(n_stats * sizeof(u64));
1999+ data = vzalloc(array_size(n_stats, sizeof(u64)));
20002000 if (n_stats && !data)
20012001 return -ENOMEM;
20022002
net/core/pktgen.c+2−1
@@ -3603,7 +3603,8 @@ static int pktgen_add_device(struct pktgen_thread *t, const char *ifname) · 3602 unmodified lines
36033603 return -ENOMEM;
36043604
36053605 strcpy(pkt_dev->odevname, ifname);
3606− pkt_dev->flows = vzalloc_node(MAX_CFLOWS * sizeof(struct flow_state),
3606+ pkt_dev->flows = vzalloc_node(array_size(MAX_CFLOWS,
3607+ sizeof(struct flow_state)),
36073608 node);
36083609 if (pkt_dev->flows == NULL) {
36093610 kfree(pkt_dev);
net/dcb/dcbnl.c+2−1
@@ -984,7 +984,8 @@ static int dcbnl_build_peer_app(struct net_device *netdev, struct sk_buff* skb, · 983 unmodified lines
984984 */
985985 err = ops->peer_getappinfo(netdev, &info, &app_count);
986986 if (!err && app_count) {
987− table = kmalloc(sizeof(struct dcb_app) * app_count, GFP_KERNEL);
987+ table = kmalloc_array(app_count, sizeof(struct dcb_app),
988+ GFP_KERNEL);
988989 if (!table)
989990 return -ENOMEM;
990991
net/dccp/ccids/ccid2.c+2−1
@@ -46,7 +46,8 @@ static int ccid2_hc_tx_alloc_seq(struct ccid2_hc_tx_sock *hc) · 45 unmodified lines
4646 return -ENOMEM;
4747
4848 /* allocate buffer and initialize linked list */
49− seqp = kmalloc(CCID2_SEQBUF_LEN * sizeof(struct ccid2_seq), gfp_any());
49+ seqp = kmalloc_array(CCID2_SEQBUF_LEN, sizeof(struct ccid2_seq),
50+ gfp_any());
5051 if (seqp == NULL)
5152 return -ENOMEM;
5253
net/ieee802154/nl-phy.c+1−1
@@ -38,7 +38,7 @@ static int ieee802154_nl_fill_phy(struct sk_buff *msg, u32 portid, · 37 unmodified lines
3838 {
3939 void *hdr;
4040 int i, pages = 0;
41− uint32_t *buf = kzalloc(32 * sizeof(uint32_t), GFP_KERNEL);
41+ uint32_t *buf = kcalloc(32, sizeof(uint32_t), GFP_KERNEL);
4242
4343 pr_debug("%s\n", __func__);
4444
net/ipv4/fib_frontend.c+1−1
@@ -567,7 +567,7 @@ static int rtentry_to_fib_config(struct net *net, int cmd, struct rtentry *rt, · 566 unmodified lines
567567 struct nlattr *mx;
568568 int len = 0;
569569
570− mx = kzalloc(3 * nla_total_size(4), GFP_KERNEL);
570+ mx = kcalloc(3, nla_total_size(4), GFP_KERNEL);
571571 if (!mx)
572572 return -ENOMEM;
573573
net/ipv4/route.c+3−2
@@ -649,7 +649,7 @@ static void update_or_create_fnhe(struct fib_nh *nh, __be32 daddr, __be32 gw, · 648 unmodified lines
649649
650650 hash = rcu_dereference(nh->nh_exceptions);
651651 if (!hash) {
652− hash = kzalloc(FNHE_HASH_SIZE * sizeof(*hash), GFP_ATOMIC);
652+ hash = kcalloc(FNHE_HASH_SIZE, sizeof(*hash), GFP_ATOMIC);
653653 if (!hash)
654654 goto out_unlock;
655655 rcu_assign_pointer(nh->nh_exceptions, hash);
@@ -3146,7 +3146,8 @@ int __init ip_rt_init(void) · 2490 unmodified lines
31463146 {
31473147 int cpu;
31483148
3149− ip_idents = kmalloc(IP_IDENTS_SZ * sizeof(*ip_idents), GFP_KERNEL);
3149+ ip_idents = kmalloc_array(IP_IDENTS_SZ, sizeof(*ip_idents),
3150+ GFP_KERNEL);
31503151 if (!ip_idents)
31513152 panic("IP: failed to allocate ip_idents\n");
31523153
net/ipv6/icmp.c+1−1
@@ -956,7 +956,7 @@ static int __net_init icmpv6_sk_init(struct net *net) · 955 unmodified lines
956956 int err, i, j;
957957
958958 net->ipv6.icmp_sk =
959− kzalloc(nr_cpu_ids * sizeof(struct sock *), GFP_KERNEL);
959+ kcalloc(nr_cpu_ids, sizeof(struct sock *), GFP_KERNEL);
960960 if (!net->ipv6.icmp_sk)
961961 return -ENOMEM;
962962
net/ipv6/ila/ila_xlat.c+2−1
@@ -42,7 +42,8 @@ static int alloc_ila_locks(struct ila_net *ilan) · 41 unmodified lines
4242 size = roundup_pow_of_two(nr_pcpus * LOCKS_PER_CPU);
4343
4444 if (sizeof(spinlock_t) != 0) {
45− ilan->locks = kvmalloc(size * sizeof(spinlock_t), GFP_KERNEL);
45+ ilan->locks = kvmalloc_array(size, sizeof(spinlock_t),
46+ GFP_KERNEL);
4647 if (!ilan->locks)
4748 return -ENOMEM;
4849 for (i = 0; i < size; i++)
net/mac80211/chan.c+1−1
@@ -1186,7 +1186,7 @@ static int ieee80211_chsw_switch_vifs(struct ieee80211_local *local, · 1185 unmodified lines
11861186 lockdep_assert_held(&local->mtx);
11871187 lockdep_assert_held(&local->chanctx_mtx);
11881188
1189− vif_chsw = kzalloc(sizeof(vif_chsw[0]) * n_vifs, GFP_KERNEL);
1189+ vif_chsw = kcalloc(n_vifs, sizeof(vif_chsw[0]), GFP_KERNEL);
11901190 if (!vif_chsw)
11911191 return -ENOMEM;
11921192
net/mac80211/main.c+1−1
@@ -772,7 +772,7 @@ static int ieee80211_init_cipher_suites(struct ieee80211_local *local) · 771 unmodified lines
772772 if (have_mfp)
773773 n_suites += 4;
774774
775− suites = kmalloc(sizeof(u32) * n_suites, GFP_KERNEL);
775+ suites = kmalloc_array(n_suites, sizeof(u32), GFP_KERNEL);
776776 if (!suites)
777777 return -ENOMEM;
778778
net/mac80211/rc80211_minstrel.c+2−2
@@ -592,11 +592,11 @@ minstrel_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) · 591 unmodified lines
592592 max_rates = sband->n_bitrates;
593593 }
594594
595− mi->r = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp);
595+ mi->r = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
596596 if (!mi->r)
597597 goto error;
598598
599− mi->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp);
599+ mi->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
600600 if (!mi->sample_table)
601601 goto error1;
602602
net/mac80211/rc80211_minstrel_ht.c+2−2
@@ -1313,11 +1313,11 @@ minstrel_ht_alloc_sta(void *priv, struct ieee80211_sta *sta, gfp_t gfp) · 1312 unmodified lines
13131313 if (!msp)
13141314 return NULL;
13151315
1316− msp->ratelist = kzalloc(sizeof(struct minstrel_rate) * max_rates, gfp);
1316+ msp->ratelist = kcalloc(max_rates, sizeof(struct minstrel_rate), gfp);
13171317 if (!msp->ratelist)
13181318 goto error;
13191319
1320− msp->sample_table = kmalloc(SAMPLE_COLUMNS * max_rates, gfp);
1320+ msp->sample_table = kmalloc_array(max_rates, SAMPLE_COLUMNS, gfp);
13211321 if (!msp->sample_table)
13221322 goto error1;
13231323
net/mac80211/scan.c+1−1
@@ -1157,7 +1157,7 @@ int __ieee80211_request_sched_scan_start(struct ieee80211_sub_if_data *sdata, · 1156 unmodified lines
11571157 }
11581158 }
11591159
1160− ie = kzalloc(num_bands * iebufsz, GFP_KERNEL);
1160+ ie = kcalloc(iebufsz, num_bands, GFP_KERNEL);
11611161 if (!ie) {
11621162 ret = -ENOMEM;
11631163 goto out;
net/mac80211/util.c+3−2
@@ -1803,8 +1803,9 @@ static int ieee80211_reconfig_nan(struct ieee80211_sub_if_data *sdata) · 1802 unmodified lines
18031803 if (WARN_ON(res))
18041804 return res;
18051805
1806− funcs = kzalloc((sdata->local->hw.max_nan_de_entries + 1) *
1807− sizeof(*funcs), GFP_KERNEL);
1806+ funcs = kcalloc(sdata->local->hw.max_nan_de_entries + 1,
1807+ sizeof(*funcs),
1808+ GFP_KERNEL);
18081809 if (!funcs)
18091810 return -ENOMEM;
18101811
net/netfilter/ipvs/ip_vs_conn.c+2−1
@@ -1380,7 +1380,8 @@ int __init ip_vs_conn_init(void) · 1379 unmodified lines
13801380 /*
13811381 * Allocate the connection hash table and initialize its list heads
13821382 */
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)));
13841385 if (!ip_vs_conn_tab)
13851386 return -ENOMEM;
13861387
net/netfilter/nf_conntrack_proto.c+2−1
@@ -402,7 +402,8 @@ int nf_ct_l4proto_register_one(const struct nf_conntrack_l4proto *l4proto) · 401 unmodified lines
402402 struct nf_conntrack_l4proto __rcu **proto_array;
403403 int i;
404404
405− proto_array = kmalloc(MAX_NF_CT_PROTO *
405+ proto_array =
406+ kmalloc_array(MAX_NF_CT_PROTO,
406407 sizeof(struct nf_conntrack_l4proto *),
407408 GFP_KERNEL);
408409 if (proto_array == NULL) {
net/netfilter/nf_nat_core.c+3−2
@@ -691,8 +691,9 @@ int nf_nat_l4proto_register(u8 l3proto, const struct nf_nat_l4proto *l4proto) · 690 unmodified lines
691691
692692 mutex_lock(&nf_nat_proto_mutex);
693693 if (nf_nat_l4protos[l3proto] == NULL) {
694− l4protos = kmalloc(IPPROTO_MAX * sizeof(struct nf_nat_l4proto *),
695− GFP_KERNEL);
694+ l4protos = kmalloc_array(IPPROTO_MAX,
695+ sizeof(struct nf_nat_l4proto *),
696+ GFP_KERNEL);
696697 if (l4protos == NULL) {
697698 ret = -ENOMEM;
698699 goto out;
net/netfilter/nf_tables_api.c+3−3
@@ -5303,7 +5303,7 @@ static int nf_tables_flowtable_parse_hook(const struct nft_ctx *ctx, · 5302 unmodified lines
53035303 if (err < 0)
53045304 return err;
53055305
5306− ops = kzalloc(sizeof(struct nf_hook_ops) * n, GFP_KERNEL);
5306+ ops = kcalloc(n, sizeof(struct nf_hook_ops), GFP_KERNEL);
53075307 if (!ops)
53085308 return -ENOMEM;
53095309
@@ -7164,8 +7164,8 @@ static int __init nf_tables_module_init(void) · 1854 unmodified lines
71647164
71657165 nft_chain_filter_init();
71667166
7167− info = kmalloc(sizeof(struct nft_expr_info) * NFT_RULE_MAXEXPRS,
7168− GFP_KERNEL);
7167+ info = kmalloc_array(NFT_RULE_MAXEXPRS, sizeof(struct nft_expr_info),
7168+ GFP_KERNEL);
71697169 if (info == NULL) {
71707170 err = -ENOMEM;
71717171 goto err1;
net/netfilter/nfnetlink_cthelper.c+3−2
@@ -190,8 +190,9 @@ nfnl_cthelper_parse_expect_policy(struct nf_conntrack_helper *helper, · 189 unmodified lines
190190 if (class_max > NF_CT_MAX_EXPECT_CLASSES)
191191 return -EOVERFLOW;
192192
193− expect_policy = kzalloc(sizeof(struct nf_conntrack_expect_policy) *
194− class_max, GFP_KERNEL);
193+ expect_policy = kcalloc(class_max,
194+ sizeof(struct nf_conntrack_expect_policy),
195+ GFP_KERNEL);
195196 if (expect_policy == NULL)
196197 return -ENOMEM;
197198
net/netfilter/x_tables.c+1−1
@@ -1904,7 +1904,7 @@ static int __init xt_init(void) · 1903 unmodified lines
19041904 seqcount_init(&per_cpu(xt_recseq, i));
19051905 }
19061906
1907− xt = kmalloc(sizeof(struct xt_af) * NFPROTO_NUMPROTO, GFP_KERNEL);
1907+ xt = kmalloc_array(NFPROTO_NUMPROTO, sizeof(struct xt_af), GFP_KERNEL);
19081908 if (!xt)
19091909 return -ENOMEM;
19101910
net/netlink/genetlink.c+6−4
@@ -352,8 +352,9 @@ int genl_register_family(struct genl_family *family) · 351 unmodified lines
352352 }
353353
354354 if (family->maxattr && !family->parallel_ops) {
355− family->attrbuf = kmalloc((family->maxattr+1) *
356− sizeof(struct nlattr *), GFP_KERNEL);
355+ family->attrbuf = kmalloc_array(family->maxattr + 1,
356+ sizeof(struct nlattr *),
357+ GFP_KERNEL);
357358 if (family->attrbuf == NULL) {
358359 err = -ENOMEM;
359360 goto errout_locked;
@@ -566,8 +567,9 @@ static int genl_family_rcv_msg(const struct genl_family *family, · 206 unmodified lines
566567 return -EOPNOTSUPP;
567568
568569 if (family->maxattr && family->parallel_ops) {
569− attrbuf = kmalloc((family->maxattr+1) *
570− sizeof(struct nlattr *), GFP_KERNEL);
570+ attrbuf = kmalloc_array(family->maxattr + 1,
571+ sizeof(struct nlattr *),
572+ GFP_KERNEL);
571573 if (attrbuf == NULL)
572574 return -ENOMEM;
573575 } else
net/netrom/af_netrom.c+1−1
@@ -1395,7 +1395,7 @@ static int __init nr_proto_init(void) · 1394 unmodified lines
13951395 return -1;
13961396 }
13971397
1398− dev_nr = kzalloc(nr_ndevs * sizeof(struct net_device *), GFP_KERNEL);
1398+ dev_nr = kcalloc(nr_ndevs, sizeof(struct net_device *), GFP_KERNEL);
13991399 if (dev_nr == NULL) {
14001400 printk(KERN_ERR "NET/ROM: nr_proto_init - unable to allocate device array\n");
14011401 return -1;
net/openvswitch/datapath.c+3−2
@@ -1578,8 +1578,9 @@ static int ovs_dp_cmd_new(struct sk_buff *skb, struct genl_info *info) · 1577 unmodified lines
15781578 goto err_destroy_table;
15791579 }
15801580
1581− dp->ports = kmalloc(DP_VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
1582− GFP_KERNEL);
1581+ dp->ports = kmalloc_array(DP_VPORT_HASH_BUCKETS,
1582+ sizeof(struct hlist_head),
1583+ GFP_KERNEL);
15831584 if (!dp->ports) {
15841585 err = -ENOMEM;
15851586 goto err_destroy_percpu;
net/openvswitch/vport.c+1−1
@@ -47,7 +47,7 @@ static struct hlist_head *dev_table; · 46 unmodified lines
4747 */
4848 int ovs_vport_init(void)
4949 {
50− dev_table = kzalloc(VPORT_HASH_BUCKETS * sizeof(struct hlist_head),
50+ dev_table = kcalloc(VPORT_HASH_BUCKETS, sizeof(struct hlist_head),
5151 GFP_KERNEL);
5252 if (!dev_table)
5353 return -ENOMEM;
net/packet/af_packet.c+1−1
@@ -4161,7 +4161,7 @@ static char *alloc_one_pg_vec_page(unsigned long order) · 4160 unmodified lines
41614161 return buffer;
41624162
41634163 /* __get_free_pages failed, fall back to vmalloc */
4164− buffer = vzalloc((1 << order) * PAGE_SIZE);
4164+ buffer = vzalloc(array_size((1 << order), PAGE_SIZE));
41654165 if (buffer)
41664166 return buffer;
41674167
net/rds/ib.c+2−1
@@ -163,7 +163,8 @@ static void rds_ib_add_one(struct ib_device *device) · 162 unmodified lines
163163 rds_ibdev->max_initiator_depth = device->attrs.max_qp_init_rd_atom;
164164 rds_ibdev->max_responder_resources = device->attrs.max_qp_rd_atom;
165165
166− rds_ibdev->vector_load = kzalloc(sizeof(int) * device->num_comp_vectors,
166+ rds_ibdev->vector_load = kcalloc(device->num_comp_vectors,
167+ sizeof(int),
167168 GFP_KERNEL);
168169 if (!rds_ibdev->vector_load) {
169170 pr_err("RDS/IB: %s failed to allocate vector memory\n",
net/rds/ib_cm.c+4−2
@@ -526,7 +526,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn) · 525 unmodified lines
526526 goto recv_hdrs_dma_out;
527527 }
528528
529− ic->i_sends = vzalloc_node(ic->i_send_ring.w_nr * sizeof(struct rds_ib_send_work),
529+ ic->i_sends = vzalloc_node(array_size(sizeof(struct rds_ib_send_work),
530+ ic->i_send_ring.w_nr),
530531 ibdev_to_node(dev));
531532 if (!ic->i_sends) {
532533 ret = -ENOMEM;
@@ -534,7 +535,8 @@ static int rds_ib_setup_qp(struct rds_connection *conn) · 1 unmodified line
534535 goto ack_dma_out;
535536 }
536537
537− ic->i_recvs = vzalloc_node(ic->i_recv_ring.w_nr * sizeof(struct rds_ib_recv_work),
538+ ic->i_recvs = vzalloc_node(array_size(sizeof(struct rds_ib_recv_work),
539+ ic->i_recv_ring.w_nr),
538540 ibdev_to_node(dev));
539541 if (!ic->i_recvs) {
540542 ret = -ENOMEM;
net/rds/info.c+1−1
@@ -188,7 +188,7 @@ int rds_info_getsockopt(struct socket *sock, int optname, char __user *optval, · 187 unmodified lines
188188 nr_pages = (PAGE_ALIGN(start + len) - (start & PAGE_MASK))
189189 >> PAGE_SHIFT;
190190
191− pages = kmalloc(nr_pages * sizeof(struct page *), GFP_KERNEL);
191+ pages = kmalloc_array(nr_pages, sizeof(struct page *), GFP_KERNEL);
192192 if (!pages) {
193193 ret = -ENOMEM;
194194 goto out;
net/rose/af_rose.c+2−1
@@ -1514,7 +1514,8 @@ static int __init rose_proto_init(void) · 1513 unmodified lines
15141514
15151515 rose_callsign = null_ax25_address;
15161516
1517− dev_rose = kzalloc(rose_ndevs * sizeof(struct net_device *), GFP_KERNEL);
1517+ dev_rose = kcalloc(rose_ndevs, sizeof(struct net_device *),
1518+ GFP_KERNEL);
15181519 if (dev_rose == NULL) {
15191520 printk(KERN_ERR "ROSE: rose_proto_init - unable to allocate device structure\n");
15201521 rc = -ENOMEM;
net/rxrpc/rxkad.c+1−1
@@ -432,7 +432,7 @@ static int rxkad_verify_packet_2(struct rxrpc_call *call, struct sk_buff *skb, · 431 unmodified lines
432432
433433 sg = _sg;
434434 if (unlikely(nsg > 4)) {
435− sg = kmalloc(sizeof(*sg) * nsg, GFP_NOIO);
435+ sg = kmalloc_array(nsg, sizeof(*sg), GFP_NOIO);
436436 if (!sg)
437437 goto nomem;
438438 }
net/sched/sch_fq_codel.c+4−3
@@ -489,11 +489,12 @@ static int fq_codel_init(struct Qdisc *sch, struct nlattr *opt, · 488 unmodified lines
489489 return err;
490490
491491 if (!q->flows) {
492− q->flows = kvzalloc(q->flows_cnt *
493− sizeof(struct fq_codel_flow), GFP_KERNEL);
492+ q->flows = kvcalloc(q->flows_cnt,
493+ sizeof(struct fq_codel_flow),
494+ GFP_KERNEL);
494495 if (!q->flows)
495496 return -ENOMEM;
496− q->backlogs = kvzalloc(q->flows_cnt * sizeof(u32), GFP_KERNEL);
497+ q->backlogs = kvcalloc(q->flows_cnt, sizeof(u32), GFP_KERNEL);
497498 if (!q->backlogs)
498499 return -ENOMEM;
499500 for (i = 0; i < q->flows_cnt; i++) {
net/sched/sch_hhf.c+5−4
@@ -599,8 +599,8 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, · 598 unmodified lines
599599
600600 if (!q->hh_flows) {
601601 /* Initialize heavy-hitter flow table. */
602− q->hh_flows = kvzalloc(HH_FLOWS_CNT *
603− sizeof(struct list_head), GFP_KERNEL);
602+ q->hh_flows = kvcalloc(HH_FLOWS_CNT, sizeof(struct list_head),
603+ GFP_KERNEL);
604604 if (!q->hh_flows)
605605 return -ENOMEM;
606606 for (i = 0; i < HH_FLOWS_CNT; i++)
@@ -614,8 +614,9 @@ static int hhf_init(struct Qdisc *sch, struct nlattr *opt, · 7 unmodified lines
614614
615615 /* Initialize heavy-hitter filter arrays. */
616616 for (i = 0; i < HHF_ARRAYS_CNT; i++) {
617− q->hhf_arrays[i] = kvzalloc(HHF_ARRAYS_LEN *
618− sizeof(u32), GFP_KERNEL);
617+ q->hhf_arrays[i] = kvcalloc(HHF_ARRAYS_LEN,
618+ sizeof(u32),
619+ GFP_KERNEL);
619620 if (!q->hhf_arrays[i]) {
620621 /* Note: hhf_destroy() will be called
621622 * by our caller.
net/sctp/auth.c+3−2
@@ -482,8 +482,9 @@ int sctp_auth_init_hmacs(struct sctp_endpoint *ep, gfp_t gfp) · 481 unmodified lines
482482 return 0;
483483
484484 /* Allocated the array of pointers to transorms */
485− ep->auth_hmacs = kzalloc(sizeof(struct crypto_shash *) *
486− SCTP_AUTH_NUM_HMACS, gfp);
485+ ep->auth_hmacs = kcalloc(SCTP_AUTH_NUM_HMACS,
486+ sizeof(struct crypto_shash *),
487+ gfp);
487488 if (!ep->auth_hmacs)
488489 return -ENOMEM;
489490
net/sctp/protocol.c+1−1
@@ -1438,7 +1438,7 @@ static __init int sctp_init(void) · 1437 unmodified lines
14381438 /* Allocate and initialize the endpoint hash table. */
14391439 sctp_ep_hashsize = 64;
14401440 sctp_ep_hashtable =
1441− kmalloc(64 * sizeof(struct sctp_hashbucket), GFP_KERNEL);
1441+ kmalloc_array(64, sizeof(struct sctp_hashbucket), GFP_KERNEL);
14421442 if (!sctp_ep_hashtable) {
14431443 pr_err("Failed endpoint_hash alloc\n");
14441444 status = -ENOMEM;
net/smc/smc_wr.c+3−3
@@ -584,9 +584,9 @@ int smc_wr_alloc_link_mem(struct smc_link *link) · 583 unmodified lines
584584 GFP_KERNEL);
585585 if (!link->wr_rx_sges)
586586 goto no_mem_wr_tx_sges;
587− link->wr_tx_mask = kzalloc(
588− BITS_TO_LONGS(SMC_WR_BUF_CNT) * sizeof(*link->wr_tx_mask),
589− GFP_KERNEL);
587+ link->wr_tx_mask = kcalloc(BITS_TO_LONGS(SMC_WR_BUF_CNT),
588+ sizeof(*link->wr_tx_mask),
589+ GFP_KERNEL);
590590 if (!link->wr_tx_mask)
591591 goto no_mem_wr_rx_sges;
592592 link->wr_tx_pends = kcalloc(SMC_WR_BUF_CNT,
net/sunrpc/auth_gss/auth_gss.c+2−1
@@ -1753,7 +1753,8 @@ alloc_enc_pages(struct rpc_rqst *rqstp) · 1752 unmodified lines
17531753 last = (snd_buf->page_base + snd_buf->page_len - 1) >> PAGE_SHIFT;
17541754 rqstp->rq_enc_pages_num = last - first + 1 + 1;
17551755 rqstp->rq_enc_pages
1756− = kmalloc(rqstp->rq_enc_pages_num * sizeof(struct page *),
1756+ = kmalloc_array(rqstp->rq_enc_pages_num,
1757+ sizeof(struct page *),
17571758 GFP_NOFS);
17581759 if (!rqstp->rq_enc_pages)
17591760 goto out;
net/sunrpc/auth_gss/gss_rpc_upcall.c+1−1
@@ -224,7 +224,7 @@ static void gssp_free_receive_pages(struct gssx_arg_accept_sec_context *arg) · 223 unmodified lines
224224 static int gssp_alloc_receive_pages(struct gssx_arg_accept_sec_context *arg)
225225 {
226226 arg->npages = DIV_ROUND_UP(NGROUPS_MAX * 4, PAGE_SIZE);
227− arg->pages = kzalloc(arg->npages * sizeof(struct page *), GFP_KERNEL);
227+ arg->pages = kcalloc(arg->npages, sizeof(struct page *), GFP_KERNEL);
228228 /*
229229 * XXX: actual pages are allocated by xdr layer in
230230 * xdr_partial_copy_from_skb.
net/sunrpc/cache.c+1−1
@@ -1683,7 +1683,7 @@ struct cache_detail *cache_create_net(const struct cache_detail *tmpl, struct ne · 1682 unmodified lines
16831683 if (cd == NULL)
16841684 return ERR_PTR(-ENOMEM);
16851685
1686− cd->hash_table = kzalloc(cd->hash_size * sizeof(struct hlist_head),
1686+ cd->hash_table = kcalloc(cd->hash_size, sizeof(struct hlist_head),
16871687 GFP_KERNEL);
16881688 if (cd->hash_table == NULL) {
16891689 kfree(cd);
net/tipc/netlink_compat.c+3−2
@@ -285,8 +285,9 @@ static int __tipc_nl_compat_doit(struct tipc_nl_compat_cmd_doit *cmd, · 284 unmodified lines
285285 if (!trans_buf)
286286 return -ENOMEM;
287287
288− attrbuf = kmalloc((tipc_genl_family.maxattr + 1) *
289− sizeof(struct nlattr *), GFP_KERNEL);
288+ attrbuf = kmalloc_array(tipc_genl_family.maxattr + 1,
289+ sizeof(struct nlattr *),
290+ GFP_KERNEL);
290291 if (!attrbuf) {
291292 err = -ENOMEM;
292293 goto trans_out;
net/wireless/nl80211.c+2−2
@@ -10833,7 +10833,7 @@ static int nl80211_parse_wowlan_nd(struct cfg80211_registered_device *rdev, · 10832 unmodified lines
1083310833 struct nlattr **tb;
1083410834 int err;
1083510835
10836− tb = kzalloc(NUM_NL80211_ATTR * sizeof(*tb), GFP_KERNEL);
10836+ tb = kcalloc(NUM_NL80211_ATTR, sizeof(*tb), GFP_KERNEL);
1083710837 if (!tb)
1083810838 return -ENOMEM;
1083910839
@@ -11793,7 +11793,7 @@ static int nl80211_nan_add_func(struct sk_buff *skb, · 953 unmodified lines
1179311793
1179411794 func->srf_num_macs = n_entries;
1179511795 func->srf_macs =
11796− kzalloc(sizeof(*func->srf_macs) * n_entries,
11796+ kcalloc(n_entries, sizeof(*func->srf_macs),
1179711797 GFP_KERNEL);
1179811798 if (!func->srf_macs) {
1179911799 err = -ENOMEM;
security/apparmor/policy_unpack.c+1−1
@@ -475,7 +475,7 @@ static bool unpack_trans_table(struct aa_ext *e, struct aa_profile *profile) · 474 unmodified lines
475475 /* currently 4 exec bits and entries 0-3 are reserved iupcx */
476476 if (size > 16 - 4)
477477 goto fail;
478− profile->file.trans.table = kzalloc(sizeof(char *) * size,
478+ profile->file.trans.table = kcalloc(size, sizeof(char *),
479479 GFP_KERNEL);
480480 if (!profile->file.trans.table)
481481 goto fail;
security/keys/trusted.c+1−1
@@ -1148,7 +1148,7 @@ static long trusted_read(const struct key *key, char __user *buffer, · 1147 unmodified lines
11481148 return -EINVAL;
11491149
11501150 if (buffer && buflen >= 2 * p->blob_len) {
1151− ascii_buf = kmalloc(2 * p->blob_len, GFP_KERNEL);
1151+ ascii_buf = kmalloc_array(2, p->blob_len, GFP_KERNEL);
11521152 if (!ascii_buf)
11531153 return -ENOMEM;
11541154
security/selinux/ss/services.c+1−1
@@ -2118,7 +2118,7 @@ int security_load_policy(struct selinux_state *state, void *data, size_t len) · 2117 unmodified lines
21182118 int rc = 0;
21192119 struct policy_file file = { data, len }, *fp = &file;
21202120
2121− oldpolicydb = kzalloc(2 * sizeof(*oldpolicydb), GFP_KERNEL);
2121+ oldpolicydb = kcalloc(2, sizeof(*oldpolicydb), GFP_KERNEL);
21222122 if (!oldpolicydb) {
21232123 rc = -ENOMEM;
21242124 goto out;
sound/core/pcm_compat.c+1−1
@@ -426,7 +426,7 @@ static int snd_pcm_ioctl_xfern_compat(struct snd_pcm_substream *substream, · 425 unmodified lines
426426 get_user(frames, &data32->frames))
427427 return -EFAULT;
428428 bufptr = compat_ptr(buf);
429− bufs = kmalloc(sizeof(void __user *) * ch, GFP_KERNEL);
429+ bufs = kmalloc_array(ch, sizeof(void __user *), GFP_KERNEL);
430430 if (bufs == NULL)
431431 return -ENOMEM;
432432 for (i = 0; i < ch; i++) {
sound/core/pcm_native.c+2−2
@@ -3072,7 +3072,7 @@ static ssize_t snd_pcm_readv(struct kiocb *iocb, struct iov_iter *to) · 3071 unmodified lines
30723072 if (!frame_aligned(runtime, to->iov->iov_len))
30733073 return -EINVAL;
30743074 frames = bytes_to_samples(runtime, to->iov->iov_len);
3075− bufs = kmalloc(sizeof(void *) * to->nr_segs, GFP_KERNEL);
3075+ bufs = kmalloc_array(to->nr_segs, sizeof(void *), GFP_KERNEL);
30763076 if (bufs == NULL)
30773077 return -ENOMEM;
30783078 for (i = 0; i < to->nr_segs; ++i)
@@ -3107,7 +3107,7 @@ static ssize_t snd_pcm_writev(struct kiocb *iocb, struct iov_iter *from) · 28 unmodified lines
31073107 !frame_aligned(runtime, from->iov->iov_len))
31083108 return -EINVAL;
31093109 frames = bytes_to_samples(runtime, from->iov->iov_len);
3110− bufs = kmalloc(sizeof(void *) * from->nr_segs, GFP_KERNEL);
3110+ bufs = kmalloc_array(from->nr_segs, sizeof(void *), GFP_KERNEL);
31113111 if (bufs == NULL)
31123112 return -ENOMEM;
31133113 for (i = 0; i < from->nr_segs; ++i)
sound/core/seq/seq_memory.c+2−1
@@ -389,7 +389,8 @@ int snd_seq_pool_init(struct snd_seq_pool *pool) · 388 unmodified lines
389389 if (snd_BUG_ON(!pool))
390390 return -EINVAL;
391391
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));
393394 if (!cellptr)
394395 return -ENOMEM;
395396
sound/core/seq/seq_midi_emul.c+1−1
@@ -657,7 +657,7 @@ static struct snd_midi_channel *snd_midi_channel_init_set(int n) · 656 unmodified lines
657657 struct snd_midi_channel *chan;
658658 int i;
659659
660− chan = kmalloc(n * sizeof(struct snd_midi_channel), GFP_KERNEL);
660+ chan = kmalloc_array(n, sizeof(struct snd_midi_channel), GFP_KERNEL);
661661 if (chan) {
662662 for (i = 0; i < n; i++)
663663 snd_midi_channel_init(chan+i, i);
sound/firewire/fireface/ff-protocol-ff400.c+1−1
@@ -147,7 +147,7 @@ static int ff400_switch_fetching_mode(struct snd_ff *ff, bool enable) · 146 unmodified lines
147147 __le32 *reg;
148148 int i;
149149
150− reg = kzalloc(sizeof(__le32) * 18, GFP_KERNEL);
150+ reg = kcalloc(18, sizeof(__le32), GFP_KERNEL);
151151 if (reg == NULL)
152152 return -ENOMEM;
153153
sound/firewire/packets-buffer.c+1−1
@@ -27,7 +27,7 @@ int iso_packets_buffer_init(struct iso_packets_buffer *b, struct fw_unit *unit, · 26 unmodified lines
2727 void *p;
2828 int err;
2929
30− b->packets = kmalloc(count * sizeof(*b->packets), GFP_KERNEL);
30+ b->packets = kmalloc_array(count, sizeof(*b->packets), GFP_KERNEL);
3131 if (!b->packets) {
3232 err = -ENOMEM;
3333 goto error;
sound/oss/dmasound/dmasound_core.c+1−1
@@ -420,7 +420,7 @@ static int sq_allocate_buffers(struct sound_queue *sq, int num, int size) · 419 unmodified lines
420420 return 0;
421421 sq->numBufs = num;
422422 sq->bufSize = size;
423− sq->buffers = kmalloc (num * sizeof(char *), GFP_KERNEL);
423+ sq->buffers = kmalloc_array (num, sizeof(char *), GFP_KERNEL);
424424 if (!sq->buffers)
425425 return -ENOMEM;
426426 for (i = 0; i < num; i++) {
sound/pci/cs46xx/cs46xx_lib.c+4−3
@@ -460,7 +460,7 @@ static int load_firmware(struct snd_cs46xx *chip, · 459 unmodified lines
460460 entry->size = le32_to_cpu(fwdat[fwlen++]);
461461 if (fwlen + entry->size > fwsize)
462462 goto error_inval;
463− entry->data = kmalloc(entry->size * 4, GFP_KERNEL);
463+ entry->data = kmalloc_array(entry->size, 4, GFP_KERNEL);
464464 if (!entry->data)
465465 goto error;
466466 memcpy_le32(entry->data, &fwdat[fwlen], entry->size * 4);
@@ -4036,8 +4036,9 @@ int snd_cs46xx_create(struct snd_card *card, · 3569 unmodified lines
40364036 snd_cs46xx_proc_init(card, chip);
40374037
40384038 #ifdef CONFIG_PM_SLEEP
4039− chip->saved_regs = kmalloc(sizeof(*chip->saved_regs) *
4040− ARRAY_SIZE(saved_regs), GFP_KERNEL);
4039+ chip->saved_regs = kmalloc_array(ARRAY_SIZE(saved_regs),
4040+ sizeof(*chip->saved_regs),
4041+ GFP_KERNEL);
40414042 if (!chip->saved_regs) {
40424043 snd_cs46xx_free(chip);
40434044 return -ENOMEM;
sound/pci/cs46xx/dsp_spos.c+6−3
@@ -240,10 +240,13 @@ struct dsp_spos_instance *cs46xx_dsp_spos_create (struct snd_cs46xx * chip) · 239 unmodified lines
240240 return NULL;
241241
242242 /* better to use vmalloc for this big table */
243− ins->symbol_table.symbols = vmalloc(sizeof(struct dsp_symbol_entry) *
244− DSP_MAX_SYMBOLS);
243+ ins->symbol_table.symbols =
244+ vmalloc(array_size(DSP_MAX_SYMBOLS,
245+ sizeof(struct dsp_symbol_entry)));
245246 ins->code.data = kmalloc(DSP_CODE_BYTE_SIZE, GFP_KERNEL);
246− ins->modules = kmalloc(sizeof(struct dsp_module_desc) * DSP_MAX_MODULES, GFP_KERNEL);
247+ ins->modules = kmalloc_array(DSP_MAX_MODULES,
248+ sizeof(struct dsp_module_desc),
249+ GFP_KERNEL);
247250 if (!ins->symbol_table.symbols || !ins->code.data || !ins->modules) {
248251 cs46xx_dsp_spos_destroy(chip);
249252 goto error;
sound/pci/ctxfi/ctatc.c+9−9
@@ -275,7 +275,7 @@ static int atc_pcm_playback_prepare(struct ct_atc *atc, struct ct_atc_pcm *apcm) · 274 unmodified lines
275275
276276 /* Get AMIXER resource */
277277 n_amixer = (n_amixer < 2) ? 2 : n_amixer;
278− apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
278+ apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
279279 if (!apcm->amixers) {
280280 err = -ENOMEM;
281281 goto error1;
@@ -543,18 +543,18 @@ atc_pcm_capture_get_resources(struct ct_atc *atc, struct ct_atc_pcm *apcm) · 261 unmodified lines
543543 }
544544
545545 if (n_srcc) {
546− apcm->srccs = kzalloc(sizeof(void *)*n_srcc, GFP_KERNEL);
546+ apcm->srccs = kcalloc(n_srcc, sizeof(void *), GFP_KERNEL);
547547 if (!apcm->srccs)
548548 return -ENOMEM;
549549 }
550550 if (n_amixer) {
551− apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
551+ apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
552552 if (!apcm->amixers) {
553553 err = -ENOMEM;
554554 goto error1;
555555 }
556556 }
557− apcm->srcimps = kzalloc(sizeof(void *)*n_srcimp, GFP_KERNEL);
557+ apcm->srcimps = kcalloc(n_srcimp, sizeof(void *), GFP_KERNEL);
558558 if (!apcm->srcimps) {
559559 err = -ENOMEM;
560560 goto error1;
@@ -819,7 +819,7 @@ static int spdif_passthru_playback_get_resources(struct ct_atc *atc, · 258 unmodified lines
819819
820820 /* Get AMIXER resource */
821821 n_amixer = (n_amixer < 2) ? 2 : n_amixer;
822− apcm->amixers = kzalloc(sizeof(void *)*n_amixer, GFP_KERNEL);
822+ apcm->amixers = kcalloc(n_amixer, sizeof(void *), GFP_KERNEL);
823823 if (!apcm->amixers) {
824824 err = -ENOMEM;
825825 goto error1;
@@ -1378,19 +1378,19 @@ static int atc_get_resources(struct ct_atc *atc) · 552 unmodified lines
13781378 num_daios = ((atc->model == CTSB1270) ? 8 : 7);
13791379 num_srcs = ((atc->model == CTSB1270) ? 6 : 4);
13801380
1381− atc->daios = kzalloc(sizeof(void *)*num_daios, GFP_KERNEL);
1381+ atc->daios = kcalloc(num_daios, sizeof(void *), GFP_KERNEL);
13821382 if (!atc->daios)
13831383 return -ENOMEM;
13841384
1385− atc->srcs = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
1385+ atc->srcs = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
13861386 if (!atc->srcs)
13871387 return -ENOMEM;
13881388
1389− atc->srcimps = kzalloc(sizeof(void *)*num_srcs, GFP_KERNEL);
1389+ atc->srcimps = kcalloc(num_srcs, sizeof(void *), GFP_KERNEL);
13901390 if (!atc->srcimps)
13911391 return -ENOMEM;
13921392
1393− atc->pcm = kzalloc(sizeof(void *)*(2*4), GFP_KERNEL);
1393+ atc->pcm = kcalloc(2 * 4, sizeof(void *), GFP_KERNEL);
13941394 if (!atc->pcm)
13951395 return -ENOMEM;
13961396
sound/pci/ctxfi/ctdaio.c+2−1
@@ -398,7 +398,8 @@ static int dao_rsc_init(struct dao *dao, · 397 unmodified lines
398398 if (err)
399399 return err;
400400
401− dao->imappers = kzalloc(sizeof(void *)*desc->msr*2, GFP_KERNEL);
401+ dao->imappers = kzalloc(array3_size(sizeof(void *), desc->msr, 2),
402+ GFP_KERNEL);
402403 if (!dao->imappers) {
403404 err = -ENOMEM;
404405 goto error1;
sound/pci/ctxfi/ctmixer.c+3−2
@@ -910,13 +910,14 @@ static int ct_mixer_get_mem(struct ct_mixer **rmixer) · 909 unmodified lines
910910 if (!mixer)
911911 return -ENOMEM;
912912
913− mixer->amixers = kzalloc(sizeof(void *)*(NUM_CT_AMIXERS*CHN_NUM),
913+ mixer->amixers = kcalloc(NUM_CT_AMIXERS * CHN_NUM, sizeof(void *),
914914 GFP_KERNEL);
915915 if (!mixer->amixers) {
916916 err = -ENOMEM;
917917 goto error1;
918918 }
919− mixer->sums = kzalloc(sizeof(void *)*(NUM_CT_SUMS*CHN_NUM), GFP_KERNEL);
919+ mixer->sums = kcalloc(NUM_CT_SUMS * CHN_NUM, sizeof(void *),
920+ GFP_KERNEL);
920921 if (!mixer->sums) {
921922 err = -ENOMEM;
922923 goto error2;
sound/pci/ctxfi/ctsrc.c+1−1
@@ -679,7 +679,7 @@ static int srcimp_rsc_init(struct srcimp *srcimp, · 678 unmodified lines
679679 return err;
680680
681681 /* Reserve memory for imapper nodes */
682− srcimp->imappers = kzalloc(sizeof(struct imapper)*desc->msr,
682+ srcimp->imappers = kcalloc(desc->msr, sizeof(struct imapper),
683683 GFP_KERNEL);
684684 if (!srcimp->imappers) {
685685 err = -ENOMEM;
sound/pci/emu10k1/emu10k1_main.c+5−4
@@ -1941,9 +1941,10 @@ int snd_emu10k1_create(struct snd_card *card, · 1940 unmodified lines
19411941 (unsigned long)emu->ptb_pages.addr,
19421942 (unsigned long)(emu->ptb_pages.addr + emu->ptb_pages.bytes));
19431943
1944− emu->page_ptr_table = vmalloc(emu->max_cache_pages * sizeof(void *));
1945− emu->page_addr_table = vmalloc(emu->max_cache_pages *
1946− sizeof(unsigned long));
1944+ emu->page_ptr_table = vmalloc(array_size(sizeof(void *),
1945+ emu->max_cache_pages));
1946+ emu->page_addr_table = vmalloc(array_size(sizeof(unsigned long),
1947+ emu->max_cache_pages));
19471948 if (emu->page_ptr_table == NULL || emu->page_addr_table == NULL) {
19481949 err = -ENOMEM;
19491950 goto error;
@@ -2099,7 +2100,7 @@ static int alloc_pm_buffer(struct snd_emu10k1 *emu) · 149 unmodified lines
20992100 size = ARRAY_SIZE(saved_regs);
21002101 if (emu->audigy)
21012102 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));
21032104 if (!emu->saved_ptr)
21042105 return -ENOMEM;
21052106 if (snd_emu10k1_efx_alloc_pm_buffer(emu) < 0)
sound/pci/emu10k1/emufx.c+4−4
@@ -2683,16 +2683,16 @@ int snd_emu10k1_efx_alloc_pm_buffer(struct snd_emu10k1 *emu) · 2682 unmodified lines
26832683 int len;
26842684
26852685 len = emu->audigy ? 0x200 : 0x100;
2686− emu->saved_gpr = kmalloc(len * 4, GFP_KERNEL);
2686+ emu->saved_gpr = kmalloc_array(len, 4, GFP_KERNEL);
26872687 if (! emu->saved_gpr)
26882688 return -ENOMEM;
26892689 len = emu->audigy ? 0x100 : 0xa0;
2690− emu->tram_val_saved = kmalloc(len * 4, GFP_KERNEL);
2691− emu->tram_addr_saved = kmalloc(len * 4, GFP_KERNEL);
2690+ emu->tram_val_saved = kmalloc_array(len, 4, GFP_KERNEL);
2691+ emu->tram_addr_saved = kmalloc_array(len, 4, GFP_KERNEL);
26922692 if (! emu->tram_val_saved || ! emu->tram_addr_saved)
26932693 return -ENOMEM;
26942694 len = emu->audigy ? 2 * 1024 : 2 * 512;
2695− emu->saved_icode = vmalloc(len * 4);
2695+ emu->saved_icode = vmalloc(array_size(len, 4));
26962696 if (! emu->saved_icode)
26972697 return -ENOMEM;
26982698 return 0;
sound/pci/emu10k1/p16v.c+1−1
@@ -874,7 +874,7 @@ int snd_p16v_mixer(struct snd_emu10k1 *emu) · 873 unmodified lines
874874
875875 int snd_p16v_alloc_pm_buffer(struct snd_emu10k1 *emu)
876876 {
877− emu->p16v_saved = vmalloc(NUM_CHS * 4 * 0x80);
877+ emu->p16v_saved = vmalloc(array_size(NUM_CHS * 4, 0x80));
878878 if (! emu->p16v_saved)
879879 return -ENOMEM;
880880 return 0;
sound/pci/hda/hda_codec.c+2−2
@@ -158,7 +158,7 @@ static int read_and_add_raw_conns(struct hda_codec *codec, hda_nid_t nid) · 157 unmodified lines
158158 len = snd_hda_get_raw_connections(codec, nid, list, ARRAY_SIZE(list));
159159 if (len == -ENOSPC) {
160160 len = snd_hda_get_num_raw_conns(codec, nid);
161− result = kmalloc(sizeof(hda_nid_t) * len, GFP_KERNEL);
161+ result = kmalloc_array(len, sizeof(hda_nid_t), GFP_KERNEL);
162162 if (!result)
163163 return -ENOMEM;
164164 len = snd_hda_get_raw_connections(codec, nid, result, len);
@@ -438,7 +438,7 @@ static int read_widget_caps(struct hda_codec *codec, hda_nid_t fg_node) · 273 unmodified lines
438438 int i;
439439 hda_nid_t nid;
440440
441− codec->wcaps = kmalloc(codec->core.num_nodes * 4, GFP_KERNEL);
441+ codec->wcaps = kmalloc_array(codec->core.num_nodes, 4, GFP_KERNEL);
442442 if (!codec->wcaps)
443443 return -ENOMEM;
444444 nid = codec->core.start_nid;
sound/pci/hda/hda_proc.c+3−2
@@ -825,8 +825,9 @@ static void print_codec_info(struct snd_info_entry *entry, · 824 unmodified lines
825825 if (wid_caps & AC_WCAP_CONN_LIST) {
826826 conn_len = snd_hda_get_num_raw_conns(codec, nid);
827827 if (conn_len > 0) {
828− conn = kmalloc(sizeof(hda_nid_t) * conn_len,
829− GFP_KERNEL);
828+ conn = kmalloc_array(conn_len,
829+ sizeof(hda_nid_t),
830+ GFP_KERNEL);
830831 if (!conn)
831832 return;
832833 if (snd_hda_get_raw_connections(codec, nid, conn,
sound/pci/hda/patch_ca0132.c+3−1
@@ -7482,7 +7482,9 @@ static int ca0132_prepare_verbs(struct hda_codec *codec) · 7481 unmodified lines
74827482 spec->chip_init_verbs = ca0132_init_verbs0;
74837483 if (spec->quirk == QUIRK_SBZ)
74847484 spec->sbz_init_verbs = sbz_init_verbs;
7485− spec->spec_init_verbs = kzalloc(sizeof(struct hda_verb) * NUM_SPEC_VERBS, GFP_KERNEL);
7485+ spec->spec_init_verbs = kcalloc(NUM_SPEC_VERBS,
7486+ sizeof(struct hda_verb),
7487+ GFP_KERNEL);
74867488 if (!spec->spec_init_verbs)
74877489 return -ENOMEM;
74887490
sound/pci/maestro3.c+4−1
@@ -2657,7 +2657,10 @@ snd_m3_create(struct snd_card *card, struct pci_dev *pci, · 2656 unmodified lines
26572657 chip->irq = pci->irq;
26582658
26592659 #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));
26612664 if (chip->suspend_mem == NULL)
26622665 dev_warn(card->dev, "can't allocate apm buffer\n");
26632666 #endif
sound/pci/trident/trident_main.c+3−1
@@ -3362,7 +3362,9 @@ static int snd_trident_tlb_alloc(struct snd_trident *trident) · 3361 unmodified lines
33623362 trident->tlb.entries = (unsigned int*)ALIGN((unsigned long)trident->tlb.buffer.area, SNDRV_TRIDENT_MAX_PAGES * 4);
33633363 trident->tlb.entries_dmaaddr = ALIGN(trident->tlb.buffer.addr, SNDRV_TRIDENT_MAX_PAGES * 4);
33643364 /* 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)));
33663368 if (!trident->tlb.shadow_entries)
33673369 return -ENOMEM;
33683370
sound/pci/via82xx.c+3−1
@@ -439,7 +439,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre · 438 unmodified lines
439439 return -ENOMEM;
440440 }
441441 if (! dev->idx_table) {
442− dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
442+ dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
443+ sizeof(*dev->idx_table),
444+ GFP_KERNEL);
443445 if (! dev->idx_table)
444446 return -ENOMEM;
445447 }
sound/pci/via82xx_modem.c+3−1
@@ -292,7 +292,9 @@ static int build_via_table(struct viadev *dev, struct snd_pcm_substream *substre · 291 unmodified lines
292292 return -ENOMEM;
293293 }
294294 if (! dev->idx_table) {
295− dev->idx_table = kmalloc(sizeof(*dev->idx_table) * VIA_TABLE_SIZE, GFP_KERNEL);
295+ dev->idx_table = kmalloc_array(VIA_TABLE_SIZE,
296+ sizeof(*dev->idx_table),
297+ GFP_KERNEL);
296298 if (! dev->idx_table)
297299 return -ENOMEM;
298300 }
sound/pci/ymfpci/ymfpci_main.c+2−2
@@ -2435,8 +2435,8 @@ int snd_ymfpci_create(struct snd_card *card, · 2434 unmodified lines
24352435 goto free_chip;
24362436
24372437 #ifdef CONFIG_PM_SLEEP
2438− chip->saved_regs = kmalloc(YDSXGR_NUM_SAVED_REGS * sizeof(u32),
2439− GFP_KERNEL);
2438+ chip->saved_regs = kmalloc_array(YDSXGR_NUM_SAVED_REGS, sizeof(u32),
2439+ GFP_KERNEL);
24402440 if (chip->saved_regs == NULL) {
24412441 err = -ENOMEM;
24422442 goto free_chip;
sound/soc/au1x/dbdma2.c+2−2
@@ -339,8 +339,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) · 338 unmodified lines
339339 {
340340 struct au1xpsc_audio_dmadata *dmadata;
341341
342− dmadata = devm_kzalloc(&pdev->dev,
343− 2 * sizeof(struct au1xpsc_audio_dmadata),
342+ dmadata = devm_kcalloc(&pdev->dev,
343+ 2, sizeof(struct au1xpsc_audio_dmadata),
344344 GFP_KERNEL);
345345 if (!dmadata)
346346 return -ENOMEM;
sound/soc/codecs/hdmi-codec.c+1−1
@@ -771,7 +771,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) · 770 unmodified lines
771771 hcp->hcd = *hcd;
772772 mutex_init(&hcp->current_stream_lock);
773773
774− hcp->daidrv = devm_kzalloc(dev, dai_count * sizeof(*hcp->daidrv),
774+ hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv),
775775 GFP_KERNEL);
776776 if (!hcp->daidrv)
777777 return -ENOMEM;
sound/soc/codecs/rt5645.c+3−2
@@ -3449,8 +3449,9 @@ static int rt5645_probe(struct snd_soc_component *component) · 3448 unmodified lines
34493449 if (rt5645->pdata.long_name)
34503450 component->card->long_name = rt5645->pdata.long_name;
34513451
3452− rt5645->eq_param = devm_kzalloc(component->dev,
3453− RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL);
3452+ rt5645->eq_param = devm_kcalloc(component->dev,
3453+ RT5645_HWEQ_NUM, sizeof(struct rt5645_eq_param_s),
3454+ GFP_KERNEL);
34543455
34553456 return 0;
34563457 }
sound/soc/codecs/wm8904.c+3−2
@@ -2023,8 +2023,9 @@ static void wm8904_handle_pdata(struct snd_soc_component *component) · 2022 unmodified lines
20232023 wm8904_get_drc_enum, wm8904_put_drc_enum);
20242024
20252025 /* We need an array of texts for the enum API */
2026− wm8904->drc_texts = kmalloc(sizeof(char *)
2027− * pdata->num_drc_cfgs, GFP_KERNEL);
2026+ wm8904->drc_texts = kmalloc_array(pdata->num_drc_cfgs,
2027+ sizeof(char *),
2028+ GFP_KERNEL);
20282029 if (!wm8904->drc_texts)
20292030 return;
20302031
sound/soc/codecs/wm8958-dsp2.c+12−8
@@ -932,8 +932,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) · 931 unmodified lines
932932 };
933933
934934 /* We need an array of texts for the enum API */
935− wm8994->mbc_texts = kmalloc(sizeof(char *)
936− * pdata->num_mbc_cfgs, GFP_KERNEL);
935+ wm8994->mbc_texts = kmalloc_array(pdata->num_mbc_cfgs,
936+ sizeof(char *),
937+ GFP_KERNEL);
937938 if (!wm8994->mbc_texts)
938939 return;
939940
@@ -957,8 +958,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) · 17 unmodified lines
957958 };
958959
959960 /* We need an array of texts for the enum API */
960− wm8994->vss_texts = kmalloc(sizeof(char *)
961− * pdata->num_vss_cfgs, GFP_KERNEL);
961+ wm8994->vss_texts = kmalloc_array(pdata->num_vss_cfgs,
962+ sizeof(char *),
963+ GFP_KERNEL);
962964 if (!wm8994->vss_texts)
963965 return;
964966
@@ -983,8 +985,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) · 18 unmodified lines
983985 };
984986
985987 /* We need an array of texts for the enum API */
986− wm8994->vss_hpf_texts = kmalloc(sizeof(char *)
987− * pdata->num_vss_hpf_cfgs, GFP_KERNEL);
988+ wm8994->vss_hpf_texts = kmalloc_array(pdata->num_vss_hpf_cfgs,
989+ sizeof(char *),
990+ GFP_KERNEL);
988991 if (!wm8994->vss_hpf_texts)
989992 return;
990993
@@ -1010,8 +1013,9 @@ void wm8958_dsp2_init(struct snd_soc_component *component) · 19 unmodified lines
10101013 };
10111014
10121015 /* We need an array of texts for the enum API */
1013− wm8994->enh_eq_texts = kmalloc(sizeof(char *)
1014− * pdata->num_enh_eq_cfgs, GFP_KERNEL);
1016+ wm8994->enh_eq_texts = kmalloc_array(pdata->num_enh_eq_cfgs,
1017+ sizeof(char *),
1018+ GFP_KERNEL);
10151019 if (!wm8994->enh_eq_texts)
10161020 return;
10171021
sound/soc/codecs/wm8994.c+2−2
@@ -3298,8 +3298,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) · 3297 unmodified lines
32983298 };
32993299
33003300 /* We need an array of texts for the enum API */
3301− wm8994->drc_texts = devm_kzalloc(wm8994->hubs.component->dev,
3302− sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL);
3301+ wm8994->drc_texts = devm_kcalloc(wm8994->hubs.component->dev,
3302+ pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL);
33033303 if (!wm8994->drc_texts)
33043304 return;
33053305
sound/soc/codecs/wm_adsp.c+1−1
@@ -1899,7 +1899,7 @@ static void *wm_adsp_read_algs(struct wm_adsp *dsp, size_t n_algs, · 1898 unmodified lines
18991899 adsp_warn(dsp, "Algorithm list end %x 0x%x != 0xbedead\n",
19001900 pos + len, be32_to_cpu(val));
19011901
1902− alg = kzalloc(len * 2, GFP_KERNEL | GFP_DMA);
1902+ alg = kcalloc(len, 2, GFP_KERNEL | GFP_DMA);
19031903 if (!alg)
19041904 return ERR_PTR(-ENOMEM);
19051905
sound/soc/davinci/davinci-mcasp.c+8−6
@@ -1868,8 +1868,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev) · 1867 unmodified lines
18681868
18691869 mcasp->num_serializer = pdata->num_serializer;
18701870 #ifdef CONFIG_PM_SLEEP
1871− mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev,
1872− sizeof(u32) * mcasp->num_serializer,
1871+ mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev,
1872+ mcasp->num_serializer, sizeof(u32),
18731873 GFP_KERNEL);
18741874 if (!mcasp->context.xrsr_regs) {
18751875 ret = -ENOMEM;
@@ -2004,13 +2004,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev) · 128 unmodified lines
20042004 * bytes.
20052005 */
20062006 mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list =
2007− devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
2008− (32 + mcasp->num_serializer - 1),
2007+ devm_kcalloc(mcasp->dev,
2008+ 32 + mcasp->num_serializer - 1,
2009+ sizeof(unsigned int),
20092010 GFP_KERNEL);
20102011
20112012 mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list =
2012− devm_kzalloc(mcasp->dev, sizeof(unsigned int) *
2013− (32 + mcasp->num_serializer - 1),
2013+ devm_kcalloc(mcasp->dev,
2014+ 32 + mcasp->num_serializer - 1,
2015+ sizeof(unsigned int),
20142016 GFP_KERNEL);
20152017
20162018 if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list ||
sound/soc/generic/audio-graph-card.c+2−2
@@ -296,8 +296,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) · 295 unmodified lines
296296 if (num == 0)
297297 return -EINVAL;
298298
299− dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
300− dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
299+ dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
300+ dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
301301 if (!dai_props || !dai_link)
302302 return -ENOMEM;
303303
sound/soc/generic/audio-graph-scu-card.c+2−2
@@ -348,8 +348,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) · 347 unmodified lines
348348 if (num == 0)
349349 return -EINVAL;
350350
351− dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
352− dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
351+ dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
352+ dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
353353 if (!dai_props || !dai_link)
354354 return -ENOMEM;
355355
sound/soc/generic/simple-card.c+4−4
@@ -340,8 +340,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node, · 339 unmodified lines
340340 if (n <= 0)
341341 return -EINVAL;
342342
343− card->aux_dev = devm_kzalloc(dev,
344− n * sizeof(*card->aux_dev), GFP_KERNEL);
343+ card->aux_dev = devm_kcalloc(dev,
344+ n, sizeof(*card->aux_dev), GFP_KERNEL);
345345 if (!card->aux_dev)
346346 return -ENOMEM;
347347
@@ -435,8 +435,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) · 87 unmodified lines
435435 if (!priv)
436436 return -ENOMEM;
437437
438− dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
439− dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
438+ dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
439+ dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
440440 if (!dai_props || !dai_link)
441441 return -ENOMEM;
442442
sound/soc/generic/simple-scu-card.c+2−2
@@ -246,8 +246,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) · 245 unmodified lines
246246
247247 num = of_get_child_count(np);
248248
249− dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL);
250− dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL);
249+ dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL);
250+ dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL);
251251 if (!dai_props || !dai_link)
252252 return -ENOMEM;
253253
sound/soc/img/img-i2s-in.c+2−2
@@ -509,8 +509,8 @@ static int img_i2s_in_probe(struct platform_device *pdev) · 508 unmodified lines
509509
510510 pm_runtime_put(&pdev->dev);
511511
512− i2s->suspend_ch_ctl = devm_kzalloc(dev,
513− sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
512+ i2s->suspend_ch_ctl = devm_kcalloc(dev,
513+ i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
514514 if (!i2s->suspend_ch_ctl) {
515515 ret = -ENOMEM;
516516 goto err_suspend;
sound/soc/img/img-i2s-out.c+2−2
@@ -479,8 +479,8 @@ static int img_i2s_out_probe(struct platform_device *pdev) · 478 unmodified lines
479479 return PTR_ERR(i2s->clk_ref);
480480 }
481481
482− i2s->suspend_ch_ctl = devm_kzalloc(dev,
483− sizeof(*i2s->suspend_ch_ctl) * i2s->max_i2s_chan, GFP_KERNEL);
482+ i2s->suspend_ch_ctl = devm_kcalloc(dev,
483+ i2s->max_i2s_chan, sizeof(*i2s->suspend_ch_ctl), GFP_KERNEL);
484484 if (!i2s->suspend_ch_ctl)
485485 return -ENOMEM;
486486
sound/soc/intel/common/sst-ipc.c+2−2
@@ -121,8 +121,8 @@ static int msg_empty_list_init(struct sst_generic_ipc *ipc) · 120 unmodified lines
121121 {
122122 int i;
123123
124− ipc->msg = kzalloc(sizeof(struct ipc_message) *
125− IPC_EMPTY_LIST_SIZE, GFP_KERNEL);
124+ ipc->msg = kcalloc(IPC_EMPTY_LIST_SIZE, sizeof(struct ipc_message),
125+ GFP_KERNEL);
126126 if (ipc->msg == NULL)
127127 return -ENOMEM;
128128
sound/soc/intel/skylake/skl-topology.c+12−8
@@ -2428,8 +2428,10 @@ static int skl_tplg_get_token(struct device *dev, · 2427 unmodified lines
24282428
24292429 case SKL_TKN_U8_DYN_IN_PIN:
24302430 if (!mconfig->m_in_pin)
2431− mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
2432− sizeof(*mconfig->m_in_pin), GFP_KERNEL);
2431+ mconfig->m_in_pin =
2432+ devm_kcalloc(dev, MAX_IN_QUEUE,
2433+ sizeof(*mconfig->m_in_pin),
2434+ GFP_KERNEL);
24332435 if (!mconfig->m_in_pin)
24342436 return -ENOMEM;
24352437
@@ -2439,8 +2441,10 @@ static int skl_tplg_get_token(struct device *dev, · 3 unmodified lines
24392441
24402442 case SKL_TKN_U8_DYN_OUT_PIN:
24412443 if (!mconfig->m_out_pin)
2442− mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE *
2443− sizeof(*mconfig->m_in_pin), GFP_KERNEL);
2444+ mconfig->m_out_pin =
2445+ devm_kcalloc(dev, MAX_IN_QUEUE,
2446+ sizeof(*mconfig->m_in_pin),
2447+ GFP_KERNEL);
24442448 if (!mconfig->m_out_pin)
24452449 return -ENOMEM;
24462450
@@ -2852,14 +2856,14 @@ static int skl_tplg_get_pvt_data_v4(struct snd_soc_tplg_dapm_widget *tplg_w, · 405 unmodified lines
28522856 mconfig->time_slot = dfw->time_slot;
28532857 mconfig->formats_config.caps_size = dfw->caps.caps_size;
28542858
2855− mconfig->m_in_pin = devm_kzalloc(dev,
2856− MAX_IN_QUEUE * sizeof(*mconfig->m_in_pin),
2859+ mconfig->m_in_pin = devm_kcalloc(dev,
2860+ MAX_IN_QUEUE, sizeof(*mconfig->m_in_pin),
28572861 GFP_KERNEL);
28582862 if (!mconfig->m_in_pin)
28592863 return -ENOMEM;
28602864
2861− mconfig->m_out_pin = devm_kzalloc(dev,
2862− MAX_OUT_QUEUE * sizeof(*mconfig->m_out_pin),
2865+ mconfig->m_out_pin = devm_kcalloc(dev,
2866+ MAX_OUT_QUEUE, sizeof(*mconfig->m_out_pin),
28632867 GFP_KERNEL);
28642868 if (!mconfig->m_out_pin)
28652869 return -ENOMEM;
sound/soc/mediatek/mt2701/mt2701-afe-pcm.c+2−1
@@ -1347,7 +1347,8 @@ static int mt2701_afe_pcm_dev_probe(struct platform_device *pdev) · 1346 unmodified lines
13471347 afe->dev = &pdev->dev;
13481348 dev = afe->dev;
13491349
1350− afe_priv->i2s_path = devm_kzalloc(dev, afe_priv->soc->i2s_num *
1350+ afe_priv->i2s_path = devm_kcalloc(dev,
1351+ afe_priv->soc->i2s_num,
13511352 sizeof(struct mt2701_i2s_path),
13521353 GFP_KERNEL);
13531354 if (!afe_priv->i2s_path)
sound/soc/pxa/mmp-sspa.c+2−2
@@ -425,8 +425,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) · 424 unmodified lines
425425 if (priv->sspa == NULL)
426426 return -ENOMEM;
427427
428− priv->dma_params = devm_kzalloc(&pdev->dev,
429− 2 * sizeof(struct snd_dmaengine_dai_dma_data),
428+ priv->dma_params = devm_kcalloc(&pdev->dev,
429+ 2, sizeof(struct snd_dmaengine_dai_dma_data),
430430 GFP_KERNEL);
431431 if (priv->dma_params == NULL)
432432 return -ENOMEM;
sound/soc/rockchip/rk3399_gru_sound.c+1−1
@@ -462,7 +462,7 @@ static int rockchip_sound_of_parse_dais(struct device *dev, · 461 unmodified lines
462462 num_routes = 0;
463463 for (i = 0; i < ARRAY_SIZE(rockchip_routes); i++)
464464 num_routes += rockchip_routes[i].num_routes;
465− routes = devm_kzalloc(dev, num_routes * sizeof(*routes),
465+ routes = devm_kcalloc(dev, num_routes, sizeof(*routes),
466466 GFP_KERNEL);
467467 if (!routes)
468468 return -ENOMEM;
sound/soc/sh/rcar/cmd.c+1−1
@@ -155,7 +155,7 @@ int rsnd_cmd_probe(struct rsnd_priv *priv) · 154 unmodified lines
155155 if (!nr)
156156 return 0;
157157
158− cmd = devm_kzalloc(dev, sizeof(*cmd) * nr, GFP_KERNEL);
158+ cmd = devm_kcalloc(dev, nr, sizeof(*cmd), GFP_KERNEL);
159159 if (!cmd)
160160 return -ENOMEM;
161161
sound/soc/sh/rcar/core.c+2−2
@@ -1110,8 +1110,8 @@ static int rsnd_dai_probe(struct rsnd_priv *priv) · 1109 unmodified lines
11101110 if (!nr)
11111111 return -EINVAL;
11121112
1113− rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL);
1114− rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL);
1113+ rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL);
1114+ rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL);
11151115 if (!rdrv || !rdai)
11161116 return -ENOMEM;
11171117
sound/soc/sh/rcar/ctu.c+1−1
@@ -378,7 +378,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv) · 377 unmodified lines
378378 goto rsnd_ctu_probe_done;
379379 }
380380
381− ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL);
381+ ctu = devm_kcalloc(dev, nr, sizeof(*ctu), GFP_KERNEL);
382382 if (!ctu) {
383383 ret = -ENOMEM;
384384 goto rsnd_ctu_probe_done;
sound/soc/sh/rcar/dvc.c+1−1
@@ -344,7 +344,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv) · 343 unmodified lines
344344 goto rsnd_dvc_probe_done;
345345 }
346346
347− dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL);
347+ dvc = devm_kcalloc(dev, nr, sizeof(*dvc), GFP_KERNEL);
348348 if (!dvc) {
349349 ret = -ENOMEM;
350350 goto rsnd_dvc_probe_done;
sound/soc/sh/rcar/mix.c+1−1
@@ -294,7 +294,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv) · 293 unmodified lines
294294 goto rsnd_mix_probe_done;
295295 }
296296
297− mix = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL);
297+ mix = devm_kcalloc(dev, nr, sizeof(*mix), GFP_KERNEL);
298298 if (!mix) {
299299 ret = -ENOMEM;
300300 goto rsnd_mix_probe_done;
sound/soc/sh/rcar/src.c+1−1
@@ -575,7 +575,7 @@ int rsnd_src_probe(struct rsnd_priv *priv) · 574 unmodified lines
575575 goto rsnd_src_probe_done;
576576 }
577577
578− src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL);
578+ src = devm_kcalloc(dev, nr, sizeof(*src), GFP_KERNEL);
579579 if (!src) {
580580 ret = -ENOMEM;
581581 goto rsnd_src_probe_done;
sound/soc/sh/rcar/ssi.c+1−1
@@ -1116,7 +1116,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) · 1115 unmodified lines
11161116 goto rsnd_ssi_probe_done;
11171117 }
11181118
1119− ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL);
1119+ ssi = devm_kcalloc(dev, nr, sizeof(*ssi), GFP_KERNEL);
11201120 if (!ssi) {
11211121 ret = -ENOMEM;
11221122 goto rsnd_ssi_probe_done;
sound/soc/sh/rcar/ssiu.c+1−1
@@ -258,7 +258,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv) · 257 unmodified lines
258258
259259 /* same number to SSI */
260260 nr = priv->ssi_nr;
261− ssiu = devm_kzalloc(dev, sizeof(*ssiu) * nr, GFP_KERNEL);
261+ ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL);
262262 if (!ssiu)
263263 return -ENOMEM;
264264
sound/soc/soc-core.c+5−5
@@ -373,8 +373,8 @@ static struct snd_soc_pcm_runtime *soc_new_pcm_runtime( · 372 unmodified lines
373373 if (!rtd->dai_link->ops)
374374 rtd->dai_link->ops = &null_snd_soc_ops;
375375
376− rtd->codec_dais = kzalloc(sizeof(struct snd_soc_dai *) *
377− dai_link->num_codecs,
376+ rtd->codec_dais = kcalloc(dai_link->num_codecs,
377+ sizeof(struct snd_soc_dai *),
378378 GFP_KERNEL);
379379 if (!rtd->codec_dais) {
380380 kfree(rtd);
@@ -3354,7 +3354,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, · 2973 unmodified lines
33543354 return -EINVAL;
33553355 }
33563356
3357− routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes),
3357+ routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes),
33583358 GFP_KERNEL);
33593359 if (!routes) {
33603360 dev_err(card->dev,
@@ -3678,8 +3678,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, · 317 unmodified lines
36783678 dev_err(dev, "Bad phandle in 'sound-dai'\n");
36793679 return num_codecs;
36803680 }
3681− component = devm_kzalloc(dev,
3682− sizeof *component * num_codecs,
3681+ component = devm_kcalloc(dev,
3682+ num_codecs, sizeof(*component),
36833683 GFP_KERNEL);
36843684 if (!component)
36853685 return -ENOMEM;
sound/soc/soc-dapm.c+1−1
@@ -3055,7 +3055,7 @@ int snd_soc_dapm_new_widgets(struct snd_soc_card *card) · 3054 unmodified lines
30553055 continue;
30563056
30573057 if (w->num_kcontrols) {
3058− w->kcontrols = kzalloc(w->num_kcontrols *
3058+ w->kcontrols = kcalloc(w->num_kcontrols,
30593059 sizeof(struct snd_kcontrol *),
30603060 GFP_KERNEL);
30613061 if (!w->kcontrols) {
sound/soc/soc-topology.c+1−1
@@ -885,7 +885,7 @@ static int soc_tplg_denum_create_texts(struct soc_enum *se, · 884 unmodified lines
885885 int i, ret;
886886
887887 se->dobj.control.dtexts =
888− kzalloc(sizeof(char *) * ec->items, GFP_KERNEL);
888+ kcalloc(ec->items, sizeof(char *), GFP_KERNEL);
889889 if (se->dobj.control.dtexts == NULL)
890890 return -ENOMEM;
891891
sound/soc/uniphier/aio-cpu.c+6−4
@@ -624,15 +624,17 @@ int uniphier_aio_probe(struct platform_device *pdev) · 623 unmodified lines
624624 return PTR_ERR(chip->rst);
625625
626626 chip->num_aios = chip->chip_spec->num_dais;
627− chip->aios = devm_kzalloc(dev,
628− sizeof(struct uniphier_aio) * chip->num_aios,
627+ chip->aios = devm_kcalloc(dev,
628+ chip->num_aios, sizeof(struct uniphier_aio),
629629 GFP_KERNEL);
630630 if (!chip->aios)
631631 return -ENOMEM;
632632
633633 chip->num_plls = chip->chip_spec->num_plls;
634− chip->plls = devm_kzalloc(dev, sizeof(struct uniphier_aio_pll) *
635− chip->num_plls, GFP_KERNEL);
634+ chip->plls = devm_kcalloc(dev,
635+ chip->num_plls,
636+ sizeof(struct uniphier_aio_pll),
637+ GFP_KERNEL);
636638 if (!chip->plls)
637639 return -ENOMEM;
638640 memcpy(chip->plls, chip->chip_spec->plls,
sound/usb/6fire/pcm.c+6−4
@@ -591,12 +591,14 @@ static int usb6fire_pcm_buffers_init(struct pcm_runtime *rt) · 590 unmodified lines
591591 int i;
592592
593593 for (i = 0; i < PCM_N_URBS; i++) {
594− rt->out_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
595− * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
594+ rt->out_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
595+ PCM_N_PACKETS_PER_URB,
596+ GFP_KERNEL);
596597 if (!rt->out_urbs[i].buffer)
597598 return -ENOMEM;
598− rt->in_urbs[i].buffer = kzalloc(PCM_N_PACKETS_PER_URB
599− * PCM_MAX_PACKET_SIZE, GFP_KERNEL);
599+ rt->in_urbs[i].buffer = kcalloc(PCM_MAX_PACKET_SIZE,
600+ PCM_N_PACKETS_PER_URB,
601+ GFP_KERNEL);
600602 if (!rt->in_urbs[i].buffer)
601603 return -ENOMEM;
602604 }
sound/usb/caiaq/audio.c+4−3
@@ -728,7 +728,7 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) · 727 unmodified lines
728728 usb_sndisocpipe(usb_dev, ENDPOINT_PLAYBACK) :
729729 usb_rcvisocpipe(usb_dev, ENDPOINT_CAPTURE);
730730
731− urbs = kmalloc(N_URBS * sizeof(*urbs), GFP_KERNEL);
731+ urbs = kmalloc_array(N_URBS, sizeof(*urbs), GFP_KERNEL);
732732 if (!urbs) {
733733 *ret = -ENOMEM;
734734 return NULL;
@@ -742,7 +742,8 @@ static struct urb **alloc_urbs(struct snd_usb_caiaqdev *cdev, int dir, int *ret) · 7 unmodified lines
742742 }
743743
744744 urbs[i]->transfer_buffer =
745− kmalloc(FRAMES_PER_URB * BYTES_PER_FRAME, GFP_KERNEL);
745+ kmalloc_array(BYTES_PER_FRAME, FRAMES_PER_URB,
746+ GFP_KERNEL);
746747 if (!urbs[i]->transfer_buffer) {
747748 *ret = -ENOMEM;
748749 return urbs;
@@ -857,7 +858,7 @@ int snd_usb_caiaq_audio_init(struct snd_usb_caiaqdev *cdev) · 108 unmodified lines
857858 &snd_usb_caiaq_ops);
858859
859860 cdev->data_cb_info =
860− kmalloc(sizeof(struct snd_usb_caiaq_cb_info) * N_URBS,
861+ kmalloc_array(N_URBS, sizeof(struct snd_usb_caiaq_cb_info),
861862 GFP_KERNEL);
862863
863864 if (!cdev->data_cb_info)
sound/usb/format.c+3−2
@@ -188,7 +188,8 @@ static int parse_audio_format_rates_v1(struct snd_usb_audio *chip, struct audiof · 187 unmodified lines
188188 */
189189 int r, idx;
190190
191− fp->rate_table = kmalloc(sizeof(int) * nr_rates, GFP_KERNEL);
191+ fp->rate_table = kmalloc_array(nr_rates, sizeof(int),
192+ GFP_KERNEL);
192193 if (fp->rate_table == NULL)
193194 return -ENOMEM;
194195
@@ -362,7 +363,7 @@ static int parse_audio_format_rates_v2v3(struct snd_usb_audio *chip, · 167 unmodified lines
362363 goto err_free;
363364 }
364365
365− fp->rate_table = kmalloc(sizeof(int) * fp->nr_rates, GFP_KERNEL);
366+ fp->rate_table = kmalloc_array(fp->nr_rates, sizeof(int), GFP_KERNEL);
366367 if (!fp->rate_table) {
367368 ret = -ENOMEM;
368369 goto err_free;
sound/usb/line6/capture.c+2−2
@@ -264,8 +264,8 @@ int line6_create_audio_in_urbs(struct snd_line6_pcm *line6pcm) · 263 unmodified lines
264264 struct usb_line6 *line6 = line6pcm->line6;
265265 int i;
266266
267− line6pcm->in.urbs = kzalloc(
268− sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
267+ line6pcm->in.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
268+ GFP_KERNEL);
269269 if (line6pcm->in.urbs == NULL)
270270 return -ENOMEM;
271271
sound/usb/line6/pcm.c+4−2
@@ -158,8 +158,10 @@ static int line6_buffer_acquire(struct snd_line6_pcm *line6pcm, · 157 unmodified lines
158158
159159 /* Invoked multiple times in a row so allocate once only */
160160 if (!test_and_set_bit(type, &pstr->opened) && !pstr->buffer) {
161− pstr->buffer = kmalloc(line6pcm->line6->iso_buffers *
162− LINE6_ISO_PACKETS * pkt_size, GFP_KERNEL);
161+ pstr->buffer =
162+ kmalloc(array3_size(line6pcm->line6->iso_buffers,
163+ LINE6_ISO_PACKETS, pkt_size),
164+ GFP_KERNEL);
163165 if (!pstr->buffer)
164166 return -ENOMEM;
165167 }
sound/usb/line6/playback.c+2−2
@@ -409,8 +409,8 @@ int line6_create_audio_out_urbs(struct snd_line6_pcm *line6pcm) · 408 unmodified lines
409409 struct usb_line6 *line6 = line6pcm->line6;
410410 int i;
411411
412− line6pcm->out.urbs = kzalloc(
413− sizeof(struct urb *) * line6->iso_buffers, GFP_KERNEL);
412+ line6pcm->out.urbs = kcalloc(line6->iso_buffers, sizeof(struct urb *),
413+ GFP_KERNEL);
414414 if (line6pcm->out.urbs == NULL)
415415 return -ENOMEM;
416416
sound/usb/mixer.c+1−1
@@ -2515,7 +2515,7 @@ static int parse_audio_selector_unit(struct mixer_build *state, int unitid, · 2514 unmodified lines
25152515 cval->control = (desc->bDescriptorSubtype == UAC2_CLOCK_SELECTOR) ?
25162516 UAC2_CX_CLOCK_SELECTOR : UAC2_SU_SELECTOR;
25172517
2518− namelist = kmalloc(sizeof(char *) * desc->bNrInPins, GFP_KERNEL);
2518+ namelist = kmalloc_array(desc->bNrInPins, sizeof(char *), GFP_KERNEL);
25192519 if (!namelist) {
25202520 kfree(cval);
25212521 return -ENOMEM;
sound/usb/pcm.c+1−1
@@ -1123,7 +1123,7 @@ static int snd_usb_pcm_check_knot(struct snd_pcm_runtime *runtime, · 1122 unmodified lines
11231123 return 0;
11241124
11251125 subs->rate_list.list = rate_list =
1126− kmalloc(sizeof(int) * count, GFP_KERNEL);
1126+ kmalloc_array(count, sizeof(int), GFP_KERNEL);
11271127 if (!subs->rate_list.list)
11281128 return -ENOMEM;
11291129 subs->rate_list.count = count;
sound/usb/usx2y/usbusx2y.c+3−1
@@ -266,7 +266,9 @@ int usX2Y_AsyncSeq04_init(struct usX2Ydev *usX2Y) · 265 unmodified lines
266266 int err = 0,
267267 i;
268268
269− if (NULL == (usX2Y->AS04.buffer = kmalloc(URB_DataLen_AsyncSeq*URBS_AsyncSeq, GFP_KERNEL))) {
269+ usX2Y->AS04.buffer = kmalloc_array(URBS_AsyncSeq,
270+ URB_DataLen_AsyncSeq, GFP_KERNEL);
271+ if (NULL == usX2Y->AS04.buffer) {
270272 err = -ENOMEM;
271273 } else
272274 for (i = 0; i < URBS_AsyncSeq; ++i) {
sound/usb/usx2y/usbusx2yaudio.c+5−2
@@ -436,7 +436,9 @@ static int usX2Y_urbs_allocate(struct snd_usX2Y_substream *subs) · 435 unmodified lines
436436 }
437437 if (!is_playback && !(*purb)->transfer_buffer) {
438438 /* allocate a capture buffer per urb */
439− (*purb)->transfer_buffer = kmalloc(subs->maxpacksize * nr_of_packs(), GFP_KERNEL);
439+ (*purb)->transfer_buffer =
440+ kmalloc_array(subs->maxpacksize,
441+ nr_of_packs(), GFP_KERNEL);
440442 if (NULL == (*purb)->transfer_buffer) {
441443 usX2Y_urbs_release(subs);
442444 return -ENOMEM;
@@ -662,7 +664,8 @@ static int usX2Y_rate_set(struct usX2Ydev *usX2Y, int rate) · 219 unmodified lines
662664 err = -ENOMEM;
663665 goto cleanup;
664666 }
665− usbdata = kmalloc(sizeof(int) * NOOF_SETRATE_URBS, GFP_KERNEL);
667+ usbdata = kmalloc_array(NOOF_SETRATE_URBS, sizeof(int),
668+ GFP_KERNEL);
666669 if (NULL == usbdata) {
667670 err = -ENOMEM;
668671 goto cleanup;
virt/kvm/arm/vgic/vgic-v4.c+1−1
@@ -126,7 +126,7 @@ int vgic_v4_init(struct kvm *kvm) · 125 unmodified lines
126126
127127 nr_vcpus = atomic_read(&kvm->online_vcpus);
128128
129− dist->its_vm.vpes = kzalloc(sizeof(*dist->its_vm.vpes) * nr_vcpus,
129+ dist->its_vm.vpes = kcalloc(nr_vcpus, sizeof(*dist->its_vm.vpes),
130130 GFP_KERNEL);
131131 if (!dist->its_vm.vpes)
132132 return -ENOMEM;
virt/kvm/kvm_main.c+2−1
@@ -3076,7 +3076,8 @@ static long kvm_vm_ioctl(struct file *filp, · 3075 unmodified lines
30763076 goto out;
30773077 if (routing.nr) {
30783078 r = -ENOMEM;
3079− entries = vmalloc(routing.nr * sizeof(*entries));
3079+ entries = vmalloc(array_size(sizeof(*entries),
3080+ routing.nr));
30803081 if (!entries)
30813082 goto out;
30823083 r = -EFAULT;