treewide: kzalloc() -> kcalloc()
authorKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 21:03:40 +0000 (14:03 -0700)
committerKees Cook <keescook@chromium.org>
Tue, 12 Jun 2018 23:19:22 +0000 (16:19 -0700)
The kzalloc() function has a 2-factor argument form, kcalloc(). This
patch replaces cases of:

        kzalloc(a * b, gfp)

with:
        kcalloc(a * b, gfp)

as well as handling cases of:

        kzalloc(a * b * c, gfp)

with:

        kzalloc(array3_size(a, b, c), gfp)

as it's slightly less ugly than:

        kzalloc_array(array_size(a, b), c, gfp)

This does, however, attempt to ignore constant size factors like:

        kzalloc(4 * 1024, gfp)

though any constants defined via macros get caught up in the conversion.

Any factors with a sizeof() of "unsigned char", "char", and "u8" were
dropped, since they're redundant.

The Coccinelle script used for this was:

// Fix redundant parens around sizeof().
@@
type TYPE;
expression THING, E;
@@

(
  kzalloc(
- (sizeof(TYPE)) * E
+ sizeof(TYPE) * E
  , ...)
|
  kzalloc(
- (sizeof(THING)) * E
+ sizeof(THING) * E
  , ...)
)

// Drop single-byte sizes and redundant parens.
@@
expression COUNT;
typedef u8;
typedef __u8;
@@

(
  kzalloc(
- sizeof(u8) * (COUNT)
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(__u8) * (COUNT)
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(char) * (COUNT)
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(unsigned char) * (COUNT)
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(u8) * COUNT
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(__u8) * COUNT
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(char) * COUNT
+ COUNT
  , ...)
|
  kzalloc(
- sizeof(unsigned char) * COUNT
+ COUNT
  , ...)
)

// 2-factor product with sizeof(type/expression) and identifier or constant.
@@
type TYPE;
expression THING;
identifier COUNT_ID;
constant COUNT_CONST;
@@

(
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * (COUNT_ID)
+ COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * COUNT_ID
+ COUNT_ID, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * (COUNT_CONST)
+ COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * COUNT_CONST
+ COUNT_CONST, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * (COUNT_ID)
+ COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * COUNT_ID
+ COUNT_ID, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * (COUNT_CONST)
+ COUNT_CONST, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * COUNT_CONST
+ COUNT_CONST, sizeof(THING)
  , ...)
)

// 2-factor product, only identifiers.
@@
identifier SIZE, COUNT;
@@

- kzalloc
+ kcalloc
  (
- SIZE * COUNT
+ COUNT, SIZE
  , ...)

// 3-factor product with 1 sizeof(type) or sizeof(expression), with
// redundant parens removed.
@@
expression THING;
identifier STRIDE, COUNT;
type TYPE;
@@

(
  kzalloc(
- sizeof(TYPE) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
- sizeof(TYPE) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
- sizeof(TYPE) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
- sizeof(TYPE) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(TYPE))
  , ...)
|
  kzalloc(
- sizeof(THING) * (COUNT) * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
- sizeof(THING) * (COUNT) * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
- sizeof(THING) * COUNT * (STRIDE)
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
|
  kzalloc(
- sizeof(THING) * COUNT * STRIDE
+ array3_size(COUNT, STRIDE, sizeof(THING))
  , ...)
)

// 3-factor product with 2 sizeof(variable), with redundant parens removed.
@@
expression THING1, THING2;
identifier COUNT;
type TYPE1, TYPE2;
@@

(
  kzalloc(
- sizeof(TYPE1) * sizeof(TYPE2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(TYPE2))
  , ...)
|
  kzalloc(
- sizeof(THING1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
- sizeof(THING1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(THING1), sizeof(THING2))
  , ...)
|
  kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * COUNT
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
|
  kzalloc(
- sizeof(TYPE1) * sizeof(THING2) * (COUNT)
+ array3_size(COUNT, sizeof(TYPE1), sizeof(THING2))
  , ...)
)

// 3-factor product, only identifiers, with redundant parens removed.
@@
identifier STRIDE, SIZE, COUNT;
@@

(
  kzalloc(
- (COUNT) * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- COUNT * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- COUNT * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- (COUNT) * (STRIDE) * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- COUNT * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- (COUNT) * STRIDE * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- (COUNT) * (STRIDE) * (SIZE)
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
|
  kzalloc(
- COUNT * STRIDE * SIZE
+ array3_size(COUNT, STRIDE, SIZE)
  , ...)
)

// Any remaining multi-factor products, first at least 3-factor products,
// when they're not all constants...
@@
expression E1, E2, E3;
constant C1, C2, C3;
@@

(
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(
- (E1) * E2 * E3
+ array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
- (E1) * (E2) * E3
+ array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
- (E1) * (E2) * (E3)
+ array3_size(E1, E2, E3)
  , ...)
|
  kzalloc(
- E1 * E2 * E3
+ array3_size(E1, E2, E3)
  , ...)
)

// And then all remaining 2 factors products when they're not all constants,
// keeping sizeof() as the second factor argument.
@@
expression THING, E1, E2;
type TYPE;
constant C1, C2, C3;
@@

(
  kzalloc(sizeof(THING) * C2, ...)
|
  kzalloc(sizeof(TYPE) * C2, ...)
|
  kzalloc(C1 * C2 * C3, ...)
|
  kzalloc(C1 * C2, ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * (E2)
+ E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(TYPE) * E2
+ E2, sizeof(TYPE)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * (E2)
+ E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
- sizeof(THING) * E2
+ E2, sizeof(THING)
  , ...)
|
- kzalloc
+ kcalloc
  (
- (E1) * E2
+ E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
- (E1) * (E2)
+ E1, E2
  , ...)
|
- kzalloc
+ kcalloc
  (
- E1 * E2
+ E1, E2
  , ...)
)

Signed-off-by: Kees Cook <keescook@chromium.org>
484 files changed:
arch/arm/mach-footbridge/dc21285.c
arch/arm/mach-ixp4xx/common-pci.c
arch/arm/mach-omap1/mcbsp.c
arch/arm/mach-omap2/hsmmc.c
arch/arm/mach-omap2/omap_device.c
arch/arm/mach-omap2/prm_common.c
arch/arm/mach-vexpress/spc.c
arch/arm/mm/dma-mapping.c
arch/arm64/kernel/armv8_deprecated.c
arch/arm64/mm/context.c
arch/ia64/kernel/topology.c
arch/ia64/sn/kernel/io_common.c
arch/ia64/sn/pci/pcibr/pcibr_provider.c
arch/mips/alchemy/common/clock.c
arch/mips/alchemy/common/dbdma.c
arch/mips/alchemy/common/platform.c
arch/mips/alchemy/devboards/platform.c
arch/mips/bmips/dma.c
arch/mips/txx9/rbtx4939/setup.c
arch/powerpc/kernel/vdso.c
arch/powerpc/mm/numa.c
arch/powerpc/net/bpf_jit_comp.c
arch/powerpc/net/bpf_jit_comp64.c
arch/powerpc/oprofile/cell/spu_profiler.c
arch/powerpc/platforms/4xx/pci.c
arch/powerpc/platforms/powernv/opal-sysparam.c
arch/powerpc/sysdev/mpic.c
arch/powerpc/sysdev/xive/native.c
arch/s390/appldata/appldata_base.c
arch/s390/kernel/vdso.c
arch/sh/drivers/dma/dmabrg.c
arch/sh/drivers/pci/pcie-sh7786.c
arch/sparc/kernel/sys_sparc_64.c
arch/x86/events/amd/iommu.c
arch/x86/events/intel/uncore.c
arch/x86/kernel/cpu/mcheck/mce.c
arch/x86/kernel/cpu/mcheck/mce_amd.c
arch/x86/kernel/cpu/mtrr/if.c
arch/x86/kernel/hpet.c
arch/x86/pci/xen.c
arch/x86/platform/uv/uv_time.c
block/bio.c
block/blk-tag.c
drivers/acpi/acpi_platform.c
drivers/acpi/sysfs.c
drivers/android/binder_alloc.c
drivers/ata/libata-core.c
drivers/ata/libata-pmp.c
drivers/atm/fore200e.c
drivers/atm/iphase.c
drivers/block/drbd/drbd_main.c
drivers/block/null_blk.c
drivers/block/ps3vram.c
drivers/block/rsxx/core.c
drivers/block/rsxx/dma.c
drivers/block/xen-blkback/xenbus.c
drivers/block/xen-blkfront.c
drivers/char/agp/amd-k7-agp.c
drivers/char/agp/ati-agp.c
drivers/char/agp/sworks-agp.c
drivers/char/ipmi/ipmi_ssif.c
drivers/clk/renesas/clk-r8a7740.c
drivers/clk/renesas/clk-r8a7779.c
drivers/clk/renesas/clk-rcar-gen2.c
drivers/clk/renesas/clk-rz.c
drivers/clk/st/clkgen-fsyn.c
drivers/clk/st/clkgen-pll.c
drivers/clk/sunxi/clk-usb.c
drivers/clk/tegra/clk.c
drivers/clk/ti/apll.c
drivers/clk/ti/divider.c
drivers/clk/ti/dpll.c
drivers/clocksource/sh_cmt.c
drivers/clocksource/sh_mtu2.c
drivers/clocksource/sh_tmu.c
drivers/cpufreq/acpi-cpufreq.c
drivers/cpufreq/arm_big_little.c
drivers/cpufreq/cppc_cpufreq.c
drivers/cpufreq/ia64-acpi-cpufreq.c
drivers/cpufreq/longhaul.c
drivers/cpufreq/pxa3xx-cpufreq.c
drivers/cpufreq/s3c24xx-cpufreq.c
drivers/cpufreq/sfi-cpufreq.c
drivers/cpufreq/spear-cpufreq.c
drivers/crypto/amcc/crypto4xx_core.c
drivers/crypto/inside-secure/safexcel_hash.c
drivers/crypto/marvell/hash.c
drivers/crypto/n2_core.c
drivers/crypto/qat/qat_common/qat_uclo.c
drivers/dma/ioat/init.c
drivers/dma/mv_xor.c
drivers/dma/pl330.c
drivers/dma/sh/shdma-base.c
drivers/dma/xilinx/zynqmp_dma.c
drivers/edac/amd64_edac.c
drivers/edac/i7core_edac.c
drivers/extcon/extcon.c
drivers/firmware/dell_rbu.c
drivers/firmware/efi/capsule.c
drivers/firmware/efi/runtime-map.c
drivers/fmc/fmc-sdb.c
drivers/gpio/gpio-ml-ioh.c
drivers/gpu/drm/amd/amdgpu/amdgpu_acp.c
drivers/gpu/drm/amd/amdgpu/amdgpu_dpm.c
drivers/gpu/drm/amd/amdgpu/amdgpu_test.c
drivers/gpu/drm/amd/amdgpu/atom.c
drivers/gpu/drm/amd/amdgpu/ci_dpm.c
drivers/gpu/drm/amd/amdgpu/kv_dpm.c
drivers/gpu/drm/amd/amdgpu/si_dpm.c
drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm_helpers.c
drivers/gpu/drm/amd/display/dc/basics/logger.c
drivers/gpu/drm/amd/display/dc/basics/vector.c
drivers/gpu/drm/amd/display/dc/dce/dce_clock_source.c
drivers/gpu/drm/amd/display/dc/gpio/gpio_service.c
drivers/gpu/drm/amd/display/modules/color/color_gamma.c
drivers/gpu/drm/amd/display/modules/freesync/freesync.c
drivers/gpu/drm/amd/display/modules/stats/stats.c
drivers/gpu/drm/amd/powerplay/hwmgr/pp_psm.c
drivers/gpu/drm/i915/gvt/vgpu.c
drivers/gpu/drm/i915/intel_hdcp.c
drivers/gpu/drm/i915/selftests/intel_uncore.c
drivers/gpu/drm/nouveau/nvif/fifo.c
drivers/gpu/drm/nouveau/nvif/object.c
drivers/gpu/drm/nouveau/nvkm/core/event.c
drivers/gpu/drm/nouveau/nvkm/engine/fifo/gk104.c
drivers/gpu/drm/omapdrm/omap_gem.c
drivers/gpu/drm/radeon/atom.c
drivers/gpu/drm/radeon/btc_dpm.c
drivers/gpu/drm/radeon/ci_dpm.c
drivers/gpu/drm/radeon/kv_dpm.c
drivers/gpu/drm/radeon/ni_dpm.c
drivers/gpu/drm/radeon/r600_dpm.c
drivers/gpu/drm/radeon/radeon_atombios.c
drivers/gpu/drm/radeon/radeon_combios.c
drivers/gpu/drm/radeon/radeon_test.c
drivers/gpu/drm/radeon/rs780_dpm.c
drivers/gpu/drm/radeon/rv6xx_dpm.c
drivers/gpu/drm/radeon/rv770_dpm.c
drivers/gpu/drm/radeon/si_dpm.c
drivers/gpu/drm/radeon/sumo_dpm.c
drivers/gpu/drm/radeon/trinity_dpm.c
drivers/gpu/drm/selftests/test-drm_mm.c
drivers/hid/hid-debug.c
drivers/hv/hv.c
drivers/hv/ring_buffer.c
drivers/hwmon/acpi_power_meter.c
drivers/hwmon/coretemp.c
drivers/hwmon/i5k_amb.c
drivers/hwmon/ibmpex.c
drivers/i2c/busses/i2c-amd756-s4882.c
drivers/i2c/busses/i2c-nforce2-s4985.c
drivers/i2c/busses/i2c-nforce2.c
drivers/i2c/i2c-stub.c
drivers/ide/hpt366.c
drivers/ide/it821x.c
drivers/iio/imu/adis_buffer.c
drivers/iio/inkern.c
drivers/infiniband/core/cache.c
drivers/infiniband/core/device.c
drivers/infiniband/core/iwpm_util.c
drivers/infiniband/hw/cxgb3/cxio_hal.c
drivers/infiniband/hw/cxgb4/device.c
drivers/infiniband/hw/cxgb4/qp.c
drivers/infiniband/hw/hns/hns_roce_hw_v2.c
drivers/infiniband/hw/mlx4/mad.c
drivers/infiniband/hw/mthca/mthca_mr.c
drivers/infiniband/hw/mthca/mthca_profile.c
drivers/infiniband/hw/nes/nes_mgt.c
drivers/infiniband/hw/nes/nes_verbs.c
drivers/infiniband/hw/ocrdma/ocrdma_hw.c
drivers/infiniband/hw/ocrdma/ocrdma_main.c
drivers/infiniband/hw/ocrdma/ocrdma_verbs.c
drivers/infiniband/hw/qedr/main.c
drivers/infiniband/hw/qedr/verbs.c
drivers/infiniband/hw/qib/qib_iba7322.c
drivers/infiniband/hw/qib/qib_init.c
drivers/infiniband/hw/usnic/usnic_ib_qp_grp.c
drivers/infiniband/hw/usnic/usnic_vnic.c
drivers/infiniband/ulp/ipoib/ipoib_main.c
drivers/infiniband/ulp/isert/ib_isert.c
drivers/input/keyboard/omap4-keypad.c
drivers/iommu/dmar.c
drivers/iommu/intel-iommu.c
drivers/iommu/omap-iommu.c
drivers/ipack/carriers/tpci200.c
drivers/irqchip/irq-alpine-msi.c
drivers/irqchip/irq-gic-v2m.c
drivers/irqchip/irq-gic-v3-its.c
drivers/irqchip/irq-gic-v3.c
drivers/irqchip/irq-partition-percpu.c
drivers/irqchip/irq-s3c24xx.c
drivers/isdn/capi/capi.c
drivers/isdn/gigaset/capi.c
drivers/isdn/gigaset/i4l.c
drivers/isdn/hardware/avm/b1.c
drivers/isdn/hisax/fsm.c
drivers/isdn/i4l/isdn_common.c
drivers/isdn/mISDN/fsm.c
drivers/lightnvm/pblk-init.c
drivers/mailbox/pcc.c
drivers/md/bcache/super.c
drivers/md/dm-crypt.c
drivers/md/md-bitmap.c
drivers/md/md-cluster.c
drivers/md/md-multipath.c
drivers/md/raid0.c
drivers/md/raid1.c
drivers/md/raid10.c
drivers/md/raid5.c
drivers/media/dvb-frontends/dib7000p.c
drivers/media/dvb-frontends/dib8000.c
drivers/media/dvb-frontends/dib9000.c
drivers/media/usb/au0828/au0828-video.c
drivers/media/usb/cx231xx/cx231xx-core.c
drivers/media/usb/cx231xx/cx231xx-vbi.c
drivers/media/usb/go7007/go7007-fw.c
drivers/media/usb/pvrusb2/pvrusb2-hdw.c
drivers/media/usb/pvrusb2/pvrusb2-std.c
drivers/media/usb/stk1160/stk1160-video.c
drivers/media/usb/stkwebcam/stk-webcam.c
drivers/media/usb/usbtv/usbtv-video.c
drivers/mfd/cros_ec_dev.c
drivers/mfd/mfd-core.c
drivers/mfd/timberdale.c
drivers/misc/altera-stapl/altera.c
drivers/misc/cxl/guest.c
drivers/misc/cxl/of.c
drivers/misc/genwqe/card_ddcb.c
drivers/misc/sgi-xp/xpc_main.c
drivers/misc/sgi-xp/xpc_partition.c
drivers/misc/sgi-xp/xpnet.c
drivers/misc/sram.c
drivers/mtd/ar7part.c
drivers/mtd/bcm47xxpart.c
drivers/mtd/chips/cfi_cmdset_0001.c
drivers/mtd/chips/cfi_cmdset_0002.c
drivers/mtd/devices/docg3.c
drivers/mtd/maps/physmap_of_core.c
drivers/mtd/nand/onenand/onenand_base.c
drivers/mtd/ofpart.c
drivers/mtd/parsers/parser_trx.c
drivers/mtd/parsers/sharpslpart.c
drivers/mtd/sm_ftl.c
drivers/mtd/tests/pagetest.c
drivers/mtd/ubi/wl.c
drivers/net/bonding/bond_main.c
drivers/net/can/grcan.c
drivers/net/can/slcan.c
drivers/net/ethernet/broadcom/bcm63xx_enet.c
drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c
drivers/net/ethernet/broadcom/cnic.c
drivers/net/ethernet/broadcom/tg3.c
drivers/net/ethernet/brocade/bna/bnad.c
drivers/net/ethernet/calxeda/xgmac.c
drivers/net/ethernet/cavium/thunder/nicvf_queues.c
drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c
drivers/net/ethernet/cortina/gemini.c
drivers/net/ethernet/hisilicon/hns/hns_enet.c
drivers/net/ethernet/intel/e1000e/netdev.c
drivers/net/ethernet/intel/igb/igb_main.c
drivers/net/ethernet/intel/ixgbe/ixgbe_main.c
drivers/net/ethernet/jme.c
drivers/net/ethernet/mellanox/mlx4/alloc.c
drivers/net/ethernet/mellanox/mlx4/cmd.c
drivers/net/ethernet/mellanox/mlx4/en_netdev.c
drivers/net/ethernet/mellanox/mlx4/main.c
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c
drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c
drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c
drivers/net/ethernet/micrel/ksz884x.c
drivers/net/ethernet/neterion/vxge/vxge-config.c
drivers/net/ethernet/neterion/vxge/vxge-main.c
drivers/net/ethernet/pasemi/pasemi_mac.c
drivers/net/ethernet/qlogic/qed/qed_debug.c
drivers/net/ethernet/qlogic/qed/qed_dev.c
drivers/net/ethernet/qlogic/qed/qed_init_ops.c
drivers/net/ethernet/qlogic/qed/qed_l2.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c
drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c
drivers/net/ethernet/socionext/netsec.c
drivers/net/ethernet/toshiba/ps3_gelic_wireless.c
drivers/net/phy/dp83640.c
drivers/net/slip/slip.c
drivers/net/team/team.c
drivers/net/usb/smsc95xx.c
drivers/net/virtio_net.c
drivers/net/wan/fsl_ucc_hdlc.c
drivers/net/wireless/ath/ath10k/htt_rx.c
drivers/net/wireless/ath/ath10k/wmi-tlv.c
drivers/net/wireless/ath/ath6kl/cfg80211.c
drivers/net/wireless/ath/carl9170/main.c
drivers/net/wireless/broadcom/b43/phy_n.c
drivers/net/wireless/broadcom/b43legacy/main.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c
drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c
drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c
drivers/net/wireless/intel/iwlegacy/common.c
drivers/net/wireless/intel/iwlwifi/mvm/scan.c
drivers/net/wireless/intersil/p54/eeprom.c
drivers/net/wireless/intersil/prism54/oid_mgt.c
drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c
drivers/net/wireless/marvell/mwifiex/sdio.c
drivers/net/wireless/quantenna/qtnfmac/commands.c
drivers/net/wireless/ralink/rt2x00/rt2x00debug.c
drivers/net/wireless/realtek/rtlwifi/efuse.c
drivers/net/wireless/realtek/rtlwifi/usb.c
drivers/net/wireless/st/cw1200/queue.c
drivers/net/wireless/st/cw1200/scan.c
drivers/nvmem/rockchip-efuse.c
drivers/nvmem/sunxi_sid.c
drivers/of/platform.c
drivers/of/unittest.c
drivers/opp/ti-opp-supply.c
drivers/pci/msi.c
drivers/pci/pci-sysfs.c
drivers/pcmcia/pd6729.c
drivers/pinctrl/bcm/pinctrl-bcm2835.c
drivers/pinctrl/freescale/pinctrl-mxs.c
drivers/pinctrl/pinctrl-lantiq.c
drivers/pinctrl/sirf/pinctrl-sirf.c
drivers/pinctrl/spear/pinctrl-spear.c
drivers/pinctrl/sunxi/pinctrl-sunxi.c
drivers/pinctrl/vt8500/pinctrl-wmt.c
drivers/platform/x86/alienware-wmi.c
drivers/platform/x86/intel_ips.c
drivers/platform/x86/panasonic-laptop.c
drivers/platform/x86/thinkpad_acpi.c
drivers/power/supply/wm97xx_battery.c
drivers/power/supply/z2_battery.c
drivers/powercap/powercap_sys.c
drivers/rapidio/rio-scan.c
drivers/regulator/s2mps11.c
drivers/s390/block/dcssblk.c
drivers/s390/char/keyboard.c
drivers/s390/char/vmur.c
drivers/s390/char/zcore.c
drivers/s390/cio/qdio_setup.c
drivers/s390/cio/qdio_thinint.c
drivers/s390/crypto/pkey_api.c
drivers/s390/net/ctcm_main.c
drivers/s390/net/qeth_core_main.c
drivers/scsi/BusLogic.c
drivers/scsi/aacraid/linit.c
drivers/scsi/aic7xxx/aic7xxx_core.c
drivers/scsi/aic94xx/aic94xx_hwi.c
drivers/scsi/aic94xx/aic94xx_init.c
drivers/scsi/be2iscsi/be_main.c
drivers/scsi/bfa/bfad_attr.c
drivers/scsi/bfa/bfad_bsg.c
drivers/scsi/bnx2fc/bnx2fc_fcoe.c
drivers/scsi/bnx2fc/bnx2fc_io.c
drivers/scsi/csiostor/csio_wr.c
drivers/scsi/esas2r/esas2r_init.c
drivers/scsi/hpsa.c
drivers/scsi/ipr.c
drivers/scsi/libsas/sas_expander.c
drivers/scsi/lpfc/lpfc_init.c
drivers/scsi/lpfc/lpfc_sli.c
drivers/scsi/lpfc/lpfc_vport.c
drivers/scsi/megaraid/megaraid_sas_base.c
drivers/scsi/megaraid/megaraid_sas_fusion.c
drivers/scsi/osst.c
drivers/scsi/pm8001/pm8001_ctl.c
drivers/scsi/pmcraid.c
drivers/scsi/qedi/qedi_main.c
drivers/scsi/qla2xxx/qla_init.c
drivers/scsi/qla2xxx/qla_isr.c
drivers/scsi/qla2xxx/qla_os.c
drivers/scsi/qla2xxx/qla_target.c
drivers/scsi/scsi_debug.c
drivers/scsi/ses.c
drivers/scsi/sg.c
drivers/scsi/smartpqi/smartpqi_init.c
drivers/scsi/st.c
drivers/sh/clk/cpg.c
drivers/sh/intc/core.c
drivers/sh/maple/maple.c
drivers/slimbus/qcom-ctrl.c
drivers/staging/mt7621-pinctrl/pinctrl-rt2880.c
drivers/staging/rtlwifi/efuse.c
drivers/staging/unisys/visorhba/visorhba_main.c
drivers/target/target_core_transport.c
drivers/target/target_core_user.c
drivers/thermal/int340x_thermal/acpi_thermal_rel.c
drivers/thermal/int340x_thermal/int340x_thermal_zone.c
drivers/thermal/of-thermal.c
drivers/thermal/x86_pkg_temp_thermal.c
drivers/tty/ehv_bytechan.c
drivers/tty/goldfish.c
drivers/tty/hvc/hvc_iucv.c
drivers/tty/serial/pch_uart.c
drivers/tty/serial/serial_core.c
drivers/tty/serial/sunsab.c
drivers/uio/uio_pruss.c
drivers/usb/core/hub.c
drivers/usb/dwc2/hcd.c
drivers/usb/gadget/udc/bdc/bdc_ep.c
drivers/usb/gadget/udc/fsl_udc_core.c
drivers/usb/host/ehci-sched.c
drivers/usb/host/imx21-hcd.c
drivers/usb/mon/mon_bin.c
drivers/usb/renesas_usbhs/mod_gadget.c
drivers/usb/renesas_usbhs/pipe.c
drivers/usb/wusbcore/wa-rpipe.c
drivers/vhost/scsi.c
drivers/video/console/sticore.c
drivers/video/fbdev/broadsheetfb.c
drivers/video/fbdev/core/fbmon.c
drivers/video/fbdev/mmp/fb/mmpfb.c
drivers/video/fbdev/omap2/omapfb/dss/manager.c
drivers/video/fbdev/omap2/omapfb/dss/overlay.c
drivers/video/fbdev/uvesafb.c
drivers/video/of_display_timing.c
drivers/virt/fsl_hypervisor.c
drivers/virtio/virtio_pci_common.c
drivers/xen/arm-device.c
fs/btrfs/check-integrity.c
fs/cifs/cifssmb.c
fs/cifs/file.c
fs/ext4/extents.c
fs/nfs/flexfilelayout/flexfilelayout.c
fs/nfs/flexfilelayout/flexfilelayoutdev.c
fs/nfsd/export.c
fs/ocfs2/journal.c
fs/ocfs2/sysfile.c
fs/overlayfs/namei.c
fs/proc/proc_sysctl.c
fs/reiserfs/inode.c
fs/udf/super.c
kernel/bpf/verifier.c
kernel/debug/kdb/kdb_main.c
kernel/events/uprobes.c
kernel/locking/locktorture.c
kernel/sched/fair.c
kernel/sched/rt.c
kernel/sysctl.c
kernel/trace/ftrace.c
kernel/trace/trace.c
kernel/workqueue.c
lib/lru_cache.c
lib/mpi/mpiutil.c
mm/slab.c
mm/slub.c
net/bridge/br_multicast.c
net/can/bcm.c
net/core/ethtool.c
net/ieee802154/nl-phy.c
net/ipv4/fib_frontend.c
net/ipv4/route.c
net/ipv6/icmp.c
net/mac80211/chan.c
net/mac80211/rc80211_minstrel.c
net/mac80211/rc80211_minstrel_ht.c
net/mac80211/scan.c
net/mac80211/util.c
net/netfilter/nf_tables_api.c
net/netfilter/nfnetlink_cthelper.c
net/netrom/af_netrom.c
net/openvswitch/vport.c
net/rds/ib.c
net/rose/af_rose.c
net/sctp/auth.c
net/smc/smc_wr.c
net/sunrpc/auth_gss/gss_rpc_upcall.c
net/sunrpc/cache.c
net/wireless/nl80211.c
security/apparmor/policy_unpack.c
security/selinux/ss/services.c
sound/firewire/fireface/ff-protocol-ff400.c
sound/pci/ctxfi/ctatc.c
sound/pci/ctxfi/ctdaio.c
sound/pci/ctxfi/ctmixer.c
sound/pci/ctxfi/ctsrc.c
sound/pci/hda/patch_ca0132.c
sound/soc/codecs/wm_adsp.c
sound/soc/intel/common/sst-ipc.c
sound/soc/soc-core.c
sound/soc/soc-dapm.c
sound/soc/soc-topology.c
sound/usb/6fire/pcm.c
sound/usb/line6/capture.c
sound/usb/line6/playback.c
virt/kvm/arm/vgic/vgic-v4.c

index e7b350f..16d71ba 100644 (file)
@@ -252,7 +252,7 @@ int __init dc21285_setup(int nr, struct pci_sys_data *sys)
        if (nr || !footbridge_cfn_mode())
                return 0;
 
-       res = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
        if (!res) {
                printk("out of memory for root bus resources");
                return 0;
index bcf3df5..6835b17 100644 (file)
@@ -421,7 +421,7 @@ int ixp4xx_setup(int nr, struct pci_sys_data *sys)
        if (nr >= 1)
                return 0;
 
-       res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(*res), GFP_KERNEL);
        if (res == NULL) {
                /* 
                 * If we're out of memory this early, something is wrong,
index 8ed67f8..27e22e7 100644 (file)
@@ -389,7 +389,7 @@ static void omap_mcbsp_register_board_cfg(struct resource *res, int res_count,
 {
        int i;
 
-       omap_mcbsp_devices = kzalloc(size * sizeof(struct platform_device *),
+       omap_mcbsp_devices = kcalloc(size, sizeof(struct platform_device *),
                                     GFP_KERNEL);
        if (!omap_mcbsp_devices) {
                printk(KERN_ERR "Could not register McBSP devices\n");
index b064066..9344035 100644 (file)
@@ -35,7 +35,7 @@ static int __init omap_hsmmc_pdata_init(struct omap2_hsmmc_info *c,
 {
        char *hc_name;
 
-       hc_name = kzalloc(sizeof(char) * (HSMMC_NAME_LEN + 1), GFP_KERNEL);
+       hc_name = kzalloc(HSMMC_NAME_LEN + 1, GFP_KERNEL);
        if (!hc_name) {
                kfree(hc_name);
                return -ENOMEM;
index 3b829a5..06b6bca 100644 (file)
@@ -155,7 +155,7 @@ static int omap_device_build_from_dt(struct platform_device *pdev)
        if (!omap_hwmod_parse_module_range(NULL, node, &res))
                return -ENODEV;
 
-       hwmods = kzalloc(sizeof(struct omap_hwmod *) * oh_cnt, GFP_KERNEL);
+       hwmods = kcalloc(oh_cnt, sizeof(struct omap_hwmod *), GFP_KERNEL);
        if (!hwmods) {
                ret = -ENOMEM;
                goto odbfd_exit;
@@ -405,7 +405,7 @@ omap_device_copy_resources(struct omap_hwmod *oh,
                goto error;
        }
 
-       res = kzalloc(sizeof(*res) * 2, GFP_KERNEL);
+       res = kcalloc(2, sizeof(*res), GFP_KERNEL);
        if (!res)
                return -ENOMEM;
 
index 021b5a8..058a37e 100644 (file)
@@ -285,10 +285,11 @@ int omap_prcm_register_chain_handler(struct omap_prcm_irq_setup *irq_setup)
 
        prcm_irq_setup = irq_setup;
 
-       prcm_irq_chips = kzalloc(sizeof(void *) * nr_regs, GFP_KERNEL);
-       prcm_irq_setup->saved_mask = kzalloc(sizeof(u32) * nr_regs, GFP_KERNEL);
-       prcm_irq_setup->priority_mask = kzalloc(sizeof(u32) * nr_regs,
-               GFP_KERNEL);
+       prcm_irq_chips = kcalloc(nr_regs, sizeof(void *), GFP_KERNEL);
+       prcm_irq_setup->saved_mask = kcalloc(nr_regs, sizeof(u32),
+                                            GFP_KERNEL);
+       prcm_irq_setup->priority_mask = kcalloc(nr_regs, sizeof(u32),
+                                               GFP_KERNEL);
 
        if (!prcm_irq_chips || !prcm_irq_setup->saved_mask ||
            !prcm_irq_setup->priority_mask)
index 21c0642..0f5381d 100644 (file)
@@ -403,7 +403,7 @@ static int ve_spc_populate_opps(uint32_t cluster)
        uint32_t data = 0, off, ret, idx;
        struct ve_spc_opp *opps;
 
-       opps = kzalloc(sizeof(*opps) * MAX_OPPS, GFP_KERNEL);
+       opps = kcalloc(MAX_OPPS, sizeof(*opps), GFP_KERNEL);
        if (!opps)
                return -ENOMEM;
 
index af27f1c..be0fa7e 100644 (file)
@@ -2162,8 +2162,8 @@ arm_iommu_create_mapping(struct bus_type *bus, dma_addr_t base, u64 size)
                goto err;
 
        mapping->bitmap_size = bitmap_size;
-       mapping->bitmaps = kzalloc(extensions * sizeof(unsigned long *),
-                               GFP_KERNEL);
+       mapping->bitmaps = kcalloc(extensions, sizeof(unsigned long *),
+                                  GFP_KERNEL);
        if (!mapping->bitmaps)
                goto err2;
 
index 97d45d5..d4707ab 100644 (file)
@@ -234,8 +234,8 @@ static void __init register_insn_emulation_sysctl(void)
        struct insn_emulation *insn;
        struct ctl_table *insns_sysctl, *sysctl;
 
-       insns_sysctl = kzalloc(sizeof(*sysctl) * (nr_insn_emulated + 1),
-                             GFP_KERNEL);
+       insns_sysctl = kcalloc(nr_insn_emulated + 1, sizeof(*sysctl),
+                              GFP_KERNEL);
 
        raw_spin_lock_irqsave(&insn_emulation_lock, flags);
        list_for_each_entry(insn, &insn_emulation, node) {
index 301417a..c127f94 100644 (file)
@@ -263,7 +263,7 @@ static int asids_init(void)
         */
        WARN_ON(NUM_USER_ASIDS - 1 <= num_possible_cpus());
        atomic64_set(&asid_generation, ASID_FIRST_VERSION);
-       asid_map = kzalloc(BITS_TO_LONGS(NUM_USER_ASIDS) * sizeof(*asid_map),
+       asid_map = kcalloc(BITS_TO_LONGS(NUM_USER_ASIDS), sizeof(*asid_map),
                           GFP_KERNEL);
        if (!asid_map)
                panic("Failed to allocate bitmap for %lu ASIDs\n",
index d76529c..9b820f7 100644 (file)
@@ -85,7 +85,7 @@ static int __init topology_init(void)
        }
 #endif
 
-       sysfs_cpus = kzalloc(sizeof(struct ia64_cpu) * NR_CPUS, GFP_KERNEL);
+       sysfs_cpus = kcalloc(NR_CPUS, sizeof(struct ia64_cpu), GFP_KERNEL);
        if (!sysfs_cpus)
                panic("kzalloc in topology_init failed - NR_CPUS too big?");
 
@@ -319,8 +319,8 @@ static int cpu_cache_sysfs_init(unsigned int cpu)
                return -1;
        }
 
-       this_cache=kzalloc(sizeof(struct cache_info)*unique_caches,
-                       GFP_KERNEL);
+       this_cache=kcalloc(unique_caches, sizeof(struct cache_info),
+                          GFP_KERNEL);
        if (this_cache == NULL)
                return -ENOMEM;
 
index 8479e9a..102aaba 100644 (file)
@@ -132,7 +132,7 @@ static s64 sn_device_fixup_war(u64 nasid, u64 widget, int device,
        printk_once(KERN_WARNING
                "PROM version < 4.50 -- implementing old PROM flush WAR\n");
 
-       war_list = kzalloc(DEV_PER_WIDGET * sizeof(*war_list), GFP_KERNEL);
+       war_list = kcalloc(DEV_PER_WIDGET, sizeof(*war_list), GFP_KERNEL);
        BUG_ON(!war_list);
 
        SAL_CALL_NOLOCK(isrv, SN_SAL_IOIF_GET_WIDGET_DMAFLUSH_LIST,
index 8dbbef4..7195df1 100644 (file)
@@ -184,7 +184,7 @@ pcibr_bus_fixup(struct pcibus_bussoft *prom_bussoft, struct pci_controller *cont
        /* Setup the PMU ATE map */
        soft->pbi_int_ate_resource.lowest_free_index = 0;
        soft->pbi_int_ate_resource.ate =
-           kzalloc(soft->pbi_int_ate_size * sizeof(u64), GFP_KERNEL);
+           kcalloc(soft->pbi_int_ate_size, sizeof(u64), GFP_KERNEL);
 
        if (!soft->pbi_int_ate_resource.ate) {
                kfree(soft);
index 6b6f685..d129475 100644 (file)
@@ -985,7 +985,7 @@ static int __init alchemy_clk_setup_imux(int ctype)
                return -ENODEV;
        }
 
-       a = kzalloc((sizeof(*a)) * 6, GFP_KERNEL);
+       a = kcalloc(6, sizeof(*a), GFP_KERNEL);
        if (!a)
                return -ENOMEM;
 
index 24b0475..4ca2c28 100644 (file)
@@ -1050,7 +1050,7 @@ static int __init dbdma_setup(unsigned int irq, dbdev_tab_t *idtable)
 {
        int ret;
 
-       dbdev_tab = kzalloc(sizeof(dbdev_tab_t) * DBDEV_TAB_SIZE, GFP_KERNEL);
+       dbdev_tab = kcalloc(DBDEV_TAB_SIZE, sizeof(dbdev_tab_t), GFP_KERNEL);
        if (!dbdev_tab)
                return -ENOMEM;
 
index d77a64f..1454d9f 100644 (file)
@@ -115,7 +115,7 @@ static void __init alchemy_setup_uarts(int ctype)
        uartclk = clk_get_rate(clk);
        clk_put(clk);
 
-       ports = kzalloc(s * (c + 1), GFP_KERNEL);
+       ports = kcalloc(s, (c + 1), GFP_KERNEL);
        if (!ports) {
                printk(KERN_INFO "Alchemy: no memory for UART data\n");
                return;
@@ -198,7 +198,7 @@ static unsigned long alchemy_ehci_data[][2] __initdata = {
 
 static int __init _new_usbres(struct resource **r, struct platform_device **d)
 {
-       *r = kzalloc(sizeof(struct resource) * 2, GFP_KERNEL);
+       *r = kcalloc(2, sizeof(struct resource), GFP_KERNEL);
        if (!*r)
                return -ENOMEM;
        *d = kzalloc(sizeof(struct platform_device), GFP_KERNEL);
index 4640eda..203854d 100644 (file)
@@ -103,7 +103,7 @@ int __init db1x_register_pcmcia_socket(phys_addr_t pcmcia_attr_start,
        if (stschg_irq)
                cnt++;
 
-       sr = kzalloc(sizeof(struct resource) * cnt, GFP_KERNEL);
+       sr = kcalloc(cnt, sizeof(struct resource), GFP_KERNEL);
        if (!sr)
                return -ENOMEM;
 
@@ -178,7 +178,7 @@ int __init db1x_register_norflash(unsigned long size, int width,
                return -EINVAL;
 
        ret = -ENOMEM;
-       parts = kzalloc(sizeof(struct mtd_partition) * 5, GFP_KERNEL);
+       parts = kcalloc(5, sizeof(struct mtd_partition), GFP_KERNEL);
        if (!parts)
                goto out;
 
index 04790f4..6dec308 100644 (file)
@@ -94,7 +94,7 @@ static int __init bmips_init_dma_ranges(void)
                goto out_bad;
 
        /* add a dummy (zero) entry at the end as a sentinel */
-       bmips_dma_ranges = kzalloc(sizeof(struct bmips_dma_range) * (len + 1),
+       bmips_dma_ranges = kcalloc(len + 1, sizeof(struct bmips_dma_range),
                                   GFP_KERNEL);
        if (!bmips_dma_ranges)
                goto out_bad;
index fd26fad..ef29a9c 100644 (file)
@@ -219,7 +219,7 @@ static int __init rbtx4939_led_probe(struct platform_device *pdev)
                "nand-disk",
        };
 
-       leds_data = kzalloc(sizeof(*leds_data) * RBTX4939_MAX_7SEGLEDS,
+       leds_data = kcalloc(RBTX4939_MAX_7SEGLEDS, sizeof(*leds_data),
                            GFP_KERNEL);
        if (!leds_data)
                return -ENOMEM;
index b44ec10..d2205b9 100644 (file)
@@ -791,7 +791,7 @@ static int __init vdso_init(void)
 
 #ifdef CONFIG_VDSO32
        /* Make sure pages are in the correct state */
-       vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 2),
+       vdso32_pagelist = kcalloc(vdso32_pages + 2, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso32_pagelist == NULL);
        for (i = 0; i < vdso32_pages; i++) {
@@ -805,7 +805,7 @@ static int __init vdso_init(void)
 #endif
 
 #ifdef CONFIG_PPC64
-       vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 2),
+       vdso64_pagelist = kcalloc(vdso64_pages + 2, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso64_pagelist == NULL);
        for (i = 0; i < vdso64_pages; i++) {
index 57a5029..0c7e05d 100644 (file)
@@ -1316,7 +1316,7 @@ int numa_update_cpu_topology(bool cpus_locked)
        if (!weight)
                return 0;
 
-       updates = kzalloc(weight * (sizeof(*updates)), GFP_KERNEL);
+       updates = kcalloc(weight, sizeof(*updates), GFP_KERNEL);
        if (!updates)
                return 0;
 
index a9636d8..5b061fc 100644 (file)
@@ -566,7 +566,7 @@ void bpf_jit_compile(struct bpf_prog *fp)
        if (!bpf_jit_enable)
                return;
 
-       addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
+       addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
        if (addrs == NULL)
                return;
 
index f1c9577..380cbf9 100644 (file)
@@ -949,7 +949,7 @@ struct bpf_prog *bpf_int_jit_compile(struct bpf_prog *fp)
                goto skip_init_ctx;
        }
 
-       addrs = kzalloc((flen+1) * sizeof(*addrs), GFP_KERNEL);
+       addrs = kcalloc(flen + 1, sizeof(*addrs), GFP_KERNEL);
        if (addrs == NULL) {
                fp = org_fp;
                goto out_addrs;
index 5182f29..4e099e5 100644 (file)
@@ -210,8 +210,8 @@ int start_spu_profiling_cycles(unsigned int cycles_reset)
        timer.function = profile_spus;
 
        /* Allocate arrays for collecting SPU PC samples */
-       samples = kzalloc(SPUS_PER_NODE *
-                         TRACE_ARRAY_SIZE * sizeof(u32), GFP_KERNEL);
+       samples = kcalloc(SPUS_PER_NODE * TRACE_ARRAY_SIZE, sizeof(u32),
+                         GFP_KERNEL);
 
        if (!samples)
                return -ENOMEM;
index 73e6b36..5aca523 100644 (file)
@@ -1449,7 +1449,7 @@ static int __init ppc4xx_pciex_check_core_init(struct device_node *np)
        count = ppc4xx_pciex_hwops->core_init(np);
        if (count > 0) {
                ppc4xx_pciex_ports =
-                      kzalloc(count * sizeof(struct ppc4xx_pciex_port),
+                      kcalloc(count, sizeof(struct ppc4xx_pciex_port),
                               GFP_KERNEL);
                if (ppc4xx_pciex_ports) {
                        ppc4xx_pciex_port_count = count;
index 6fd4092..9aa87df 100644 (file)
@@ -198,21 +198,21 @@ void __init opal_sys_param_init(void)
                goto out_param_buf;
        }
 
-       id = kzalloc(sizeof(*id) * count, GFP_KERNEL);
+       id = kcalloc(count, sizeof(*id), GFP_KERNEL);
        if (!id) {
                pr_err("SYSPARAM: Failed to allocate memory to read parameter "
                                "id\n");
                goto out_param_buf;
        }
 
-       size = kzalloc(sizeof(*size) * count, GFP_KERNEL);
+       size = kcalloc(count, sizeof(*size), GFP_KERNEL);
        if (!size) {
                pr_err("SYSPARAM: Failed to allocate memory to read parameter "
                                "size\n");
                goto out_free_id;
        }
 
-       perm = kzalloc(sizeof(*perm) * count, GFP_KERNEL);
+       perm = kcalloc(count, sizeof(*perm), GFP_KERNEL);
        if (!perm) {
                pr_err("SYSPARAM: Failed to allocate memory to read supported "
                                "action on the parameter");
@@ -235,7 +235,7 @@ void __init opal_sys_param_init(void)
                goto out_free_perm;
        }
 
-       attr = kzalloc(sizeof(*attr) * count, GFP_KERNEL);
+       attr = kcalloc(count, sizeof(*attr), GFP_KERNEL);
        if (!attr) {
                pr_err("SYSPARAM: Failed to allocate memory for parameter "
                                "attributes\n");
index df062a1..353b439 100644 (file)
@@ -544,7 +544,7 @@ static void __init mpic_scan_ht_pics(struct mpic *mpic)
        printk(KERN_INFO "mpic: Setting up HT PICs workarounds for U3/U4\n");
 
        /* Allocate fixups array */
-       mpic->fixups = kzalloc(128 * sizeof(*mpic->fixups), GFP_KERNEL);
+       mpic->fixups = kcalloc(128, sizeof(*mpic->fixups), GFP_KERNEL);
        BUG_ON(mpic->fixups == NULL);
 
        /* Init spinlock */
@@ -1324,7 +1324,7 @@ struct mpic * __init mpic_alloc(struct device_node *node,
        if (psrc) {
                /* Allocate a bitmap with one bit per interrupt */
                unsigned int mapsize = BITS_TO_LONGS(intvec_top + 1);
-               mpic->protected = kzalloc(mapsize*sizeof(long), GFP_KERNEL);
+               mpic->protected = kcalloc(mapsize, sizeof(long), GFP_KERNEL);
                BUG_ON(mpic->protected == NULL);
                for (i = 0; i < psize/sizeof(u32); i++) {
                        if (psrc[i] > intvec_top)
index 83bcd72..311185b 100644 (file)
@@ -489,7 +489,7 @@ static bool xive_parse_provisioning(struct device_node *np)
        if (rc == 0)
                return true;
 
-       xive_provision_chips = kzalloc(4 * xive_provision_chip_count,
+       xive_provision_chips = kcalloc(4, xive_provision_chip_count,
                                       GFP_KERNEL);
        if (WARN_ON(!xive_provision_chips))
                return false;
index cb6e806..ee6a9c3 100644 (file)
@@ -391,7 +391,7 @@ int appldata_register_ops(struct appldata_ops *ops)
        if (ops->size > APPLDATA_MAX_REC_SIZE)
                return -EINVAL;
 
-       ops->ctl_table = kzalloc(4 * sizeof(struct ctl_table), GFP_KERNEL);
+       ops->ctl_table = kcalloc(4, sizeof(struct ctl_table), GFP_KERNEL);
        if (!ops->ctl_table)
                return -ENOMEM;
 
index f3a1c7c..09abae4 100644 (file)
@@ -285,7 +285,7 @@ static int __init vdso_init(void)
                         + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
 
        /* Make sure pages are in the correct state */
-       vdso32_pagelist = kzalloc(sizeof(struct page *) * (vdso32_pages + 1),
+       vdso32_pagelist = kcalloc(vdso32_pages + 1, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso32_pagelist == NULL);
        for (i = 0; i < vdso32_pages - 1; i++) {
@@ -303,7 +303,7 @@ static int __init vdso_init(void)
                         + PAGE_SIZE - 1) >> PAGE_SHIFT) + 1;
 
        /* Make sure pages are in the correct state */
-       vdso64_pagelist = kzalloc(sizeof(struct page *) * (vdso64_pages + 1),
+       vdso64_pagelist = kcalloc(vdso64_pages + 1, sizeof(struct page *),
                                  GFP_KERNEL);
        BUG_ON(vdso64_pagelist == NULL);
        for (i = 0; i < vdso64_pages - 1; i++) {
index c0dd904..e5a57a1 100644 (file)
@@ -154,7 +154,7 @@ static int __init dmabrg_init(void)
        unsigned long or;
        int ret;
 
-       dmabrg_handlers = kzalloc(10 * sizeof(struct dmabrg_handler),
+       dmabrg_handlers = kcalloc(10, sizeof(struct dmabrg_handler),
                                  GFP_KERNEL);
        if (!dmabrg_handlers)
                return -ENOMEM;
index 382e7ec..3d81a8b 100644 (file)
@@ -561,7 +561,7 @@ static int __init sh7786_pcie_init(void)
        if (unlikely(nr_ports == 0))
                return -ENODEV;
 
-       sh7786_pcie_ports = kzalloc(nr_ports * sizeof(struct sh7786_pcie_port),
+       sh7786_pcie_ports = kcalloc(nr_ports, sizeof(struct sh7786_pcie_port),
                                    GFP_KERNEL);
        if (unlikely(!sh7786_pcie_ports))
                return -ENOMEM;
index 33e3517..63baa8a 100644 (file)
@@ -565,7 +565,8 @@ SYSCALL_DEFINE5(utrap_install, utrap_entry_t, type,
        }
        if (!current_thread_info()->utraps) {
                current_thread_info()->utraps =
-                       kzalloc((UT_TRAP_INSTRUCTION_31+1)*sizeof(long), GFP_KERNEL);
+                       kcalloc(UT_TRAP_INSTRUCTION_31 + 1, sizeof(long),
+                               GFP_KERNEL);
                if (!current_thread_info()->utraps)
                        return -ENOMEM;
                current_thread_info()->utraps[0] = 1;
index 38b5d41..3210fee 100644 (file)
@@ -387,7 +387,7 @@ static __init int _init_events_attrs(void)
        while (amd_iommu_v2_event_descs[i].attr.attr.name)
                i++;
 
-       attrs = kzalloc(sizeof(struct attribute **) * (i + 1), GFP_KERNEL);
+       attrs = kcalloc(i + 1, sizeof(struct attribute **), GFP_KERNEL);
        if (!attrs)
                return -ENOMEM;
 
index e15cfad..27a4614 100644 (file)
@@ -868,7 +868,7 @@ static int __init uncore_type_init(struct intel_uncore_type *type, bool setid)
        size_t size;
        int i, j;
 
-       pmus = kzalloc(sizeof(*pmus) * type->num_boxes, GFP_KERNEL);
+       pmus = kcalloc(type->num_boxes, sizeof(*pmus), GFP_KERNEL);
        if (!pmus)
                return -ENOMEM;
 
index cd76380..e4cf6ff 100644 (file)
@@ -1457,7 +1457,7 @@ static int __mcheck_cpu_mce_banks_init(void)
        int i;
        u8 num_banks = mca_cfg.banks;
 
-       mce_banks = kzalloc(num_banks * sizeof(struct mce_bank), GFP_KERNEL);
+       mce_banks = kcalloc(num_banks, sizeof(struct mce_bank), GFP_KERNEL);
        if (!mce_banks)
                return -ENOMEM;
 
index f591b01..dd33c35 100644 (file)
@@ -1384,7 +1384,7 @@ int mce_threshold_create_device(unsigned int cpu)
        if (bp)
                return 0;
 
-       bp = kzalloc(sizeof(struct threshold_bank *) * mca_cfg.banks,
+       bp = kcalloc(mca_cfg.banks, sizeof(struct threshold_bank *),
                     GFP_KERNEL);
        if (!bp)
                return -ENOMEM;
index c610f47..4021d38 100644 (file)
@@ -43,7 +43,7 @@ mtrr_file_add(unsigned long base, unsigned long size,
 
        max = num_var_ranges;
        if (fcount == NULL) {
-               fcount = kzalloc(max * sizeof *fcount, GFP_KERNEL);
+               fcount = kcalloc(max, sizeof(*fcount), GFP_KERNEL);
                if (!fcount)
                        return -ENOMEM;
                FILE_FCOUNT(file) = fcount;
index ddccdea..346b248 100644 (file)
@@ -610,7 +610,7 @@ static void hpet_msi_capability_lookup(unsigned int start_timer)
        if (!hpet_domain)
                return;
 
-       hpet_devs = kzalloc(sizeof(struct hpet_dev) * num_timers, GFP_KERNEL);
+       hpet_devs = kcalloc(num_timers, sizeof(struct hpet_dev), GFP_KERNEL);
        if (!hpet_devs)
                return;
 
index 9542a74..9112d1c 100644 (file)
@@ -168,7 +168,7 @@ static int xen_setup_msi_irqs(struct pci_dev *dev, int nvec, int type)
        if (type == PCI_CAP_ID_MSI && nvec > 1)
                return 1;
 
-       v = kzalloc(sizeof(int) * max(1, nvec), GFP_KERNEL);
+       v = kcalloc(max(1, nvec), sizeof(int), GFP_KERNEL);
        if (!v)
                return -ENOMEM;
 
index b082d71..a36b368 100644 (file)
@@ -158,7 +158,7 @@ static __init int uv_rtc_allocate_timers(void)
 {
        int cpu;
 
-       blade_info = kzalloc(uv_possible_blades * sizeof(void *), GFP_KERNEL);
+       blade_info = kcalloc(uv_possible_blades, sizeof(void *), GFP_KERNEL);
        if (!blade_info)
                return -ENOMEM;
 
index db9a40e..9710e27 100644 (file)
@@ -2091,7 +2091,8 @@ static int __init init_bio(void)
 {
        bio_slab_max = 2;
        bio_slab_nr = 0;
-       bio_slabs = kzalloc(bio_slab_max * sizeof(struct bio_slab), GFP_KERNEL);
+       bio_slabs = kcalloc(bio_slab_max, sizeof(struct bio_slab),
+                           GFP_KERNEL);
        if (!bio_slabs)
                panic("bio: can't allocate bios\n");
 
index 09f19c6..24b20d8 100644 (file)
@@ -99,12 +99,12 @@ init_tag_map(struct request_queue *q, struct blk_queue_tag *tags, int depth)
                       __func__, depth);
        }
 
-       tag_index = kzalloc(depth * sizeof(struct request *), GFP_ATOMIC);
+       tag_index = kcalloc(depth, sizeof(struct request *), GFP_ATOMIC);
        if (!tag_index)
                goto fail;
 
        nr_ulongs = ALIGN(depth, BITS_PER_LONG) / BITS_PER_LONG;
-       tag_map = kzalloc(nr_ulongs * sizeof(unsigned long), GFP_ATOMIC);
+       tag_map = kcalloc(nr_ulongs, sizeof(unsigned long), GFP_ATOMIC);
        if (!tag_map)
                goto fail;
 
index 88cd949..eaa60c9 100644 (file)
@@ -82,7 +82,7 @@ struct platform_device *acpi_create_platform_device(struct acpi_device *adev,
        if (count < 0) {
                return NULL;
        } else if (count > 0) {
-               resources = kzalloc(count * sizeof(struct resource),
+               resources = kcalloc(count, sizeof(struct resource),
                                    GFP_KERNEL);
                if (!resources) {
                        dev_err(&adev->dev, "No memory for resources\n");
index 4fc59c3..41324f0 100644 (file)
@@ -857,12 +857,12 @@ void acpi_irq_stats_init(void)
        num_gpes = acpi_current_gpe_count;
        num_counters = num_gpes + ACPI_NUM_FIXED_EVENTS + NUM_COUNTERS_EXTRA;
 
-       all_attrs = kzalloc(sizeof(struct attribute *) * (num_counters + 1),
+       all_attrs = kcalloc(num_counters + 1, sizeof(struct attribute *),
                            GFP_KERNEL);
        if (all_attrs == NULL)
                return;
 
-       all_counters = kzalloc(sizeof(struct event_counter) * (num_counters),
+       all_counters = kcalloc(num_counters, sizeof(struct event_counter),
                               GFP_KERNEL);
        if (all_counters == NULL)
                goto fail;
@@ -871,7 +871,7 @@ void acpi_irq_stats_init(void)
        if (ACPI_FAILURE(status))
                goto fail;
 
-       counter_attrs = kzalloc(sizeof(struct kobj_attribute) * (num_counters),
+       counter_attrs = kcalloc(num_counters, sizeof(struct kobj_attribute),
                                GFP_KERNEL);
        if (counter_attrs == NULL)
                goto fail;
index 4f382d5..2628806 100644 (file)
@@ -692,8 +692,8 @@ int binder_alloc_mmap_handler(struct binder_alloc *alloc,
                }
        }
 #endif
-       alloc->pages = kzalloc(sizeof(alloc->pages[0]) *
-                                  ((vma->vm_end - vma->vm_start) / PAGE_SIZE),
+       alloc->pages = kcalloc((vma->vm_end - vma->vm_start) / PAGE_SIZE,
+                              sizeof(alloc->pages[0]),
                               GFP_KERNEL);
        if (alloc->pages == NULL) {
                ret = -ENOMEM;
index c41b9ee..27d15ed 100644 (file)
@@ -6987,7 +6987,7 @@ static void __init ata_parse_force_param(void)
                if (*p == ',')
                        size++;
 
-       ata_force_tbl = kzalloc(sizeof(ata_force_tbl[0]) * size, GFP_KERNEL);
+       ata_force_tbl = kcalloc(size, sizeof(ata_force_tbl[0]), GFP_KERNEL);
        if (!ata_force_tbl) {
                printk(KERN_WARNING "ata: failed to extend force table, "
                       "libata.force ignored\n");
index 85aa761..2ae1799 100644 (file)
@@ -340,7 +340,7 @@ static int sata_pmp_init_links (struct ata_port *ap, int nr_ports)
        int i, err;
 
        if (!pmp_link) {
-               pmp_link = kzalloc(sizeof(pmp_link[0]) * SATA_PMP_MAX_PORTS,
+               pmp_link = kcalloc(SATA_PMP_MAX_PORTS, sizeof(pmp_link[0]),
                                   GFP_NOIO);
                if (!pmp_link)
                        return -ENOMEM;
index 6ebc4e4..99a3811 100644 (file)
@@ -2094,7 +2094,8 @@ static int fore200e_alloc_rx_buf(struct fore200e *fore200e)
            DPRINTK(2, "rx buffers %d / %d are being allocated\n", scheme, magn);
 
            /* allocate the array of receive buffers */
-           buffer = bsq->buffer = kzalloc(nbr * sizeof(struct buffer), GFP_KERNEL);
+           buffer = bsq->buffer = kcalloc(nbr, sizeof(struct buffer),
+                                           GFP_KERNEL);
 
            if (buffer == NULL)
                return -ENOMEM;
index be07660..ff81a57 100644 (file)
@@ -1618,7 +1618,7 @@ static int rx_init(struct atm_dev *dev)
        skb_queue_head_init(&iadev->rx_dma_q);  
        iadev->rx_free_desc_qhead = NULL;   
 
-       iadev->rx_open = kzalloc(4 * iadev->num_vc, GFP_KERNEL);
+       iadev->rx_open = kcalloc(4, iadev->num_vc, GFP_KERNEL);
        if (!iadev->rx_open) {
                printk(KERN_ERR DEV_LABEL "itf %d couldn't get free page\n",
                dev->number);  
index 7655d61..a80809b 100644 (file)
@@ -511,7 +511,8 @@ static void drbd_calc_cpu_mask(cpumask_var_t *cpu_mask)
 {
        unsigned int *resources_per_cpu, min_index = ~0;
 
-       resources_per_cpu = kzalloc(nr_cpu_ids * sizeof(*resources_per_cpu), GFP_KERNEL);
+       resources_per_cpu = kcalloc(nr_cpu_ids, sizeof(*resources_per_cpu),
+                                   GFP_KERNEL);
        if (resources_per_cpu) {
                struct drbd_resource *resource;
                unsigned int cpu, min = ~0;
index 2bdadd7..7948049 100644 (file)
@@ -1575,12 +1575,12 @@ static int setup_commands(struct nullb_queue *nq)
        struct nullb_cmd *cmd;
        int i, tag_size;
 
-       nq->cmds = kzalloc(nq->queue_depth * sizeof(*cmd), GFP_KERNEL);
+       nq->cmds = kcalloc(nq->queue_depth, sizeof(*cmd), GFP_KERNEL);
        if (!nq->cmds)
                return -ENOMEM;
 
        tag_size = ALIGN(nq->queue_depth, BITS_PER_LONG) / BITS_PER_LONG;
-       nq->tag_map = kzalloc(tag_size * sizeof(unsigned long), GFP_KERNEL);
+       nq->tag_map = kcalloc(tag_size, sizeof(unsigned long), GFP_KERNEL);
        if (!nq->tag_map) {
                kfree(nq->cmds);
                return -ENOMEM;
@@ -1598,8 +1598,9 @@ static int setup_commands(struct nullb_queue *nq)
 
 static int setup_queues(struct nullb *nullb)
 {
-       nullb->queues = kzalloc(nullb->dev->submit_queues *
-               sizeof(struct nullb_queue), GFP_KERNEL);
+       nullb->queues = kcalloc(nullb->dev->submit_queues,
+                               sizeof(struct nullb_queue),
+                               GFP_KERNEL);
        if (!nullb->queues)
                return -ENOMEM;
 
index 8fa4533..1e3d5de 100644 (file)
@@ -407,8 +407,9 @@ static int ps3vram_cache_init(struct ps3_system_bus_device *dev)
 
        priv->cache.page_count = CACHE_PAGE_COUNT;
        priv->cache.page_size = CACHE_PAGE_SIZE;
-       priv->cache.tags = kzalloc(sizeof(struct ps3vram_tag) *
-                                  CACHE_PAGE_COUNT, GFP_KERNEL);
+       priv->cache.tags = kcalloc(CACHE_PAGE_COUNT,
+                                  sizeof(struct ps3vram_tag),
+                                  GFP_KERNEL);
        if (!priv->cache.tags)
                return -ENOMEM;
 
index 09537be..b7d7191 100644 (file)
@@ -873,7 +873,8 @@ static int rsxx_pci_probe(struct pci_dev *dev,
                dev_info(CARD_TO_DEV(card),
                        "Failed reading the number of DMA targets\n");
 
-       card->ctrl = kzalloc(card->n_targets * sizeof(*card->ctrl), GFP_KERNEL);
+       card->ctrl = kcalloc(card->n_targets, sizeof(*card->ctrl),
+                            GFP_KERNEL);
        if (!card->ctrl) {
                st = -ENOMEM;
                goto failed_dma_setup;
index beaccf1..8fbc1bf 100644 (file)
@@ -1038,7 +1038,7 @@ int rsxx_eeh_save_issued_dmas(struct rsxx_cardinfo *card)
        struct rsxx_dma *dma;
        struct list_head *issued_dmas;
 
-       issued_dmas = kzalloc(sizeof(*issued_dmas) * card->n_targets,
+       issued_dmas = kcalloc(card->n_targets, sizeof(*issued_dmas),
                              GFP_KERNEL);
        if (!issued_dmas)
                return -ENOMEM;
index 66412ee..a4bc74e 100644 (file)
@@ -139,7 +139,8 @@ static int xen_blkif_alloc_rings(struct xen_blkif *blkif)
 {
        unsigned int r;
 
-       blkif->rings = kzalloc(blkif->nr_rings * sizeof(struct xen_blkif_ring), GFP_KERNEL);
+       blkif->rings = kcalloc(blkif->nr_rings, sizeof(struct xen_blkif_ring),
+                              GFP_KERNEL);
        if (!blkif->rings)
                return -ENOMEM;
 
index ae00a82..b5cedcc 100644 (file)
@@ -1906,7 +1906,9 @@ static int negotiate_mq(struct blkfront_info *info)
        if (!info->nr_rings)
                info->nr_rings = 1;
 
-       info->rinfo = kzalloc(sizeof(struct blkfront_ring_info) * info->nr_rings, GFP_KERNEL);
+       info->rinfo = kcalloc(info->nr_rings,
+                             sizeof(struct blkfront_ring_info),
+                             GFP_KERNEL);
        if (!info->rinfo) {
                xenbus_dev_fatal(info->xbdev, -ENOMEM, "allocating ring_info structure");
                return -ENOMEM;
@@ -2216,15 +2218,18 @@ static int blkfront_setup_indirect(struct blkfront_ring_info *rinfo)
        }
 
        for (i = 0; i < BLK_RING_SIZE(info); i++) {
-               rinfo->shadow[i].grants_used = kzalloc(
-                       sizeof(rinfo->shadow[i].grants_used[0]) * grants,
-                       GFP_NOIO);
-               rinfo->shadow[i].sg = kzalloc(sizeof(rinfo->shadow[i].sg[0]) * psegs, GFP_NOIO);
-               if (info->max_indirect_segments)
-                       rinfo->shadow[i].indirect_grants = kzalloc(
-                               sizeof(rinfo->shadow[i].indirect_grants[0]) *
-                               INDIRECT_GREFS(grants),
+               rinfo->shadow[i].grants_used =
+                       kcalloc(grants,
+                               sizeof(rinfo->shadow[i].grants_used[0]),
                                GFP_NOIO);
+               rinfo->shadow[i].sg = kcalloc(psegs,
+                                             sizeof(rinfo->shadow[i].sg[0]),
+                                             GFP_NOIO);
+               if (info->max_indirect_segments)
+                       rinfo->shadow[i].indirect_grants =
+                               kcalloc(INDIRECT_GREFS(grants),
+                                       sizeof(rinfo->shadow[i].indirect_grants[0]),
+                                       GFP_NOIO);
                if ((rinfo->shadow[i].grants_used == NULL) ||
                        (rinfo->shadow[i].sg == NULL) ||
                     (info->max_indirect_segments &&
index b450544..6914e4f 100644 (file)
@@ -85,7 +85,8 @@ static int amd_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct amd_page_map *),GFP_KERNEL);
+       tables = kcalloc(nr_tables + 1, sizeof(struct amd_page_map *),
+                        GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
 
index 88b4cbe..20bf5f7 100644 (file)
@@ -108,7 +108,8 @@ static int ati_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct ati_page_map *),GFP_KERNEL);
+       tables = kcalloc(nr_tables + 1, sizeof(struct ati_page_map *),
+                        GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
 
index 4dbdd3b..7729414 100644 (file)
@@ -96,7 +96,7 @@ static int serverworks_create_gatt_pages(int nr_tables)
        int retval = 0;
        int i;
 
-       tables = kzalloc((nr_tables + 1) * sizeof(struct serverworks_page_map *),
+       tables = kcalloc(nr_tables + 1, sizeof(struct serverworks_page_map *),
                         GFP_KERNEL);
        if (tables == NULL)
                return -ENOMEM;
index 22f634e..18e4650 100644 (file)
@@ -1757,7 +1757,8 @@ static unsigned short *ssif_address_list(void)
        list_for_each_entry(info, &ssif_infos, link)
                count++;
 
-       address_list = kzalloc(sizeof(*address_list) * (count + 1), GFP_KERNEL);
+       address_list = kcalloc(count + 1, sizeof(*address_list),
+                              GFP_KERNEL);
        if (!address_list)
                return NULL;
 
index d074f8e..a7a30d2 100644 (file)
@@ -161,7 +161,7 @@ static void __init r8a7740_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index 27fbfaf..5adcca4 100644 (file)
@@ -138,7 +138,7 @@ static void __init r8a7779_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(CPG_NUM_CLOCKS * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(CPG_NUM_CLOCKS, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index ee32a02..bccd62f 100644 (file)
@@ -417,7 +417,7 @@ static void __init rcar_gen2_cpg_clocks_init(struct device_node *np)
        }
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        if (cpg == NULL || clks == NULL) {
                /* We're leaking memory on purpose, there's no point in cleaning
                 * up as the system won't boot anyway.
index 67dd712..ac2f86d 100644 (file)
@@ -97,7 +97,7 @@ static void __init rz_cpg_clocks_init(struct device_node *np)
                return;
 
        cpg = kzalloc(sizeof(*cpg), GFP_KERNEL);
-       clks = kzalloc(num_clks * sizeof(*clks), GFP_KERNEL);
+       clks = kcalloc(num_clks, sizeof(*clks), GFP_KERNEL);
        BUG_ON(!cpg || !clks);
 
        cpg->data.clks = clks;
index 14819d9..a79d819 100644 (file)
@@ -874,7 +874,7 @@ static void __init st_of_create_quadfs_fsynths(
                return;
 
        clk_data->clk_num = QUADFS_MAX_CHAN;
-       clk_data->clks = kzalloc(QUADFS_MAX_CHAN * sizeof(struct clk *),
+       clk_data->clks = kcalloc(QUADFS_MAX_CHAN, sizeof(struct clk *),
                                 GFP_KERNEL);
 
        if (!clk_data->clks) {
index 25bda48..7a7106d 100644 (file)
@@ -738,7 +738,7 @@ static void __init clkgen_c32_pll_setup(struct device_node *np,
                return;
 
        clk_data->clk_num = num_odfs;
-       clk_data->clks = kzalloc(clk_data->clk_num * sizeof(struct clk *),
+       clk_data->clks = kcalloc(clk_data->clk_num, sizeof(struct clk *),
                                 GFP_KERNEL);
 
        if (!clk_data->clks)
index fe0c3d1..917fc27 100644 (file)
@@ -122,7 +122,7 @@ static void __init sunxi_usb_clk_setup(struct device_node *node,
        if (!clk_data)
                return;
 
-       clk_data->clks = kzalloc((qty+1) * sizeof(struct clk *), GFP_KERNEL);
+       clk_data->clks = kcalloc(qty + 1, sizeof(struct clk *), GFP_KERNEL);
        if (!clk_data->clks) {
                kfree(clk_data);
                return;
index 593d76a..ffaf17f 100644 (file)
@@ -216,14 +216,15 @@ struct clk ** __init tegra_clk_init(void __iomem *regs, int num, int banks)
        if (WARN_ON(banks > ARRAY_SIZE(periph_regs)))
                return NULL;
 
-       periph_clk_enb_refcnt = kzalloc(32 * banks *
-                               sizeof(*periph_clk_enb_refcnt), GFP_KERNEL);
+       periph_clk_enb_refcnt = kcalloc(32 * banks,
+                                       sizeof(*periph_clk_enb_refcnt),
+                                       GFP_KERNEL);
        if (!periph_clk_enb_refcnt)
                return NULL;
 
        periph_banks = banks;
 
-       clks = kzalloc(num * sizeof(struct clk *), GFP_KERNEL);
+       clks = kcalloc(num, sizeof(struct clk *), GFP_KERNEL);
        if (!clks)
                kfree(periph_clk_enb_refcnt);
 
index 9498e93..61c126a 100644 (file)
@@ -206,7 +206,7 @@ static void __init of_dra7_apll_setup(struct device_node *node)
                goto cleanup;
        }
 
-       parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
+       parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
        if (!parent_names)
                goto cleanup;
 
index aaa277d..ccfb4d9 100644 (file)
@@ -366,7 +366,7 @@ int ti_clk_parse_divider_data(int *div_table, int num_dividers, int max_div,
 
        num_dividers = i;
 
-       tmp = kzalloc(sizeof(*tmp) * (valid_div + 1), GFP_KERNEL);
+       tmp = kcalloc(valid_div + 1, sizeof(*tmp), GFP_KERNEL);
        if (!tmp)
                return -ENOMEM;
 
@@ -496,7 +496,7 @@ __init ti_clk_get_div_table(struct device_node *node)
                return ERR_PTR(-EINVAL);
        }
 
-       table = kzalloc(sizeof(*table) * (valid_div + 1), GFP_KERNEL);
+       table = kcalloc(valid_div + 1, sizeof(*table), GFP_KERNEL);
 
        if (!table)
                return ERR_PTR(-ENOMEM);
index 7d33ca9..dc86d07 100644 (file)
@@ -309,7 +309,7 @@ static void __init of_ti_dpll_setup(struct device_node *node,
                goto cleanup;
        }
 
-       parent_names = kzalloc(sizeof(char *) * init->num_parents, GFP_KERNEL);
+       parent_names = kcalloc(init->num_parents, sizeof(char *), GFP_KERNEL);
        if (!parent_names)
                goto cleanup;
 
index 70b3cf8..bbbf37c 100644 (file)
@@ -1000,7 +1000,7 @@ static int sh_cmt_setup(struct sh_cmt_device *cmt, struct platform_device *pdev)
 
        /* Allocate and setup the channels. */
        cmt->num_channels = hweight8(cmt->hw_channels);
-       cmt->channels = kzalloc(cmt->num_channels * sizeof(*cmt->channels),
+       cmt->channels = kcalloc(cmt->num_channels, sizeof(*cmt->channels),
                                GFP_KERNEL);
        if (cmt->channels == NULL) {
                ret = -ENOMEM;
index 53aa7e9..6812e09 100644 (file)
@@ -418,7 +418,7 @@ static int sh_mtu2_setup(struct sh_mtu2_device *mtu,
        /* Allocate and setup the channels. */
        mtu->num_channels = 3;
 
-       mtu->channels = kzalloc(sizeof(*mtu->channels) * mtu->num_channels,
+       mtu->channels = kcalloc(mtu->num_channels, sizeof(*mtu->channels),
                                GFP_KERNEL);
        if (mtu->channels == NULL) {
                ret = -ENOMEM;
index 31d8816..c74a6c5 100644 (file)
@@ -569,7 +569,7 @@ static int sh_tmu_setup(struct sh_tmu_device *tmu, struct platform_device *pdev)
        }
 
        /* Allocate and setup the channels. */
-       tmu->channels = kzalloc(sizeof(*tmu->channels) * tmu->num_channels,
+       tmu->channels = kcalloc(tmu->num_channels, sizeof(*tmu->channels),
                                GFP_KERNEL);
        if (tmu->channels == NULL) {
                ret = -ENOMEM;
index 9449657..8ff1c91 100644 (file)
@@ -759,8 +759,8 @@ static int acpi_cpufreq_cpu_init(struct cpufreq_policy *policy)
                goto err_unreg;
        }
 
-       freq_table = kzalloc(sizeof(*freq_table) *
-                   (perf->state_count+1), GFP_KERNEL);
+       freq_table = kcalloc(perf->state_count + 1, sizeof(*freq_table),
+                            GFP_KERNEL);
        if (!freq_table) {
                result = -ENOMEM;
                goto err_unreg;
index 1d7ef5f..cf62a1f 100644 (file)
@@ -280,7 +280,7 @@ static int merge_cluster_tables(void)
        for (i = 0; i < MAX_CLUSTERS; i++)
                count += get_table_count(freq_table[i]);
 
-       table = kzalloc(sizeof(*table) * count, GFP_KERNEL);
+       table = kcalloc(count, sizeof(*table), GFP_KERNEL);
        if (!table)
                return -ENOMEM;
 
index 3464580..a9d3eec 100644 (file)
@@ -313,7 +313,8 @@ static int __init cppc_cpufreq_init(void)
        if (acpi_disabled)
                return -ENODEV;
 
-       all_cpu_data = kzalloc(sizeof(void *) * num_possible_cpus(), GFP_KERNEL);
+       all_cpu_data = kcalloc(num_possible_cpus(), sizeof(void *),
+                              GFP_KERNEL);
        if (!all_cpu_data)
                return -ENOMEM;
 
index 7974a2f..dd5440d 100644 (file)
@@ -241,8 +241,8 @@ acpi_cpufreq_cpu_init (
        }
 
        /* alloc freq_table */
-       freq_table = kzalloc(sizeof(*freq_table) *
-                                  (data->acpi_data.state_count + 1),
+       freq_table = kcalloc(data->acpi_data.state_count + 1,
+                                  sizeof(*freq_table),
                                   GFP_KERNEL);
        if (!freq_table) {
                result = -ENOMEM;
index 61a4c5b..279bd9e 100644 (file)
@@ -474,8 +474,8 @@ static int longhaul_get_ranges(void)
                return -EINVAL;
        }
 
-       longhaul_table = kzalloc((numscales + 1) * sizeof(*longhaul_table),
-                       GFP_KERNEL);
+       longhaul_table = kcalloc(numscales + 1, sizeof(*longhaul_table),
+                                GFP_KERNEL);
        if (!longhaul_table)
                return -ENOMEM;
 
index 7acc7fa..9daa2cc 100644 (file)
@@ -93,7 +93,7 @@ static int setup_freqs_table(struct cpufreq_policy *policy,
        struct cpufreq_frequency_table *table;
        int i;
 
-       table = kzalloc((num + 1) * sizeof(*table), GFP_KERNEL);
+       table = kcalloc(num + 1, sizeof(*table), GFP_KERNEL);
        if (table == NULL)
                return -ENOMEM;
 
index 909bd6e..3b291a2 100644 (file)
@@ -562,7 +562,7 @@ static int s3c_cpufreq_build_freq(void)
        size = cpu_cur.info->calc_freqtable(&cpu_cur, NULL, 0);
        size++;
 
-       ftab = kzalloc(sizeof(*ftab) * size, GFP_KERNEL);
+       ftab = kcalloc(size, sizeof(*ftab), GFP_KERNEL);
        if (!ftab)
                return -ENOMEM;
 
index 9767afe..9787704 100644 (file)
@@ -95,8 +95,8 @@ static int __init sfi_cpufreq_init(void)
        if (ret)
                return ret;
 
-       freq_table = kzalloc(sizeof(*freq_table) *
-                       (num_freq_table_entries + 1), GFP_KERNEL);
+       freq_table = kcalloc(num_freq_table_entries + 1, sizeof(*freq_table),
+                            GFP_KERNEL);
        if (!freq_table) {
                ret = -ENOMEM;
                goto err_free_array;
index 195f27f..4074e26 100644 (file)
@@ -195,7 +195,7 @@ static int spear_cpufreq_probe(struct platform_device *pdev)
        cnt = prop->length / sizeof(u32);
        val = prop->value;
 
-       freq_tbl = kzalloc(sizeof(*freq_tbl) * (cnt + 1), GFP_KERNEL);
+       freq_tbl = kcalloc(cnt + 1, sizeof(*freq_tbl), GFP_KERNEL);
        if (!freq_tbl) {
                ret = -ENOMEM;
                goto out_put_node;
index 9cb234c..05981cc 100644 (file)
@@ -141,11 +141,11 @@ static void crypto4xx_hw_init(struct crypto4xx_device *dev)
 
 int crypto4xx_alloc_sa(struct crypto4xx_ctx *ctx, u32 size)
 {
-       ctx->sa_in = kzalloc(size * 4, GFP_ATOMIC);
+       ctx->sa_in = kcalloc(size, 4, GFP_ATOMIC);
        if (ctx->sa_in == NULL)
                return -ENOMEM;
 
-       ctx->sa_out = kzalloc(size * 4, GFP_ATOMIC);
+       ctx->sa_out = kcalloc(size, 4, GFP_ATOMIC);
        if (ctx->sa_out == NULL) {
                kfree(ctx->sa_in);
                ctx->sa_in = NULL;
@@ -180,8 +180,8 @@ static u32 crypto4xx_build_pdr(struct crypto4xx_device *dev)
        if (!dev->pdr)
                return -ENOMEM;
 
-       dev->pdr_uinfo = kzalloc(sizeof(struct pd_uinfo) * PPC4XX_NUM_PD,
-                               GFP_KERNEL);
+       dev->pdr_uinfo = kcalloc(PPC4XX_NUM_PD, sizeof(struct pd_uinfo),
+                                GFP_KERNEL);
        if (!dev->pdr_uinfo) {
                dma_free_coherent(dev->core_dev->device,
                                  sizeof(struct ce_pd) * PPC4XX_NUM_PD,
index d138d6b..c77b0e1 100644 (file)
@@ -922,7 +922,7 @@ int safexcel_hmac_setkey(const char *alg, const u8 *key, unsigned int keylen,
        crypto_ahash_clear_flags(tfm, ~0);
        blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
 
-       ipad = kzalloc(2 * blocksize, GFP_KERNEL);
+       ipad = kcalloc(2, blocksize, GFP_KERNEL);
        if (!ipad) {
                ret = -ENOMEM;
                goto free_request;
index e61b085..e34d80b 100644 (file)
@@ -1198,7 +1198,7 @@ static int mv_cesa_ahmac_setkey(const char *hash_alg_name,
 
        blocksize = crypto_tfm_alg_blocksize(crypto_ahash_tfm(tfm));
 
-       ipad = kzalloc(2 * blocksize, GFP_KERNEL);
+       ipad = kcalloc(2, blocksize, GFP_KERNEL);
        if (!ipad) {
                ret = -ENOMEM;
                goto free_req;
index 80e9c84..ab6235b 100644 (file)
@@ -1919,12 +1919,12 @@ static int grab_global_resources(void)
                goto out_hvapi_release;
 
        err = -ENOMEM;
-       cpu_to_cwq = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
+       cpu_to_cwq = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
                             GFP_KERNEL);
        if (!cpu_to_cwq)
                goto out_queue_cache_destroy;
 
-       cpu_to_mau = kzalloc(sizeof(struct spu_queue *) * NR_CPUS,
+       cpu_to_mau = kcalloc(NR_CPUS, sizeof(struct spu_queue *),
                             GFP_KERNEL);
        if (!cpu_to_mau)
                goto out_free_cwq_table;
index 98d22c2..6bd8f6a 100644 (file)
@@ -1162,8 +1162,9 @@ static int qat_uclo_map_suof(struct icp_qat_fw_loader_handle *handle,
        suof_handle->img_table.num_simgs = suof_ptr->num_chunks - 1;
 
        if (suof_handle->img_table.num_simgs != 0) {
-               suof_img_hdr = kzalloc(suof_handle->img_table.num_simgs *
-                                      sizeof(img_header), GFP_KERNEL);
+               suof_img_hdr = kcalloc(suof_handle->img_table.num_simgs,
+                                      sizeof(img_header),
+                                      GFP_KERNEL);
                if (!suof_img_hdr)
                        return -ENOMEM;
                suof_handle->img_table.simg_hdr = suof_img_hdr;
index 7792a91..4fa4c06 100644 (file)
@@ -322,10 +322,10 @@ static int ioat_dma_self_test(struct ioatdma_device *ioat_dma)
        unsigned long tmo;
        unsigned long flags;
 
-       src = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
+       src = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
        if (!src)
                return -ENOMEM;
-       dest = kzalloc(sizeof(u8) * IOAT_TEST_SIZE, GFP_KERNEL);
+       dest = kzalloc(IOAT_TEST_SIZE, GFP_KERNEL);
        if (!dest) {
                kfree(src);
                return -ENOMEM;
index 4528b56..969534c 100644 (file)
@@ -781,7 +781,7 @@ static int mv_chan_memcpy_self_test(struct mv_xor_chan *mv_chan)
        if (!src)
                return -ENOMEM;
 
-       dest = kzalloc(sizeof(u8) * PAGE_SIZE, GFP_KERNEL);
+       dest = kzalloc(PAGE_SIZE, GFP_KERNEL);
        if (!dest) {
                kfree(src);
                return -ENOMEM;
index 6237069..defcdde 100644 (file)
@@ -1866,7 +1866,7 @@ static int dmac_alloc_threads(struct pl330_dmac *pl330)
        int i;
 
        /* Allocate 1 Manager and 'chans' Channel threads */
-       pl330->channels = kzalloc((1 + chans) * sizeof(*thrd),
+       pl330->channels = kcalloc(1 + chans, sizeof(*thrd),
                                        GFP_KERNEL);
        if (!pl330->channels)
                return -ENOMEM;
@@ -2990,7 +2990,7 @@ pl330_probe(struct amba_device *adev, const struct amba_id *id)
 
        pl330->num_peripherals = num_chan;
 
-       pl330->peripherals = kzalloc(num_chan * sizeof(*pch), GFP_KERNEL);
+       pl330->peripherals = kcalloc(num_chan, sizeof(*pch), GFP_KERNEL);
        if (!pl330->peripherals) {
                ret = -ENOMEM;
                goto probe_err2;
index 12fa48e..6b5626e 100644 (file)
@@ -1045,8 +1045,9 @@ EXPORT_SYMBOL(shdma_cleanup);
 
 static int __init shdma_enter(void)
 {
-       shdma_slave_used = kzalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG) *
-                                   sizeof(long), GFP_KERNEL);
+       shdma_slave_used = kcalloc(DIV_ROUND_UP(slave_num, BITS_PER_LONG),
+                                  sizeof(long),
+                                  GFP_KERNEL);
        if (!shdma_slave_used)
                return -ENOMEM;
        return 0;
index f146458..c74a88b 100644 (file)
@@ -471,7 +471,7 @@ static int zynqmp_dma_alloc_chan_resources(struct dma_chan *dchan)
        if (ret < 0)
                return ret;
 
-       chan->sw_desc_pool = kzalloc(sizeof(*desc) * ZYNQMP_DMA_NUM_DESCS,
+       chan->sw_desc_pool = kcalloc(ZYNQMP_DMA_NUM_DESCS, sizeof(*desc),
                                     GFP_KERNEL);
        if (!chan->sw_desc_pool)
                return -ENOMEM;
index 329cb96..18aeabb 100644 (file)
@@ -3451,7 +3451,7 @@ static int __init amd64_edac_init(void)
        opstate_init();
 
        err = -ENOMEM;
-       ecc_stngs = kzalloc(amd_nb_num() * sizeof(ecc_stngs[0]), GFP_KERNEL);
+       ecc_stngs = kcalloc(amd_nb_num(), sizeof(ecc_stngs[0]), GFP_KERNEL);
        if (!ecc_stngs)
                goto err_free;
 
index 4d0ea35..8ed4dd9 100644 (file)
@@ -461,7 +461,7 @@ static struct i7core_dev *alloc_i7core_dev(u8 socket,
        if (!i7core_dev)
                return NULL;
 
-       i7core_dev->pdev = kzalloc(sizeof(*i7core_dev->pdev) * table->n_devs,
+       i7core_dev->pdev = kcalloc(table->n_devs, sizeof(*i7core_dev->pdev),
                                   GFP_KERNEL);
        if (!i7core_dev->pdev) {
                kfree(i7core_dev);
index 8bff5fd..af83ad5 100644 (file)
@@ -1126,8 +1126,9 @@ int extcon_dev_register(struct extcon_dev *edev)
                char *str;
                struct extcon_cable *cable;
 
-               edev->cables = kzalloc(sizeof(struct extcon_cable) *
-                                      edev->max_supported, GFP_KERNEL);
+               edev->cables = kcalloc(edev->max_supported,
+                                      sizeof(struct extcon_cable),
+                                      GFP_KERNEL);
                if (!edev->cables) {
                        ret = -ENOMEM;
                        goto err_sysfs_alloc;
@@ -1136,7 +1137,7 @@ int extcon_dev_register(struct extcon_dev *edev)
                        cable = &edev->cables[index];
 
                        snprintf(buf, 10, "cable.%d", index);
-                       str = kzalloc(sizeof(char) * (strlen(buf) + 1),
+                       str = kzalloc(strlen(buf) + 1,
                                      GFP_KERNEL);
                        if (!str) {
                                for (index--; index >= 0; index--) {
@@ -1177,15 +1178,17 @@ int extcon_dev_register(struct extcon_dev *edev)
                for (index = 0; edev->mutually_exclusive[index]; index++)
                        ;
 
-               edev->attrs_muex = kzalloc(sizeof(struct attribute *) *
-                                          (index + 1), GFP_KERNEL);
+               edev->attrs_muex = kcalloc(index + 1,
+                                          sizeof(struct attribute *),
+                                          GFP_KERNEL);
                if (!edev->attrs_muex) {
                        ret = -ENOMEM;
                        goto err_muex;
                }
 
-               edev->d_attrs_muex = kzalloc(sizeof(struct device_attribute) *
-                                            index, GFP_KERNEL);
+               edev->d_attrs_muex = kcalloc(index,
+                                            sizeof(struct device_attribute),
+                                            GFP_KERNEL);
                if (!edev->d_attrs_muex) {
                        ret = -ENOMEM;
                        kfree(edev->attrs_muex);
@@ -1194,7 +1197,7 @@ int extcon_dev_register(struct extcon_dev *edev)
 
                for (index = 0; edev->mutually_exclusive[index]; index++) {
                        sprintf(buf, "0x%x", edev->mutually_exclusive[index]);
-                       name = kzalloc(sizeof(char) * (strlen(buf) + 1),
+                       name = kzalloc(strlen(buf) + 1,
                                       GFP_KERNEL);
                        if (!name) {
                                for (index--; index >= 0; index--) {
@@ -1220,8 +1223,9 @@ int extcon_dev_register(struct extcon_dev *edev)
 
        if (edev->max_supported) {
                edev->extcon_dev_type.groups =
-                       kzalloc(sizeof(struct attribute_group *) *
-                               (edev->max_supported + 2), GFP_KERNEL);
+                       kcalloc(edev->max_supported + 2,
+                               sizeof(struct attribute_group *),
+                               GFP_KERNEL);
                if (!edev->extcon_dev_type.groups) {
                        ret = -ENOMEM;
                        goto err_alloc_groups;
index 2f452f1..fb8af5c 100644 (file)
@@ -146,7 +146,7 @@ static int create_packet(void *data, size_t length)
        packet_array_size = max(
                        (unsigned int)(allocation_floor / rbu_data.packetsize),
                        (unsigned int)1);
-       invalid_addr_packet_array = kzalloc(packet_array_size * sizeof(void*),
+       invalid_addr_packet_array = kcalloc(packet_array_size, sizeof(void *),
                                                GFP_KERNEL);
 
        if (!invalid_addr_packet_array) {
index 901b930..4938c29 100644 (file)
@@ -231,7 +231,7 @@ int efi_capsule_update(efi_capsule_header_t *capsule, phys_addr_t *pages)
        count = DIV_ROUND_UP(imagesize, PAGE_SIZE);
        sg_count = sg_pages_num(count);
 
-       sg_pages = kzalloc(sg_count * sizeof(*sg_pages), GFP_KERNEL);
+       sg_pages = kcalloc(sg_count, sizeof(*sg_pages), GFP_KERNEL);
        if (!sg_pages)
                return -ENOMEM;
 
index f377609..84a11d0 100644 (file)
@@ -166,7 +166,7 @@ int __init efi_runtime_map_init(struct kobject *efi_kobj)
        if (!efi_enabled(EFI_MEMMAP))
                return 0;
 
-       map_entries = kzalloc(efi.memmap.nr_map * sizeof(entry), GFP_KERNEL);
+       map_entries = kcalloc(efi.memmap.nr_map, sizeof(entry), GFP_KERNEL);
        if (!map_entries) {
                ret = -ENOMEM;
                goto out;
index ffdc176..d0e65b8 100644 (file)
@@ -48,8 +48,8 @@ static struct sdb_array *__fmc_scan_sdb_tree(struct fmc_device *fmc,
        arr = kzalloc(sizeof(*arr), GFP_KERNEL);
        if (!arr)
                return ERR_PTR(-ENOMEM);
-       arr->record = kzalloc(sizeof(arr->record[0]) * n, GFP_KERNEL);
-       arr->subtree = kzalloc(sizeof(arr->subtree[0]) * n, GFP_KERNEL);
+       arr->record = kcalloc(n, sizeof(arr->record[0]), GFP_KERNEL);
+       arr->subtree = kcalloc(n, sizeof(arr->subtree[0]), GFP_KERNEL);
        if (!arr->record || !arr->subtree) {
                kfree(arr->record);
                kfree(arr->subtree);
index e2bee27..b23d9a3 100644 (file)
@@ -443,7 +443,7 @@ static int ioh_gpio_probe(struct pci_dev *pdev,
                goto err_iomap;
        }
 
-       chip_save = kzalloc(sizeof(*chip) * 8, GFP_KERNEL);
+       chip_save = kcalloc(8, sizeof(*chip), GFP_KERNEL);
        if (chip_save == NULL) {
                ret = -ENOMEM;
                goto err_kzalloc;
index 428e5eb..f4c474a 100644 (file)
@@ -310,20 +310,20 @@ static int acp_hw_init(void *handle)
                pm_genpd_init(&adev->acp.acp_genpd->gpd, NULL, false);
        }
 
-       adev->acp.acp_cell = kzalloc(sizeof(struct mfd_cell) * ACP_DEVS,
+       adev->acp.acp_cell = kcalloc(ACP_DEVS, sizeof(struct mfd_cell),
                                                        GFP_KERNEL);
 
        if (adev->acp.acp_cell == NULL)
                return -ENOMEM;
 
-       adev->acp.acp_res = kzalloc(sizeof(struct resource) * 4, GFP_KERNEL);
+       adev->acp.acp_res = kcalloc(4, sizeof(struct resource), GFP_KERNEL);
 
        if (adev->acp.acp_res == NULL) {
                kfree(adev->acp.acp_cell);
                return -ENOMEM;
        }
 
-       i2s_pdata = kzalloc(sizeof(struct i2s_platform_data) * 2, GFP_KERNEL);
+       i2s_pdata = kcalloc(2, sizeof(struct i2s_platform_data), GFP_KERNEL);
        if (i2s_pdata == NULL) {
                kfree(adev->acp.acp_res);
                kfree(adev->acp.acp_cell);
index def1010..77ad59a 100644 (file)
@@ -452,7 +452,7 @@ int amdgpu_parse_extended_power_table(struct amdgpu_device *adev)
                        ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
 
                        adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
-                               kzalloc(psl->ucNumEntries *
+                               kcalloc(psl->ucNumEntries,
                                        sizeof(struct amdgpu_phase_shedding_limits_entry),
                                        GFP_KERNEL);
                        if (!adev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
index d167e8a..e387825 100644 (file)
@@ -53,7 +53,7 @@ static void amdgpu_do_test_moves(struct amdgpu_device *adev)
                n -= adev->irq.ih.ring_size;
        n /= size;
 
-       gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
+       gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
        if (!gtt_obj) {
                DRM_ERROR("Failed to allocate %d pointers\n", n);
                r = 1;
index 69500a8..e9934de 100644 (file)
@@ -1221,7 +1221,7 @@ static int amdgpu_atom_execute_table_locked(struct atom_context *ctx, int index,
        ectx.abort = false;
        ectx.last_jump = 0;
        if (ws)
-               ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
+               ectx.ws = kcalloc(4, ws, GFP_KERNEL);
        else
                ectx.ws = NULL;
 
index a266dcf..7fbad2f 100644 (file)
@@ -5679,8 +5679,9 @@ static int ci_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -5927,7 +5928,9 @@ static int ci_dpm_init(struct amdgpu_device *adev)
        ci_set_private_data_variables_based_on_pptable(adev);
 
        adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct amdgpu_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                ci_dpm_fini(adev);
                return -ENOMEM;
index 17f7f07..7a1e77c 100644 (file)
@@ -2727,8 +2727,9 @@ static int kv_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index b12d7c9..5c97a36 100644 (file)
@@ -7242,8 +7242,9 @@ static int si_parse_power_table(struct amdgpu_device *adev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       adev->pm.dpm.ps = kzalloc(sizeof(struct amdgpu_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       adev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct amdgpu_ps),
+                                 GFP_KERNEL);
        if (!adev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -7346,7 +7347,9 @@ static int si_dpm_init(struct amdgpu_device *adev)
                return ret;
 
        adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct amdgpu_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct amdgpu_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!adev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                amdgpu_free_extended_power_table(adev);
                return -ENOMEM;
index bd44935..ec304b1 100644 (file)
@@ -435,7 +435,7 @@ bool dm_helpers_submit_i2c(
                return false;
        }
 
-       msgs = kzalloc(num * sizeof(struct i2c_msg), GFP_KERNEL);
+       msgs = kcalloc(num, sizeof(struct i2c_msg), GFP_KERNEL);
 
        if (!msgs)
                return false;
index 738a818..0866874 100644 (file)
@@ -364,7 +364,7 @@ void dm_logger_open(
        entry->type = log_type;
        entry->logger = logger;
 
-       entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE * sizeof(char),
+       entry->buf = kzalloc(DAL_LOGGER_BUFFER_MAX_SIZE,
                             GFP_KERNEL);
 
        entry->buf_offset = 0;
index 217b8f1..d28e9cf 100644 (file)
@@ -40,7 +40,7 @@ bool dal_vector_construct(
                return false;
        }
 
-       vector->container = kzalloc(struct_size * capacity, GFP_KERNEL);
+       vector->container = kcalloc(capacity, struct_size, GFP_KERNEL);
        if (vector->container == NULL)
                return false;
        vector->capacity = capacity;
@@ -67,7 +67,7 @@ bool dal_vector_presized_costruct(
                return false;
        }
 
-       vector->container = kzalloc(struct_size * count, GFP_KERNEL);
+       vector->container = kcalloc(count, struct_size, GFP_KERNEL);
 
        if (vector->container == NULL)
                return false;
index 599c7ab..88b09dd 100644 (file)
@@ -1079,13 +1079,15 @@ static void get_ss_info_from_atombios(
        if (*ss_entries_num == 0)
                return;
 
-       ss_info = kzalloc(sizeof(struct spread_spectrum_info) * (*ss_entries_num),
+       ss_info = kcalloc(*ss_entries_num,
+                         sizeof(struct spread_spectrum_info),
                          GFP_KERNEL);
        ss_info_cur = ss_info;
        if (ss_info == NULL)
                return;
 
-       ss_data = kzalloc(sizeof(struct spread_spectrum_data) * (*ss_entries_num),
+       ss_data = kcalloc(*ss_entries_num,
+                         sizeof(struct spread_spectrum_data),
                          GFP_KERNEL);
        if (ss_data == NULL)
                goto out_free_info;
index 80038e0..ab5483c 100644 (file)
@@ -98,7 +98,8 @@ struct gpio_service *dal_gpio_service_create(
                        if (number_of_bits) {
                                uint32_t index_of_uint = 0;
 
-                               slot = kzalloc(number_of_uints * sizeof(uint32_t),
+                               slot = kcalloc(number_of_uints,
+                                              sizeof(uint32_t),
                                               GFP_KERNEL);
 
                                if (!slot) {
index 0cd111d..2533274 100644 (file)
@@ -1413,13 +1413,15 @@ bool calculate_user_regamma_ramp(struct dc_transfer_func *output_tf,
 
        output_tf->type = TF_TYPE_DISTRIBUTED_POINTS;
 
-       rgb_user = kzalloc(sizeof(*rgb_user) * (GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS),
-                       GFP_KERNEL);
+       rgb_user = kcalloc(GAMMA_RGB_256_ENTRIES + _EXTRA_POINTS,
+                          sizeof(*rgb_user),
+                          GFP_KERNEL);
        if (!rgb_user)
                goto rgb_user_alloc_fail;
 
-       rgb_regamma = kzalloc(sizeof(*rgb_regamma) * (MAX_HW_POINTS + _EXTRA_POINTS),
-                       GFP_KERNEL);
+       rgb_regamma = kcalloc(MAX_HW_POINTS + _EXTRA_POINTS,
+                             sizeof(*rgb_regamma),
+                             GFP_KERNEL);
        if (!rgb_regamma)
                goto rgb_regamma_alloc_fail;
 
index 27d4003..fa344ce 100644 (file)
@@ -155,7 +155,8 @@ struct mod_freesync *mod_freesync_create(struct dc *dc)
        if (core_freesync == NULL)
                goto fail_alloc_context;
 
-       core_freesync->map = kzalloc(sizeof(struct freesync_entity) * MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
+       core_freesync->map = kcalloc(MOD_FREESYNC_MAX_CONCURRENT_STREAMS,
+                                       sizeof(struct freesync_entity),
                                        GFP_KERNEL);
 
        if (core_freesync->map == NULL)
index 3f7d47f..710852a 100644 (file)
@@ -141,19 +141,17 @@ struct mod_stats *mod_stats_create(struct dc *dc)
                        else
                                core_stats->entries = reg_data;
                }
-               core_stats->time = kzalloc(
-                       sizeof(struct stats_time_cache) *
-                               core_stats->entries,
+               core_stats->time = kcalloc(core_stats->entries,
+                                               sizeof(struct stats_time_cache),
                                                GFP_KERNEL);
 
                if (core_stats->time == NULL)
                        goto fail_construct_time;
 
                core_stats->event_entries = DAL_STATS_EVENT_ENTRIES_DEFAULT;
-               core_stats->events = kzalloc(
-                       sizeof(struct stats_event_cache) *
-                               core_stats->event_entries,
-                                               GFP_KERNEL);
+               core_stats->events = kcalloc(core_stats->event_entries,
+                                            sizeof(struct stats_event_cache),
+                                            GFP_KERNEL);
 
                if (core_stats->events == NULL)
                        goto fail_construct_events;
index 0af13c1..e45a1fc 100644 (file)
@@ -50,7 +50,7 @@ int psm_init_power_state_table(struct pp_hwmgr *hwmgr)
                return 0;
        }
 
-       hwmgr->ps = kzalloc(size * table_entries, GFP_KERNEL);
+       hwmgr->ps = kcalloc(table_entries, size, GFP_KERNEL);
        if (hwmgr->ps == NULL)
                return -ENOMEM;
 
index 2e0a02a..572a18c 100644 (file)
@@ -121,7 +121,7 @@ int intel_gvt_init_vgpu_types(struct intel_gvt *gvt)
        high_avail = gvt_hidden_sz(gvt) - HOST_HIGH_GM_SIZE;
        num_types = sizeof(vgpu_types) / sizeof(vgpu_types[0]);
 
-       gvt->types = kzalloc(num_types * sizeof(struct intel_vgpu_type),
+       gvt->types = kcalloc(num_types, sizeof(struct intel_vgpu_type),
                             GFP_KERNEL);
        if (!gvt->types)
                return -ENOMEM;
index 2db5da5..0cc6a86 100644 (file)
@@ -429,7 +429,7 @@ int intel_hdcp_auth_downstream(struct intel_digital_port *intel_dig_port,
        if (num_downstream == 0)
                return -EINVAL;
 
-       ksv_fifo = kzalloc(num_downstream * DRM_HDCP_KSV_LEN, GFP_KERNEL);
+       ksv_fifo = kcalloc(DRM_HDCP_KSV_LEN, num_downstream, GFP_KERNEL);
        if (!ksv_fifo)
                return -ENOMEM;
 
index f76f259..47bc5b2 100644 (file)
@@ -137,7 +137,7 @@ static int intel_uncore_check_forcewake_domains(struct drm_i915_private *dev_pri
        if (!IS_ENABLED(CONFIG_DRM_I915_SELFTEST_BROKEN))
                return 0;
 
-       valid = kzalloc(BITS_TO_LONGS(FW_RANGE) * sizeof(*valid),
+       valid = kcalloc(BITS_TO_LONGS(FW_RANGE), sizeof(*valid),
                        GFP_KERNEL);
        if (!valid)
                return -ENOMEM;
index 99d4fd1..e84a2e2 100644 (file)
@@ -50,8 +50,8 @@ nvif_fifo_runlists(struct nvif_device *device)
                goto done;
 
        device->runlists = fls64(a->v.runlists.data);
-       device->runlist = kzalloc(sizeof(*device->runlist) *
-                                 device->runlists, GFP_KERNEL);
+       device->runlist = kcalloc(device->runlists, sizeof(*device->runlist),
+                                 GFP_KERNEL);
        if (!device->runlist) {
                ret = -ENOMEM;
                goto done;
index 40adfe9..ef3f628 100644 (file)
@@ -83,7 +83,7 @@ nvif_object_sclass_get(struct nvif_object *object, struct nvif_sclass **psclass)
                        return ret;
        }
 
-       *psclass = kzalloc(sizeof(**psclass) * args->sclass.count, GFP_KERNEL);
+       *psclass = kcalloc(args->sclass.count, sizeof(**psclass), GFP_KERNEL);
        if (*psclass) {
                for (i = 0; i < args->sclass.count; i++) {
                        (*psclass)[i].oclass = args->sclass.oclass[i].oclass;
index 4e8d3fa..006618d 100644 (file)
@@ -84,7 +84,8 @@ int
 nvkm_event_init(const struct nvkm_event_func *func, int types_nr, int index_nr,
                struct nvkm_event *event)
 {
-       event->refs = kzalloc(sizeof(*event->refs) * index_nr * types_nr,
+       event->refs = kzalloc(array3_size(index_nr, types_nr,
+                                         sizeof(*event->refs)),
                              GFP_KERNEL);
        if (!event->refs)
                return -ENOMEM;
index a990464..afccf97 100644 (file)
@@ -910,7 +910,7 @@ gk104_fifo_oneinit(struct nvkm_fifo *base)
        nvkm_debug(subdev, "%d PBDMA(s)\n", fifo->pbdma_nr);
 
        /* Read PBDMA->runlist(s) mapping from HW. */
-       if (!(map = kzalloc(sizeof(*map) * fifo->pbdma_nr, GFP_KERNEL)))
+       if (!(map = kcalloc(fifo->pbdma_nr, sizeof(*map), GFP_KERNEL)))
                return -ENOMEM;
 
        for (i = 0; i < fifo->pbdma_nr; i++)
index 3ea7168..17a53d2 100644 (file)
@@ -268,7 +268,7 @@ static int omap_gem_attach_pages(struct drm_gem_object *obj)
                        }
                }
        } else {
-               addrs = kzalloc(npages * sizeof(*addrs), GFP_KERNEL);
+               addrs = kcalloc(npages, sizeof(*addrs), GFP_KERNEL);
                if (!addrs) {
                        ret = -ENOMEM;
                        goto free_pages;
index 6a2e091..e55cbee 100644 (file)
@@ -1176,7 +1176,7 @@ static int atom_execute_table_locked(struct atom_context *ctx, int index, uint32
        ectx.abort = false;
        ectx.last_jump = 0;
        if (ws)
-               ectx.ws = kzalloc(4 * ws, GFP_KERNEL);
+               ectx.ws = kcalloc(4, ws, GFP_KERNEL);
        else
                ectx.ws = NULL;
 
index 95652e6..0aef493 100644 (file)
@@ -2581,7 +2581,9 @@ int btc_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index 7e1b04d..b9302c9 100644 (file)
@@ -5568,8 +5568,9 @@ static int ci_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -5770,7 +5771,9 @@ int ci_dpm_init(struct radeon_device *rdev)
        ci_set_private_data_variables_based_on_pptable(rdev);
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                ci_dpm_fini(rdev);
                return -ENOMEM;
index ae1529b..f055d6e 100644 (file)
@@ -2660,8 +2660,9 @@ static int kv_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 9416e72..0fd8d6b 100644 (file)
@@ -3998,8 +3998,9 @@ static int ni_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
@@ -4075,7 +4076,9 @@ int ni_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index 31d1b47..73d4c53 100644 (file)
@@ -991,7 +991,7 @@ int r600_parse_extended_power_table(struct radeon_device *rdev)
                        ATOM_PPLIB_PhaseSheddingLimits_Record *entry;
 
                        rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries =
-                               kzalloc(psl->ucNumEntries *
+                               kcalloc(psl->ucNumEntries,
                                        sizeof(struct radeon_phase_shedding_limits_entry),
                                        GFP_KERNEL);
                        if (!rdev->pm.dpm.dyn_state.phase_shedding_limits_table.entries) {
index 4134759..f422a8d 100644 (file)
@@ -2126,13 +2126,16 @@ static int radeon_atombios_parse_power_table_1_3(struct radeon_device *rdev)
                num_modes = ATOM_MAX_NUMBEROF_POWER_BLOCK;
        if (num_modes == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * num_modes, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(num_modes,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        /* last mode is usually default, array is low to high */
        for (i = 0; i < num_modes; i++) {
                rdev->pm.power_state[state_index].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[state_index].clock_info)
                        return state_index;
                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)
        radeon_atombios_add_pplib_thermal_controller(rdev, &power_info->pplib.sThermalController);
        if (power_info->pplib.ucNumStates == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
-                                      power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(power_info->pplib.ucNumStates,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        /* 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)
                         le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset) +
                         (power_state->v1.ucNonClockStateIndex *
                          power_info->pplib.ucNonClockSize));
-               rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
-                                                            ((power_info->pplib.ucStateEntrySize - 1) ?
-                                                             (power_info->pplib.ucStateEntrySize - 1) : 1),
-                                                            GFP_KERNEL);
+               rdev->pm.power_state[i].clock_info =
+                       kcalloc((power_info->pplib.ucStateEntrySize - 1) ?
+                               (power_info->pplib.ucStateEntrySize - 1) : 1,
+                               sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[i].clock_info)
                        return state_index;
                if (power_info->pplib.ucStateEntrySize - 1) {
@@ -2688,8 +2693,9 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
        if (state_array->ucNumEntries == 0)
                return state_index;
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) *
-                                      state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(state_array->ucNumEntries,
+                                      sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (!rdev->pm.power_state)
                return state_index;
        power_state_offset = (u8 *)state_array->states;
@@ -2699,10 +2705,11 @@ static int radeon_atombios_parse_power_table_6(struct radeon_device *rdev)
                non_clock_array_index = power_state->v2.nonClockInfoIndex;
                non_clock_info = (struct _ATOM_PPLIB_NONCLOCK_INFO *)
                        &non_clock_info_array->nonClockInfo[non_clock_array_index];
-               rdev->pm.power_state[i].clock_info = kzalloc(sizeof(struct radeon_pm_clock_info) *
-                                                            (power_state->v2.ucNumDPMLevels ?
-                                                             power_state->v2.ucNumDPMLevels : 1),
-                                                            GFP_KERNEL);
+               rdev->pm.power_state[i].clock_info =
+                       kcalloc(power_state->v2.ucNumDPMLevels ?
+                               power_state->v2.ucNumDPMLevels : 1,
+                               sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[i].clock_info)
                        return state_index;
                if (power_state->v2.ucNumDPMLevels) {
@@ -2782,7 +2789,9 @@ void radeon_atombios_get_power_modes(struct radeon_device *rdev)
                rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state), GFP_KERNEL);
                if (rdev->pm.power_state) {
                        rdev->pm.power_state[0].clock_info =
-                               kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                               kcalloc(1,
+                                       sizeof(struct radeon_pm_clock_info),
+                                       GFP_KERNEL);
                        if (rdev->pm.power_state[0].clock_info) {
                                /* add the default mode */
                                rdev->pm.power_state[state_index].type =
index 3178ba0..60a61d3 100644 (file)
@@ -2642,13 +2642,16 @@ void radeon_combios_get_power_modes(struct radeon_device *rdev)
        rdev->pm.default_power_state_index = -1;
 
        /* allocate 2 power states */
-       rdev->pm.power_state = kzalloc(sizeof(struct radeon_power_state) * 2, GFP_KERNEL);
+       rdev->pm.power_state = kcalloc(2, sizeof(struct radeon_power_state),
+                                      GFP_KERNEL);
        if (rdev->pm.power_state) {
                /* allocate 1 clock mode per state */
                rdev->pm.power_state[0].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                rdev->pm.power_state[1].clock_info =
-                       kzalloc(sizeof(struct radeon_pm_clock_info) * 1, GFP_KERNEL);
+                       kcalloc(1, sizeof(struct radeon_pm_clock_info),
+                               GFP_KERNEL);
                if (!rdev->pm.power_state[0].clock_info ||
                    !rdev->pm.power_state[1].clock_info)
                        goto pm_failed;
index f5e9abf..48f4b27 100644 (file)
@@ -59,7 +59,7 @@ static void radeon_do_test_moves(struct radeon_device *rdev, int flag)
        n = rdev->mc.gtt_size - rdev->gart_pin_size;
        n /= size;
 
-       gtt_obj = kzalloc(n * sizeof(*gtt_obj), GFP_KERNEL);
+       gtt_obj = kcalloc(n, sizeof(*gtt_obj), GFP_KERNEL);
        if (!gtt_obj) {
                DRM_ERROR("Failed to allocate %d pointers\n", n);
                r = 1;
index b5e4e09..694b7b3 100644 (file)
@@ -804,8 +804,9 @@ static int rs780_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index d91aa39..6986051 100644 (file)
@@ -1888,8 +1888,9 @@ static int rv6xx_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index cb2a7ec..c765ae7 100644 (file)
@@ -2282,8 +2282,9 @@ int rv7xx_parse_power_table(struct radeon_device *rdev)
                return -EINVAL;
        power_info = (union power_info *)(mode_info->atom_context->bios + data_offset);
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 power_info->pplib.ucNumStates, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(power_info->pplib.ucNumStates,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
 
index 90d5b41..fea8807 100644 (file)
@@ -6832,8 +6832,9 @@ static int si_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
@@ -6941,7 +6942,9 @@ int si_dpm_init(struct radeon_device *rdev)
                return ret;
 
        rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries =
-               kzalloc(4 * sizeof(struct radeon_clock_voltage_dependency_entry), GFP_KERNEL);
+               kcalloc(4,
+                       sizeof(struct radeon_clock_voltage_dependency_entry),
+                       GFP_KERNEL);
        if (!rdev->pm.dpm.dyn_state.vddc_dependency_on_dispclk.entries) {
                r600_free_extended_power_table(rdev);
                return -ENOMEM;
index fd48048..1e4975f 100644 (file)
@@ -1482,8 +1482,9 @@ static int sumo_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 2ef7c4e..5d317f7 100644 (file)
@@ -1757,8 +1757,9 @@ static int trinity_parse_power_table(struct radeon_device *rdev)
                (mode_info->atom_context->bios + data_offset +
                 le16_to_cpu(power_info->pplib.usNonClockInfoArrayOffset));
 
-       rdev->pm.dpm.ps = kzalloc(sizeof(struct radeon_ps) *
-                                 state_array->ucNumEntries, GFP_KERNEL);
+       rdev->pm.dpm.ps = kcalloc(state_array->ucNumEntries,
+                                 sizeof(struct radeon_ps),
+                                 GFP_KERNEL);
        if (!rdev->pm.dpm.ps)
                return -ENOMEM;
        power_state_offset = (u8 *)state_array->states;
index 7cc935d..ab6c6c9 100644 (file)
@@ -1631,7 +1631,7 @@ static int igt_topdown(void *ignored)
        if (!nodes)
                goto err;
 
-       bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
+       bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
                         GFP_KERNEL);
        if (!bitmap)
                goto err_nodes;
@@ -1745,7 +1745,7 @@ static int igt_bottomup(void *ignored)
        if (!nodes)
                goto err;
 
-       bitmap = kzalloc(count / BITS_PER_LONG * sizeof(unsigned long),
+       bitmap = kcalloc(count / BITS_PER_LONG, sizeof(unsigned long),
                         GFP_KERNEL);
        if (!bitmap)
                goto err_nodes;
index 6d99534..8469b69 100644 (file)
@@ -457,7 +457,7 @@ static char *resolv_usage_page(unsigned page, struct seq_file *f) {
        char *buf = NULL;
 
        if (!f) {
-               buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_ATOMIC);
+               buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_ATOMIC);
                if (!buf)
                        return ERR_PTR(-ENOMEM);
        }
@@ -1088,7 +1088,7 @@ static int hid_debug_events_open(struct inode *inode, struct file *file)
                goto out;
        }
 
-       if (!(list->hid_debug_buf = kzalloc(sizeof(char) * HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
+       if (!(list->hid_debug_buf = kzalloc(HID_DEBUG_BUFSIZE, GFP_KERNEL))) {
                err = -ENOMEM;
                kfree(list);
                goto out;
index 9b82549..658dc76 100644 (file)
@@ -190,7 +190,7 @@ int hv_synic_alloc(void)
 {
        int cpu;
 
-       hv_context.hv_numa_map = kzalloc(sizeof(struct cpumask) * nr_node_ids,
+       hv_context.hv_numa_map = kcalloc(nr_node_ids, sizeof(struct cpumask),
                                         GFP_KERNEL);
        if (hv_context.hv_numa_map == NULL) {
                pr_err("Unable to allocate NUMA map\n");
index 3c836c0..be3c8b1 100644 (file)
@@ -202,7 +202,7 @@ int hv_ringbuffer_init(struct hv_ring_buffer_info *ring_info,
         * First page holds struct hv_ring_buffer, do wraparound mapping for
         * the rest.
         */
-       pages_wraparound = kzalloc(sizeof(struct page *) * (page_cnt * 2 - 1),
+       pages_wraparound = kcalloc(page_cnt * 2 - 1, sizeof(struct page *),
                                   GFP_KERNEL);
        if (!pages_wraparound)
                return -ENOMEM;
index 14a94d9..34e45b9 100644 (file)
@@ -575,8 +575,9 @@ static int read_domain_devices(struct acpi_power_meter_resource *resource)
        if (!pss->package.count)
                goto end;
 
-       resource->domain_devices = kzalloc(sizeof(struct acpi_device *) *
-                                          pss->package.count, GFP_KERNEL);
+       resource->domain_devices = kcalloc(pss->package.count,
+                                          sizeof(struct acpi_device *),
+                                          GFP_KERNEL);
        if (!resource->domain_devices) {
                res = -ENOMEM;
                goto end;
@@ -796,7 +797,7 @@ static int read_capabilities(struct acpi_power_meter_resource *resource)
                        goto error;
                }
 
-               *str = kzalloc(sizeof(u8) * (element->string.length + 1),
+               *str = kcalloc(element->string.length + 1, sizeof(u8),
                               GFP_KERNEL);
                if (!*str) {
                        res = -ENOMEM;
index 72c338e..10645c9 100644 (file)
@@ -742,7 +742,7 @@ static int __init coretemp_init(void)
                return -ENODEV;
 
        max_packages = topology_max_packages();
-       pkg_devices = kzalloc(max_packages * sizeof(struct platform_device *),
+       pkg_devices = kcalloc(max_packages, sizeof(struct platform_device *),
                              GFP_KERNEL);
        if (!pkg_devices)
                return -ENOMEM;
index 9397d2f..a4edc43 100644 (file)
@@ -274,8 +274,9 @@ static int i5k_amb_hwmon_init(struct platform_device *pdev)
                num_ambs += hweight16(data->amb_present[i] & 0x7fff);
 
        /* Set up sysfs stuff */
-       data->attrs = kzalloc(sizeof(*data->attrs) * num_ambs * KNOBS_PER_AMB,
-                               GFP_KERNEL);
+       data->attrs = kzalloc(array3_size(num_ambs, KNOBS_PER_AMB,
+                                         sizeof(*data->attrs)),
+                             GFP_KERNEL);
        if (!data->attrs)
                return -ENOMEM;
        data->num_attrs = 0;
index 21b9c72..ab72cab 100644 (file)
@@ -387,7 +387,7 @@ static int ibmpex_find_sensors(struct ibmpex_bmc_data *data)
                return -ENOENT;
        data->num_sensors = err;
 
-       data->sensors = kzalloc(data->num_sensors * sizeof(*data->sensors),
+       data->sensors = kcalloc(data->num_sensors, sizeof(*data->sensors),
                                GFP_KERNEL);
        if (!data->sensors)
                return -ENOMEM;
index 65e3240..a2f5f99 100644 (file)
@@ -169,12 +169,12 @@ static int __init amd756_s4882_init(void)
 
        printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4882\n");
        /* Define the 5 virtual adapters and algorithms structures */
-       if (!(s4882_adapter = kzalloc(5 * sizeof(struct i2c_adapter),
+       if (!(s4882_adapter = kcalloc(5, sizeof(struct i2c_adapter),
                                      GFP_KERNEL))) {
                error = -ENOMEM;
                goto ERROR1;
        }
-       if (!(s4882_algo = kzalloc(5 * sizeof(struct i2c_algorithm),
+       if (!(s4882_algo = kcalloc(5, sizeof(struct i2c_algorithm),
                                   GFP_KERNEL))) {
                error = -ENOMEM;
                goto ERROR2;
index 88eda09..58a0fbf 100644 (file)
@@ -164,12 +164,12 @@ static int __init nforce2_s4985_init(void)
 
        printk(KERN_INFO "Enabling SMBus multiplexing for Tyan S4985\n");
        /* Define the 5 virtual adapters and algorithms structures */
-       s4985_adapter = kzalloc(5 * sizeof(struct i2c_adapter), GFP_KERNEL);
+       s4985_adapter = kcalloc(5, sizeof(struct i2c_adapter), GFP_KERNEL);
        if (!s4985_adapter) {
                error = -ENOMEM;
                goto ERROR1;
        }
-       s4985_algo = kzalloc(5 * sizeof(struct i2c_algorithm), GFP_KERNEL);
+       s4985_algo = kcalloc(5, sizeof(struct i2c_algorithm), GFP_KERNEL);
        if (!s4985_algo) {
                error = -ENOMEM;
                goto ERROR2;
index 3241bb9..f6a1272 100644 (file)
@@ -381,7 +381,7 @@ static int nforce2_probe(struct pci_dev *dev, const struct pci_device_id *id)
        int res1, res2;
 
        /* we support 2 SMBus adapters */
-       smbuses = kzalloc(2 * sizeof(struct nforce2_smbus), GFP_KERNEL);
+       smbuses = kcalloc(2, sizeof(struct nforce2_smbus), GFP_KERNEL);
        if (!smbuses)
                return -ENOMEM;
        pci_set_drvdata(dev, smbuses);
index 4a9ad91..f31ec08 100644 (file)
@@ -338,8 +338,9 @@ static int __init i2c_stub_allocate_banks(int i)
                chip->bank_mask >>= 1;
        }
 
-       chip->bank_words = kzalloc(chip->bank_mask * chip->bank_size *
-                                  sizeof(u16), GFP_KERNEL);
+       chip->bank_words = kcalloc(chip->bank_mask * chip->bank_size,
+                                  sizeof(u16),
+                                  GFP_KERNEL);
        if (!chip->bank_words)
                return -ENOMEM;
 
index 4b5dc01..e52c58c 100644 (file)
@@ -1455,7 +1455,7 @@ static int hpt366_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        if (info == &hpt36x || info == &hpt374)
                dev2 = pci_get_slot(dev->bus, dev->devfn + 1);
 
-       dyn_info = kzalloc(sizeof(*dyn_info) * (dev2 ? 2 : 1), GFP_KERNEL);
+       dyn_info = kcalloc(dev2 ? 2 : 1, sizeof(*dyn_info), GFP_KERNEL);
        if (dyn_info == NULL) {
                printk(KERN_ERR "%s %s: out of memory!\n",
                        d.name, pci_name(dev));
index 04029d1..36a64c8 100644 (file)
@@ -652,7 +652,7 @@ static int it821x_init_one(struct pci_dev *dev, const struct pci_device_id *id)
        struct it821x_dev *itdevs;
        int rc;
 
-       itdevs = kzalloc(2 * sizeof(*itdevs), GFP_KERNEL);
+       itdevs = kcalloc(2, sizeof(*itdevs), GFP_KERNEL);
        if (itdevs == NULL) {
                printk(KERN_ERR DRV_NAME " %s: out of memory\n", pci_name(dev));
                return -ENOMEM;
index 36607d5..76643c5 100644 (file)
@@ -38,7 +38,7 @@ int adis_update_scan_mode(struct iio_dev *indio_dev,
        if (!adis->xfer)
                return -ENOMEM;
 
-       adis->buffer = kzalloc(indio_dev->scan_bytes * 2, GFP_KERNEL);
+       adis->buffer = kcalloc(indio_dev->scan_bytes, 2, GFP_KERNEL);
        if (!adis->buffer)
                return -ENOMEM;
 
index ec98790..06ca3f7 100644 (file)
@@ -436,7 +436,7 @@ struct iio_channel *iio_channel_get_all(struct device *dev)
        }
 
        /* NULL terminated array to save passing size */
-       chans = kzalloc(sizeof(*chans)*(nummaps + 1), GFP_KERNEL);
+       chans = kcalloc(nummaps + 1, sizeof(*chans), GFP_KERNEL);
        if (chans == NULL) {
                ret = -ENOMEM;
                goto error_ret;
index 71a34be..81d66f5 100644 (file)
@@ -1245,8 +1245,9 @@ int ib_cache_setup_one(struct ib_device *device)
        rwlock_init(&device->cache.lock);
 
        device->cache.ports =
-               kzalloc(sizeof(*device->cache.ports) *
-                       (rdma_end_port(device) - rdma_start_port(device) + 1), GFP_KERNEL);
+               kcalloc(rdma_end_port(device) - rdma_start_port(device) + 1,
+                       sizeof(*device->cache.ports),
+                       GFP_KERNEL);
        if (!device->cache.ports)
                return -ENOMEM;
 
index 84f5138..6fa4c59 100644 (file)
@@ -336,8 +336,8 @@ static int read_port_immutable(struct ib_device *device)
         * Therefore port_immutable is declared as a 1 based array with
         * potential empty slots at the beginning.
         */
-       device->port_immutable = kzalloc(sizeof(*device->port_immutable)
-                                        * (end_port + 1),
+       device->port_immutable = kcalloc(end_port + 1,
+                                        sizeof(*device->port_immutable),
                                         GFP_KERNEL);
        if (!device->port_immutable)
                return -ENOMEM;
index da12da1..cdb63f3 100644 (file)
@@ -56,14 +56,16 @@ int iwpm_init(u8 nl_client)
        int ret = 0;
        mutex_lock(&iwpm_admin_lock);
        if (atomic_read(&iwpm_admin.refcount) == 0) {
-               iwpm_hash_bucket = kzalloc(IWPM_MAPINFO_HASH_SIZE *
-                                       sizeof(struct hlist_head), GFP_KERNEL);
+               iwpm_hash_bucket = kcalloc(IWPM_MAPINFO_HASH_SIZE,
+                                          sizeof(struct hlist_head),
+                                          GFP_KERNEL);
                if (!iwpm_hash_bucket) {
                        ret = -ENOMEM;
                        goto init_exit;
                }
-               iwpm_reminfo_bucket = kzalloc(IWPM_REMINFO_HASH_SIZE *
-                                       sizeof(struct hlist_head), GFP_KERNEL);
+               iwpm_reminfo_bucket = kcalloc(IWPM_REMINFO_HASH_SIZE,
+                                             sizeof(struct hlist_head),
+                                             GFP_KERNEL);
                if (!iwpm_reminfo_bucket) {
                        kfree(iwpm_hash_bucket);
                        ret = -ENOMEM;
index 3328acc..dcb4bba 100644 (file)
@@ -279,7 +279,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
        if (!wq->qpid)
                return -ENOMEM;
 
-       wq->rq = kzalloc(depth * sizeof(struct t3_swrq), GFP_KERNEL);
+       wq->rq = kcalloc(depth, sizeof(struct t3_swrq), GFP_KERNEL);
        if (!wq->rq)
                goto err1;
 
@@ -287,7 +287,7 @@ int cxio_create_qp(struct cxio_rdev *rdev_p, u32 kernel_domain,
        if (!wq->rq_addr)
                goto err2;
 
-       wq->sq = kzalloc(depth * sizeof(struct t3_swsq), GFP_KERNEL);
+       wq->sq = kcalloc(depth, sizeof(struct t3_swsq), GFP_KERNEL);
        if (!wq->sq)
                goto err3;
 
index 44161ca..a3c3418 100644 (file)
@@ -859,8 +859,9 @@ static int c4iw_rdev_open(struct c4iw_rdev *rdev)
        rdev->status_page->cq_size = rdev->lldi.vr->cq.size;
 
        if (c4iw_wr_log) {
-               rdev->wr_log = kzalloc((1 << c4iw_wr_log_size_order) *
-                                      sizeof(*rdev->wr_log), GFP_KERNEL);
+               rdev->wr_log = kcalloc(1 << c4iw_wr_log_size_order,
+                                      sizeof(*rdev->wr_log),
+                                      GFP_KERNEL);
                if (rdev->wr_log) {
                        rdev->wr_log_size = 1 << c4iw_wr_log_size_order;
                        atomic_set(&rdev->wr_log_idx, 0);
@@ -1445,7 +1446,7 @@ static void recover_queues(struct uld_ctx *ctx)
        ctx->dev->db_state = RECOVERY;
        idr_for_each(&ctx->dev->qpidr, count_qps, &count);
 
-       qp_list.qps = kzalloc(count * sizeof *qp_list.qps, GFP_ATOMIC);
+       qp_list.qps = kcalloc(count, sizeof(*qp_list.qps), GFP_ATOMIC);
        if (!qp_list.qps) {
                spin_unlock_irq(&ctx->dev->lock);
                return;
index 4106eed..aef5330 100644 (file)
@@ -216,15 +216,15 @@ static int create_qp(struct c4iw_rdev *rdev, struct t4_wq *wq,
        }
 
        if (!user) {
-               wq->sq.sw_sq = kzalloc(wq->sq.size * sizeof *wq->sq.sw_sq,
-                                GFP_KERNEL);
+               wq->sq.sw_sq = kcalloc(wq->sq.size, sizeof(*wq->sq.sw_sq),
+                                      GFP_KERNEL);
                if (!wq->sq.sw_sq) {
                        ret = -ENOMEM;
                        goto free_rq_qid;
                }
 
-               wq->rq.sw_rq = kzalloc(wq->rq.size * sizeof *wq->rq.sw_rq,
-                                GFP_KERNEL);
+               wq->rq.sw_rq = kcalloc(wq->rq.size, sizeof(*wq->rq.sw_rq),
+                                      GFP_KERNEL);
                if (!wq->rq.sw_rq) {
                        ret = -ENOMEM;
                        goto free_sw_sq;
index 0e8dad6..a6e11be 100644 (file)
@@ -3177,7 +3177,7 @@ static int hns_roce_v2_modify_qp(struct ib_qp *ibqp,
        struct device *dev = hr_dev->dev;
        int ret = -EINVAL;
 
-       context = kzalloc(2 * sizeof(*context), GFP_KERNEL);
+       context = kcalloc(2, sizeof(*context), GFP_KERNEL);
        if (!context)
                return -ENOMEM;
 
index d604b3d..90a3e26 100644 (file)
@@ -1613,7 +1613,8 @@ static int mlx4_ib_alloc_pv_bufs(struct mlx4_ib_demux_pv_ctx *ctx,
 
        tun_qp = &ctx->qp[qp_type];
 
-       tun_qp->ring = kzalloc(sizeof (struct mlx4_ib_buf) * MLX4_NUM_TUNNEL_BUFS,
+       tun_qp->ring = kcalloc(MLX4_NUM_TUNNEL_BUFS,
+                              sizeof(struct mlx4_ib_buf),
                               GFP_KERNEL);
        if (!tun_qp->ring)
                return -ENOMEM;
index dc3c234..6686042 100644 (file)
@@ -144,7 +144,7 @@ static int mthca_buddy_init(struct mthca_buddy *buddy, int max_order)
        buddy->max_order = max_order;
        spin_lock_init(&buddy->lock);
 
-       buddy->bits = kzalloc((buddy->max_order + 1) * sizeof (long *),
+       buddy->bits = kcalloc(buddy->max_order + 1, sizeof(long *),
                              GFP_KERNEL);
        buddy->num_free = kcalloc((buddy->max_order + 1), sizeof *buddy->num_free,
                                  GFP_KERNEL);
index 15d0644..7ea9707 100644 (file)
@@ -79,7 +79,7 @@ s64 mthca_make_profile(struct mthca_dev *dev,
        struct mthca_resource *profile;
        int i, j;
 
-       profile = kzalloc(MTHCA_RES_NUM * sizeof *profile, GFP_KERNEL);
+       profile = kcalloc(MTHCA_RES_NUM, sizeof(*profile), GFP_KERNEL);
        if (!profile)
                return -ENOMEM;
 
index 21e0ebd..9bdb84d 100644 (file)
@@ -878,7 +878,8 @@ int nes_init_mgt_qp(struct nes_device *nesdev, struct net_device *netdev, struct
        int ret;
 
        /* Allocate space the all mgt QPs once */
-       mgtvnic = kzalloc(NES_MGT_QP_COUNT * sizeof(struct nes_vnic_mgt), GFP_KERNEL);
+       mgtvnic = kcalloc(NES_MGT_QP_COUNT, sizeof(struct nes_vnic_mgt),
+                         GFP_KERNEL);
        if (!mgtvnic)
                return -ENOMEM;
 
index 1040a6e..32f2655 100644 (file)
@@ -2254,8 +2254,9 @@ static struct ib_mr *nes_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
                                                                ibmr = ERR_PTR(-ENOMEM);
                                                                goto reg_user_mr_err;
                                                        }
-                                                       root_vpbl.leaf_vpbl = kzalloc(sizeof(*root_vpbl.leaf_vpbl)*1024,
-                                                                       GFP_KERNEL);
+                                                       root_vpbl.leaf_vpbl = kcalloc(1024,
+                                                                                     sizeof(*root_vpbl.leaf_vpbl),
+                                                                                     GFP_KERNEL);
                                                        if (!root_vpbl.leaf_vpbl) {
                                                                ib_umem_release(region);
                                                                pci_free_consistent(nesdev->pcidev, 8192, root_vpbl.pbl_vbase,
index 2c260e1..6c136e5 100644 (file)
@@ -3096,7 +3096,7 @@ static int ocrdma_create_eqs(struct ocrdma_dev *dev)
        if (!num_eq)
                return -EINVAL;
 
-       dev->eq_tbl = kzalloc(sizeof(struct ocrdma_eq) * num_eq, GFP_KERNEL);
+       dev->eq_tbl = kcalloc(num_eq, sizeof(struct ocrdma_eq), GFP_KERNEL);
        if (!dev->eq_tbl)
                return -ENOMEM;
 
index eb8b6a9..5962c0e 100644 (file)
@@ -221,19 +221,20 @@ static int ocrdma_register_device(struct ocrdma_dev *dev)
 static int ocrdma_alloc_resources(struct ocrdma_dev *dev)
 {
        mutex_init(&dev->dev_lock);
-       dev->cq_tbl = kzalloc(sizeof(struct ocrdma_cq *) *
-                             OCRDMA_MAX_CQ, GFP_KERNEL);
+       dev->cq_tbl = kcalloc(OCRDMA_MAX_CQ, sizeof(struct ocrdma_cq *),
+                             GFP_KERNEL);
        if (!dev->cq_tbl)
                goto alloc_err;
 
        if (dev->attr.max_qp) {
-               dev->qp_tbl = kzalloc(sizeof(struct ocrdma_qp *) *
-                                     OCRDMA_MAX_QP, GFP_KERNEL);
+               dev->qp_tbl = kcalloc(OCRDMA_MAX_QP,
+                                     sizeof(struct ocrdma_qp *),
+                                     GFP_KERNEL);
                if (!dev->qp_tbl)
                        goto alloc_err;
        }
 
-       dev->stag_arr = kzalloc(sizeof(u64) * OCRDMA_MAX_STAG, GFP_KERNEL);
+       dev->stag_arr = kcalloc(OCRDMA_MAX_STAG, sizeof(u64), GFP_KERNEL);
        if (dev->stag_arr == NULL)
                goto alloc_err;
 
index eb9f9e9..82e20fc 100644 (file)
@@ -843,8 +843,8 @@ static int ocrdma_build_pbl_tbl(struct ocrdma_dev *dev, struct ocrdma_hw_mr *mr)
        void *va;
        dma_addr_t pa;
 
-       mr->pbl_table = kzalloc(sizeof(struct ocrdma_pbl) *
-                               mr->num_pbls, GFP_KERNEL);
+       mr->pbl_table = kcalloc(mr->num_pbls, sizeof(struct ocrdma_pbl),
+                               GFP_KERNEL);
 
        if (!mr->pbl_table)
                return -ENOMEM;
@@ -1323,12 +1323,12 @@ static void ocrdma_set_qp_db(struct ocrdma_dev *dev, struct ocrdma_qp *qp,
 static int ocrdma_alloc_wr_id_tbl(struct ocrdma_qp *qp)
 {
        qp->wqe_wr_id_tbl =
-           kzalloc(sizeof(*(qp->wqe_wr_id_tbl)) * qp->sq.max_cnt,
+           kcalloc(qp->sq.max_cnt, sizeof(*(qp->wqe_wr_id_tbl)),
                    GFP_KERNEL);
        if (qp->wqe_wr_id_tbl == NULL)
                return -ENOMEM;
        qp->rqe_wr_id_tbl =
-           kzalloc(sizeof(u64) * qp->rq.max_cnt, GFP_KERNEL);
+           kcalloc(qp->rq.max_cnt, sizeof(u64), GFP_KERNEL);
        if (qp->rqe_wr_id_tbl == NULL)
                return -ENOMEM;
 
@@ -1865,8 +1865,8 @@ struct ib_srq *ocrdma_create_srq(struct ib_pd *ibpd,
 
        if (udata == NULL) {
                status = -ENOMEM;
-               srq->rqe_wr_id_tbl = kzalloc(sizeof(u64) * srq->rq.max_cnt,
-                           GFP_KERNEL);
+               srq->rqe_wr_id_tbl = kcalloc(srq->rq.max_cnt, sizeof(u64),
+                                            GFP_KERNEL);
                if (srq->rqe_wr_id_tbl == NULL)
                        goto arm_err;
 
index f4cb60b..ad22b32 100644 (file)
@@ -317,8 +317,8 @@ static int qedr_alloc_resources(struct qedr_dev *dev)
        u16 n_entries;
        int i, rc;
 
-       dev->sgid_tbl = kzalloc(sizeof(union ib_gid) *
-                               QEDR_MAX_SGID, GFP_KERNEL);
+       dev->sgid_tbl = kcalloc(QEDR_MAX_SGID, sizeof(union ib_gid),
+                               GFP_KERNEL);
        if (!dev->sgid_tbl)
                return -ENOMEM;
 
index 710032f..f7ac8fc 100644 (file)
@@ -1614,7 +1614,7 @@ static int qedr_create_kernel_qp(struct qedr_dev *dev,
        qp->sq.max_wr = min_t(u32, attrs->cap.max_send_wr * dev->wq_multiplier,
                              dev->attr.max_sqe);
 
-       qp->wqe_wr_id = kzalloc(qp->sq.max_wr * sizeof(*qp->wqe_wr_id),
+       qp->wqe_wr_id = kcalloc(qp->sq.max_wr, sizeof(*qp->wqe_wr_id),
                                GFP_KERNEL);
        if (!qp->wqe_wr_id) {
                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,
        qp->rq.max_wr = (u16) max_t(u32, attrs->cap.max_recv_wr, 1);
 
        /* Allocate driver internal RQ array */
-       qp->rqe_wr_id = kzalloc(qp->rq.max_wr * sizeof(*qp->rqe_wr_id),
+       qp->rqe_wr_id = kcalloc(qp->rq.max_wr, sizeof(*qp->rqe_wr_id),
                                GFP_KERNEL);
        if (!qp->rqe_wr_id) {
                DP_ERR(dev,
index 27155d9..bf5e222 100644 (file)
@@ -7295,8 +7295,9 @@ struct qib_devdata *qib_init_iba7322_funcs(struct pci_dev *pdev,
                actual_cnt -= dd->num_pports;
 
        tabsize = actual_cnt;
-       dd->cspec->msix_entries = kzalloc(tabsize *
-                       sizeof(struct qib_msix_entry), GFP_KERNEL);
+       dd->cspec->msix_entries = kcalloc(tabsize,
+                                         sizeof(struct qib_msix_entry),
+                                         GFP_KERNEL);
        if (!dd->cspec->msix_entries)
                tabsize = 0;
 
index 0155202..dd4547f 100644 (file)
@@ -1134,8 +1134,8 @@ struct qib_devdata *qib_alloc_devdata(struct pci_dev *pdev, size_t extra)
        if (!qib_cpulist_count) {
                u32 count = num_online_cpus();
 
-               qib_cpulist = kzalloc(BITS_TO_LONGS(count) *
-                                     sizeof(long), GFP_KERNEL);
+               qib_cpulist = kcalloc(BITS_TO_LONGS(count), sizeof(long),
+                                     GFP_KERNEL);
                if (qib_cpulist)
                        qib_cpulist_count = count;
        }
index 912d8ef..bf51365 100644 (file)
@@ -543,7 +543,7 @@ alloc_res_chunk_list(struct usnic_vnic *vnic,
                /* Do Nothing */
        }
 
-       res_chunk_list = kzalloc(sizeof(*res_chunk_list)*(res_lst_sz+1),
+       res_chunk_list = kcalloc(res_lst_sz + 1, sizeof(*res_chunk_list),
                                        GFP_ATOMIC);
        if (!res_chunk_list)
                return ERR_PTR(-ENOMEM);
index e7b0030..ebe08f3 100644 (file)
@@ -312,7 +312,7 @@ static int usnic_vnic_alloc_res_chunk(struct usnic_vnic *vnic,
        }
 
        chunk->cnt = chunk->free_cnt = cnt;
-       chunk->res = kzalloc(sizeof(*(chunk->res))*cnt, GFP_KERNEL);
+       chunk->res = kcalloc(cnt, sizeof(*(chunk->res)), GFP_KERNEL);
        if (!chunk->res)
                return -ENOMEM;
 
index 2ce40a7..0d74c80 100644 (file)
@@ -1526,7 +1526,7 @@ static int ipoib_neigh_hash_init(struct ipoib_dev_priv *priv)
                return -ENOMEM;
        set_bit(IPOIB_STOP_NEIGH_GC, &priv->flags);
        size = roundup_pow_of_two(arp_tbl.gc_thresh3);
-       buckets = kzalloc(size * sizeof(*buckets), GFP_KERNEL);
+       buckets = kcalloc(size, sizeof(*buckets), GFP_KERNEL);
        if (!buckets) {
                kfree(htbl);
                return -ENOMEM;
@@ -1704,8 +1704,9 @@ static int ipoib_dev_init_default(struct net_device *dev)
        ipoib_napi_add(dev);
 
        /* Allocate RX/TX "rings" to hold queued skbs */
-       priv->rx_ring = kzalloc(ipoib_recvq_size * sizeof *priv->rx_ring,
-                               GFP_KERNEL);
+       priv->rx_ring = kcalloc(ipoib_recvq_size,
+                                      sizeof(*priv->rx_ring),
+                                      GFP_KERNEL);
        if (!priv->rx_ring)
                goto out;
 
index f2f9318..cccbcf0 100644 (file)
@@ -181,8 +181,9 @@ isert_alloc_rx_descriptors(struct isert_conn *isert_conn)
        u64 dma_addr;
        int i, j;
 
-       isert_conn->rx_descs = kzalloc(ISERT_QP_MAX_RECV_DTOS *
-                               sizeof(struct iser_rx_desc), GFP_KERNEL);
+       isert_conn->rx_descs = kcalloc(ISERT_QP_MAX_RECV_DTOS,
+                                      sizeof(struct iser_rx_desc),
+                                      GFP_KERNEL);
        if (!isert_conn->rx_descs)
                return -ENOMEM;
 
index 940d38b..4640634 100644 (file)
@@ -337,7 +337,8 @@ static int omap4_keypad_probe(struct platform_device *pdev)
 
        keypad_data->row_shift = get_count_order(keypad_data->cols);
        max_keys = keypad_data->rows << keypad_data->row_shift;
-       keypad_data->keymap = kzalloc(max_keys * sizeof(keypad_data->keymap[0]),
+       keypad_data->keymap = kcalloc(max_keys,
+                                     sizeof(keypad_data->keymap[0]),
                                      GFP_KERNEL);
        if (!keypad_data->keymap) {
                dev_err(&pdev->dev, "Not enough memory for keymap\n");
index 4321f77..75456b5 100644 (file)
@@ -1458,7 +1458,7 @@ int dmar_enable_qi(struct intel_iommu *iommu)
 
        qi->desc = page_address(desc_page);
 
-       qi->desc_status = kzalloc(QI_LENGTH * sizeof(int), GFP_ATOMIC);
+       qi->desc_status = kcalloc(QI_LENGTH, sizeof(int), GFP_ATOMIC);
        if (!qi->desc_status) {
                free_page((unsigned long) qi->desc);
                kfree(qi);
index 89e49a4..14e4b37 100644 (file)
@@ -3189,7 +3189,7 @@ static int copy_translation_tables(struct intel_iommu *iommu)
        /* This is too big for the stack - allocate it from slab */
        ctxt_table_entries = ext ? 512 : 256;
        ret = -ENOMEM;
-       ctxt_tbls = kzalloc(ctxt_table_entries * sizeof(void *), GFP_KERNEL);
+       ctxt_tbls = kcalloc(ctxt_table_entries, sizeof(void *), GFP_KERNEL);
        if (!ctxt_tbls)
                goto out_unmap;
 
@@ -4032,7 +4032,7 @@ static int iommu_suspend(void)
        unsigned long flag;
 
        for_each_active_iommu(iommu, drhd) {
-               iommu->iommu_state = kzalloc(sizeof(u32) * MAX_SR_DMAR_REGS,
+               iommu->iommu_state = kcalloc(MAX_SR_DMAR_REGS, sizeof(u32),
                                                 GFP_ATOMIC);
                if (!iommu->iommu_state)
                        goto nomem;
index c33b7b1..af4a8e7 100644 (file)
@@ -1455,7 +1455,7 @@ static int omap_iommu_add_device(struct device *dev)
        if (num_iommus < 0)
                return 0;
 
-       arch_data = kzalloc((num_iommus + 1) * sizeof(*arch_data), GFP_KERNEL);
+       arch_data = kcalloc(num_iommus + 1, sizeof(*arch_data), GFP_KERNEL);
        if (!arch_data)
                return -ENOMEM;
 
index 9b23843..a16b320 100644 (file)
@@ -457,8 +457,8 @@ static int tpci200_install(struct tpci200_board *tpci200)
 {
        int res;
 
-       tpci200->slots = kzalloc(
-               TPCI200_NB_SLOT * sizeof(struct tpci200_slot), GFP_KERNEL);
+       tpci200->slots = kcalloc(TPCI200_NB_SLOT, sizeof(struct tpci200_slot),
+                                GFP_KERNEL);
        if (tpci200->slots == NULL)
                return -ENOMEM;
 
index 63d9809..23a3b87 100644 (file)
@@ -268,7 +268,8 @@ static int alpine_msix_init(struct device_node *node,
                goto err_priv;
        }
 
-       priv->msi_map = kzalloc(sizeof(*priv->msi_map) * BITS_TO_LONGS(priv->num_spis),
+       priv->msi_map = kcalloc(BITS_TO_LONGS(priv->num_spis),
+                               sizeof(*priv->msi_map),
                                GFP_KERNEL);
        if (!priv->msi_map) {
                ret = -ENOMEM;
index 1ff38af..0f52d44 100644 (file)
@@ -361,7 +361,7 @@ static int __init gicv2m_init_one(struct fwnode_handle *fwnode,
                break;
        }
 
-       v2m->bm = kzalloc(sizeof(long) * BITS_TO_LONGS(v2m->nr_spis),
+       v2m->bm = kcalloc(BITS_TO_LONGS(v2m->nr_spis), sizeof(long),
                          GFP_KERNEL);
        if (!v2m->bm) {
                ret = -ENOMEM;
index 4e7ce74..5377d7e 100644 (file)
@@ -1239,7 +1239,7 @@ static int its_vlpi_map(struct irq_data *d, struct its_cmd_info *info)
        if (!its_dev->event_map.vm) {
                struct its_vlpi_map *maps;
 
-               maps = kzalloc(sizeof(*maps) * its_dev->event_map.nr_lpis,
+               maps = kcalloc(its_dev->event_map.nr_lpis, sizeof(*maps),
                               GFP_KERNEL);
                if (!maps) {
                        ret = -ENOMEM;
@@ -1437,7 +1437,7 @@ static int __init its_lpi_init(u32 id_bits)
 {
        lpi_chunks = its_lpi_to_chunk(1UL << id_bits);
 
-       lpi_bitmap = kzalloc(BITS_TO_LONGS(lpi_chunks) * sizeof(long),
+       lpi_bitmap = kcalloc(BITS_TO_LONGS(lpi_chunks), sizeof(long),
                             GFP_KERNEL);
        if (!lpi_bitmap) {
                lpi_chunks = 0;
@@ -1471,7 +1471,8 @@ static unsigned long *its_lpi_alloc_chunks(int nr_irqs, int *base, int *nr_ids)
        if (!nr_chunks)
        &n