diff options
| author | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-12 21:28:00 -0400 |
|---|---|---|
| committer | Linus Torvalds <torvalds@linux-foundation.org> | 2018-06-12 21:28:00 -0400 |
| commit | b08fc5277aaa1d8ea15470d38bf36f19dfb0e125 (patch) | |
| tree | 1910dc474cb1ede95581dd9faa81a3bebeded0dc /drivers/net | |
| parent | 4597fcff07044d89c646d0c5d8b42cd976d966a1 (diff) | |
| parent | 9d2a789c1db75d0f55b14fa57bec548d94332ad8 (diff) | |
Merge tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux
Pull more overflow updates from Kees Cook:
"The rest of the overflow changes for v4.18-rc1.
This includes the explicit overflow fixes from Silvio, further
struct_size() conversions from Matthew, and a bug fix from Dan.
But the bulk of it is the treewide conversions to use either the
2-factor argument allocators (e.g. kmalloc(a * b, ...) into
kmalloc_array(a, b, ...) or the array_size() macros (e.g. vmalloc(a *
b) into vmalloc(array_size(a, b)).
Coccinelle was fighting me on several fronts, so I've done a bunch of
manual whitespace updates in the patches as well.
Summary:
- Error path bug fix for overflow tests (Dan)
- Additional struct_size() conversions (Matthew, Kees)
- Explicitly reported overflow fixes (Silvio, Kees)
- Add missing kvcalloc() function (Kees)
- Treewide conversions of allocators to use either 2-factor argument
variant when available, or array_size() and array3_size() as needed
(Kees)"
* tag 'overflow-v4.18-rc1-part2' of git://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: (26 commits)
treewide: Use array_size in f2fs_kvzalloc()
treewide: Use array_size() in f2fs_kzalloc()
treewide: Use array_size() in f2fs_kmalloc()
treewide: Use array_size() in sock_kmalloc()
treewide: Use array_size() in kvzalloc_node()
treewide: Use array_size() in vzalloc_node()
treewide: Use array_size() in vzalloc()
treewide: Use array_size() in vmalloc()
treewide: devm_kzalloc() -> devm_kcalloc()
treewide: devm_kmalloc() -> devm_kmalloc_array()
treewide: kvzalloc() -> kvcalloc()
treewide: kvmalloc() -> kvmalloc_array()
treewide: kzalloc_node() -> kcalloc_node()
treewide: kzalloc() -> kcalloc()
treewide: kmalloc() -> kmalloc_array()
mm: Introduce kvcalloc()
video: uvesafb: Fix integer overflow in allocation
UBIFS: Fix potential integer overflow in allocation
leds: Use struct_size() in allocation
Convert intel uncore to struct_size
...
Diffstat (limited to 'drivers/net')
137 files changed, 430 insertions, 364 deletions
diff --git a/drivers/net/bonding/bond_main.c b/drivers/net/bonding/bond_main.c index bd53a71f6b00..63e3844c5bec 100644 --- a/drivers/net/bonding/bond_main.c +++ b/drivers/net/bonding/bond_main.c | |||
| @@ -2418,7 +2418,7 @@ struct bond_vlan_tag *bond_verify_device_path(struct net_device *start_dev, | |||
| 2418 | struct list_head *iter; | 2418 | struct list_head *iter; |
| 2419 | 2419 | ||
| 2420 | if (start_dev == end_dev) { | 2420 | if (start_dev == end_dev) { |
| 2421 | tags = kzalloc(sizeof(*tags) * (level + 1), GFP_ATOMIC); | 2421 | tags = kcalloc(level + 1, sizeof(*tags), GFP_ATOMIC); |
| 2422 | if (!tags) | 2422 | if (!tags) |
| 2423 | return ERR_PTR(-ENOMEM); | 2423 | return ERR_PTR(-ENOMEM); |
| 2424 | tags[level].vlan_proto = VLAN_N_VID; | 2424 | tags[level].vlan_proto = VLAN_N_VID; |
diff --git a/drivers/net/can/grcan.c b/drivers/net/can/grcan.c index 2d3046afa80d..7eec1d9f86a0 100644 --- a/drivers/net/can/grcan.c +++ b/drivers/net/can/grcan.c | |||
| @@ -1057,7 +1057,7 @@ static int grcan_open(struct net_device *dev) | |||
| 1057 | return err; | 1057 | return err; |
| 1058 | } | 1058 | } |
| 1059 | 1059 | ||
| 1060 | priv->echo_skb = kzalloc(dma->tx.size * sizeof(*priv->echo_skb), | 1060 | priv->echo_skb = kcalloc(dma->tx.size, sizeof(*priv->echo_skb), |
| 1061 | GFP_KERNEL); | 1061 | GFP_KERNEL); |
| 1062 | if (!priv->echo_skb) { | 1062 | if (!priv->echo_skb) { |
| 1063 | err = -ENOMEM; | 1063 | err = -ENOMEM; |
| @@ -1066,7 +1066,7 @@ static int grcan_open(struct net_device *dev) | |||
| 1066 | priv->can.echo_skb_max = dma->tx.size; | 1066 | priv->can.echo_skb_max = dma->tx.size; |
| 1067 | priv->can.echo_skb = priv->echo_skb; | 1067 | priv->can.echo_skb = priv->echo_skb; |
| 1068 | 1068 | ||
| 1069 | priv->txdlc = kzalloc(dma->tx.size * sizeof(*priv->txdlc), GFP_KERNEL); | 1069 | priv->txdlc = kcalloc(dma->tx.size, sizeof(*priv->txdlc), GFP_KERNEL); |
| 1070 | if (!priv->txdlc) { | 1070 | if (!priv->txdlc) { |
| 1071 | err = -ENOMEM; | 1071 | err = -ENOMEM; |
| 1072 | goto exit_free_echo_skb; | 1072 | goto exit_free_echo_skb; |
diff --git a/drivers/net/can/slcan.c b/drivers/net/can/slcan.c index 89d60d8e467c..aa97dbc797b6 100644 --- a/drivers/net/can/slcan.c +++ b/drivers/net/can/slcan.c | |||
| @@ -703,7 +703,7 @@ static int __init slcan_init(void) | |||
| 703 | pr_info("slcan: serial line CAN interface driver\n"); | 703 | pr_info("slcan: serial line CAN interface driver\n"); |
| 704 | pr_info("slcan: %d dynamic interface channels.\n", maxdev); | 704 | pr_info("slcan: %d dynamic interface channels.\n", maxdev); |
| 705 | 705 | ||
| 706 | slcan_devs = kzalloc(sizeof(struct net_device *)*maxdev, GFP_KERNEL); | 706 | slcan_devs = kcalloc(maxdev, sizeof(struct net_device *), GFP_KERNEL); |
| 707 | if (!slcan_devs) | 707 | if (!slcan_devs) |
| 708 | return -ENOMEM; | 708 | return -ENOMEM; |
| 709 | 709 | ||
diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 5e010b1592f7..d93c790bfbe8 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c | |||
| @@ -2044,14 +2044,14 @@ static int b53_switch_init(struct b53_device *dev) | |||
| 2044 | } | 2044 | } |
| 2045 | } | 2045 | } |
| 2046 | 2046 | ||
| 2047 | dev->ports = devm_kzalloc(dev->dev, | 2047 | dev->ports = devm_kcalloc(dev->dev, |
| 2048 | sizeof(struct b53_port) * dev->num_ports, | 2048 | dev->num_ports, sizeof(struct b53_port), |
| 2049 | GFP_KERNEL); | 2049 | GFP_KERNEL); |
| 2050 | if (!dev->ports) | 2050 | if (!dev->ports) |
| 2051 | return -ENOMEM; | 2051 | return -ENOMEM; |
| 2052 | 2052 | ||
| 2053 | dev->vlans = devm_kzalloc(dev->dev, | 2053 | dev->vlans = devm_kcalloc(dev->dev, |
| 2054 | sizeof(struct b53_vlan) * dev->num_vlans, | 2054 | dev->num_vlans, sizeof(struct b53_vlan), |
| 2055 | GFP_KERNEL); | 2055 | GFP_KERNEL); |
| 2056 | if (!dev->vlans) | 2056 | if (!dev->vlans) |
| 2057 | return -ENOMEM; | 2057 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c index 060cb18fa659..521607bc4393 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c | |||
| @@ -838,8 +838,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) | |||
| 838 | return; | 838 | return; |
| 839 | } | 839 | } |
| 840 | 840 | ||
| 841 | strings_buf = devm_kzalloc(&adapter->pdev->dev, | 841 | strings_buf = devm_kcalloc(&adapter->pdev->dev, |
| 842 | strings_num * ETH_GSTRING_LEN, | 842 | ETH_GSTRING_LEN, strings_num, |
| 843 | GFP_ATOMIC); | 843 | GFP_ATOMIC); |
| 844 | if (!strings_buf) { | 844 | if (!strings_buf) { |
| 845 | netif_err(adapter, drv, netdev, | 845 | netif_err(adapter, drv, netdev, |
| @@ -847,8 +847,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) | |||
| 847 | return; | 847 | return; |
| 848 | } | 848 | } |
| 849 | 849 | ||
| 850 | data_buf = devm_kzalloc(&adapter->pdev->dev, | 850 | data_buf = devm_kcalloc(&adapter->pdev->dev, |
| 851 | strings_num * sizeof(u64), | 851 | strings_num, sizeof(u64), |
| 852 | GFP_ATOMIC); | 852 | GFP_ATOMIC); |
| 853 | if (!data_buf) { | 853 | if (!data_buf) { |
| 854 | netif_err(adapter, drv, netdev, | 854 | netif_err(adapter, drv, netdev, |
diff --git a/drivers/net/ethernet/amd/lance.c b/drivers/net/ethernet/amd/lance.c index 12a6a93d221b..b56d84c7df46 100644 --- a/drivers/net/ethernet/amd/lance.c +++ b/drivers/net/ethernet/amd/lance.c | |||
| @@ -551,13 +551,13 @@ static int __init lance_probe1(struct net_device *dev, int ioaddr, int irq, int | |||
| 551 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); | 551 | if (lance_debug > 6) printk(" (#0x%05lx)", (unsigned long)lp); |
| 552 | dev->ml_priv = lp; | 552 | dev->ml_priv = lp; |
| 553 | lp->name = chipname; | 553 | lp->name = chipname; |
| 554 | lp->rx_buffs = (unsigned long)kmalloc(PKT_BUF_SZ*RX_RING_SIZE, | 554 | lp->rx_buffs = (unsigned long)kmalloc_array(RX_RING_SIZE, PKT_BUF_SZ, |
| 555 | GFP_DMA | GFP_KERNEL); | 555 | GFP_DMA | GFP_KERNEL); |
| 556 | if (!lp->rx_buffs) | 556 | if (!lp->rx_buffs) |
| 557 | goto out_lp; | 557 | goto out_lp; |
| 558 | if (lance_need_isa_bounce_buffers) { | 558 | if (lance_need_isa_bounce_buffers) { |
| 559 | lp->tx_bounce_buffs = kmalloc(PKT_BUF_SZ*TX_RING_SIZE, | 559 | lp->tx_bounce_buffs = kmalloc_array(TX_RING_SIZE, PKT_BUF_SZ, |
| 560 | GFP_DMA | GFP_KERNEL); | 560 | GFP_DMA | GFP_KERNEL); |
| 561 | if (!lp->tx_bounce_buffs) | 561 | if (!lp->tx_bounce_buffs) |
| 562 | goto out_rx; | 562 | goto out_rx; |
| 563 | } else | 563 | } else |
diff --git a/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c b/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c index cfe86a20c899..28e9ae1a193b 100644 --- a/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1c/atl1c_ethtool.c | |||
| @@ -209,8 +209,8 @@ static int atl1c_get_eeprom(struct net_device *netdev, | |||
| 209 | first_dword = eeprom->offset >> 2; | 209 | first_dword = eeprom->offset >> 2; |
| 210 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 210 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 211 | 211 | ||
| 212 | eeprom_buff = kmalloc(sizeof(u32) * | 212 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 213 | (last_dword - first_dword + 1), GFP_KERNEL); | 213 | GFP_KERNEL); |
| 214 | if (eeprom_buff == NULL) | 214 | if (eeprom_buff == NULL) |
| 215 | return -ENOMEM; | 215 | return -ENOMEM; |
| 216 | 216 | ||
diff --git a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c index cb489e7e8374..282ebdde4769 100644 --- a/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c +++ b/drivers/net/ethernet/atheros/atl1e/atl1e_ethtool.c | |||
| @@ -236,8 +236,8 @@ static int atl1e_get_eeprom(struct net_device *netdev, | |||
| 236 | first_dword = eeprom->offset >> 2; | 236 | first_dword = eeprom->offset >> 2; |
| 237 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 237 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 238 | 238 | ||
| 239 | eeprom_buff = kmalloc(sizeof(u32) * | 239 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 240 | (last_dword - first_dword + 1), GFP_KERNEL); | 240 | GFP_KERNEL); |
| 241 | if (eeprom_buff == NULL) | 241 | if (eeprom_buff == NULL) |
| 242 | return -ENOMEM; | 242 | return -ENOMEM; |
| 243 | 243 | ||
diff --git a/drivers/net/ethernet/atheros/atlx/atl2.c b/drivers/net/ethernet/atheros/atlx/atl2.c index db4bcc51023a..bb41becb6609 100644 --- a/drivers/net/ethernet/atheros/atlx/atl2.c +++ b/drivers/net/ethernet/atheros/atlx/atl2.c | |||
| @@ -1941,8 +1941,8 @@ static int atl2_get_eeprom(struct net_device *netdev, | |||
| 1941 | first_dword = eeprom->offset >> 2; | 1941 | first_dword = eeprom->offset >> 2; |
| 1942 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; | 1942 | last_dword = (eeprom->offset + eeprom->len - 1) >> 2; |
| 1943 | 1943 | ||
| 1944 | eeprom_buff = kmalloc(sizeof(u32) * (last_dword - first_dword + 1), | 1944 | eeprom_buff = kmalloc_array(last_dword - first_dword + 1, sizeof(u32), |
| 1945 | GFP_KERNEL); | 1945 | GFP_KERNEL); |
| 1946 | if (!eeprom_buff) | 1946 | if (!eeprom_buff) |
| 1947 | return -ENOMEM; | 1947 | return -ENOMEM; |
| 1948 | 1948 | ||
diff --git a/drivers/net/ethernet/broadcom/bcm63xx_enet.c b/drivers/net/ethernet/broadcom/bcm63xx_enet.c index 14a59e51db67..897302adc38e 100644 --- a/drivers/net/ethernet/broadcom/bcm63xx_enet.c +++ b/drivers/net/ethernet/broadcom/bcm63xx_enet.c | |||
| @@ -2150,7 +2150,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2150 | priv->tx_desc_alloc_size = size; | 2150 | priv->tx_desc_alloc_size = size; |
| 2151 | priv->tx_desc_cpu = p; | 2151 | priv->tx_desc_cpu = p; |
| 2152 | 2152 | ||
| 2153 | priv->tx_skb = kzalloc(sizeof(struct sk_buff *) * priv->tx_ring_size, | 2153 | priv->tx_skb = kcalloc(priv->tx_ring_size, sizeof(struct sk_buff *), |
| 2154 | GFP_KERNEL); | 2154 | GFP_KERNEL); |
| 2155 | if (!priv->tx_skb) { | 2155 | if (!priv->tx_skb) { |
| 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2156 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
| @@ -2164,7 +2164,7 @@ static int bcm_enetsw_open(struct net_device *dev) | |||
| 2164 | spin_lock_init(&priv->tx_lock); | 2164 | spin_lock_init(&priv->tx_lock); |
| 2165 | 2165 | ||
| 2166 | /* init & fill rx ring with skbs */ | 2166 | /* init & fill rx ring with skbs */ |
| 2167 | priv->rx_skb = kzalloc(sizeof(struct sk_buff *) * priv->rx_ring_size, | 2167 | priv->rx_skb = kcalloc(priv->rx_ring_size, sizeof(struct sk_buff *), |
| 2168 | GFP_KERNEL); | 2168 | GFP_KERNEL); |
| 2169 | if (!priv->rx_skb) { | 2169 | if (!priv->rx_skb) { |
| 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); | 2170 | dev_err(kdev, "cannot allocate rx skb queue\n"); |
diff --git a/drivers/net/ethernet/broadcom/bnx2.c b/drivers/net/ethernet/broadcom/bnx2.c index 3853296d78c1..122fdb80a789 100644 --- a/drivers/net/ethernet/broadcom/bnx2.c +++ b/drivers/net/ethernet/broadcom/bnx2.c | |||
| @@ -778,7 +778,7 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) | |||
| 778 | int j; | 778 | int j; |
| 779 | 779 | ||
| 780 | rxr->rx_buf_ring = | 780 | rxr->rx_buf_ring = |
| 781 | vzalloc(SW_RXBD_RING_SIZE * bp->rx_max_ring); | 781 | vzalloc(array_size(SW_RXBD_RING_SIZE, bp->rx_max_ring)); |
| 782 | if (!rxr->rx_buf_ring) | 782 | if (!rxr->rx_buf_ring) |
| 783 | return -ENOMEM; | 783 | return -ENOMEM; |
| 784 | 784 | ||
| @@ -794,8 +794,9 @@ bnx2_alloc_rx_mem(struct bnx2 *bp) | |||
| 794 | } | 794 | } |
| 795 | 795 | ||
| 796 | if (bp->rx_pg_ring_size) { | 796 | if (bp->rx_pg_ring_size) { |
| 797 | rxr->rx_pg_ring = vzalloc(SW_RXPG_RING_SIZE * | 797 | rxr->rx_pg_ring = |
| 798 | bp->rx_max_pg_ring); | 798 | vzalloc(array_size(SW_RXPG_RING_SIZE, |
| 799 | bp->rx_max_pg_ring)); | ||
| 799 | if (!rxr->rx_pg_ring) | 800 | if (!rxr->rx_pg_ring) |
| 800 | return -ENOMEM; | 801 | return -ENOMEM; |
| 801 | 802 | ||
| @@ -2666,7 +2667,7 @@ bnx2_alloc_bad_rbuf(struct bnx2 *bp) | |||
| 2666 | u32 good_mbuf_cnt; | 2667 | u32 good_mbuf_cnt; |
| 2667 | u32 val; | 2668 | u32 val; |
| 2668 | 2669 | ||
| 2669 | good_mbuf = kmalloc(512 * sizeof(u16), GFP_KERNEL); | 2670 | good_mbuf = kmalloc_array(512, sizeof(u16), GFP_KERNEL); |
| 2670 | if (!good_mbuf) | 2671 | if (!good_mbuf) |
| 2671 | return -ENOMEM; | 2672 | return -ENOMEM; |
| 2672 | 2673 | ||
diff --git a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c index ffa7959f6b31..dc77bfded865 100644 --- a/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c +++ b/drivers/net/ethernet/broadcom/bnx2x/bnx2x_sriov.c | |||
| @@ -571,7 +571,7 @@ int bnx2x_vf_mcast(struct bnx2x *bp, struct bnx2x_virtf *vf, | |||
| 571 | else | 571 | else |
| 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); | 572 | set_bit(RAMROD_COMP_WAIT, &mcast.ramrod_flags); |
| 573 | if (mc_num) { | 573 | if (mc_num) { |
| 574 | mc = kzalloc(mc_num * sizeof(struct bnx2x_mcast_list_elem), | 574 | mc = kcalloc(mc_num, sizeof(struct bnx2x_mcast_list_elem), |
| 575 | GFP_KERNEL); | 575 | GFP_KERNEL); |
| 576 | if (!mc) { | 576 | if (!mc) { |
| 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); | 577 | BNX2X_ERR("Cannot Configure multicasts due to lack of memory\n"); |
| @@ -1253,8 +1253,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1253 | num_vfs_param, iov->nr_virtfn); | 1253 | num_vfs_param, iov->nr_virtfn); |
| 1254 | 1254 | ||
| 1255 | /* allocate the vf array */ | 1255 | /* allocate the vf array */ |
| 1256 | bp->vfdb->vfs = kzalloc(sizeof(struct bnx2x_virtf) * | 1256 | bp->vfdb->vfs = kcalloc(BNX2X_NR_VIRTFN(bp), |
| 1257 | BNX2X_NR_VIRTFN(bp), GFP_KERNEL); | 1257 | sizeof(struct bnx2x_virtf), |
| 1258 | GFP_KERNEL); | ||
| 1258 | if (!bp->vfdb->vfs) { | 1259 | if (!bp->vfdb->vfs) { |
| 1259 | BNX2X_ERR("failed to allocate vf array\n"); | 1260 | BNX2X_ERR("failed to allocate vf array\n"); |
| 1260 | err = -ENOMEM; | 1261 | err = -ENOMEM; |
| @@ -1278,9 +1279,9 @@ int bnx2x_iov_init_one(struct bnx2x *bp, int int_mode_param, | |||
| 1278 | } | 1279 | } |
| 1279 | 1280 | ||
| 1280 | /* allocate the queue arrays for all VFs */ | 1281 | /* allocate the queue arrays for all VFs */ |
| 1281 | bp->vfdb->vfqs = kzalloc( | 1282 | bp->vfdb->vfqs = kcalloc(BNX2X_MAX_NUM_VF_QUEUES, |
| 1282 | BNX2X_MAX_NUM_VF_QUEUES * sizeof(struct bnx2x_vf_queue), | 1283 | sizeof(struct bnx2x_vf_queue), |
| 1283 | GFP_KERNEL); | 1284 | GFP_KERNEL); |
| 1284 | 1285 | ||
| 1285 | if (!bp->vfdb->vfqs) { | 1286 | if (!bp->vfdb->vfqs) { |
| 1286 | BNX2X_ERR("failed to allocate vf queue array\n"); | 1287 | BNX2X_ERR("failed to allocate vf queue array\n"); |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c index 38f635cf8408..05d405905906 100644 --- a/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c +++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_vfr.c | |||
| @@ -444,8 +444,8 @@ static int bnxt_vf_reps_create(struct bnxt *bp) | |||
| 444 | return -ENOMEM; | 444 | return -ENOMEM; |
| 445 | 445 | ||
| 446 | /* storage for cfa_code to vf-idx mapping */ | 446 | /* storage for cfa_code to vf-idx mapping */ |
| 447 | cfa_code_map = kmalloc(sizeof(*bp->cfa_code_map) * MAX_CFA_CODE, | 447 | cfa_code_map = kmalloc_array(MAX_CFA_CODE, sizeof(*bp->cfa_code_map), |
| 448 | GFP_KERNEL); | 448 | GFP_KERNEL); |
| 449 | if (!cfa_code_map) { | 449 | if (!cfa_code_map) { |
| 450 | rc = -ENOMEM; | 450 | rc = -ENOMEM; |
| 451 | goto err; | 451 | goto err; |
diff --git a/drivers/net/ethernet/broadcom/cnic.c b/drivers/net/ethernet/broadcom/cnic.c index 8bc126a156e8..30273a7717e2 100644 --- a/drivers/net/ethernet/broadcom/cnic.c +++ b/drivers/net/ethernet/broadcom/cnic.c | |||
| @@ -660,7 +660,7 @@ static int cnic_init_id_tbl(struct cnic_id_tbl *id_tbl, u32 size, u32 start_id, | |||
| 660 | id_tbl->max = size; | 660 | id_tbl->max = size; |
| 661 | id_tbl->next = next; | 661 | id_tbl->next = next; |
| 662 | spin_lock_init(&id_tbl->lock); | 662 | spin_lock_init(&id_tbl->lock); |
| 663 | id_tbl->table = kzalloc(DIV_ROUND_UP(size, 32) * 4, GFP_KERNEL); | 663 | id_tbl->table = kcalloc(DIV_ROUND_UP(size, 32), 4, GFP_KERNEL); |
| 664 | if (!id_tbl->table) | 664 | if (!id_tbl->table) |
| 665 | return -ENOMEM; | 665 | return -ENOMEM; |
| 666 | 666 | ||
| @@ -1255,13 +1255,13 @@ static int cnic_alloc_bnx2x_resc(struct cnic_dev *dev) | |||
| 1255 | cp->fcoe_init_cid = 0x10; | 1255 | cp->fcoe_init_cid = 0x10; |
| 1256 | } | 1256 | } |
| 1257 | 1257 | ||
| 1258 | cp->iscsi_tbl = kzalloc(sizeof(struct cnic_iscsi) * MAX_ISCSI_TBL_SZ, | 1258 | cp->iscsi_tbl = kcalloc(MAX_ISCSI_TBL_SZ, sizeof(struct cnic_iscsi), |
| 1259 | GFP_KERNEL); | 1259 | GFP_KERNEL); |
| 1260 | if (!cp->iscsi_tbl) | 1260 | if (!cp->iscsi_tbl) |
| 1261 | goto error; | 1261 | goto error; |
| 1262 | 1262 | ||
| 1263 | cp->ctx_tbl = kzalloc(sizeof(struct cnic_context) * | 1263 | cp->ctx_tbl = kcalloc(cp->max_cid_space, sizeof(struct cnic_context), |
| 1264 | cp->max_cid_space, GFP_KERNEL); | 1264 | GFP_KERNEL); |
| 1265 | if (!cp->ctx_tbl) | 1265 | if (!cp->ctx_tbl) |
| 1266 | goto error; | 1266 | goto error; |
| 1267 | 1267 | ||
| @@ -4100,7 +4100,7 @@ static int cnic_cm_alloc_mem(struct cnic_dev *dev) | |||
| 4100 | struct cnic_local *cp = dev->cnic_priv; | 4100 | struct cnic_local *cp = dev->cnic_priv; |
| 4101 | u32 port_id; | 4101 | u32 port_id; |
| 4102 | 4102 | ||
| 4103 | cp->csk_tbl = kzalloc(sizeof(struct cnic_sock) * MAX_CM_SK_TBL_SZ, | 4103 | cp->csk_tbl = kcalloc(MAX_CM_SK_TBL_SZ, sizeof(struct cnic_sock), |
| 4104 | GFP_KERNEL); | 4104 | GFP_KERNEL); |
| 4105 | if (!cp->csk_tbl) | 4105 | if (!cp->csk_tbl) |
| 4106 | return -ENOMEM; | 4106 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/broadcom/tg3.c b/drivers/net/ethernet/broadcom/tg3.c index 9f59b1270a7c..3be87efdc93d 100644 --- a/drivers/net/ethernet/broadcom/tg3.c +++ b/drivers/net/ethernet/broadcom/tg3.c | |||
| @@ -8631,8 +8631,9 @@ static int tg3_mem_tx_acquire(struct tg3 *tp) | |||
| 8631 | tnapi++; | 8631 | tnapi++; |
| 8632 | 8632 | ||
| 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { | 8633 | for (i = 0; i < tp->txq_cnt; i++, tnapi++) { |
| 8634 | tnapi->tx_buffers = kzalloc(sizeof(struct tg3_tx_ring_info) * | 8634 | tnapi->tx_buffers = kcalloc(TG3_TX_RING_SIZE, |
| 8635 | TG3_TX_RING_SIZE, GFP_KERNEL); | 8635 | sizeof(struct tg3_tx_ring_info), |
| 8636 | GFP_KERNEL); | ||
| 8636 | if (!tnapi->tx_buffers) | 8637 | if (!tnapi->tx_buffers) |
| 8637 | goto err_out; | 8638 | goto err_out; |
| 8638 | 8639 | ||
diff --git a/drivers/net/ethernet/brocade/bna/bnad.c b/drivers/net/ethernet/brocade/bna/bnad.c index 69cc3e0119d6..ea5f32ea308a 100644 --- a/drivers/net/ethernet/brocade/bna/bnad.c +++ b/drivers/net/ethernet/brocade/bna/bnad.c | |||
| @@ -3141,7 +3141,7 @@ bnad_set_rx_ucast_fltr(struct bnad *bnad) | |||
| 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) | 3141 | if (uc_count > bna_attr(&bnad->bna)->num_ucmac) |
| 3142 | goto mode_default; | 3142 | goto mode_default; |
| 3143 | 3143 | ||
| 3144 | mac_list = kzalloc(uc_count * ETH_ALEN, GFP_ATOMIC); | 3144 | mac_list = kcalloc(ETH_ALEN, uc_count, GFP_ATOMIC); |
| 3145 | if (mac_list == NULL) | 3145 | if (mac_list == NULL) |
| 3146 | goto mode_default; | 3146 | goto mode_default; |
| 3147 | 3147 | ||
| @@ -3182,7 +3182,7 @@ bnad_set_rx_mcast_fltr(struct bnad *bnad) | |||
| 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) | 3182 | if (mc_count > bna_attr(&bnad->bna)->num_mcmac) |
| 3183 | goto mode_allmulti; | 3183 | goto mode_allmulti; |
| 3184 | 3184 | ||
| 3185 | mac_list = kzalloc((mc_count + 1) * ETH_ALEN, GFP_ATOMIC); | 3185 | mac_list = kcalloc(mc_count + 1, ETH_ALEN, GFP_ATOMIC); |
| 3186 | 3186 | ||
| 3187 | if (mac_list == NULL) | 3187 | if (mac_list == NULL) |
| 3188 | goto mode_allmulti; | 3188 | goto mode_allmulti; |
diff --git a/drivers/net/ethernet/calxeda/xgmac.c b/drivers/net/ethernet/calxeda/xgmac.c index 2bd7c638b178..2c63afff1382 100644 --- a/drivers/net/ethernet/calxeda/xgmac.c +++ b/drivers/net/ethernet/calxeda/xgmac.c | |||
| @@ -739,7 +739,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 739 | 739 | ||
| 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); | 740 | netdev_dbg(priv->dev, "mtu [%d] bfsize [%d]\n", dev->mtu, bfsize); |
| 741 | 741 | ||
| 742 | priv->rx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_RX_RING_SZ, | 742 | priv->rx_skbuff = kcalloc(DMA_RX_RING_SZ, sizeof(struct sk_buff *), |
| 743 | GFP_KERNEL); | 743 | GFP_KERNEL); |
| 744 | if (!priv->rx_skbuff) | 744 | if (!priv->rx_skbuff) |
| 745 | return -ENOMEM; | 745 | return -ENOMEM; |
| @@ -752,7 +752,7 @@ static int xgmac_dma_desc_rings_init(struct net_device *dev) | |||
| 752 | if (!priv->dma_rx) | 752 | if (!priv->dma_rx) |
| 753 | goto err_dma_rx; | 753 | goto err_dma_rx; |
| 754 | 754 | ||
| 755 | priv->tx_skbuff = kzalloc(sizeof(struct sk_buff *) * DMA_TX_RING_SZ, | 755 | priv->tx_skbuff = kcalloc(DMA_TX_RING_SZ, sizeof(struct sk_buff *), |
| 756 | GFP_KERNEL); | 756 | GFP_KERNEL); |
| 757 | if (!priv->tx_skbuff) | 757 | if (!priv->tx_skbuff) |
| 758 | goto err_tx_skb; | 758 | goto err_tx_skb; |
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c index f044718cea52..a71dbb7ab6af 100644 --- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c +++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c | |||
| @@ -281,13 +281,12 @@ int octeon_init_droq(struct octeon_device *oct, | |||
| 281 | droq->max_count); | 281 | droq->max_count); |
| 282 | 282 | ||
| 283 | droq->recv_buf_list = (struct octeon_recv_buffer *) | 283 | droq->recv_buf_list = (struct octeon_recv_buffer *) |
| 284 | vzalloc_node(droq->max_count * | 284 | vzalloc_node(array_size(droq->max_count, OCT_DROQ_RECVBUF_SIZE), |
| 285 | OCT_DROQ_RECVBUF_SIZE, | 285 | numa_node); |
| 286 | numa_node); | ||
| 287 | if (!droq->recv_buf_list) | 286 | if (!droq->recv_buf_list) |
| 288 | droq->recv_buf_list = (struct octeon_recv_buffer *) | 287 | droq->recv_buf_list = (struct octeon_recv_buffer *) |
| 289 | vzalloc(droq->max_count * | 288 | vzalloc(array_size(droq->max_count, |
| 290 | OCT_DROQ_RECVBUF_SIZE); | 289 | OCT_DROQ_RECVBUF_SIZE)); |
| 291 | if (!droq->recv_buf_list) { | 290 | if (!droq->recv_buf_list) { |
| 292 | dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n"); | 291 | dev_err(&oct->pci_dev->dev, "Output queue recv buf list alloc failed\n"); |
| 293 | goto init_droq_fail; | 292 | goto init_droq_fail; |
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c b/drivers/net/ethernet/cavium/liquidio/request_manager.c index b1270355b0b1..1f2e75da28f8 100644 --- a/drivers/net/ethernet/cavium/liquidio/request_manager.c +++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c | |||
| @@ -98,8 +98,9 @@ int octeon_init_instr_queue(struct octeon_device *oct, | |||
| 98 | iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs), | 98 | iq->request_list = vmalloc_node((sizeof(*iq->request_list) * num_descs), |
| 99 | numa_node); | 99 | numa_node); |
| 100 | if (!iq->request_list) | 100 | if (!iq->request_list) |
| 101 | iq->request_list = vmalloc(sizeof(*iq->request_list) * | 101 | iq->request_list = |
| 102 | num_descs); | 102 | vmalloc(array_size(num_descs, |
| 103 | sizeof(*iq->request_list))); | ||
| 103 | if (!iq->request_list) { | 104 | if (!iq->request_list) { |
| 104 | lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); | 105 | lio_dma_free(oct, q_size, iq->base_addr, iq->base_addr_dma); |
| 105 | dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", | 106 | dev_err(&oct->pci_dev->dev, "Alloc failed for IQ[%d] nr free list\n", |
diff --git a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c index d42704d07484..187a249ff2d1 100644 --- a/drivers/net/ethernet/cavium/thunder/nicvf_queues.c +++ b/drivers/net/ethernet/cavium/thunder/nicvf_queues.c | |||
| @@ -292,8 +292,8 @@ static int nicvf_init_rbdr(struct nicvf *nic, struct rbdr *rbdr, | |||
| 292 | rbdr->is_xdp = true; | 292 | rbdr->is_xdp = true; |
| 293 | } | 293 | } |
| 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); | 294 | rbdr->pgcnt = roundup_pow_of_two(rbdr->pgcnt); |
| 295 | rbdr->pgcache = kzalloc(sizeof(*rbdr->pgcache) * | 295 | rbdr->pgcache = kcalloc(rbdr->pgcnt, sizeof(*rbdr->pgcache), |
| 296 | rbdr->pgcnt, GFP_KERNEL); | 296 | GFP_KERNEL); |
| 297 | if (!rbdr->pgcache) | 297 | if (!rbdr->pgcache) |
| 298 | return -ENOMEM; | 298 | return -ENOMEM; |
| 299 | rbdr->pgidx = 0; | 299 | rbdr->pgidx = 0; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c b/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c index 290039026ece..5701272aa7f7 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c +++ b/drivers/net/ethernet/chelsio/cxgb4/clip_tbl.c | |||
| @@ -304,7 +304,7 @@ struct clip_tbl *t4_init_clip_tbl(unsigned int clipt_start, | |||
| 304 | for (i = 0; i < ctbl->clipt_size; ++i) | 304 | for (i = 0; i < ctbl->clipt_size; ++i) |
| 305 | INIT_LIST_HEAD(&ctbl->hash_list[i]); | 305 | INIT_LIST_HEAD(&ctbl->hash_list[i]); |
| 306 | 306 | ||
| 307 | cl_list = kvzalloc(clipt_size*sizeof(struct clip_entry), GFP_KERNEL); | 307 | cl_list = kvcalloc(clipt_size, sizeof(struct clip_entry), GFP_KERNEL); |
| 308 | if (!cl_list) { | 308 | if (!cl_list) { |
| 309 | kvfree(ctbl); | 309 | kvfree(ctbl); |
| 310 | return NULL; | 310 | return NULL; |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c index 251d5bdc972f..c301aaf79d64 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_debugfs.c | |||
| @@ -873,7 +873,7 @@ static int cctrl_tbl_show(struct seq_file *seq, void *v) | |||
| 873 | u16 (*incr)[NCCTRL_WIN]; | 873 | u16 (*incr)[NCCTRL_WIN]; |
| 874 | struct adapter *adap = seq->private; | 874 | struct adapter *adap = seq->private; |
| 875 | 875 | ||
| 876 | incr = kmalloc(sizeof(*incr) * NMTUS, GFP_KERNEL); | 876 | incr = kmalloc_array(NMTUS, sizeof(*incr), GFP_KERNEL); |
| 877 | if (!incr) | 877 | if (!incr) |
| 878 | return -ENOMEM; | 878 | return -ENOMEM; |
| 879 | 879 | ||
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c index 35cb3ae4f7b6..dd04a2f89ce6 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c | |||
| @@ -713,7 +713,7 @@ int cxgb4_write_rss(const struct port_info *pi, const u16 *queues) | |||
| 713 | const struct sge_eth_rxq *rxq; | 713 | const struct sge_eth_rxq *rxq; |
| 714 | 714 | ||
| 715 | rxq = &adapter->sge.ethrxq[pi->first_qset]; | 715 | rxq = &adapter->sge.ethrxq[pi->first_qset]; |
| 716 | rss = kmalloc(pi->rss_size * sizeof(u16), GFP_KERNEL); | 716 | rss = kmalloc_array(pi->rss_size, sizeof(u16), GFP_KERNEL); |
| 717 | if (!rss) | 717 | if (!rss) |
| 718 | return -ENOMEM; | 718 | return -ENOMEM; |
| 719 | 719 | ||
| @@ -4972,8 +4972,8 @@ static int enable_msix(struct adapter *adap) | |||
| 4972 | max_ingq += (MAX_OFLD_QSETS * adap->num_uld); | 4972 | max_ingq += (MAX_OFLD_QSETS * adap->num_uld); |
| 4973 | if (is_offload(adap)) | 4973 | if (is_offload(adap)) |
| 4974 | max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld); | 4974 | max_ingq += (MAX_OFLD_QSETS * adap->num_ofld_uld); |
| 4975 | entries = kmalloc(sizeof(*entries) * (max_ingq + 1), | 4975 | entries = kmalloc_array(max_ingq + 1, sizeof(*entries), |
| 4976 | GFP_KERNEL); | 4976 | GFP_KERNEL); |
| 4977 | if (!entries) | 4977 | if (!entries) |
| 4978 | return -ENOMEM; | 4978 | return -ENOMEM; |
| 4979 | 4979 | ||
| @@ -5646,8 +5646,8 @@ static int init_one(struct pci_dev *pdev, const struct pci_device_id *ent) | |||
| 5646 | adapter->params.offload = 0; | 5646 | adapter->params.offload = 0; |
| 5647 | } | 5647 | } |
| 5648 | 5648 | ||
| 5649 | adapter->mps_encap = kvzalloc(sizeof(struct mps_encap_entry) * | 5649 | adapter->mps_encap = kvcalloc(adapter->params.arch.mps_tcam_size, |
| 5650 | adapter->params.arch.mps_tcam_size, | 5650 | sizeof(struct mps_encap_entry), |
| 5651 | GFP_KERNEL); | 5651 | GFP_KERNEL); |
| 5652 | if (!adapter->mps_encap) | 5652 | if (!adapter->mps_encap) |
| 5653 | dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n"); | 5653 | dev_warn(&pdev->dev, "could not allocate MPS Encap entries, continuing\n"); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c index ab174bcfbfb0..18eb2aedd4cb 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_tc_u32.c | |||
| @@ -457,7 +457,8 @@ struct cxgb4_tc_u32_table *cxgb4_init_tc_u32(struct adapter *adap) | |||
| 457 | unsigned int bmap_size; | 457 | unsigned int bmap_size; |
| 458 | 458 | ||
| 459 | bmap_size = BITS_TO_LONGS(max_tids); | 459 | bmap_size = BITS_TO_LONGS(max_tids); |
| 460 | link->tid_map = kvzalloc(sizeof(unsigned long) * bmap_size, GFP_KERNEL); | 460 | link->tid_map = kvcalloc(bmap_size, sizeof(unsigned long), |
| 461 | GFP_KERNEL); | ||
| 461 | if (!link->tid_map) | 462 | if (!link->tid_map) |
| 462 | goto out_no_mem; | 463 | goto out_no_mem; |
| 463 | bitmap_zero(link->tid_map, max_tids); | 464 | bitmap_zero(link->tid_map, max_tids); |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c index a95cde0fadf7..4bc211093c98 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c +++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_uld.c | |||
| @@ -561,13 +561,13 @@ int t4_uld_mem_alloc(struct adapter *adap) | |||
| 561 | if (!adap->uld) | 561 | if (!adap->uld) |
| 562 | return -ENOMEM; | 562 | return -ENOMEM; |
| 563 | 563 | ||
| 564 | s->uld_rxq_info = kzalloc(CXGB4_ULD_MAX * | 564 | s->uld_rxq_info = kcalloc(CXGB4_ULD_MAX, |
| 565 | sizeof(struct sge_uld_rxq_info *), | 565 | sizeof(struct sge_uld_rxq_info *), |
| 566 | GFP_KERNEL); | 566 | GFP_KERNEL); |
| 567 | if (!s->uld_rxq_info) | 567 | if (!s->uld_rxq_info) |
| 568 | goto err_uld; | 568 | goto err_uld; |
| 569 | 569 | ||
| 570 | s->uld_txq_info = kzalloc(CXGB4_TX_MAX * | 570 | s->uld_txq_info = kcalloc(CXGB4_TX_MAX, |
| 571 | sizeof(struct sge_uld_txq_info *), | 571 | sizeof(struct sge_uld_txq_info *), |
| 572 | GFP_KERNEL); | 572 | GFP_KERNEL); |
| 573 | if (!s->uld_txq_info) | 573 | if (!s->uld_txq_info) |
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 7a271feec5e7..395e2a0e8d7f 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -699,7 +699,7 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size, | |||
| 699 | if (!p) | 699 | if (!p) |
| 700 | return NULL; | 700 | return NULL; |
| 701 | if (sw_size) { | 701 | if (sw_size) { |
| 702 | s = kzalloc_node(nelem * sw_size, GFP_KERNEL, node); | 702 | s = kcalloc_node(sw_size, nelem, GFP_KERNEL, node); |
| 703 | 703 | ||
| 704 | if (!s) { | 704 | if (!s) { |
| 705 | dma_free_coherent(dev, len, p, *phys); | 705 | dma_free_coherent(dev, len, p, *phys); |
diff --git a/drivers/net/ethernet/cortina/gemini.c b/drivers/net/ethernet/cortina/gemini.c index ff9eb45f67f8..6d7404f66f84 100644 --- a/drivers/net/ethernet/cortina/gemini.c +++ b/drivers/net/ethernet/cortina/gemini.c | |||
| @@ -910,8 +910,8 @@ static int geth_setup_freeq(struct gemini_ethernet *geth) | |||
| 910 | } | 910 | } |
| 911 | 911 | ||
| 912 | /* Allocate a mapping to page look-up index */ | 912 | /* Allocate a mapping to page look-up index */ |
| 913 | geth->freeq_pages = kzalloc(pages * sizeof(*geth->freeq_pages), | 913 | geth->freeq_pages = kcalloc(pages, sizeof(*geth->freeq_pages), |
| 914 | GFP_KERNEL); | 914 | GFP_KERNEL); |
| 915 | if (!geth->freeq_pages) | 915 | if (!geth->freeq_pages) |
| 916 | goto err_freeq; | 916 | goto err_freeq; |
| 917 | geth->num_freeq_pages = pages; | 917 | geth->num_freeq_pages = pages; |
diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 00a57273b753..60da0499ad66 100644 --- a/drivers/net/ethernet/ethoc.c +++ b/drivers/net/ethernet/ethoc.c | |||
| @@ -1141,7 +1141,8 @@ static int ethoc_probe(struct platform_device *pdev) | |||
| 1141 | dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", | 1141 | dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", |
| 1142 | priv->num_tx, priv->num_rx); | 1142 | priv->num_tx, priv->num_rx); |
| 1143 | 1143 | ||
| 1144 | priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL); | 1144 | priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *), |
| 1145 | GFP_KERNEL); | ||
| 1145 | if (!priv->vma) { | 1146 | if (!priv->vma) { |
| 1146 | ret = -ENOMEM; | 1147 | ret = -ENOMEM; |
| 1147 | goto free; | 1148 | goto free; |
diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index fd43f98ddbe7..5f4e1ffa7b95 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c | |||
| @@ -664,7 +664,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev, | |||
| 664 | struct dpaa_fq *dpaa_fq; | 664 | struct dpaa_fq *dpaa_fq; |
| 665 | int i; | 665 | int i; |
| 666 | 666 | ||
| 667 | dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count, | 667 | dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq), |
| 668 | GFP_KERNEL); | 668 | GFP_KERNEL); |
| 669 | if (!dpaa_fq) | 669 | if (!dpaa_fq) |
| 670 | return NULL; | 670 | return NULL; |
diff --git a/drivers/net/ethernet/freescale/ucc_geth.c b/drivers/net/ethernet/freescale/ucc_geth.c index a96b838cffce..42fca3208c0b 100644 --- a/drivers/net/ethernet/freescale/ucc_geth.c +++ b/drivers/net/ethernet/freescale/ucc_geth.c | |||
| @@ -2253,9 +2253,9 @@ static int ucc_geth_alloc_tx(struct ucc_geth_private *ugeth) | |||
| 2253 | /* Init Tx bds */ | 2253 | /* Init Tx bds */ |
| 2254 | for (j = 0; j < ug_info->numQueuesTx; j++) { | 2254 | for (j = 0; j < ug_info->numQueuesTx; j++) { |
| 2255 | /* Setup the skbuff rings */ | 2255 | /* Setup the skbuff rings */ |
| 2256 | ugeth->tx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * | 2256 | ugeth->tx_skbuff[j] = |
| 2257 | ugeth->ug_info->bdRingLenTx[j], | 2257 | kmalloc_array(ugeth->ug_info->bdRingLenTx[j], |
| 2258 | GFP_KERNEL); | 2258 | sizeof(struct sk_buff *), GFP_KERNEL); |
| 2259 | 2259 | ||
| 2260 | if (ugeth->tx_skbuff[j] == NULL) { | 2260 | if (ugeth->tx_skbuff[j] == NULL) { |
| 2261 | if (netif_msg_ifup(ugeth)) | 2261 | if (netif_msg_ifup(ugeth)) |
| @@ -2326,9 +2326,9 @@ static int ucc_geth_alloc_rx(struct ucc_geth_private *ugeth) | |||
| 2326 | /* Init Rx bds */ | 2326 | /* Init Rx bds */ |
| 2327 | for (j = 0; j < ug_info->numQueuesRx; j++) { | 2327 | for (j = 0; j < ug_info->numQueuesRx; j++) { |
| 2328 | /* Setup the skbuff rings */ | 2328 | /* Setup the skbuff rings */ |
| 2329 | ugeth->rx_skbuff[j] = kmalloc(sizeof(struct sk_buff *) * | 2329 | ugeth->rx_skbuff[j] = |
| 2330 | ugeth->ug_info->bdRingLenRx[j], | 2330 | kmalloc_array(ugeth->ug_info->bdRingLenRx[j], |
| 2331 | GFP_KERNEL); | 2331 | sizeof(struct sk_buff *), GFP_KERNEL); |
| 2332 | 2332 | ||
| 2333 | if (ugeth->rx_skbuff[j] == NULL) { | 2333 | if (ugeth->rx_skbuff[j] == NULL) { |
| 2334 | if (netif_msg_ifup(ugeth)) | 2334 | if (netif_msg_ifup(ugeth)) |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c index 85e1d14514fc..0ce07f6eb1e6 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_dsaf_main.c | |||
| @@ -1406,8 +1406,8 @@ static int hns_dsaf_init(struct dsaf_device *dsaf_dev) | |||
| 1406 | return ret; | 1406 | return ret; |
| 1407 | 1407 | ||
| 1408 | /* malloc mem for tcam mac key(vlan+mac) */ | 1408 | /* malloc mem for tcam mac key(vlan+mac) */ |
| 1409 | priv->soft_mac_tbl = vzalloc(sizeof(*priv->soft_mac_tbl) | 1409 | priv->soft_mac_tbl = vzalloc(array_size(DSAF_TCAM_SUM, |
| 1410 | * DSAF_TCAM_SUM); | 1410 | sizeof(*priv->soft_mac_tbl))); |
| 1411 | if (!priv->soft_mac_tbl) { | 1411 | if (!priv->soft_mac_tbl) { |
| 1412 | ret = -ENOMEM; | 1412 | ret = -ENOMEM; |
| 1413 | goto remove_hw; | 1413 | goto remove_hw; |
diff --git a/drivers/net/ethernet/hisilicon/hns/hns_enet.c b/drivers/net/ethernet/hisilicon/hns/hns_enet.c index 1ccb6443d2ed..ef9ef703d13a 100644 --- a/drivers/net/ethernet/hisilicon/hns/hns_enet.c +++ b/drivers/net/ethernet/hisilicon/hns/hns_enet.c | |||
| @@ -2197,7 +2197,8 @@ static int hns_nic_init_ring_data(struct hns_nic_priv *priv) | |||
| 2197 | return -EINVAL; | 2197 | return -EINVAL; |
| 2198 | } | 2198 | } |
| 2199 | 2199 | ||
| 2200 | priv->ring_data = kzalloc(h->q_num * sizeof(*priv->ring_data) * 2, | 2200 | priv->ring_data = kzalloc(array3_size(h->q_num, |
| 2201 | sizeof(*priv->ring_data), 2), | ||
| 2201 | GFP_KERNEL); | 2202 | GFP_KERNEL); |
| 2202 | if (!priv->ring_data) | 2203 | if (!priv->ring_data) |
| 2203 | return -ENOMEM; | 2204 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c index f2b31d278bc9..25a73bb2e642 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3_enet.c | |||
| @@ -2846,8 +2846,10 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) | |||
| 2846 | struct pci_dev *pdev = h->pdev; | 2846 | struct pci_dev *pdev = h->pdev; |
| 2847 | int i, ret; | 2847 | int i, ret; |
| 2848 | 2848 | ||
| 2849 | priv->ring_data = devm_kzalloc(&pdev->dev, h->kinfo.num_tqps * | 2849 | priv->ring_data = devm_kzalloc(&pdev->dev, |
| 2850 | sizeof(*priv->ring_data) * 2, | 2850 | array3_size(h->kinfo.num_tqps, |
| 2851 | sizeof(*priv->ring_data), | ||
| 2852 | 2), | ||
| 2851 | GFP_KERNEL); | 2853 | GFP_KERNEL); |
| 2852 | if (!priv->ring_data) | 2854 | if (!priv->ring_data) |
| 2853 | return -ENOMEM; | 2855 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c index 28a81ac97af5..4d09ea786b35 100644 --- a/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c +++ b/drivers/net/ethernet/huawei/hinic/hinic_hw_cmdq.c | |||
| @@ -753,11 +753,12 @@ static int init_cmdq(struct hinic_cmdq *cmdq, struct hinic_wq *wq, | |||
| 753 | 753 | ||
| 754 | spin_lock_init(&cmdq->cmdq_lock); | 754 | spin_lock_init(&cmdq->cmdq_lock); |
| 755 | 755 | ||
| 756 | cmdq->done = vzalloc(wq->q_depth * sizeof(*cmdq->done)); | 756 | cmdq->done = vzalloc(array_size(sizeof(*cmdq->done), wq->q_depth)); |
| 757 | if (!cmdq->done) | 757 | if (!cmdq->done) |
| 758 | return -ENOMEM; | 758 | return -ENOMEM; |
| 759 | 759 | ||
| 760 | cmdq->errcode = vzalloc(wq->q_depth * sizeof(*cmdq->errcode)); | 760 | cmdq->errcode = vzalloc(array_size(sizeof(*cmdq->errcode), |
| 761 | wq->q_depth)); | ||
| 761 | if (!cmdq->errcode) { | 762 | if (!cmdq->errcode) { |
| 762 | err = -ENOMEM; | 763 | err = -ENOMEM; |
| 763 | goto err_errcode; | 764 | goto err_errcode; |
diff --git a/drivers/net/ethernet/ibm/ibmveth.c b/drivers/net/ethernet/ibm/ibmveth.c index c1b51edaaf62..525d8b89187b 100644 --- a/drivers/net/ethernet/ibm/ibmveth.c +++ b/drivers/net/ethernet/ibm/ibmveth.c | |||
| @@ -171,7 +171,7 @@ static int ibmveth_alloc_buffer_pool(struct ibmveth_buff_pool *pool) | |||
| 171 | { | 171 | { |
| 172 | int i; | 172 | int i; |
| 173 | 173 | ||
| 174 | pool->free_map = kmalloc(sizeof(u16) * pool->size, GFP_KERNEL); | 174 | pool->free_map = kmalloc_array(pool->size, sizeof(u16), GFP_KERNEL); |
| 175 | 175 | ||
| 176 | if (!pool->free_map) | 176 | if (!pool->free_map) |
| 177 | return -1; | 177 | return -1; |
diff --git a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c index 5d365a986bb0..bdb3f8e65ed4 100644 --- a/drivers/net/ethernet/intel/e1000/e1000_ethtool.c +++ b/drivers/net/ethernet/intel/e1000/e1000_ethtool.c | |||
| @@ -435,8 +435,8 @@ static int e1000_get_eeprom(struct net_device *netdev, | |||
| 435 | first_word = eeprom->offset >> 1; | 435 | first_word = eeprom->offset >> 1; |
| 436 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 436 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 437 | 437 | ||
| 438 | eeprom_buff = kmalloc(sizeof(u16) * | 438 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 439 | (last_word - first_word + 1), GFP_KERNEL); | 439 | GFP_KERNEL); |
| 440 | if (!eeprom_buff) | 440 | if (!eeprom_buff) |
| 441 | return -ENOMEM; | 441 | return -ENOMEM; |
| 442 | 442 | ||
diff --git a/drivers/net/ethernet/intel/e1000e/ethtool.c b/drivers/net/ethernet/intel/e1000e/ethtool.c index e084cb734eb1..02ebf208f48b 100644 --- a/drivers/net/ethernet/intel/e1000e/ethtool.c +++ b/drivers/net/ethernet/intel/e1000e/ethtool.c | |||
| @@ -509,8 +509,8 @@ static int e1000_get_eeprom(struct net_device *netdev, | |||
| 509 | first_word = eeprom->offset >> 1; | 509 | first_word = eeprom->offset >> 1; |
| 510 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 510 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 511 | 511 | ||
| 512 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 512 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 513 | GFP_KERNEL); | 513 | GFP_KERNEL); |
| 514 | if (!eeprom_buff) | 514 | if (!eeprom_buff) |
| 515 | return -ENOMEM; | 515 | return -ENOMEM; |
| 516 | 516 | ||
diff --git a/drivers/net/ethernet/intel/e1000e/netdev.c b/drivers/net/ethernet/intel/e1000e/netdev.c index acf1e8b52b8e..3ba0c90e7055 100644 --- a/drivers/net/ethernet/intel/e1000e/netdev.c +++ b/drivers/net/ethernet/intel/e1000e/netdev.c | |||
| @@ -3312,7 +3312,7 @@ static int e1000e_write_mc_addr_list(struct net_device *netdev) | |||
| 3312 | return 0; | 3312 | return 0; |
| 3313 | } | 3313 | } |
| 3314 | 3314 | ||
| 3315 | mta_list = kzalloc(netdev_mc_count(netdev) * ETH_ALEN, GFP_ATOMIC); | 3315 | mta_list = kcalloc(netdev_mc_count(netdev), ETH_ALEN, GFP_ATOMIC); |
| 3316 | if (!mta_list) | 3316 | if (!mta_list) |
| 3317 | return -ENOMEM; | 3317 | return -ENOMEM; |
| 3318 | 3318 | ||
diff --git a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c index 7657daa27298..4895dd83dd08 100644 --- a/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c +++ b/drivers/net/ethernet/intel/fm10k/fm10k_ethtool.c | |||
| @@ -558,7 +558,7 @@ static int fm10k_set_ringparam(struct net_device *netdev, | |||
| 558 | 558 | ||
| 559 | /* allocate temporary buffer to store rings in */ | 559 | /* allocate temporary buffer to store rings in */ |
| 560 | i = max_t(int, interface->num_tx_queues, interface->num_rx_queues); | 560 | i = max_t(int, interface->num_tx_queues, interface->num_rx_queues); |
| 561 | temp_ring = vmalloc(i * sizeof(struct fm10k_ring)); | 561 | temp_ring = vmalloc(array_size(i, sizeof(struct fm10k_ring))); |
| 562 | 562 | ||
| 563 | if (!temp_ring) { | 563 | if (!temp_ring) { |
| 564 | err = -ENOMEM; | 564 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/igb/igb_ethtool.c b/drivers/net/ethernet/intel/igb/igb_ethtool.c index 2d798499d35e..f92f7918112d 100644 --- a/drivers/net/ethernet/intel/igb/igb_ethtool.c +++ b/drivers/net/ethernet/intel/igb/igb_ethtool.c | |||
| @@ -736,8 +736,8 @@ static int igb_get_eeprom(struct net_device *netdev, | |||
| 736 | first_word = eeprom->offset >> 1; | 736 | first_word = eeprom->offset >> 1; |
| 737 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 737 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 738 | 738 | ||
| 739 | eeprom_buff = kmalloc(sizeof(u16) * | 739 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 740 | (last_word - first_word + 1), GFP_KERNEL); | 740 | GFP_KERNEL); |
| 741 | if (!eeprom_buff) | 741 | if (!eeprom_buff) |
| 742 | return -ENOMEM; | 742 | return -ENOMEM; |
| 743 | 743 | ||
| @@ -902,11 +902,11 @@ static int igb_set_ringparam(struct net_device *netdev, | |||
| 902 | } | 902 | } |
| 903 | 903 | ||
| 904 | if (adapter->num_tx_queues > adapter->num_rx_queues) | 904 | if (adapter->num_tx_queues > adapter->num_rx_queues) |
| 905 | temp_ring = vmalloc(adapter->num_tx_queues * | 905 | temp_ring = vmalloc(array_size(sizeof(struct igb_ring), |
| 906 | sizeof(struct igb_ring)); | 906 | adapter->num_tx_queues)); |
| 907 | else | 907 | else |
| 908 | temp_ring = vmalloc(adapter->num_rx_queues * | 908 | temp_ring = vmalloc(array_size(sizeof(struct igb_ring), |
| 909 | sizeof(struct igb_ring)); | 909 | adapter->num_rx_queues)); |
| 910 | 910 | ||
| 911 | if (!temp_ring) { | 911 | if (!temp_ring) { |
| 912 | err = -ENOMEM; | 912 | err = -ENOMEM; |
| @@ -3245,8 +3245,8 @@ static int igb_get_module_eeprom(struct net_device *netdev, | |||
| 3245 | first_word = ee->offset >> 1; | 3245 | first_word = ee->offset >> 1; |
| 3246 | last_word = (ee->offset + ee->len - 1) >> 1; | 3246 | last_word = (ee->offset + ee->len - 1) >> 1; |
| 3247 | 3247 | ||
| 3248 | dataword = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 3248 | dataword = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 3249 | GFP_KERNEL); | 3249 | GFP_KERNEL); |
| 3250 | if (!dataword) | 3250 | if (!dataword) |
| 3251 | return -ENOMEM; | 3251 | return -ENOMEM; |
| 3252 | 3252 | ||
diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c index c33821d2afb3..f707709969ac 100644 --- a/drivers/net/ethernet/intel/igb/igb_main.c +++ b/drivers/net/ethernet/intel/igb/igb_main.c | |||
| @@ -3763,8 +3763,9 @@ static int igb_sw_init(struct igb_adapter *adapter) | |||
| 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ | 3763 | /* Assume MSI-X interrupts, will be checked during IRQ allocation */ |
| 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; | 3764 | adapter->flags |= IGB_FLAG_HAS_MSIX; |
| 3765 | 3765 | ||
| 3766 | adapter->mac_table = kzalloc(sizeof(struct igb_mac_addr) * | 3766 | adapter->mac_table = kcalloc(hw->mac.rar_entry_count, |
| 3767 | hw->mac.rar_entry_count, GFP_ATOMIC); | 3767 | sizeof(struct igb_mac_addr), |
| 3768 | GFP_ATOMIC); | ||
| 3768 | if (!adapter->mac_table) | 3769 | if (!adapter->mac_table) |
| 3769 | return -ENOMEM; | 3770 | return -ENOMEM; |
| 3770 | 3771 | ||
| @@ -4752,7 +4753,7 @@ static int igb_write_mc_addr_list(struct net_device *netdev) | |||
| 4752 | return 0; | 4753 | return 0; |
| 4753 | } | 4754 | } |
| 4754 | 4755 | ||
| 4755 | mta_list = kzalloc(netdev_mc_count(netdev) * 6, GFP_ATOMIC); | 4756 | mta_list = kcalloc(netdev_mc_count(netdev), 6, GFP_ATOMIC); |
| 4756 | if (!mta_list) | 4757 | if (!mta_list) |
| 4757 | return -ENOMEM; | 4758 | return -ENOMEM; |
| 4758 | 4759 | ||
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c index 43744bf0fc1c..c8c93ac436d4 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_ethtool.c | |||
| @@ -375,8 +375,9 @@ ixgb_get_eeprom(struct net_device *netdev, | |||
| 375 | first_word = eeprom->offset >> 1; | 375 | first_word = eeprom->offset >> 1; |
| 376 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 376 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 377 | 377 | ||
| 378 | eeprom_buff = kmalloc(sizeof(__le16) * | 378 | eeprom_buff = kmalloc_array(last_word - first_word + 1, |
| 379 | (last_word - first_word + 1), GFP_KERNEL); | 379 | sizeof(__le16), |
| 380 | GFP_KERNEL); | ||
| 380 | if (!eeprom_buff) | 381 | if (!eeprom_buff) |
| 381 | return -ENOMEM; | 382 | return -ENOMEM; |
| 382 | 383 | ||
diff --git a/drivers/net/ethernet/intel/ixgb/ixgb_main.c b/drivers/net/ethernet/intel/ixgb/ixgb_main.c index 62f2173bc20e..43664adf7a3c 100644 --- a/drivers/net/ethernet/intel/ixgb/ixgb_main.c +++ b/drivers/net/ethernet/intel/ixgb/ixgb_main.c | |||
| @@ -1093,8 +1093,9 @@ ixgb_set_multi(struct net_device *netdev) | |||
| 1093 | rctl |= IXGB_RCTL_MPE; | 1093 | rctl |= IXGB_RCTL_MPE; |
| 1094 | IXGB_WRITE_REG(hw, RCTL, rctl); | 1094 | IXGB_WRITE_REG(hw, RCTL, rctl); |
| 1095 | } else { | 1095 | } else { |
| 1096 | u8 *mta = kmalloc(IXGB_MAX_NUM_MULTICAST_ADDRESSES * | 1096 | u8 *mta = kmalloc_array(ETH_ALEN, |
| 1097 | ETH_ALEN, GFP_ATOMIC); | 1097 | IXGB_MAX_NUM_MULTICAST_ADDRESSES, |
| 1098 | GFP_ATOMIC); | ||
| 1098 | u8 *addr; | 1099 | u8 *addr; |
| 1099 | if (!mta) | 1100 | if (!mta) |
| 1100 | goto alloc_failed; | 1101 | goto alloc_failed; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c index bdd179c29ea4..bd1ba88ec1d5 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_ethtool.c | |||
| @@ -901,7 +901,7 @@ static int ixgbe_get_eeprom(struct net_device *netdev, | |||
| 901 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 901 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 902 | eeprom_len = last_word - first_word + 1; | 902 | eeprom_len = last_word - first_word + 1; |
| 903 | 903 | ||
| 904 | eeprom_buff = kmalloc(sizeof(u16) * eeprom_len, GFP_KERNEL); | 904 | eeprom_buff = kmalloc_array(eeprom_len, sizeof(u16), GFP_KERNEL); |
| 905 | if (!eeprom_buff) | 905 | if (!eeprom_buff) |
| 906 | return -ENOMEM; | 906 | return -ENOMEM; |
| 907 | 907 | ||
| @@ -1063,7 +1063,7 @@ static int ixgbe_set_ringparam(struct net_device *netdev, | |||
| 1063 | /* allocate temporary buffer to store rings in */ | 1063 | /* allocate temporary buffer to store rings in */ |
| 1064 | i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues, | 1064 | i = max_t(int, adapter->num_tx_queues + adapter->num_xdp_queues, |
| 1065 | adapter->num_rx_queues); | 1065 | adapter->num_rx_queues); |
| 1066 | temp_ring = vmalloc(i * sizeof(struct ixgbe_ring)); | 1066 | temp_ring = vmalloc(array_size(i, sizeof(struct ixgbe_ring))); |
| 1067 | 1067 | ||
| 1068 | if (!temp_ring) { | 1068 | if (!temp_ring) { |
| 1069 | err = -ENOMEM; | 1069 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c index 4929f7265598..0b1ba3ae159c 100644 --- a/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c +++ b/drivers/net/ethernet/intel/ixgbe/ixgbe_main.c | |||
| @@ -6034,8 +6034,8 @@ static int ixgbe_sw_init(struct ixgbe_adapter *adapter, | |||
| 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) | 6034 | for (i = 1; i < IXGBE_MAX_LINK_HANDLE; i++) |
| 6035 | adapter->jump_tables[i] = NULL; | 6035 | adapter->jump_tables[i] = NULL; |
| 6036 | 6036 | ||
| 6037 | adapter->mac_table = kzalloc(sizeof(struct ixgbe_mac_addr) * | 6037 | adapter->mac_table = kcalloc(hw->mac.num_rar_entries, |
| 6038 | hw->mac.num_rar_entries, | 6038 | sizeof(struct ixgbe_mac_addr), |
| 6039 | GFP_ATOMIC); | 6039 | GFP_ATOMIC); |
| 6040 | if (!adapter->mac_table) | 6040 | if (!adapter->mac_table) |
| 6041 | return -ENOMEM; | 6041 | return -ENOMEM; |
diff --git a/drivers/net/ethernet/intel/ixgbevf/ethtool.c b/drivers/net/ethernet/intel/ixgbevf/ethtool.c index e7813d76527c..631c91046f39 100644 --- a/drivers/net/ethernet/intel/ixgbevf/ethtool.c +++ b/drivers/net/ethernet/intel/ixgbevf/ethtool.c | |||
| @@ -282,8 +282,9 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, | |||
| 282 | } | 282 | } |
| 283 | 283 | ||
| 284 | if (new_tx_count != adapter->tx_ring_count) { | 284 | if (new_tx_count != adapter->tx_ring_count) { |
| 285 | tx_ring = vmalloc((adapter->num_tx_queues + | 285 | tx_ring = vmalloc(array_size(sizeof(*tx_ring), |
| 286 | adapter->num_xdp_queues) * sizeof(*tx_ring)); | 286 | adapter->num_tx_queues + |
| 287 | adapter->num_xdp_queues)); | ||
| 287 | if (!tx_ring) { | 288 | if (!tx_ring) { |
| 288 | err = -ENOMEM; | 289 | err = -ENOMEM; |
| 289 | goto clear_reset; | 290 | goto clear_reset; |
| @@ -327,7 +328,8 @@ static int ixgbevf_set_ringparam(struct net_device *netdev, | |||
| 327 | } | 328 | } |
| 328 | 329 | ||
| 329 | if (new_rx_count != adapter->rx_ring_count) { | 330 | if (new_rx_count != adapter->rx_ring_count) { |
| 330 | rx_ring = vmalloc(adapter->num_rx_queues * sizeof(*rx_ring)); | 331 | rx_ring = vmalloc(array_size(sizeof(*rx_ring), |
| 332 | adapter->num_rx_queues)); | ||
| 331 | if (!rx_ring) { | 333 | if (!rx_ring) { |
| 332 | err = -ENOMEM; | 334 | err = -ENOMEM; |
| 333 | goto clear_reset; | 335 | goto clear_reset; |
diff --git a/drivers/net/ethernet/jme.c b/drivers/net/ethernet/jme.c index 8a165842fa85..06ff185eb188 100644 --- a/drivers/net/ethernet/jme.c +++ b/drivers/net/ethernet/jme.c | |||
| @@ -589,8 +589,9 @@ jme_setup_tx_resources(struct jme_adapter *jme) | |||
| 589 | atomic_set(&txring->next_to_clean, 0); | 589 | atomic_set(&txring->next_to_clean, 0); |
| 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); | 590 | atomic_set(&txring->nr_free, jme->tx_ring_size); |
| 591 | 591 | ||
| 592 | txring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 592 | txring->bufinf = kcalloc(jme->tx_ring_size, |
| 593 | jme->tx_ring_size, GFP_ATOMIC); | 593 | sizeof(struct jme_buffer_info), |
| 594 | GFP_ATOMIC); | ||
| 594 | if (unlikely(!(txring->bufinf))) | 595 | if (unlikely(!(txring->bufinf))) |
| 595 | goto err_free_txring; | 596 | goto err_free_txring; |
| 596 | 597 | ||
| @@ -838,8 +839,9 @@ jme_setup_rx_resources(struct jme_adapter *jme) | |||
| 838 | rxring->next_to_use = 0; | 839 | rxring->next_to_use = 0; |
| 839 | atomic_set(&rxring->next_to_clean, 0); | 840 | atomic_set(&rxring->next_to_clean, 0); |
| 840 | 841 | ||
| 841 | rxring->bufinf = kzalloc(sizeof(struct jme_buffer_info) * | 842 | rxring->bufinf = kcalloc(jme->rx_ring_size, |
| 842 | jme->rx_ring_size, GFP_ATOMIC); | 843 | sizeof(struct jme_buffer_info), |
| 844 | GFP_ATOMIC); | ||
| 843 | if (unlikely(!(rxring->bufinf))) | 845 | if (unlikely(!(rxring->bufinf))) |
| 844 | goto err_free_rxring; | 846 | goto err_free_rxring; |
| 845 | 847 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/alloc.c b/drivers/net/ethernet/mellanox/mlx4/alloc.c index 6dabd983e7e0..4bdf25059542 100644 --- a/drivers/net/ethernet/mellanox/mlx4/alloc.c +++ b/drivers/net/ethernet/mellanox/mlx4/alloc.c | |||
| @@ -185,8 +185,8 @@ int mlx4_bitmap_init(struct mlx4_bitmap *bitmap, u32 num, u32 mask, | |||
| 185 | bitmap->avail = num - reserved_top - reserved_bot; | 185 | bitmap->avail = num - reserved_top - reserved_bot; |
| 186 | bitmap->effective_len = bitmap->avail; | 186 | bitmap->effective_len = bitmap->avail; |
| 187 | spin_lock_init(&bitmap->lock); | 187 | spin_lock_init(&bitmap->lock); |
| 188 | bitmap->table = kzalloc(BITS_TO_LONGS(bitmap->max) * | 188 | bitmap->table = kcalloc(BITS_TO_LONGS(bitmap->max), sizeof(long), |
| 189 | sizeof(long), GFP_KERNEL); | 189 | GFP_KERNEL); |
| 190 | if (!bitmap->table) | 190 | if (!bitmap->table) |
| 191 | return -ENOMEM; | 191 | return -ENOMEM; |
| 192 | 192 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c index 6a9086dc1e92..e65bc3c95630 100644 --- a/drivers/net/ethernet/mellanox/mlx4/cmd.c +++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c | |||
| @@ -2377,20 +2377,23 @@ int mlx4_multi_func_init(struct mlx4_dev *dev) | |||
| 2377 | struct mlx4_vf_admin_state *vf_admin; | 2377 | struct mlx4_vf_admin_state *vf_admin; |
| 2378 | 2378 | ||
| 2379 | priv->mfunc.master.slave_state = | 2379 | priv->mfunc.master.slave_state = |
| 2380 | kzalloc(dev->num_slaves * | 2380 | kcalloc(dev->num_slaves, |
| 2381 | sizeof(struct mlx4_slave_state), GFP_KERNEL); | 2381 | sizeof(struct mlx4_slave_state), |
| 2382 | GFP_KERNEL); | ||
| 2382 | if (!priv->mfunc.master.slave_state) | 2383 | if (!priv->mfunc.master.slave_state) |
| 2383 | goto err_comm; | 2384 | goto err_comm; |
| 2384 | 2385 | ||
| 2385 | priv->mfunc.master.vf_admin = | 2386 | priv->mfunc.master.vf_admin = |
| 2386 | kzalloc(dev->num_slaves * | 2387 | kcalloc(dev->num_slaves, |
| 2387 | sizeof(struct mlx4_vf_admin_state), GFP_KERNEL); | 2388 | sizeof(struct mlx4_vf_admin_state), |
| 2389 | GFP_KERNEL); | ||
| 2388 | if (!priv->mfunc.master.vf_admin) | 2390 | if (!priv->mfunc.master.vf_admin) |
| 2389 | goto err_comm_admin; | 2391 | goto err_comm_admin; |
| 2390 | 2392 | ||
| 2391 | priv->mfunc.master.vf_oper = | 2393 | priv->mfunc.master.vf_oper = |
| 2392 | kzalloc(dev->num_slaves * | 2394 | kcalloc(dev->num_slaves, |
| 2393 | sizeof(struct mlx4_vf_oper_state), GFP_KERNEL); | 2395 | sizeof(struct mlx4_vf_oper_state), |
| 2396 | GFP_KERNEL); | ||
| 2394 | if (!priv->mfunc.master.vf_oper) | 2397 | if (!priv->mfunc.master.vf_oper) |
| 2395 | goto err_comm_oper; | 2398 | goto err_comm_oper; |
| 2396 | 2399 | ||
| @@ -2636,9 +2639,9 @@ int mlx4_cmd_use_events(struct mlx4_dev *dev) | |||
| 2636 | int i; | 2639 | int i; |
| 2637 | int err = 0; | 2640 | int err = 0; |
| 2638 | 2641 | ||
| 2639 | priv->cmd.context = kmalloc(priv->cmd.max_cmds * | 2642 | priv->cmd.context = kmalloc_array(priv->cmd.max_cmds, |
| 2640 | sizeof(struct mlx4_cmd_context), | 2643 | sizeof(struct mlx4_cmd_context), |
| 2641 | GFP_KERNEL); | 2644 | GFP_KERNEL); |
| 2642 | if (!priv->cmd.context) | 2645 | if (!priv->cmd.context) |
| 2643 | return -ENOMEM; | 2646 | return -ENOMEM; |
| 2644 | 2647 | ||
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c index 9670b33fc9b1..65eb06e017e4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c | |||
| @@ -2229,13 +2229,15 @@ static int mlx4_en_copy_priv(struct mlx4_en_priv *dst, | |||
| 2229 | if (!dst->tx_ring_num[t]) | 2229 | if (!dst->tx_ring_num[t]) |
| 2230 | continue; | 2230 | continue; |
| 2231 | 2231 | ||
| 2232 | dst->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 2232 | dst->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 2233 | MAX_TX_RINGS, GFP_KERNEL); | 2233 | sizeof(struct mlx4_en_tx_ring *), |
| 2234 | GFP_KERNEL); | ||
| 2234 | if (!dst->tx_ring[t]) | 2235 | if (!dst->tx_ring[t]) |
| 2235 | goto err_free_tx; | 2236 | goto err_free_tx; |
| 2236 | 2237 | ||
| 2237 | dst->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 2238 | dst->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 2238 | MAX_TX_RINGS, GFP_KERNEL); | 2239 | sizeof(struct mlx4_en_cq *), |
| 2240 | GFP_KERNEL); | ||
| 2239 | if (!dst->tx_cq[t]) { | 2241 | if (!dst->tx_cq[t]) { |
| 2240 | kfree(dst->tx_ring[t]); | 2242 | kfree(dst->tx_ring[t]); |
| 2241 | goto err_free_tx; | 2243 | goto err_free_tx; |
| @@ -3320,14 +3322,16 @@ int mlx4_en_init_netdev(struct mlx4_en_dev *mdev, int port, | |||
| 3320 | if (!priv->tx_ring_num[t]) | 3322 | if (!priv->tx_ring_num[t]) |
| 3321 | continue; | 3323 | continue; |
| 3322 | 3324 | ||
| 3323 | priv->tx_ring[t] = kzalloc(sizeof(struct mlx4_en_tx_ring *) * | 3325 | priv->tx_ring[t] = kcalloc(MAX_TX_RINGS, |
| 3324 | MAX_TX_RINGS, GFP_KERNEL); | 3326 | sizeof(struct mlx4_en_tx_ring *), |
| 3327 | GFP_KERNEL); | ||
| 3325 | if (!priv->tx_ring[t]) { | 3328 | if (!priv->tx_ring[t]) { |
| 3326 | err = -ENOMEM; | 3329 | err = -ENOMEM; |
| 3327 | goto out; | 3330 | goto out; |
| 3328 | } | 3331 | } |
| 3329 | priv->tx_cq[t] = kzalloc(sizeof(struct mlx4_en_cq *) * | 3332 | priv->tx_cq[t] = kcalloc(MAX_TX_RINGS, |
| 3330 | MAX_TX_RINGS, GFP_KERNEL); | 3333 | sizeof(struct mlx4_en_cq *), |
| 3334 | GFP_KERNEL); | ||
| 3331 | if (!priv->tx_cq[t]) { | 3335 | if (!priv->tx_cq[t]) { |
| 3332 | err = -ENOMEM; | 3336 | err = -ENOMEM; |
| 3333 | goto out; | 3337 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/eq.c b/drivers/net/ethernet/mellanox/mlx4/eq.c index 6f57c052053e..1f3372c1802e 100644 --- a/drivers/net/ethernet/mellanox/mlx4/eq.c +++ b/drivers/net/ethernet/mellanox/mlx4/eq.c | |||
| @@ -1211,8 +1211,9 @@ int mlx4_init_eq_table(struct mlx4_dev *dev) | |||
| 1211 | } | 1211 | } |
| 1212 | 1212 | ||
| 1213 | priv->eq_table.irq_names = | 1213 | priv->eq_table.irq_names = |
| 1214 | kmalloc(MLX4_IRQNAME_SIZE * (dev->caps.num_comp_vectors + 1), | 1214 | kmalloc_array(MLX4_IRQNAME_SIZE, |
| 1215 | GFP_KERNEL); | 1215 | (dev->caps.num_comp_vectors + 1), |
| 1216 | GFP_KERNEL); | ||
| 1216 | if (!priv->eq_table.irq_names) { | 1217 | if (!priv->eq_table.irq_names) { |
| 1217 | err = -ENOMEM; | 1218 | err = -ENOMEM; |
| 1218 | goto err_out_clr_int; | 1219 | goto err_out_clr_int; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/icm.c b/drivers/net/ethernet/mellanox/mlx4/icm.c index 5342bd8a3d0b..7262c6310650 100644 --- a/drivers/net/ethernet/mellanox/mlx4/icm.c +++ b/drivers/net/ethernet/mellanox/mlx4/icm.c | |||
| @@ -408,7 +408,7 @@ int mlx4_init_icm_table(struct mlx4_dev *dev, struct mlx4_icm_table *table, | |||
| 408 | return -EINVAL; | 408 | return -EINVAL; |
| 409 | num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; | 409 | num_icm = (nobj + obj_per_chunk - 1) / obj_per_chunk; |
| 410 | 410 | ||
| 411 | table->icm = kvzalloc(num_icm * sizeof(*table->icm), GFP_KERNEL); | 411 | table->icm = kvcalloc(num_icm, sizeof(*table->icm), GFP_KERNEL); |
| 412 | if (!table->icm) | 412 | if (!table->icm) |
| 413 | return -ENOMEM; | 413 | return -ENOMEM; |
| 414 | table->virt = virt; | 414 | table->virt = virt; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c index 0a30d81aab3b..872014702fc1 100644 --- a/drivers/net/ethernet/mellanox/mlx4/main.c +++ b/drivers/net/ethernet/mellanox/mlx4/main.c | |||
| @@ -2982,7 +2982,8 @@ static int mlx4_init_steering(struct mlx4_dev *dev) | |||
| 2982 | int num_entries = dev->caps.num_ports; | 2982 | int num_entries = dev->caps.num_ports; |
| 2983 | int i, j; | 2983 | int i, j; |
| 2984 | 2984 | ||
| 2985 | priv->steer = kzalloc(sizeof(struct mlx4_steer) * num_entries, GFP_KERNEL); | 2985 | priv->steer = kcalloc(num_entries, sizeof(struct mlx4_steer), |
| 2986 | GFP_KERNEL); | ||
| 2986 | if (!priv->steer) | 2987 | if (!priv->steer) |
| 2987 | return -ENOMEM; | 2988 | return -ENOMEM; |
| 2988 | 2989 | ||
| @@ -3103,7 +3104,7 @@ static u64 mlx4_enable_sriov(struct mlx4_dev *dev, struct pci_dev *pdev, | |||
| 3103 | } | 3104 | } |
| 3104 | } | 3105 | } |
| 3105 | 3106 | ||
| 3106 | dev->dev_vfs = kzalloc(total_vfs * sizeof(*dev->dev_vfs), GFP_KERNEL); | 3107 | dev->dev_vfs = kcalloc(total_vfs, sizeof(*dev->dev_vfs), GFP_KERNEL); |
| 3107 | if (NULL == dev->dev_vfs) { | 3108 | if (NULL == dev->dev_vfs) { |
| 3108 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); | 3109 | mlx4_err(dev, "Failed to allocate memory for VFs\n"); |
| 3109 | goto disable_sriov; | 3110 | goto disable_sriov; |
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c index 29e50f787349..7b1b5ac986d0 100644 --- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c +++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | |||
| @@ -487,7 +487,7 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); | 487 | int max_vfs_guarantee_counter = get_max_gauranteed_vfs_counter(dev); |
| 488 | 488 | ||
| 489 | priv->mfunc.master.res_tracker.slave_list = | 489 | priv->mfunc.master.res_tracker.slave_list = |
| 490 | kzalloc(dev->num_slaves * sizeof(struct slave_list), | 490 | kcalloc(dev->num_slaves, sizeof(struct slave_list), |
| 491 | GFP_KERNEL); | 491 | GFP_KERNEL); |
| 492 | if (!priv->mfunc.master.res_tracker.slave_list) | 492 | if (!priv->mfunc.master.res_tracker.slave_list) |
| 493 | return -ENOMEM; | 493 | return -ENOMEM; |
| @@ -507,19 +507,21 @@ int mlx4_init_resource_tracker(struct mlx4_dev *dev) | |||
| 507 | for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) { | 507 | for (i = 0; i < MLX4_NUM_OF_RESOURCE_TYPE; i++) { |
| 508 | struct resource_allocator *res_alloc = | 508 | struct resource_allocator *res_alloc = |
| 509 | &priv->mfunc.master.res_tracker.res_alloc[i]; | 509 | &priv->mfunc.master.res_tracker.res_alloc[i]; |
| 510 | res_alloc->quota = kmalloc((dev->persist->num_vfs + 1) * | 510 | res_alloc->quota = kmalloc_array(dev->persist->num_vfs + 1, |
| 511 | sizeof(int), GFP_KERNEL); | 511 | sizeof(int), |
| 512 | res_alloc->guaranteed = kmalloc((dev->persist->num_vfs + 1) * | 512 | GFP_KERNEL); |
| 513 | sizeof(int), GFP_KERNEL); | 513 | res_alloc->guaranteed = kmalloc_array(dev->persist->num_vfs + 1, |
| 514 | sizeof(int), | ||
| 515 | GFP_KERNEL); | ||
| 514 | if (i == RES_MAC || i == RES_VLAN) | 516 | if (i == RES_MAC || i == RES_VLAN) |
| 515 | res_alloc->allocated = kzalloc(MLX4_MAX_PORTS * | 517 | res_alloc->allocated = |
| 516 | (dev->persist->num_vfs | 518 | kcalloc(MLX4_MAX_PORTS * |
| 517 | + 1) * | 519 | (dev->persist->num_vfs + 1), |
| 518 | sizeof(int), GFP_KERNEL); | 520 | sizeof(int), GFP_KERNEL); |
| 519 | else | 521 | else |
| 520 | res_alloc->allocated = kzalloc((dev->persist-> | 522 | res_alloc->allocated = |
| 521 | num_vfs + 1) * | 523 | kcalloc(dev->persist->num_vfs + 1, |
| 522 | sizeof(int), GFP_KERNEL); | 524 | sizeof(int), GFP_KERNEL); |
| 523 | /* Reduce the sink counter */ | 525 | /* Reduce the sink counter */ |
| 524 | if (i == RES_COUNTER) | 526 | if (i == RES_COUNTER) |
| 525 | res_alloc->res_free = dev->caps.max_counters - 1; | 527 | res_alloc->res_free = dev->caps.max_counters - 1; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c index 89c96a0f708e..56c1b6f5593e 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c | |||
| @@ -352,7 +352,7 @@ static int mlx5e_rq_alloc_mpwqe_info(struct mlx5e_rq *rq, | |||
| 352 | { | 352 | { |
| 353 | int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); | 353 | int wq_sz = mlx5_wq_ll_get_size(&rq->mpwqe.wq); |
| 354 | 354 | ||
| 355 | rq->mpwqe.info = kzalloc_node(wq_sz * sizeof(*rq->mpwqe.info), | 355 | rq->mpwqe.info = kcalloc_node(wq_sz, sizeof(*rq->mpwqe.info), |
| 356 | GFP_KERNEL, cpu_to_node(c->cpu)); | 356 | GFP_KERNEL, cpu_to_node(c->cpu)); |
| 357 | if (!rq->mpwqe.info) | 357 | if (!rq->mpwqe.info) |
| 358 | return -ENOMEM; | 358 | return -ENOMEM; |
| @@ -448,7 +448,7 @@ static int mlx5e_init_di_list(struct mlx5e_rq *rq, | |||
| 448 | { | 448 | { |
| 449 | int len = wq_sz << rq->wqe.info.log_num_frags; | 449 | int len = wq_sz << rq->wqe.info.log_num_frags; |
| 450 | 450 | ||
| 451 | rq->wqe.di = kvzalloc_node(len * sizeof(*rq->wqe.di), | 451 | rq->wqe.di = kvzalloc_node(array_size(len, sizeof(*rq->wqe.di)), |
| 452 | GFP_KERNEL, cpu_to_node(cpu)); | 452 | GFP_KERNEL, cpu_to_node(cpu)); |
| 453 | if (!rq->wqe.di) | 453 | if (!rq->wqe.di) |
| 454 | return -ENOMEM; | 454 | return -ENOMEM; |
| @@ -563,8 +563,8 @@ static int mlx5e_alloc_rq(struct mlx5e_channel *c, | |||
| 563 | 563 | ||
| 564 | rq->wqe.info = rqp->frags_info; | 564 | rq->wqe.info = rqp->frags_info; |
| 565 | rq->wqe.frags = | 565 | rq->wqe.frags = |
| 566 | kvzalloc_node((wq_sz << rq->wqe.info.log_num_frags) * | 566 | kvzalloc_node(array_size(sizeof(*rq->wqe.frags), |
| 567 | sizeof(*rq->wqe.frags), | 567 | (wq_sz << rq->wqe.info.log_num_frags)), |
| 568 | GFP_KERNEL, cpu_to_node(c->cpu)); | 568 | GFP_KERNEL, cpu_to_node(c->cpu)); |
| 569 | if (!rq->wqe.frags) { | 569 | if (!rq->wqe.frags) { |
| 570 | err = -ENOMEM; | 570 | err = -ENOMEM; |
| @@ -972,7 +972,7 @@ static int mlx5e_alloc_xdpsq_db(struct mlx5e_xdpsq *sq, int numa) | |||
| 972 | { | 972 | { |
| 973 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 973 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 974 | 974 | ||
| 975 | sq->db.di = kzalloc_node(sizeof(*sq->db.di) * wq_sz, | 975 | sq->db.di = kcalloc_node(wq_sz, sizeof(*sq->db.di), |
| 976 | GFP_KERNEL, numa); | 976 | GFP_KERNEL, numa); |
| 977 | if (!sq->db.di) { | 977 | if (!sq->db.di) { |
| 978 | mlx5e_free_xdpsq_db(sq); | 978 | mlx5e_free_xdpsq_db(sq); |
| @@ -1031,7 +1031,7 @@ static int mlx5e_alloc_icosq_db(struct mlx5e_icosq *sq, int numa) | |||
| 1031 | { | 1031 | { |
| 1032 | u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 1032 | u8 wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 1033 | 1033 | ||
| 1034 | sq->db.ico_wqe = kzalloc_node(sizeof(*sq->db.ico_wqe) * wq_sz, | 1034 | sq->db.ico_wqe = kcalloc_node(wq_sz, sizeof(*sq->db.ico_wqe), |
| 1035 | GFP_KERNEL, numa); | 1035 | GFP_KERNEL, numa); |
| 1036 | if (!sq->db.ico_wqe) | 1036 | if (!sq->db.ico_wqe) |
| 1037 | return -ENOMEM; | 1037 | return -ENOMEM; |
| @@ -1086,9 +1086,9 @@ static int mlx5e_alloc_txqsq_db(struct mlx5e_txqsq *sq, int numa) | |||
| 1086 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); | 1086 | int wq_sz = mlx5_wq_cyc_get_size(&sq->wq); |
| 1087 | int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; | 1087 | int df_sz = wq_sz * MLX5_SEND_WQEBB_NUM_DS; |
| 1088 | 1088 | ||
| 1089 | sq->db.dma_fifo = kzalloc_node(df_sz * sizeof(*sq->db.dma_fifo), | 1089 | sq->db.dma_fifo = kcalloc_node(df_sz, sizeof(*sq->db.dma_fifo), |
| 1090 | GFP_KERNEL, numa); | 1090 | GFP_KERNEL, numa); |
| 1091 | sq->db.wqe_info = kzalloc_node(wq_sz * sizeof(*sq->db.wqe_info), | 1091 | sq->db.wqe_info = kcalloc_node(wq_sz, sizeof(*sq->db.wqe_info), |
| 1092 | GFP_KERNEL, numa); | 1092 | GFP_KERNEL, numa); |
| 1093 | if (!sq->db.dma_fifo || !sq->db.wqe_info) { | 1093 | if (!sq->db.dma_fifo || !sq->db.wqe_info) { |
| 1094 | mlx5e_free_txqsq_db(sq); | 1094 | mlx5e_free_txqsq_db(sq); |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c index 4138a770ed57..8ca1d1949d93 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/conn.c | |||
| @@ -549,15 +549,17 @@ static int mlx5_fpga_conn_create_qp(struct mlx5_fpga_conn *conn, | |||
| 549 | if (err) | 549 | if (err) |
| 550 | goto out; | 550 | goto out; |
| 551 | 551 | ||
| 552 | conn->qp.rq.bufs = kvzalloc(sizeof(conn->qp.rq.bufs[0]) * | 552 | conn->qp.rq.bufs = kvcalloc(conn->qp.rq.size, |
| 553 | conn->qp.rq.size, GFP_KERNEL); | 553 | sizeof(conn->qp.rq.bufs[0]), |
| 554 | GFP_KERNEL); | ||
| 554 | if (!conn->qp.rq.bufs) { | 555 | if (!conn->qp.rq.bufs) { |
| 555 | err = -ENOMEM; | 556 | err = -ENOMEM; |
| 556 | goto err_wq; | 557 | goto err_wq; |
| 557 | } | 558 | } |
| 558 | 559 | ||
| 559 | conn->qp.sq.bufs = kvzalloc(sizeof(conn->qp.sq.bufs[0]) * | 560 | conn->qp.sq.bufs = kvcalloc(conn->qp.sq.size, |
| 560 | conn->qp.sq.size, GFP_KERNEL); | 561 | sizeof(conn->qp.sq.bufs[0]), |
| 562 | GFP_KERNEL); | ||
| 561 | if (!conn->qp.sq.bufs) { | 563 | if (!conn->qp.sq.bufs) { |
| 562 | err = -ENOMEM; | 564 | err = -ENOMEM; |
| 563 | goto err_rq_bufs; | 565 | goto err_rq_bufs; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c index a0433b48e833..5645a4facad2 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/fpga/ipsec.c | |||
| @@ -381,7 +381,7 @@ int mlx5_fpga_ipsec_counters_read(struct mlx5_core_dev *mdev, u64 *counters, | |||
| 381 | 381 | ||
| 382 | count = mlx5_fpga_ipsec_counters_count(mdev); | 382 | count = mlx5_fpga_ipsec_counters_count(mdev); |
| 383 | 383 | ||
| 384 | data = kzalloc(sizeof(*data) * count * 2, GFP_KERNEL); | 384 | data = kzalloc(array3_size(sizeof(*data), count, 2), GFP_KERNEL); |
| 385 | if (!data) { | 385 | if (!data) { |
| 386 | ret = -ENOMEM; | 386 | ret = -ENOMEM; |
| 387 | goto out; | 387 | goto out; |
diff --git a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c index 857035583ccd..1e062e6b2587 100644 --- a/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c +++ b/drivers/net/ethernet/mellanox/mlx5/core/lib/clock.c | |||
| @@ -394,8 +394,9 @@ static int mlx5_init_pin_config(struct mlx5_clock *clock) | |||
| 394 | int i; | 394 | int i; |
| 395 | 395 | ||
| 396 | clock->ptp_info.pin_config = | 396 | clock->ptp_info.pin_config = |
| 397 | kzalloc(sizeof(*clock->ptp_info.pin_config) * | 397 | kcalloc(clock->ptp_info.n_pins, |
| 398 | clock->ptp_info.n_pins, GFP_KERNEL); | 398 | sizeof(*clock->ptp_info.pin_config), |
| 399 | GFP_KERNEL); | ||
| 399 | if (!clock->ptp_info.pin_config) | 400 | if (!clock->ptp_info.pin_config) |
| 400 | return -ENOMEM; | 401 | return -ENOMEM; |
| 401 | clock->ptp_info.enable = mlx5_ptp_enable; | 402 | clock->ptp_info.enable = mlx5_ptp_enable; |
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c index 91262b0573e3..cad603c35271 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c +++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_qdisc.c | |||
| @@ -740,7 +740,8 @@ int mlxsw_sp_tc_qdisc_init(struct mlxsw_sp_port *mlxsw_sp_port) | |||
| 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; | 740 | mlxsw_sp_port->root_qdisc->prio_bitmap = 0xff; |
| 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; | 741 | mlxsw_sp_port->root_qdisc->tclass_num = MLXSW_SP_PORT_DEFAULT_TCLASS; |
| 742 | 742 | ||
| 743 | mlxsw_sp_qdisc = kzalloc(sizeof(*mlxsw_sp_qdisc) * IEEE_8021QAZ_MAX_TCS, | 743 | mlxsw_sp_qdisc = kcalloc(IEEE_8021QAZ_MAX_TCS, |
| 744 | sizeof(*mlxsw_sp_qdisc), | ||
| 744 | GFP_KERNEL); | 745 | GFP_KERNEL); |
| 745 | if (!mlxsw_sp_qdisc) | 746 | if (!mlxsw_sp_qdisc) |
| 746 | goto err_tclass_qdiscs_init; | 747 | goto err_tclass_qdiscs_init; |
diff --git a/drivers/net/ethernet/micrel/ksz884x.c b/drivers/net/ethernet/micrel/ksz884x.c index 52207508744c..b72d1bd11296 100644 --- a/drivers/net/ethernet/micrel/ksz884x.c +++ b/drivers/net/ethernet/micrel/ksz884x.c | |||
| @@ -4372,7 +4372,7 @@ static void ksz_update_timer(struct ksz_timer_info *info) | |||
| 4372 | */ | 4372 | */ |
| 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) | 4373 | static int ksz_alloc_soft_desc(struct ksz_desc_info *desc_info, int transmit) |
| 4374 | { | 4374 | { |
| 4375 | desc_info->ring = kzalloc(sizeof(struct ksz_desc) * desc_info->alloc, | 4375 | desc_info->ring = kcalloc(desc_info->alloc, sizeof(struct ksz_desc), |
| 4376 | GFP_KERNEL); | 4376 | GFP_KERNEL); |
| 4377 | if (!desc_info->ring) | 4377 | if (!desc_info->ring) |
| 4378 | return 1; | 4378 | return 1; |
diff --git a/drivers/net/ethernet/moxa/moxart_ether.c b/drivers/net/ethernet/moxa/moxart_ether.c index 2e4effa9fe45..b34055ac476f 100644 --- a/drivers/net/ethernet/moxa/moxart_ether.c +++ b/drivers/net/ethernet/moxa/moxart_ether.c | |||
| @@ -507,15 +507,15 @@ static int moxart_mac_probe(struct platform_device *pdev) | |||
| 507 | goto init_fail; | 507 | goto init_fail; |
| 508 | } | 508 | } |
| 509 | 509 | ||
| 510 | priv->tx_buf_base = kmalloc(priv->tx_buf_size * TX_DESC_NUM, | 510 | priv->tx_buf_base = kmalloc_array(priv->tx_buf_size, TX_DESC_NUM, |
| 511 | GFP_ATOMIC); | 511 | GFP_ATOMIC); |
| 512 | if (!priv->tx_buf_base) { | 512 | if (!priv->tx_buf_base) { |
| 513 | ret = -ENOMEM; | 513 | ret = -ENOMEM; |
| 514 | goto init_fail; | 514 | goto init_fail; |
| 515 | } | 515 | } |
| 516 | 516 | ||
| 517 | priv->rx_buf_base = kmalloc(priv->rx_buf_size * RX_DESC_NUM, | 517 | priv->rx_buf_base = kmalloc_array(priv->rx_buf_size, RX_DESC_NUM, |
| 518 | GFP_ATOMIC); | 518 | GFP_ATOMIC); |
| 519 | if (!priv->rx_buf_base) { | 519 | if (!priv->rx_buf_base) { |
| 520 | ret = -ENOMEM; | 520 | ret = -ENOMEM; |
| 521 | goto init_fail; | 521 | goto init_fail; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-config.c b/drivers/net/ethernet/neterion/vxge/vxge-config.c index c60da9e8bf14..358ed6118881 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-config.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-config.c | |||
| @@ -2220,22 +2220,22 @@ __vxge_hw_channel_allocate(struct __vxge_hw_vpath_handle *vph, | |||
| 2220 | channel->length = length; | 2220 | channel->length = length; |
| 2221 | channel->vp_id = vp_id; | 2221 | channel->vp_id = vp_id; |
| 2222 | 2222 | ||
| 2223 | channel->work_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2223 | channel->work_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2224 | if (channel->work_arr == NULL) | 2224 | if (channel->work_arr == NULL) |
| 2225 | goto exit1; | 2225 | goto exit1; |
| 2226 | 2226 | ||
| 2227 | channel->free_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2227 | channel->free_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2228 | if (channel->free_arr == NULL) | 2228 | if (channel->free_arr == NULL) |
| 2229 | goto exit1; | 2229 | goto exit1; |
| 2230 | channel->free_ptr = length; | 2230 | channel->free_ptr = length; |
| 2231 | 2231 | ||
| 2232 | channel->reserve_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2232 | channel->reserve_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2233 | if (channel->reserve_arr == NULL) | 2233 | if (channel->reserve_arr == NULL) |
| 2234 | goto exit1; | 2234 | goto exit1; |
| 2235 | channel->reserve_ptr = length; | 2235 | channel->reserve_ptr = length; |
| 2236 | channel->reserve_top = 0; | 2236 | channel->reserve_top = 0; |
| 2237 | 2237 | ||
| 2238 | channel->orig_arr = kzalloc(sizeof(void *)*length, GFP_KERNEL); | 2238 | channel->orig_arr = kcalloc(length, sizeof(void *), GFP_KERNEL); |
| 2239 | if (channel->orig_arr == NULL) | 2239 | if (channel->orig_arr == NULL) |
| 2240 | goto exit1; | 2240 | goto exit1; |
| 2241 | 2241 | ||
| @@ -2565,7 +2565,7 @@ __vxge_hw_mempool_grow(struct vxge_hw_mempool *mempool, u32 num_allocate, | |||
| 2565 | * allocate new memblock and its private part at once. | 2565 | * allocate new memblock and its private part at once. |
| 2566 | * This helps to minimize memory usage a lot. */ | 2566 | * This helps to minimize memory usage a lot. */ |
| 2567 | mempool->memblocks_priv_arr[i] = | 2567 | mempool->memblocks_priv_arr[i] = |
| 2568 | vzalloc(mempool->items_priv_size * n_items); | 2568 | vzalloc(array_size(mempool->items_priv_size, n_items)); |
| 2569 | if (mempool->memblocks_priv_arr[i] == NULL) { | 2569 | if (mempool->memblocks_priv_arr[i] == NULL) { |
| 2570 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2570 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| 2571 | goto exit; | 2571 | goto exit; |
| @@ -2665,7 +2665,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2665 | 2665 | ||
| 2666 | /* allocate array of memblocks */ | 2666 | /* allocate array of memblocks */ |
| 2667 | mempool->memblocks_arr = | 2667 | mempool->memblocks_arr = |
| 2668 | vzalloc(sizeof(void *) * mempool->memblocks_max); | 2668 | vzalloc(array_size(sizeof(void *), mempool->memblocks_max)); |
| 2669 | if (mempool->memblocks_arr == NULL) { | 2669 | if (mempool->memblocks_arr == NULL) { |
| 2670 | __vxge_hw_mempool_destroy(mempool); | 2670 | __vxge_hw_mempool_destroy(mempool); |
| 2671 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2671 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2675,7 +2675,7 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2675 | 2675 | ||
| 2676 | /* allocate array of private parts of items per memblocks */ | 2676 | /* allocate array of private parts of items per memblocks */ |
| 2677 | mempool->memblocks_priv_arr = | 2677 | mempool->memblocks_priv_arr = |
| 2678 | vzalloc(sizeof(void *) * mempool->memblocks_max); | 2678 | vzalloc(array_size(sizeof(void *), mempool->memblocks_max)); |
| 2679 | if (mempool->memblocks_priv_arr == NULL) { | 2679 | if (mempool->memblocks_priv_arr == NULL) { |
| 2680 | __vxge_hw_mempool_destroy(mempool); | 2680 | __vxge_hw_mempool_destroy(mempool); |
| 2681 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2681 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2685,8 +2685,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2685 | 2685 | ||
| 2686 | /* allocate array of memblocks DMA objects */ | 2686 | /* allocate array of memblocks DMA objects */ |
| 2687 | mempool->memblocks_dma_arr = | 2687 | mempool->memblocks_dma_arr = |
| 2688 | vzalloc(sizeof(struct vxge_hw_mempool_dma) * | 2688 | vzalloc(array_size(sizeof(struct vxge_hw_mempool_dma), |
| 2689 | mempool->memblocks_max); | 2689 | mempool->memblocks_max)); |
| 2690 | if (mempool->memblocks_dma_arr == NULL) { | 2690 | if (mempool->memblocks_dma_arr == NULL) { |
| 2691 | __vxge_hw_mempool_destroy(mempool); | 2691 | __vxge_hw_mempool_destroy(mempool); |
| 2692 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2692 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
| @@ -2695,7 +2695,8 @@ __vxge_hw_mempool_create(struct __vxge_hw_device *devh, | |||
| 2695 | } | 2695 | } |
| 2696 | 2696 | ||
| 2697 | /* allocate hash array of items */ | 2697 | /* allocate hash array of items */ |
| 2698 | mempool->items_arr = vzalloc(sizeof(void *) * mempool->items_max); | 2698 | mempool->items_arr = vzalloc(array_size(sizeof(void *), |
| 2699 | mempool->items_max)); | ||
| 2699 | if (mempool->items_arr == NULL) { | 2700 | if (mempool->items_arr == NULL) { |
| 2700 | __vxge_hw_mempool_destroy(mempool); | 2701 | __vxge_hw_mempool_destroy(mempool); |
| 2701 | status = VXGE_HW_ERR_OUT_OF_MEMORY; | 2702 | status = VXGE_HW_ERR_OUT_OF_MEMORY; |
diff --git a/drivers/net/ethernet/neterion/vxge/vxge-main.c b/drivers/net/ethernet/neterion/vxge/vxge-main.c index a8918bb7c802..5ae3fa82909f 100644 --- a/drivers/net/ethernet/neterion/vxge/vxge-main.c +++ b/drivers/net/ethernet/neterion/vxge/vxge-main.c | |||
| @@ -3429,8 +3429,8 @@ static int vxge_device_register(struct __vxge_hw_device *hldev, | |||
| 3429 | vxge_initialize_ethtool_ops(ndev); | 3429 | vxge_initialize_ethtool_ops(ndev); |
| 3430 | 3430 | ||
| 3431 | /* Allocate memory for vpath */ | 3431 | /* Allocate memory for vpath */ |
| 3432 | vdev->vpaths = kzalloc((sizeof(struct vxge_vpath)) * | 3432 | vdev->vpaths = kcalloc(no_of_vpath, sizeof(struct vxge_vpath), |
| 3433 | no_of_vpath, GFP_KERNEL); | 3433 | GFP_KERNEL); |
| 3434 | if (!vdev->vpaths) { | 3434 | if (!vdev->vpaths) { |
| 3435 | vxge_debug_init(VXGE_ERR, | 3435 | vxge_debug_init(VXGE_ERR, |
| 3436 | "%s: vpath memory allocation failed", | 3436 | "%s: vpath memory allocation failed", |
diff --git a/drivers/net/ethernet/netronome/nfp/abm/main.c b/drivers/net/ethernet/netronome/nfp/abm/main.c index 1561c2724c26..b84a6c2d387b 100644 --- a/drivers/net/ethernet/netronome/nfp/abm/main.c +++ b/drivers/net/ethernet/netronome/nfp/abm/main.c | |||
| @@ -590,7 +590,7 @@ nfp_abm_vnic_alloc(struct nfp_app *app, struct nfp_net *nn, unsigned int id) | |||
| 590 | alink->id = id; | 590 | alink->id = id; |
| 591 | alink->parent = TC_H_ROOT; | 591 | alink->parent = TC_H_ROOT; |
| 592 | alink->total_queues = alink->vnic->max_rx_rings; | 592 | alink->total_queues = alink->vnic->max_rx_rings; |
| 593 | alink->qdiscs = kvzalloc(sizeof(*alink->qdiscs) * alink->total_queues, | 593 | alink->qdiscs = kvcalloc(alink->total_queues, sizeof(*alink->qdiscs), |
| 594 | GFP_KERNEL); | 594 | GFP_KERNEL); |
| 595 | if (!alink->qdiscs) { | 595 | if (!alink->qdiscs) { |
| 596 | err = -ENOMEM; | 596 | err = -ENOMEM; |
diff --git a/drivers/net/ethernet/netronome/nfp/flower/metadata.c b/drivers/net/ethernet/netronome/nfp/flower/metadata.c index 21668aa435e8..93fb809f50d1 100644 --- a/drivers/net/ethernet/netronome/nfp/flower/metadata.c +++ b/drivers/net/ethernet/netronome/nfp/flower/metadata.c | |||
| @@ -417,7 +417,8 @@ int nfp_flower_metadata_init(struct nfp_app *app) | |||
| 417 | 417 | ||
| 418 | /* Init ring buffer and unallocated stats_ids. */ | 418 | /* Init ring buffer and unallocated stats_ids. */ |
| 419 | priv->stats_ids.free_list.buf = | 419 | priv->stats_ids.free_list.buf = |
| 420 | vmalloc(NFP_FL_STATS_ENTRY_RS * NFP_FL_STATS_ELEM_RS); | 420 | vmalloc(array_size(NFP_FL_STATS_ELEM_RS, |
| 421 | NFP_FL_STATS_ENTRY_RS)); | ||
| 421 | if (!priv->stats_ids.free_list.buf) | 422 | if (!priv->stats_ids.free_list.buf) |
| 422 | goto err_free_last_used; | 423 | goto err_free_last_used; |
| 423 | 424 | ||
diff --git a/drivers/net/ethernet/ni/nixge.c b/drivers/net/ethernet/ni/nixge.c index b092894dd128..09f674ec0f9e 100644 --- a/drivers/net/ethernet/ni/nixge.c +++ b/drivers/net/ethernet/ni/nixge.c | |||
| @@ -247,9 +247,8 @@ static int nixge_hw_dma_bd_init(struct net_device *ndev) | |||
| 247 | if (!priv->tx_bd_v) | 247 | if (!priv->tx_bd_v) |
| 248 | goto out; | 248 | goto out; |
| 249 | 249 | ||
| 250 | priv->tx_skb = devm_kzalloc(ndev->dev.parent, | 250 | priv->tx_skb = devm_kcalloc(ndev->dev.parent, |
| 251 | sizeof(*priv->tx_skb) * | 251 | TX_BD_NUM, sizeof(*priv->tx_skb), |
| 252 | TX_BD_NUM, | ||
| 253 | GFP_KERNEL); | 252 | GFP_KERNEL); |
| 254 | if (!priv->tx_skb) | 253 | if (!priv->tx_skb) |
| 255 | goto out; | 254 | goto out; |
diff --git a/drivers/net/ethernet/nvidia/forcedeth.c b/drivers/net/ethernet/nvidia/forcedeth.c index 66c665d0b926..7cbd0174459c 100644 --- a/drivers/net/ethernet/nvidia/forcedeth.c +++ b/drivers/net/ethernet/nvidia/forcedeth.c | |||
| @@ -4630,8 +4630,10 @@ static int nv_set_ringparam(struct net_device *dev, struct ethtool_ringparam* ri | |||
| 4630 | ring->tx_pending), | 4630 | ring->tx_pending), |
| 4631 | &ring_addr, GFP_ATOMIC); | 4631 | &ring_addr, GFP_ATOMIC); |
| 4632 | } | 4632 | } |
| 4633 | rx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->rx_pending, GFP_KERNEL); | 4633 | rx_skbuff = kmalloc_array(ring->rx_pending, sizeof(struct nv_skb_map), |
| 4634 | tx_skbuff = kmalloc(sizeof(struct nv_skb_map) * ring->tx_pending, GFP_KERNEL); | 4634 | GFP_KERNEL); |
| 4635 | tx_skbuff = kmalloc_array(ring->tx_pending, sizeof(struct nv_skb_map), | ||
| 4636 | GFP_KERNEL); | ||
| 4635 | if (!rxtx_ring || !rx_skbuff || !tx_skbuff) { | 4637 | if (!rxtx_ring || !rx_skbuff || !tx_skbuff) { |
| 4636 | /* fall back to old rings */ | 4638 | /* fall back to old rings */ |
| 4637 | if (!nv_optimized(np)) { | 4639 | if (!nv_optimized(np)) { |
diff --git a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c index 7cd494611a74..34a1581eda95 100644 --- a/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c +++ b/drivers/net/ethernet/oki-semi/pch_gbe/pch_gbe_main.c | |||
| @@ -2178,7 +2178,7 @@ static void pch_gbe_set_multi(struct net_device *netdev) | |||
| 2178 | 2178 | ||
| 2179 | if (mc_count >= PCH_GBE_MAR_ENTRIES) | 2179 | if (mc_count >= PCH_GBE_MAR_ENTRIES) |
| 2180 | return; | 2180 | return; |
| 2181 | mta_list = kmalloc(mc_count * ETH_ALEN, GFP_ATOMIC); | 2181 | mta_list = kmalloc_array(ETH_ALEN, mc_count, GFP_ATOMIC); |
| 2182 | if (!mta_list) | 2182 | if (!mta_list) |
| 2183 | return; | 2183 | return; |
| 2184 | 2184 | ||
diff --git a/drivers/net/ethernet/pasemi/pasemi_mac.c b/drivers/net/ethernet/pasemi/pasemi_mac.c index 07a2eb3781b1..8a31a02c9f47 100644 --- a/drivers/net/ethernet/pasemi/pasemi_mac.c +++ b/drivers/net/ethernet/pasemi/pasemi_mac.c | |||
| @@ -390,8 +390,9 @@ static int pasemi_mac_setup_rx_resources(const struct net_device *dev) | |||
| 390 | spin_lock_init(&ring->lock); | 390 | spin_lock_init(&ring->lock); |
| 391 | 391 | ||
| 392 | ring->size = RX_RING_SIZE; | 392 | ring->size = RX_RING_SIZE; |
| 393 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 393 | ring->ring_info = kcalloc(RX_RING_SIZE, |
| 394 | RX_RING_SIZE, GFP_KERNEL); | 394 | sizeof(struct pasemi_mac_buffer), |
| 395 | GFP_KERNEL); | ||
| 395 | 396 | ||
| 396 | if (!ring->ring_info) | 397 | if (!ring->ring_info) |
| 397 | goto out_ring_info; | 398 | goto out_ring_info; |
| @@ -473,8 +474,9 @@ pasemi_mac_setup_tx_resources(const struct net_device *dev) | |||
| 473 | spin_lock_init(&ring->lock); | 474 | spin_lock_init(&ring->lock); |
| 474 | 475 | ||
| 475 | ring->size = TX_RING_SIZE; | 476 | ring->size = TX_RING_SIZE; |
| 476 | ring->ring_info = kzalloc(sizeof(struct pasemi_mac_buffer) * | 477 | ring->ring_info = kcalloc(TX_RING_SIZE, |
| 477 | TX_RING_SIZE, GFP_KERNEL); | 478 | sizeof(struct pasemi_mac_buffer), |
| 479 | GFP_KERNEL); | ||
| 478 | if (!ring->ring_info) | 480 | if (!ring->ring_info) |
| 479 | goto out_ring_info; | 481 | goto out_ring_info; |
| 480 | 482 | ||
diff --git a/drivers/net/ethernet/qlogic/qed/qed_debug.c b/drivers/net/ethernet/qlogic/qed/qed_debug.c index b9ec460dd996..a14e48489029 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_debug.c +++ b/drivers/net/ethernet/qlogic/qed/qed_debug.c | |||
| @@ -6617,7 +6617,8 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6617 | 6617 | ||
| 6618 | /* Read no. of modules and allocate memory for their pointers */ | 6618 | /* Read no. of modules and allocate memory for their pointers */ |
| 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); | 6619 | meta->modules_num = qed_read_byte_from_buf(meta_buf_bytes, &offset); |
| 6620 | meta->modules = kzalloc(meta->modules_num * sizeof(char *), GFP_KERNEL); | 6620 | meta->modules = kcalloc(meta->modules_num, sizeof(char *), |
| 6621 | GFP_KERNEL); | ||
| 6621 | if (!meta->modules) | 6622 | if (!meta->modules) |
| 6622 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; | 6623 | return DBG_STATUS_VIRT_MEM_ALLOC_FAILED; |
| 6623 | 6624 | ||
| @@ -6645,7 +6646,7 @@ static enum dbg_status qed_mcp_trace_alloc_meta(struct qed_hwfn *p_hwfn, | |||
| 6645 | 6646 | ||
| 6646 | /* Read number of formats and allocate memory for all formats */ | 6647 | /* Read number of formats and allocate memory for all formats */ |
| 6647 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); | 6648 | meta->formats_num = qed_read_dword_from_buf(meta_buf_bytes, &offset); |
| 6648 | meta->formats = kzalloc(meta->formats_num * | 6649 | meta->formats = kcalloc(meta->formats_num, |
| 6649 | sizeof(struct mcp_trace_format), | 6650 | sizeof(struct mcp_trace_format), |
| 6650 | GFP_KERNEL); | 6651 | GFP_KERNEL); |
| 6651 | if (!meta->formats) | 6652 | if (!meta->formats) |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_dev.c b/drivers/net/ethernet/qlogic/qed/qed_dev.c index b285edc8d6a1..329781cda77f 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_dev.c +++ b/drivers/net/ethernet/qlogic/qed/qed_dev.c | |||
| @@ -814,26 +814,26 @@ static int qed_alloc_qm_data(struct qed_hwfn *p_hwfn) | |||
| 814 | if (rc) | 814 | if (rc) |
| 815 | goto alloc_err; | 815 | goto alloc_err; |
| 816 | 816 | ||
| 817 | qm_info->qm_pq_params = kzalloc(sizeof(*qm_info->qm_pq_params) * | 817 | qm_info->qm_pq_params = kcalloc(qed_init_qm_get_num_pqs(p_hwfn), |
| 818 | qed_init_qm_get_num_pqs(p_hwfn), | 818 | sizeof(*qm_info->qm_pq_params), |
| 819 | GFP_KERNEL); | 819 | GFP_KERNEL); |
| 820 | if (!qm_info->qm_pq_params) | 820 | if (!qm_info->qm_pq_params) |
| 821 | goto alloc_err; | 821 | goto alloc_err; |
| 822 | 822 | ||
| 823 | qm_info->qm_vport_params = kzalloc(sizeof(*qm_info->qm_vport_params) * | 823 | qm_info->qm_vport_params = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 824 | qed_init_qm_get_num_vports(p_hwfn), | 824 | sizeof(*qm_info->qm_vport_params), |
| 825 | GFP_KERNEL); | 825 | GFP_KERNEL); |
| 826 | if (!qm_info->qm_vport_params) | 826 | if (!qm_info->qm_vport_params) |
| 827 | goto alloc_err; | 827 | goto alloc_err; |
| 828 | 828 | ||
| 829 | qm_info->qm_port_params = kzalloc(sizeof(*qm_info->qm_port_params) * | 829 | qm_info->qm_port_params = kcalloc(p_hwfn->cdev->num_ports_in_engine, |
| 830 | p_hwfn->cdev->num_ports_in_engine, | 830 | sizeof(*qm_info->qm_port_params), |
| 831 | GFP_KERNEL); | 831 | GFP_KERNEL); |
| 832 | if (!qm_info->qm_port_params) | 832 | if (!qm_info->qm_port_params) |
| 833 | goto alloc_err; | 833 | goto alloc_err; |
| 834 | 834 | ||
| 835 | qm_info->wfq_data = kzalloc(sizeof(*qm_info->wfq_data) * | 835 | qm_info->wfq_data = kcalloc(qed_init_qm_get_num_vports(p_hwfn), |
| 836 | qed_init_qm_get_num_vports(p_hwfn), | 836 | sizeof(*qm_info->wfq_data), |
| 837 | GFP_KERNEL); | 837 | GFP_KERNEL); |
| 838 | if (!qm_info->wfq_data) | 838 | if (!qm_info->wfq_data) |
| 839 | goto alloc_err; | 839 | goto alloc_err; |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c index 3bb76da6baa2..d9ab5add27a8 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_init_ops.c +++ b/drivers/net/ethernet/qlogic/qed/qed_init_ops.c | |||
| @@ -149,12 +149,12 @@ int qed_init_alloc(struct qed_hwfn *p_hwfn) | |||
| 149 | if (IS_VF(p_hwfn->cdev)) | 149 | if (IS_VF(p_hwfn->cdev)) |
| 150 | return 0; | 150 | return 0; |
| 151 | 151 | ||
| 152 | rt_data->b_valid = kzalloc(sizeof(bool) * RUNTIME_ARRAY_SIZE, | 152 | rt_data->b_valid = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(bool), |
| 153 | GFP_KERNEL); | 153 | GFP_KERNEL); |
| 154 | if (!rt_data->b_valid) | 154 | if (!rt_data->b_valid) |
| 155 | return -ENOMEM; | 155 | return -ENOMEM; |
| 156 | 156 | ||
| 157 | rt_data->init_val = kzalloc(sizeof(u32) * RUNTIME_ARRAY_SIZE, | 157 | rt_data->init_val = kcalloc(RUNTIME_ARRAY_SIZE, sizeof(u32), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!rt_data->init_val) { | 159 | if (!rt_data->init_val) { |
| 160 | kfree(rt_data->b_valid); | 160 | kfree(rt_data->b_valid); |
diff --git a/drivers/net/ethernet/qlogic/qed/qed_l2.c b/drivers/net/ethernet/qlogic/qed/qed_l2.c index 1f6ac848109d..99973e10b179 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_l2.c +++ b/drivers/net/ethernet/qlogic/qed/qed_l2.c | |||
| @@ -98,7 +98,7 @@ int qed_l2_alloc(struct qed_hwfn *p_hwfn) | |||
| 98 | p_l2_info->queues = max_t(u8, rx, tx); | 98 | p_l2_info->queues = max_t(u8, rx, tx); |
| 99 | } | 99 | } |
| 100 | 100 | ||
| 101 | pp_qids = kzalloc(sizeof(unsigned long *) * p_l2_info->queues, | 101 | pp_qids = kcalloc(p_l2_info->queues, sizeof(unsigned long *), |
| 102 | GFP_KERNEL); | 102 | GFP_KERNEL); |
| 103 | if (!pp_qids) | 103 | if (!pp_qids) |
| 104 | return -ENOMEM; | 104 | return -ENOMEM; |
| @@ -2435,7 +2435,7 @@ static int qed_update_vport(struct qed_dev *cdev, | |||
| 2435 | if (!cdev) | 2435 | if (!cdev) |
| 2436 | return -ENODEV; | 2436 | return -ENODEV; |
| 2437 | 2437 | ||
| 2438 | rss = vzalloc(sizeof(*rss) * cdev->num_hwfns); | 2438 | rss = vzalloc(array_size(sizeof(*rss), cdev->num_hwfns)); |
| 2439 | if (!rss) | 2439 | if (!rss) |
| 2440 | return -ENOMEM; | 2440 | return -ENOMEM; |
| 2441 | 2441 | ||
diff --git a/drivers/net/ethernet/qlogic/qed/qed_mcp.c b/drivers/net/ethernet/qlogic/qed/qed_mcp.c index 6f9927d1a501..4e0b443c9519 100644 --- a/drivers/net/ethernet/qlogic/qed/qed_mcp.c +++ b/drivers/net/ethernet/qlogic/qed/qed_mcp.c | |||
| @@ -2578,9 +2578,9 @@ int qed_mcp_nvm_info_populate(struct qed_hwfn *p_hwfn) | |||
| 2578 | goto err0; | 2578 | goto err0; |
| 2579 | } | 2579 | } |
| 2580 | 2580 | ||
| 2581 | nvm_info->image_att = kmalloc(nvm_info->num_images * | 2581 | nvm_info->image_att = kmalloc_array(nvm_info->num_images, |
| 2582 | sizeof(struct bist_nvm_image_att), | 2582 | sizeof(struct bist_nvm_image_att), |
| 2583 | GFP_KERNEL); | 2583 | GFP_KERNEL); |
| 2584 | if (!nvm_info->image_att) { | 2584 | if (!nvm_info->image_att) { |
| 2585 | rc = -ENOMEM; | 2585 | rc = -ENOMEM; |
| 2586 | goto err0; | 2586 | goto err0; |
diff --git a/drivers/net/ethernet/qlogic/qede/qede_filter.c b/drivers/net/ethernet/qlogic/qede/qede_filter.c index e9e088d9c815..b823bfe2ea4d 100644 --- a/drivers/net/ethernet/qlogic/qede/qede_filter.c +++ b/drivers/net/ethernet/qlogic/qede/qede_filter.c | |||
| @@ -342,8 +342,9 @@ int qede_alloc_arfs(struct qede_dev *edev) | |||
| 342 | for (i = 0; i <= QEDE_RFS_FLW_MASK; i++) | 342 | for (i = 0; i <= QEDE_RFS_FLW_MASK; i++) |
| 343 | INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i)); | 343 | INIT_HLIST_HEAD(QEDE_ARFS_BUCKET_HEAD(edev, i)); |
| 344 | 344 | ||
| 345 | edev->arfs->arfs_fltr_bmap = vzalloc(BITS_TO_LONGS(QEDE_RFS_MAX_FLTR) * | 345 | edev->arfs->arfs_fltr_bmap = |
| 346 | sizeof(long)); | 346 | vzalloc(array_size(sizeof(long), |
| 347 | BITS_TO_LONGS(QEDE_RFS_MAX_FLTR))); | ||
| 347 | if (!edev->arfs->arfs_fltr_bmap) { | 348 | if (!edev->arfs->arfs_fltr_bmap) { |
| 348 | vfree(edev->arfs); | 349 | vfree(edev->arfs); |
| 349 | edev->arfs = NULL; | 350 | edev->arfs = NULL; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c index 97c146e7698a..569d54ededec 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_83xx_hw.c | |||
| @@ -386,8 +386,9 @@ int qlcnic_83xx_setup_intr(struct qlcnic_adapter *adapter) | |||
| 386 | } | 386 | } |
| 387 | 387 | ||
| 388 | /* setup interrupt mapping table for fw */ | 388 | /* setup interrupt mapping table for fw */ |
| 389 | ahw->intr_tbl = vzalloc(num_msix * | 389 | ahw->intr_tbl = |
| 390 | sizeof(struct qlcnic_intrpt_config)); | 390 | vzalloc(array_size(num_msix, |
| 391 | sizeof(struct qlcnic_intrpt_config))); | ||
| 391 | if (!ahw->intr_tbl) | 392 | if (!ahw->intr_tbl) |
| 392 | return -ENOMEM; | 393 | return -ENOMEM; |
| 393 | 394 | ||
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c index 1b5f7d57b6f8..2d38d1ac2aae 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_main.c | |||
| @@ -916,8 +916,9 @@ int qlcnic_82xx_mq_intrpt(struct qlcnic_adapter *adapter, int op_type) | |||
| 916 | if (qlcnic_check_multi_tx(adapter) && | 916 | if (qlcnic_check_multi_tx(adapter) && |
| 917 | !ahw->diag_test && | 917 | !ahw->diag_test && |
| 918 | (adapter->flags & QLCNIC_MSIX_ENABLED)) { | 918 | (adapter->flags & QLCNIC_MSIX_ENABLED)) { |
| 919 | ahw->intr_tbl = vzalloc(ahw->num_msix * | 919 | ahw->intr_tbl = |
| 920 | sizeof(struct qlcnic_intrpt_config)); | 920 | vzalloc(array_size(sizeof(struct qlcnic_intrpt_config), |
| 921 | ahw->num_msix)); | ||
| 921 | if (!ahw->intr_tbl) | 922 | if (!ahw->intr_tbl) |
| 922 | return -ENOMEM; | 923 | return -ENOMEM; |
| 923 | 924 | ||
| @@ -1025,15 +1026,17 @@ int qlcnic_init_pci_info(struct qlcnic_adapter *adapter) | |||
| 1025 | 1026 | ||
| 1026 | act_pci_func = ahw->total_nic_func; | 1027 | act_pci_func = ahw->total_nic_func; |
| 1027 | 1028 | ||
| 1028 | adapter->npars = kzalloc(sizeof(struct qlcnic_npar_info) * | 1029 | adapter->npars = kcalloc(act_pci_func, |
| 1029 | act_pci_func, GFP_KERNEL); | 1030 | sizeof(struct qlcnic_npar_info), |
| 1031 | GFP_KERNEL); | ||
| 1030 | if (!adapter->npars) { | 1032 | if (!adapter->npars) { |
| 1031 | ret = -ENOMEM; | 1033 | ret = -ENOMEM; |
| 1032 | goto err_pci_info; | 1034 | goto err_pci_info; |
| 1033 | } | 1035 | } |
| 1034 | 1036 | ||
| 1035 | adapter->eswitch = kzalloc(sizeof(struct qlcnic_eswitch) * | 1037 | adapter->eswitch = kcalloc(QLCNIC_NIU_MAX_XG_PORTS, |
| 1036 | QLCNIC_NIU_MAX_XG_PORTS, GFP_KERNEL); | 1038 | sizeof(struct qlcnic_eswitch), |
| 1039 | GFP_KERNEL); | ||
| 1037 | if (!adapter->eswitch) { | 1040 | if (!adapter->eswitch) { |
| 1038 | ret = -ENOMEM; | 1041 | ret = -ENOMEM; |
| 1039 | goto err_npars; | 1042 | goto err_npars; |
diff --git a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c index c58180f40844..0c744b9c6e0a 100644 --- a/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c +++ b/drivers/net/ethernet/qlogic/qlcnic/qlcnic_sriov_common.c | |||
| @@ -157,8 +157,8 @@ int qlcnic_sriov_init(struct qlcnic_adapter *adapter, int num_vfs) | |||
| 157 | adapter->ahw->sriov = sriov; | 157 | adapter->ahw->sriov = sriov; |
| 158 | sriov->num_vfs = num_vfs; | 158 | sriov->num_vfs = num_vfs; |
| 159 | bc = &sriov->bc; | 159 | bc = &sriov->bc; |
| 160 | sriov->vf_info = kzalloc(sizeof(struct qlcnic_vf_info) * | 160 | sriov->vf_info = kcalloc(num_vfs, sizeof(struct qlcnic_vf_info), |
| 161 | num_vfs, GFP_KERNEL); | 161 | GFP_KERNEL); |
| 162 | if (!sriov->vf_info) { | 162 | if (!sriov->vf_info) { |
| 163 | err = -ENOMEM; | 163 | err = -ENOMEM; |
| 164 | goto qlcnic_free_sriov; | 164 | goto qlcnic_free_sriov; |
| @@ -450,7 +450,7 @@ static int qlcnic_sriov_set_guest_vlan_mode(struct qlcnic_adapter *adapter, | |||
| 450 | return 0; | 450 | return 0; |
| 451 | 451 | ||
| 452 | num_vlans = sriov->num_allowed_vlans; | 452 | num_vlans = sriov->num_allowed_vlans; |
| 453 | sriov->allowed_vlans = kzalloc(sizeof(u16) * num_vlans, GFP_KERNEL); | 453 | sriov->allowed_vlans = kcalloc(num_vlans, sizeof(u16), GFP_KERNEL); |
| 454 | if (!sriov->allowed_vlans) | 454 | if (!sriov->allowed_vlans) |
| 455 | return -ENOMEM; | 455 | return -ENOMEM; |
| 456 | 456 | ||
| @@ -706,7 +706,7 @@ static inline int qlcnic_sriov_alloc_bc_trans(struct qlcnic_bc_trans **trans) | |||
| 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, | 706 | static inline int qlcnic_sriov_alloc_bc_msg(struct qlcnic_bc_hdr **hdr, |
| 707 | u32 size) | 707 | u32 size) |
| 708 | { | 708 | { |
| 709 | *hdr = kzalloc(sizeof(struct qlcnic_bc_hdr) * size, GFP_ATOMIC); | 709 | *hdr = kcalloc(size, sizeof(struct qlcnic_bc_hdr), GFP_ATOMIC); |
| 710 | if (!*hdr) | 710 | if (!*hdr) |
| 711 | return -ENOMEM; | 711 | return -ENOMEM; |
| 712 | 712 | ||
diff --git a/drivers/net/ethernet/qlogic/qlge/qlge_main.c b/drivers/net/ethernet/qlogic/qlge/qlge_main.c index 70de062b72a1..353f1c129af1 100644 --- a/drivers/net/ethernet/qlogic/qlge/qlge_main.c +++ b/drivers/net/ethernet/qlogic/qlge/qlge_main.c | |||
| @@ -2810,7 +2810,8 @@ static int ql_alloc_tx_resources(struct ql_adapter *qdev, | |||
| 2810 | goto pci_alloc_err; | 2810 | goto pci_alloc_err; |
| 2811 | 2811 | ||
| 2812 | tx_ring->q = | 2812 | tx_ring->q = |
| 2813 | kmalloc(tx_ring->wq_len * sizeof(struct tx_ring_desc), GFP_KERNEL); | 2813 | kmalloc_array(tx_ring->wq_len, sizeof(struct tx_ring_desc), |
| 2814 | GFP_KERNEL); | ||
| 2814 | if (tx_ring->q == NULL) | 2815 | if (tx_ring->q == NULL) |
| 2815 | goto err; | 2816 | goto err; |
| 2816 | 2817 | ||
diff --git a/drivers/net/ethernet/sfc/ef10.c b/drivers/net/ethernet/sfc/ef10.c index d90a7b1f4088..23f0785c0573 100644 --- a/drivers/net/ethernet/sfc/ef10.c +++ b/drivers/net/ethernet/sfc/ef10.c | |||
| @@ -4984,7 +4984,8 @@ static int efx_ef10_filter_table_probe(struct efx_nic *efx) | |||
| 4984 | net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; | 4984 | net_dev->hw_features &= ~NETIF_F_HW_VLAN_CTAG_FILTER; |
| 4985 | } | 4985 | } |
| 4986 | 4986 | ||
| 4987 | table->entry = vzalloc(HUNT_FILTER_TBL_ROWS * sizeof(*table->entry)); | 4987 | table->entry = vzalloc(array_size(HUNT_FILTER_TBL_ROWS, |
| 4988 | sizeof(*table->entry))); | ||
| 4988 | if (!table->entry) { | 4989 | if (!table->entry) { |
| 4989 | rc = -ENOMEM; | 4990 | rc = -ENOMEM; |
| 4990 | goto fail; | 4991 | goto fail; |
diff --git a/drivers/net/ethernet/sfc/falcon/farch.c b/drivers/net/ethernet/sfc/falcon/farch.c index 494884f6af4a..411a2f419447 100644 --- a/drivers/net/ethernet/sfc/falcon/farch.c +++ b/drivers/net/ethernet/sfc/falcon/farch.c | |||
| @@ -2755,7 +2755,8 @@ int ef4_farch_filter_table_probe(struct ef4_nic *efx) | |||
| 2755 | GFP_KERNEL); | 2755 | GFP_KERNEL); |
| 2756 | if (!table->used_bitmap) | 2756 | if (!table->used_bitmap) |
| 2757 | goto fail; | 2757 | goto fail; |
| 2758 | table->spec = vzalloc(table->size * sizeof(*table->spec)); | 2758 | table->spec = vzalloc(array_size(sizeof(*table->spec), |
| 2759 | table->size)); | ||
| 2759 | if (!table->spec) | 2760 | if (!table->spec) |
| 2760 | goto fail; | 2761 | goto fail; |
| 2761 | } | 2762 | } |
diff --git a/drivers/net/ethernet/sfc/farch.c b/drivers/net/ethernet/sfc/farch.c index c72adf8b52ea..8edf20967c82 100644 --- a/drivers/net/ethernet/sfc/farch.c +++ b/drivers/net/ethernet/sfc/farch.c | |||
| @@ -2826,7 +2826,8 @@ int efx_farch_filter_table_probe(struct efx_nic *efx) | |||
| 2826 | GFP_KERNEL); | 2826 | GFP_KERNEL); |
| 2827 | if (!table->used_bitmap) | 2827 | if (!table->used_bitmap) |
| 2828 | goto fail; | 2828 | goto fail; |
| 2829 | table->spec = vzalloc(table->size * sizeof(*table->spec)); | 2829 | table->spec = vzalloc(array_size(sizeof(*table->spec), |
| 2830 | table->size)); | ||
| 2830 | if (!table->spec) | 2831 | if (!table->spec) |
| 2831 | goto fail; | 2832 | goto fail; |
| 2832 | } | 2833 | } |
diff --git a/drivers/net/ethernet/socionext/netsec.c b/drivers/net/ethernet/socionext/netsec.c index ce8071fc90c4..e080d3e7c582 100644 --- a/drivers/net/ethernet/socionext/netsec.c +++ b/drivers/net/ethernet/socionext/netsec.c | |||
| @@ -973,7 +973,7 @@ static int netsec_alloc_dring(struct netsec_priv *priv, enum ring_id id) | |||
| 973 | goto err; | 973 | goto err; |
| 974 | } | 974 | } |
| 975 | 975 | ||
| 976 | dring->desc = kzalloc(DESC_NUM * sizeof(*dring->desc), GFP_KERNEL); | 976 | dring->desc = kcalloc(DESC_NUM, sizeof(*dring->desc), GFP_KERNEL); |
| 977 | if (!dring->desc) { | 977 | if (!dring->desc) { |
| 978 | ret = -ENOMEM; | 978 | ret = -ENOMEM; |
| 979 | goto err; | 979 | goto err; |
diff --git a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c index 881c94b73e2f..2258cd8cc844 100644 --- a/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c +++ b/drivers/net/ethernet/stmicro/stmmac/stmmac_tc.c | |||
| @@ -277,8 +277,8 @@ static int tc_init(struct stmmac_priv *priv) | |||
| 277 | 277 | ||
| 278 | /* Reserve one last filter which lets all pass */ | 278 | /* Reserve one last filter which lets all pass */ |
| 279 | priv->tc_entries_max = count; | 279 | priv->tc_entries_max = count; |
| 280 | priv->tc_entries = devm_kzalloc(priv->device, | 280 | priv->tc_entries = devm_kcalloc(priv->device, |
| 281 | sizeof(*priv->tc_entries) * count, GFP_KERNEL); | 281 | count, sizeof(*priv->tc_entries), GFP_KERNEL); |
| 282 | if (!priv->tc_entries) | 282 | if (!priv->tc_entries) |
| 283 | return -ENOMEM; | 283 | return -ENOMEM; |
| 284 | 284 | ||
diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 534596ce00d3..358edab9e72e 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c | |||
| @@ -2740,8 +2740,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, | |||
| 2740 | } | 2740 | } |
| 2741 | data->active_slave = prop; | 2741 | data->active_slave = prop; |
| 2742 | 2742 | ||
| 2743 | data->slave_data = devm_kzalloc(&pdev->dev, data->slaves | 2743 | data->slave_data = devm_kcalloc(&pdev->dev, |
| 2744 | * sizeof(struct cpsw_slave_data), | 2744 | data->slaves, |
| 2745 | sizeof(struct cpsw_slave_data), | ||
| 2745 | GFP_KERNEL); | 2746 | GFP_KERNEL); |
| 2746 | if (!data->slave_data) | 2747 | if (!data->slave_data) |
| 2747 | return -ENOMEM; | 2748 | return -ENOMEM; |
| @@ -3045,8 +3046,8 @@ static int cpsw_probe(struct platform_device *pdev) | |||
| 3045 | 3046 | ||
| 3046 | memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); | 3047 | memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); |
| 3047 | 3048 | ||
| 3048 | cpsw->slaves = devm_kzalloc(&pdev->dev, | 3049 | cpsw->slaves = devm_kcalloc(&pdev->dev, |
| 3049 | sizeof(struct cpsw_slave) * data->slaves, | 3050 | data->slaves, sizeof(struct cpsw_slave), |
| 3050 | GFP_KERNEL); | 3051 | GFP_KERNEL); |
| 3051 | if (!cpsw->slaves) { | 3052 | if (!cpsw->slaves) { |
| 3052 | ret = -ENOMEM; | 3053 | ret = -ENOMEM; |
diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index 6e455a27a8de..72b98e27c992 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c | |||
| @@ -3285,8 +3285,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, | |||
| 3285 | gbe_dev->et_stats = xgbe10_et_stats; | 3285 | gbe_dev->et_stats = xgbe10_et_stats; |
| 3286 | gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); | 3286 | gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); |
| 3287 | 3287 | ||
| 3288 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3288 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3289 | gbe_dev->num_et_stats * sizeof(u64), | 3289 | gbe_dev->num_et_stats, sizeof(u64), |
| 3290 | GFP_KERNEL); | 3290 | GFP_KERNEL); |
| 3291 | if (!gbe_dev->hw_stats) { | 3291 | if (!gbe_dev->hw_stats) { |
| 3292 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3292 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3294,8 +3294,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, | |||
| 3294 | } | 3294 | } |
| 3295 | 3295 | ||
| 3296 | gbe_dev->hw_stats_prev = | 3296 | gbe_dev->hw_stats_prev = |
| 3297 | devm_kzalloc(gbe_dev->dev, | 3297 | devm_kcalloc(gbe_dev->dev, |
| 3298 | gbe_dev->num_et_stats * sizeof(u32), | 3298 | gbe_dev->num_et_stats, sizeof(u32), |
| 3299 | GFP_KERNEL); | 3299 | GFP_KERNEL); |
| 3300 | if (!gbe_dev->hw_stats_prev) { | 3300 | if (!gbe_dev->hw_stats_prev) { |
| 3301 | dev_err(gbe_dev->dev, | 3301 | dev_err(gbe_dev->dev, |
| @@ -3405,8 +3405,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, | |||
| 3405 | gbe_dev->et_stats = gbe13_et_stats; | 3405 | gbe_dev->et_stats = gbe13_et_stats; |
| 3406 | gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); | 3406 | gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); |
| 3407 | 3407 | ||
| 3408 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3408 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3409 | gbe_dev->num_et_stats * sizeof(u64), | 3409 | gbe_dev->num_et_stats, sizeof(u64), |
| 3410 | GFP_KERNEL); | 3410 | GFP_KERNEL); |
| 3411 | if (!gbe_dev->hw_stats) { | 3411 | if (!gbe_dev->hw_stats) { |
| 3412 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3412 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3414,8 +3414,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, | |||
| 3414 | } | 3414 | } |
| 3415 | 3415 | ||
| 3416 | gbe_dev->hw_stats_prev = | 3416 | gbe_dev->hw_stats_prev = |
| 3417 | devm_kzalloc(gbe_dev->dev, | 3417 | devm_kcalloc(gbe_dev->dev, |
| 3418 | gbe_dev->num_et_stats * sizeof(u32), | 3418 | gbe_dev->num_et_stats, sizeof(u32), |
| 3419 | GFP_KERNEL); | 3419 | GFP_KERNEL); |
| 3420 | if (!gbe_dev->hw_stats_prev) { | 3420 | if (!gbe_dev->hw_stats_prev) { |
| 3421 | dev_err(gbe_dev->dev, | 3421 | dev_err(gbe_dev->dev, |
| @@ -3477,8 +3477,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, | |||
| 3477 | gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + | 3477 | gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + |
| 3478 | GBENU_ET_STATS_PORT_SIZE; | 3478 | GBENU_ET_STATS_PORT_SIZE; |
| 3479 | 3479 | ||
| 3480 | gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, | 3480 | gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, |
| 3481 | gbe_dev->num_et_stats * sizeof(u64), | 3481 | gbe_dev->num_et_stats, sizeof(u64), |
| 3482 | GFP_KERNEL); | 3482 | GFP_KERNEL); |
| 3483 | if (!gbe_dev->hw_stats) { | 3483 | if (!gbe_dev->hw_stats) { |
| 3484 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); | 3484 | dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); |
| @@ -3486,8 +3486,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, | |||
| 3486 | } | 3486 | } |
| 3487 | 3487 | ||
| 3488 | gbe_dev->hw_stats_prev = | 3488 | gbe_dev->hw_stats_prev = |
| 3489 | devm_kzalloc(gbe_dev->dev, | 3489 | devm_kcalloc(gbe_dev->dev, |
| 3490 | gbe_dev->num_et_stats * sizeof(u32), | 3490 | gbe_dev->num_et_stats, sizeof(u32), |
| 3491 | GFP_KERNEL); | 3491 | GFP_KERNEL); |
| 3492 | if (!gbe_dev->hw_stats_prev) { | 3492 | if (!gbe_dev->hw_stats_prev) { |
| 3493 | dev_err(gbe_dev->dev, | 3493 | dev_err(gbe_dev->dev, |
diff --git a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c index eed18f88bdff..302079e22b06 100644 --- a/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c +++ b/drivers/net/ethernet/toshiba/ps3_gelic_wireless.c | |||
| @@ -2320,8 +2320,9 @@ static struct net_device *gelic_wl_alloc(struct gelic_card *card) | |||
| 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); | 2320 | pr_debug("%s: wl=%p port=%p\n", __func__, wl, port); |
| 2321 | 2321 | ||
| 2322 | /* allocate scan list */ | 2322 | /* allocate scan list */ |
| 2323 | wl->networks = kzalloc(sizeof(struct gelic_wl_scan_info) * | 2323 | wl->networks = kcalloc(GELIC_WL_BSS_MAX_ENT, |
| 2324 | GELIC_WL_BSS_MAX_ENT, GFP_KERNEL); | 2324 | sizeof(struct gelic_wl_scan_info), |
| 2325 | GFP_KERNEL); | ||
| 2325 | 2326 | ||
| 2326 | if (!wl->networks) | 2327 | if (!wl->networks) |
| 2327 | goto fail_bss; | 2328 | goto fail_bss; |
diff --git a/drivers/net/gtp.c b/drivers/net/gtp.c index f38e32a7ec9c..ec629a730005 100644 --- a/drivers/net/gtp.c +++ b/drivers/net/gtp.c | |||
| @@ -742,11 +742,13 @@ static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) | |||
| 742 | { | 742 | { |
| 743 | int i; | 743 | int i; |
| 744 | 744 | ||
| 745 | gtp->addr_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL); | 745 | gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
| 746 | GFP_KERNEL); | ||
| 746 | if (gtp->addr_hash == NULL) | 747 | if (gtp->addr_hash == NULL) |
| 747 | return -ENOMEM; | 748 | return -ENOMEM; |
| 748 | 749 | ||
| 749 | gtp->tid_hash = kmalloc(sizeof(struct hlist_head) * hsize, GFP_KERNEL); | 750 | gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head), |
| 751 | GFP_KERNEL); | ||
| 750 | if (gtp->tid_hash == NULL) | 752 | if (gtp->tid_hash == NULL) |
| 751 | goto err1; | 753 | goto err1; |
| 752 | 754 | ||
diff --git a/drivers/net/hippi/rrunner.c b/drivers/net/hippi/rrunner.c index f41116488079..029206e4da3b 100644 --- a/drivers/net/hippi/rrunner.c +++ b/drivers/net/hippi/rrunner.c | |||
| @@ -1583,7 +1583,7 @@ static int rr_ioctl(struct net_device *dev, struct ifreq *rq, int cmd) | |||
| 1583 | return -EPERM; | 1583 | return -EPERM; |
| 1584 | } | 1584 | } |
| 1585 | 1585 | ||
| 1586 | image = kmalloc(EEPROM_WORDS * sizeof(u32), GFP_KERNEL); | 1586 | image = kmalloc_array(EEPROM_WORDS, sizeof(u32), GFP_KERNEL); |
| 1587 | if (!image) | 1587 | if (!image) |
| 1588 | return -ENOMEM; | 1588 | return -ENOMEM; |
| 1589 | 1589 | ||
diff --git a/drivers/net/phy/dp83640.c b/drivers/net/phy/dp83640.c index a6c87793d899..79e9b103188b 100644 --- a/drivers/net/phy/dp83640.c +++ b/drivers/net/phy/dp83640.c | |||
| @@ -1097,8 +1097,9 @@ static struct dp83640_clock *dp83640_clock_get_bus(struct mii_bus *bus) | |||
| 1097 | if (!clock) | 1097 | if (!clock) |
| 1098 | goto out; | 1098 | goto out; |
| 1099 | 1099 | ||
| 1100 | clock->caps.pin_config = kzalloc(sizeof(struct ptp_pin_desc) * | 1100 | clock->caps.pin_config = kcalloc(DP83640_N_PINS, |
| 1101 | DP83640_N_PINS, GFP_KERNEL); | 1101 | sizeof(struct ptp_pin_desc), |
| 1102 | GFP_KERNEL); | ||
| 1102 | if (!clock->caps.pin_config) { | 1103 | if (!clock->caps.pin_config) { |
| 1103 | kfree(clock); | 1104 | kfree(clock); |
| 1104 | clock = NULL; | 1105 | clock = NULL; |
diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index 39ecad25b201..491efc1bf5c4 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c | |||
| @@ -128,9 +128,9 @@ int phy_led_triggers_register(struct phy_device *phy) | |||
| 128 | if (err) | 128 | if (err) |
| 129 | goto out_free_link; | 129 | goto out_free_link; |
| 130 | 130 | ||
| 131 | phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev, | 131 | phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, |
| 132 | sizeof(struct phy_led_trigger) * | 132 | phy->phy_num_led_triggers, |
| 133 | phy->phy_num_led_triggers, | 133 | sizeof(struct phy_led_trigger), |
| 134 | GFP_KERNEL); | 134 | GFP_KERNEL); |
| 135 | if (!phy->phy_led_triggers) { | 135 | if (!phy->phy_led_triggers) { |
| 136 | err = -ENOMEM; | 136 | err = -ENOMEM; |
diff --git a/drivers/net/ppp/bsd_comp.c b/drivers/net/ppp/bsd_comp.c index a9b759add187..61fedb23d3cf 100644 --- a/drivers/net/ppp/bsd_comp.c +++ b/drivers/net/ppp/bsd_comp.c | |||
| @@ -406,7 +406,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
| 406 | * Allocate space for the dictionary. This may be more than one page in | 406 | * Allocate space for the dictionary. This may be more than one page in |
| 407 | * length. | 407 | * length. |
| 408 | */ | 408 | */ |
| 409 | db->dict = vmalloc(hsize * sizeof(struct bsd_dict)); | 409 | db->dict = vmalloc(array_size(hsize, sizeof(struct bsd_dict))); |
| 410 | if (!db->dict) | 410 | if (!db->dict) |
| 411 | { | 411 | { |
| 412 | bsd_free (db); | 412 | bsd_free (db); |
| @@ -425,7 +425,7 @@ static void *bsd_alloc (unsigned char *options, int opt_len, int decomp) | |||
| 425 | */ | 425 | */ |
| 426 | else | 426 | else |
| 427 | { | 427 | { |
| 428 | db->lens = vmalloc((maxmaxcode + 1) * sizeof(db->lens[0])); | 428 | db->lens = vmalloc(array_size(sizeof(db->lens[0]), (maxmaxcode + 1))); |
| 429 | if (!db->lens) | 429 | if (!db->lens) |
| 430 | { | 430 | { |
| 431 | bsd_free (db); | 431 | bsd_free (db); |
diff --git a/drivers/net/ppp/pptp.c b/drivers/net/ppp/pptp.c index 157b67c1bf8e..67ffe74747a1 100644 --- a/drivers/net/ppp/pptp.c +++ b/drivers/net/ppp/pptp.c | |||
| @@ -648,7 +648,7 @@ static int __init pptp_init_module(void) | |||
| 648 | int err = 0; | 648 | int err = 0; |
| 649 | pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); | 649 | pr_info("PPTP driver version " PPTP_DRIVER_VERSION "\n"); |
| 650 | 650 | ||
| 651 | callid_sock = vzalloc((MAX_CALLID + 1) * sizeof(void *)); | 651 | callid_sock = vzalloc(array_size(sizeof(void *), (MAX_CALLID + 1))); |
| 652 | if (!callid_sock) | 652 | if (!callid_sock) |
| 653 | return -ENOMEM; | 653 | return -ENOMEM; |
| 654 | 654 | ||
diff --git a/drivers/net/slip/slip.c b/drivers/net/slip/slip.c index 8940417c30e5..b008266e91ea 100644 --- a/drivers/net/slip/slip.c +++ b/drivers/net/slip/slip.c | |||
| @@ -1307,7 +1307,7 @@ static int __init slip_init(void) | |||
| 1307 | printk(KERN_INFO "SLIP linefill/keepalive option.\n"); | 1307 | printk(KERN_INFO "SLIP linefill/keepalive option.\n"); |
| 1308 | #endif | 1308 | #endif |
| 1309 | 1309 | ||
| 1310 | slip_devs = kzalloc(sizeof(struct net_device *)*slip_maxdev, | 1310 | slip_devs = kcalloc(slip_maxdev, sizeof(struct net_device *), |
| 1311 | GFP_KERNEL); | 1311 | GFP_KERNEL); |
| 1312 | if (!slip_devs) | 1312 | if (!slip_devs) |
| 1313 | return -ENOMEM; | 1313 | return -ENOMEM; |
diff --git a/drivers/net/team/team.c b/drivers/net/team/team.c index 8863fa023500..b070959737ff 100644 --- a/drivers/net/team/team.c +++ b/drivers/net/team/team.c | |||
| @@ -280,7 +280,7 @@ static int __team_options_register(struct team *team, | |||
| 280 | struct team_option **dst_opts; | 280 | struct team_option **dst_opts; |
| 281 | int err; | 281 | int err; |
| 282 | 282 | ||
| 283 | dst_opts = kzalloc(sizeof(struct team_option *) * option_count, | 283 | dst_opts = kcalloc(option_count, sizeof(struct team_option *), |
| 284 | GFP_KERNEL); | 284 | GFP_KERNEL); |
| 285 | if (!dst_opts) | 285 | if (!dst_opts) |
| 286 | return -ENOMEM; | 286 | return -ENOMEM; |
| @@ -791,7 +791,8 @@ static int team_queue_override_init(struct team *team) | |||
| 791 | 791 | ||
| 792 | if (!queue_cnt) | 792 | if (!queue_cnt) |
| 793 | return 0; | 793 | return 0; |
| 794 | listarr = kmalloc(sizeof(struct list_head) * queue_cnt, GFP_KERNEL); | 794 | listarr = kmalloc_array(queue_cnt, sizeof(struct list_head), |
| 795 | GFP_KERNEL); | ||
| 795 | if (!listarr) | 796 | if (!listarr) |
| 796 | return -ENOMEM; | 797 | return -ENOMEM; |
| 797 | team->qom_lists = listarr; | 798 | team->qom_lists = listarr; |
diff --git a/drivers/net/usb/asix_common.c b/drivers/net/usb/asix_common.c index f4d7362eb325..e95dd12edec4 100644 --- a/drivers/net/usb/asix_common.c +++ b/drivers/net/usb/asix_common.c | |||
| @@ -640,8 +640,8 @@ int asix_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 640 | first_word = eeprom->offset >> 1; | 640 | first_word = eeprom->offset >> 1; |
| 641 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 641 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 642 | 642 | ||
| 643 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 643 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 644 | GFP_KERNEL); | 644 | GFP_KERNEL); |
| 645 | if (!eeprom_buff) | 645 | if (!eeprom_buff) |
| 646 | return -ENOMEM; | 646 | return -ENOMEM; |
| 647 | 647 | ||
| @@ -680,8 +680,8 @@ int asix_set_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 680 | first_word = eeprom->offset >> 1; | 680 | first_word = eeprom->offset >> 1; |
| 681 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 681 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 682 | 682 | ||
| 683 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 683 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 684 | GFP_KERNEL); | 684 | GFP_KERNEL); |
| 685 | if (!eeprom_buff) | 685 | if (!eeprom_buff) |
| 686 | return -ENOMEM; | 686 | return -ENOMEM; |
| 687 | 687 | ||
diff --git a/drivers/net/usb/ax88179_178a.c b/drivers/net/usb/ax88179_178a.c index a6ef75907ae9..9e8ad372f419 100644 --- a/drivers/net/usb/ax88179_178a.c +++ b/drivers/net/usb/ax88179_178a.c | |||
| @@ -599,8 +599,8 @@ ax88179_get_eeprom(struct net_device *net, struct ethtool_eeprom *eeprom, | |||
| 599 | 599 | ||
| 600 | first_word = eeprom->offset >> 1; | 600 | first_word = eeprom->offset >> 1; |
| 601 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; | 601 | last_word = (eeprom->offset + eeprom->len - 1) >> 1; |
| 602 | eeprom_buff = kmalloc(sizeof(u16) * (last_word - first_word + 1), | 602 | eeprom_buff = kmalloc_array(last_word - first_word + 1, sizeof(u16), |
| 603 | GFP_KERNEL); | 603 | GFP_KERNEL); |
| 604 | if (!eeprom_buff) | 604 | if (!eeprom_buff) |
| 605 | return -ENOMEM; | 605 | return -ENOMEM; |
| 606 | 606 | ||
diff --git a/drivers/net/usb/smsc95xx.c b/drivers/net/usb/smsc95xx.c index 309b88acd3d0..06b4d290784d 100644 --- a/drivers/net/usb/smsc95xx.c +++ b/drivers/net/usb/smsc95xx.c | |||
| @@ -1661,7 +1661,7 @@ static int smsc95xx_suspend(struct usb_interface *intf, pm_message_t message) | |||
| 1661 | } | 1661 | } |
| 1662 | 1662 | ||
| 1663 | if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { | 1663 | if (pdata->wolopts & (WAKE_BCAST | WAKE_MCAST | WAKE_ARP | WAKE_UCAST)) { |
| 1664 | u32 *filter_mask = kzalloc(sizeof(u32) * 32, GFP_KERNEL); | 1664 | u32 *filter_mask = kcalloc(32, sizeof(u32), GFP_KERNEL); |
| 1665 | u32 command[2]; | 1665 | u32 command[2]; |
| 1666 | u32 offset[2]; | 1666 | u32 offset[2]; |
| 1667 | u32 crc[4]; | 1667 | u32 crc[4]; |
diff --git a/drivers/net/usb/usbnet.c b/drivers/net/usb/usbnet.c index d9eea8cfe6cb..770aa624147f 100644 --- a/drivers/net/usb/usbnet.c +++ b/drivers/net/usb/usbnet.c | |||
| @@ -1323,8 +1323,8 @@ static int build_dma_sg(const struct sk_buff *skb, struct urb *urb) | |||
| 1323 | return 0; | 1323 | return 0; |
| 1324 | 1324 | ||
| 1325 | /* reserve one for zero packet */ | 1325 | /* reserve one for zero packet */ |
| 1326 | urb->sg = kmalloc((num_sgs + 1) * sizeof(struct scatterlist), | 1326 | urb->sg = kmalloc_array(num_sgs + 1, sizeof(struct scatterlist), |
| 1327 | GFP_ATOMIC); | 1327 | GFP_ATOMIC); |
| 1328 | if (!urb->sg) | 1328 | if (!urb->sg) |
| 1329 | return -ENOMEM; | 1329 | return -ENOMEM; |
| 1330 | 1330 | ||
diff --git a/drivers/net/virtio_net.c b/drivers/net/virtio_net.c index 1619ee3070b6..b6c9a2af3732 100644 --- a/drivers/net/virtio_net.c +++ b/drivers/net/virtio_net.c | |||
| @@ -2552,17 +2552,17 @@ static int virtnet_find_vqs(struct virtnet_info *vi) | |||
| 2552 | virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ); | 2552 | virtio_has_feature(vi->vdev, VIRTIO_NET_F_CTRL_VQ); |
| 2553 | 2553 | ||
| 2554 | /* Allocate space for find_vqs parameters */ | 2554 | /* Allocate space for find_vqs parameters */ |
| 2555 | vqs = kzalloc(total_vqs * sizeof(*vqs), GFP_KERNEL); | 2555 | vqs = kcalloc(total_vqs, sizeof(*vqs), GFP_KERNEL); |
| 2556 | if (!vqs) | 2556 | if (!vqs) |
| 2557 | goto err_vq; | 2557 | goto err_vq; |
| 2558 | callbacks = kmalloc(total_vqs * sizeof(*callbacks), GFP_KERNEL); | 2558 | callbacks = kmalloc_array(total_vqs, sizeof(*callbacks), GFP_KERNEL); |
| 2559 | if (!callbacks) | 2559 | if (!callbacks) |
| 2560 | goto err_callback; | 2560 | goto err_callback; |
| 2561 | names = kmalloc(total_vqs * sizeof(*names), GFP_KERNEL); | 2561 | names = kmalloc_array(total_vqs, sizeof(*names), GFP_KERNEL); |
| 2562 | if (!names) | 2562 | if (!names) |
| 2563 | goto err_names; | 2563 | goto err_names; |
| 2564 | if (!vi->big_packets || vi->mergeable_rx_bufs) { | 2564 | if (!vi->big_packets || vi->mergeable_rx_bufs) { |
| 2565 | ctx = kzalloc(total_vqs * sizeof(*ctx), GFP_KERNEL); | 2565 | ctx = kcalloc(total_vqs, sizeof(*ctx), GFP_KERNEL); |
| 2566 | if (!ctx) | 2566 | if (!ctx) |
| 2567 | goto err_ctx; | 2567 | goto err_ctx; |
| 2568 | } else { | 2568 | } else { |
| @@ -2626,10 +2626,10 @@ static int virtnet_alloc_queues(struct virtnet_info *vi) | |||
| 2626 | vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL); | 2626 | vi->ctrl = kzalloc(sizeof(*vi->ctrl), GFP_KERNEL); |
| 2627 | if (!vi->ctrl) | 2627 | if (!vi->ctrl) |
| 2628 | goto err_ctrl; | 2628 | goto err_ctrl; |
| 2629 | vi->sq = kzalloc(sizeof(*vi->sq) * vi->max_queue_pairs, GFP_KERNEL); | 2629 | vi->sq = kcalloc(vi->max_queue_pairs, sizeof(*vi->sq), GFP_KERNEL); |
| 2630 | if (!vi->sq) | 2630 | if (!vi->sq) |
| 2631 | goto err_sq; | 2631 | goto err_sq; |
| 2632 | vi->rq = kzalloc(sizeof(*vi->rq) * vi->max_queue_pairs, GFP_KERNEL); | 2632 | vi->rq = kcalloc(vi->max_queue_pairs, sizeof(*vi->rq), GFP_KERNEL); |
| 2633 | if (!vi->rq) | 2633 | if (!vi->rq) |
| 2634 | goto err_rq; | 2634 | goto err_rq; |
| 2635 | 2635 | ||
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c index 4205dfd19da3..9b09c9d0d0fb 100644 --- a/drivers/net/wan/fsl_ucc_hdlc.c +++ b/drivers/net/wan/fsl_ucc_hdlc.c | |||
| @@ -198,12 +198,14 @@ static int uhdlc_init(struct ucc_hdlc_private *priv) | |||
| 198 | goto free_tx_bd; | 198 | goto free_tx_bd; |
| 199 | } | 199 | } |
| 200 | 200 | ||
| 201 | priv->rx_skbuff = kzalloc(priv->rx_ring_size * sizeof(*priv->rx_skbuff), | 201 | priv->rx_skbuff = kcalloc(priv->rx_ring_size, |
| 202 | sizeof(*priv->rx_skbuff), | ||
| 202 | GFP_KERNEL); | 203 | GFP_KERNEL); |
| 203 | if (!priv->rx_skbuff) | 204 | if (!priv->rx_skbuff) |
| 204 | goto free_ucc_pram; | 205 | goto free_ucc_pram; |
| 205 | 206 | ||
| 206 | priv->tx_skbuff = kzalloc(priv->tx_ring_size * sizeof(*priv->tx_skbuff), | 207 | priv->tx_skbuff = kcalloc(priv->tx_ring_size, |
| 208 | sizeof(*priv->tx_skbuff), | ||
| 207 | GFP_KERNEL); | 209 | GFP_KERNEL); |
| 208 | if (!priv->tx_skbuff) | 210 | if (!priv->tx_skbuff) |
| 209 | goto free_rx_skbuff; | 211 | goto free_rx_skbuff; |
diff --git a/drivers/net/wireless/ath/ath10k/htt_rx.c b/drivers/net/wireless/ath/ath10k/htt_rx.c index bd23f6940488..c72d8af122a2 100644 --- a/drivers/net/wireless/ath/ath10k/htt_rx.c +++ b/drivers/net/wireless/ath/ath10k/htt_rx.c | |||
| @@ -582,7 +582,7 @@ int ath10k_htt_rx_alloc(struct ath10k_htt *htt) | |||
| 582 | } | 582 | } |
| 583 | 583 | ||
| 584 | htt->rx_ring.netbufs_ring = | 584 | htt->rx_ring.netbufs_ring = |
| 585 | kzalloc(htt->rx_ring.size * sizeof(struct sk_buff *), | 585 | kcalloc(htt->rx_ring.size, sizeof(struct sk_buff *), |
| 586 | GFP_KERNEL); | 586 | GFP_KERNEL); |
| 587 | if (!htt->rx_ring.netbufs_ring) | 587 | if (!htt->rx_ring.netbufs_ring) |
| 588 | goto err_netbuf; | 588 | goto err_netbuf; |
diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c index 2e34a1fc5ba6..8c49a26fc571 100644 --- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c +++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c | |||
| @@ -155,7 +155,7 @@ ath10k_wmi_tlv_parse_alloc(struct ath10k *ar, const void *ptr, | |||
| 155 | const void **tb; | 155 | const void **tb; |
| 156 | int ret; | 156 | int ret; |
| 157 | 157 | ||
| 158 | tb = kzalloc(sizeof(*tb) * WMI_TLV_TAG_MAX, gfp); | 158 | tb = kcalloc(WMI_TLV_TAG_MAX, sizeof(*tb), gfp); |
| 159 | if (!tb) | 159 | if (!tb) |
| 160 | return ERR_PTR(-ENOMEM); | 160 | return ERR_PTR(-ENOMEM); |
| 161 | 161 | ||
diff --git a/drivers/net/wireless/ath/ath5k/debug.c b/drivers/net/wireless/ath/ath5k/debug.c index 3513bbec4639..e01faf641288 100644 --- a/drivers/net/wireless/ath/ath5k/debug.c +++ b/drivers/net/wireless/ath/ath5k/debug.c | |||
| @@ -931,7 +931,7 @@ static int open_file_eeprom(struct inode *inode, struct file *file) | |||
| 931 | 931 | ||
| 932 | /* Create buffer and read in eeprom */ | 932 | /* Create buffer and read in eeprom */ |
| 933 | 933 | ||
| 934 | buf = vmalloc(eesize * 2); | 934 | buf = vmalloc(array_size(eesize, 2)); |
| 935 | if (!buf) { | 935 | if (!buf) { |
| 936 | ret = -ENOMEM; | 936 | ret = -ENOMEM; |
| 937 | goto err; | 937 | goto err; |
diff --git a/drivers/net/wireless/ath/ath5k/phy.c b/drivers/net/wireless/ath/ath5k/phy.c index 641b13a279e1..b1b8bc326830 100644 --- a/drivers/net/wireless/ath/ath5k/phy.c +++ b/drivers/net/wireless/ath/ath5k/phy.c | |||
| @@ -890,7 +890,8 @@ ath5k_hw_rfregs_init(struct ath5k_hw *ah, | |||
| 890 | * ah->ah_rf_banks based on ah->ah_rf_banks_size | 890 | * ah->ah_rf_banks based on ah->ah_rf_banks_size |
| 891 | * we set above */ | 891 | * we set above */ |
| 892 | if (ah->ah_rf_banks == NULL) { | 892 | if (ah->ah_rf_banks == NULL) { |
| 893 | ah->ah_rf_banks = kmalloc(sizeof(u32) * ah->ah_rf_banks_size, | 893 | ah->ah_rf_banks = kmalloc_array(ah->ah_rf_banks_size, |
| 894 | sizeof(u32), | ||
| 894 | GFP_KERNEL); | 895 | GFP_KERNEL); |
| 895 | if (ah->ah_rf_banks == NULL) { | 896 | if (ah->ah_rf_banks == NULL) { |
| 896 | ATH5K_ERR(ah, "out of memory\n"); | 897 | ATH5K_ERR(ah, "out of memory\n"); |
diff --git a/drivers/net/wireless/ath/ath6kl/cfg80211.c b/drivers/net/wireless/ath/ath6kl/cfg80211.c index 2ba8cf3f38af..0687697d5e2d 100644 --- a/drivers/net/wireless/ath/ath6kl/cfg80211.c +++ b/drivers/net/wireless/ath/ath6kl/cfg80211.c | |||
| @@ -1041,7 +1041,7 @@ static int ath6kl_cfg80211_scan(struct wiphy *wiphy, | |||
| 1041 | 1041 | ||
| 1042 | n_channels = request->n_channels; | 1042 | n_channels = request->n_channels; |
| 1043 | 1043 | ||
| 1044 | channels = kzalloc(n_channels * sizeof(u16), GFP_KERNEL); | 1044 | channels = kcalloc(n_channels, sizeof(u16), GFP_KERNEL); |
| 1045 | if (channels == NULL) { | 1045 | if (channels == NULL) { |
| 1046 | ath6kl_warn("failed to set scan channels, scan all channels"); | 1046 | ath6kl_warn("failed to set scan channels, scan all channels"); |
| 1047 | n_channels = 0; | 1047 | n_channels = 0; |
diff --git a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c index 6343cc91953e..34e100940284 100644 --- a/drivers/net/wireless/ath/ath9k/ar9003_paprd.c +++ b/drivers/net/wireless/ath/ath9k/ar9003_paprd.c | |||
| @@ -925,7 +925,7 @@ int ar9003_paprd_create_curve(struct ath_hw *ah, | |||
| 925 | 925 | ||
| 926 | memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain])); | 926 | memset(caldata->pa_table[chain], 0, sizeof(caldata->pa_table[chain])); |
| 927 | 927 | ||
| 928 | buf = kmalloc(2 * 48 * sizeof(u32), GFP_KERNEL); | 928 | buf = kmalloc_array(2 * 48, sizeof(u32), GFP_KERNEL); |
| 929 | if (!buf) | 929 | if (!buf) |
| 930 | return -ENOMEM; | 930 | return -ENOMEM; |
| 931 | 931 | ||
diff --git a/drivers/net/wireless/ath/ath9k/hw.c b/drivers/net/wireless/ath/ath9k/hw.c index 6b37036b2d36..e60bea4604e4 100644 --- a/drivers/net/wireless/ath/ath9k/hw.c +++ b/drivers/net/wireless/ath/ath9k/hw.c | |||
| @@ -127,13 +127,13 @@ void ath9k_hw_read_array(struct ath_hw *ah, u32 array[][2], int size) | |||
| 127 | u32 *tmp_reg_list, *tmp_data; | 127 | u32 *tmp_reg_list, *tmp_data; |
| 128 | int i; | 128 | int i; |
| 129 | 129 | ||
| 130 | tmp_reg_list = kmalloc(size * sizeof(u32), GFP_KERNEL); | 130 | tmp_reg_list = kmalloc_array(size, sizeof(u32), GFP_KERNEL); |
| 131 | if (!tmp_reg_list) { | 131 | if (!tmp_reg_list) { |
| 132 | dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__); | 132 | dev_err(ah->dev, "%s: tmp_reg_list: alloc filed\n", __func__); |
| 133 | return; | 133 | return; |
| 134 | } | 134 | } |
| 135 | 135 | ||
| 136 | tmp_data = kmalloc(size * sizeof(u32), GFP_KERNEL); | 136 | tmp_data = kmalloc_array(size, sizeof(u32), GFP_KERNEL); |
| 137 | if (!tmp_data) { | 137 | if (!tmp_data) { |
| 138 | dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__); | 138 | dev_err(ah->dev, "%s tmp_data: alloc filed\n", __func__); |
| 139 | goto error_tmp_data; | 139 | goto error_tmp_data; |
diff --git a/drivers/net/wireless/ath/carl9170/main.c b/drivers/net/wireless/ath/carl9170/main.c index 29e93c953d93..7f1bdea742b8 100644 --- a/drivers/net/wireless/ath/carl9170/main.c +++ b/drivers/net/wireless/ath/carl9170/main.c | |||
| @@ -1958,7 +1958,7 @@ static int carl9170_parse_eeprom(struct ar9170 *ar) | |||
| 1958 | if (!bands) | 1958 | if (!bands) |
| 1959 | return -EINVAL; | 1959 | return -EINVAL; |
| 1960 | 1960 | ||
| 1961 | ar->survey = kzalloc(sizeof(struct survey_info) * chans, GFP_KERNEL); | 1961 | ar->survey = kcalloc(chans, sizeof(struct survey_info), GFP_KERNEL); |
| 1962 | if (!ar->survey) | 1962 | if (!ar->survey) |
| 1963 | return -ENOMEM; | 1963 | return -ENOMEM; |
| 1964 | ar->num_channels = chans; | 1964 | ar->num_channels = chans; |
| @@ -1988,8 +1988,9 @@ int carl9170_register(struct ar9170 *ar) | |||
| 1988 | if (WARN_ON(ar->mem_bitmap)) | 1988 | if (WARN_ON(ar->mem_bitmap)) |
| 1989 | return -EINVAL; | 1989 | return -EINVAL; |
| 1990 | 1990 | ||
| 1991 | ar->mem_bitmap = kzalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG) * | 1991 | ar->mem_bitmap = kcalloc(roundup(ar->fw.mem_blocks, BITS_PER_LONG), |
| 1992 | sizeof(unsigned long), GFP_KERNEL); | 1992 | sizeof(unsigned long), |
| 1993 | GFP_KERNEL); | ||
| 1993 | 1994 | ||
| 1994 | if (!ar->mem_bitmap) | 1995 | if (!ar->mem_bitmap) |
| 1995 | return -ENOMEM; | 1996 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/b43/phy_n.c b/drivers/net/wireless/broadcom/b43/phy_n.c index f2a2f41e3c96..44ab080d6518 100644 --- a/drivers/net/wireless/broadcom/b43/phy_n.c +++ b/drivers/net/wireless/broadcom/b43/phy_n.c | |||
| @@ -1518,7 +1518,7 @@ static int b43_nphy_load_samples(struct b43_wldev *dev, | |||
| 1518 | u16 i; | 1518 | u16 i; |
| 1519 | u32 *data; | 1519 | u32 *data; |
| 1520 | 1520 | ||
| 1521 | data = kzalloc(len * sizeof(u32), GFP_KERNEL); | 1521 | data = kcalloc(len, sizeof(u32), GFP_KERNEL); |
| 1522 | if (!data) { | 1522 | if (!data) { |
| 1523 | b43err(dev->wl, "allocation for samples loading failed\n"); | 1523 | b43err(dev->wl, "allocation for samples loading failed\n"); |
| 1524 | return -ENOMEM; | 1524 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/b43legacy/main.c b/drivers/net/wireless/broadcom/b43legacy/main.c index f1e3dad57629..55f411925960 100644 --- a/drivers/net/wireless/broadcom/b43legacy/main.c +++ b/drivers/net/wireless/broadcom/b43legacy/main.c | |||
| @@ -3300,8 +3300,8 @@ static int b43legacy_wireless_core_init(struct b43legacy_wldev *dev) | |||
| 3300 | 3300 | ||
| 3301 | if ((phy->type == B43legacy_PHYTYPE_B) || | 3301 | if ((phy->type == B43legacy_PHYTYPE_B) || |
| 3302 | (phy->type == B43legacy_PHYTYPE_G)) { | 3302 | (phy->type == B43legacy_PHYTYPE_G)) { |
| 3303 | phy->_lo_pairs = kzalloc(sizeof(struct b43legacy_lopair) | 3303 | phy->_lo_pairs = kcalloc(B43legacy_LO_COUNT, |
| 3304 | * B43legacy_LO_COUNT, | 3304 | sizeof(struct b43legacy_lopair), |
| 3305 | GFP_KERNEL); | 3305 | GFP_KERNEL); |
| 3306 | if (!phy->_lo_pairs) | 3306 | if (!phy->_lo_pairs) |
| 3307 | return -ENOMEM; | 3307 | return -ENOMEM; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c index 49d37ad96958..c40ba8855cd5 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/msgbuf.c | |||
| @@ -1486,8 +1486,9 @@ int brcmf_proto_msgbuf_attach(struct brcmf_pub *drvr) | |||
| 1486 | (struct brcmf_commonring **)if_msgbuf->commonrings; | 1486 | (struct brcmf_commonring **)if_msgbuf->commonrings; |
| 1487 | msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings; | 1487 | msgbuf->flowrings = (struct brcmf_commonring **)if_msgbuf->flowrings; |
| 1488 | msgbuf->max_flowrings = if_msgbuf->max_flowrings; | 1488 | msgbuf->max_flowrings = if_msgbuf->max_flowrings; |
| 1489 | msgbuf->flowring_dma_handle = kzalloc(msgbuf->max_flowrings * | 1489 | msgbuf->flowring_dma_handle = |
| 1490 | sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL); | 1490 | kcalloc(msgbuf->max_flowrings, |
| 1491 | sizeof(*msgbuf->flowring_dma_handle), GFP_KERNEL); | ||
| 1491 | if (!msgbuf->flowring_dma_handle) | 1492 | if (!msgbuf->flowring_dma_handle) |
| 1492 | goto fail; | 1493 | goto fail; |
| 1493 | 1494 | ||
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c index 4b2149b48362..3e9c4f2f5dd1 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmfmac/p2p.c | |||
| @@ -1058,7 +1058,7 @@ static s32 brcmf_p2p_act_frm_search(struct brcmf_p2p_info *p2p, u16 channel) | |||
| 1058 | channel_cnt = AF_PEER_SEARCH_CNT; | 1058 | channel_cnt = AF_PEER_SEARCH_CNT; |
| 1059 | else | 1059 | else |
| 1060 | channel_cnt = SOCIAL_CHAN_CNT; | 1060 | channel_cnt = SOCIAL_CHAN_CNT; |
| 1061 | default_chan_list = kzalloc(channel_cnt * sizeof(*default_chan_list), | 1061 | default_chan_list = kcalloc(channel_cnt, sizeof(*default_chan_list), |
| 1062 | GFP_KERNEL); | 1062 | GFP_KERNEL); |
| 1063 | if (default_chan_list == NULL) { | 1063 | if (default_chan_list == NULL) { |
| 1064 | brcmf_err("channel list allocation failed\n"); | 1064 | brcmf_err("channel list allocation failed\n"); |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c index 0a14942b8216..7d4e8f589fdc 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/main.c | |||
| @@ -507,7 +507,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 507 | wlc->hw->wlc = wlc; | 507 | wlc->hw->wlc = wlc; |
| 508 | 508 | ||
| 509 | wlc->hw->bandstate[0] = | 509 | wlc->hw->bandstate[0] = |
| 510 | kzalloc(sizeof(struct brcms_hw_band) * MAXBANDS, GFP_ATOMIC); | 510 | kcalloc(MAXBANDS, sizeof(struct brcms_hw_band), GFP_ATOMIC); |
| 511 | if (wlc->hw->bandstate[0] == NULL) { | 511 | if (wlc->hw->bandstate[0] == NULL) { |
| 512 | *err = 1006; | 512 | *err = 1006; |
| 513 | goto fail; | 513 | goto fail; |
| @@ -521,7 +521,8 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 521 | } | 521 | } |
| 522 | 522 | ||
| 523 | wlc->modulecb = | 523 | wlc->modulecb = |
| 524 | kzalloc(sizeof(struct modulecb) * BRCMS_MAXMODULES, GFP_ATOMIC); | 524 | kcalloc(BRCMS_MAXMODULES, sizeof(struct modulecb), |
| 525 | GFP_ATOMIC); | ||
| 525 | if (wlc->modulecb == NULL) { | 526 | if (wlc->modulecb == NULL) { |
| 526 | *err = 1009; | 527 | *err = 1009; |
| 527 | goto fail; | 528 | goto fail; |
| @@ -553,7 +554,7 @@ brcms_c_attach_malloc(uint unit, uint *err, uint devid) | |||
| 553 | } | 554 | } |
| 554 | 555 | ||
| 555 | wlc->bandstate[0] = | 556 | wlc->bandstate[0] = |
| 556 | kzalloc(sizeof(struct brcms_band)*MAXBANDS, GFP_ATOMIC); | 557 | kcalloc(MAXBANDS, sizeof(struct brcms_band), GFP_ATOMIC); |
| 557 | if (wlc->bandstate[0] == NULL) { | 558 | if (wlc->bandstate[0] == NULL) { |
| 558 | *err = 1025; | 559 | *err = 1025; |
| 559 | goto fail; | 560 | goto fail; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c index 9d830d27b229..9fb0d9fbd939 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_lcn.c | |||
| @@ -1387,7 +1387,7 @@ wlc_lcnphy_rx_iq_cal(struct brcms_phy *pi, | |||
| 1387 | s16 *ptr; | 1387 | s16 *ptr; |
| 1388 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; | 1388 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
| 1389 | 1389 | ||
| 1390 | ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); | 1390 | ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC); |
| 1391 | if (NULL == ptr) | 1391 | if (NULL == ptr) |
| 1392 | return false; | 1392 | return false; |
| 1393 | if (module == 2) { | 1393 | if (module == 2) { |
| @@ -2670,7 +2670,7 @@ wlc_lcnphy_tx_iqlo_cal(struct brcms_phy *pi, | |||
| 2670 | u16 *values_to_save; | 2670 | u16 *values_to_save; |
| 2671 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; | 2671 | struct brcms_phy_lcnphy *pi_lcn = pi->u.pi_lcnphy; |
| 2672 | 2672 | ||
| 2673 | values_to_save = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); | 2673 | values_to_save = kmalloc_array(20, sizeof(u16), GFP_ATOMIC); |
| 2674 | if (NULL == values_to_save) | 2674 | if (NULL == values_to_save) |
| 2675 | return; | 2675 | return; |
| 2676 | 2676 | ||
| @@ -3678,11 +3678,11 @@ wlc_lcnphy_a1(struct brcms_phy *pi, int cal_type, int num_levels, | |||
| 3678 | u16 *phy_c32; | 3678 | u16 *phy_c32; |
| 3679 | phy_c21 = 0; | 3679 | phy_c21 = 0; |
| 3680 | phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; | 3680 | phy_c10 = phy_c13 = phy_c14 = phy_c8 = 0; |
| 3681 | ptr = kmalloc(sizeof(s16) * 131, GFP_ATOMIC); | 3681 | ptr = kmalloc_array(131, sizeof(s16), GFP_ATOMIC); |
| 3682 | if (NULL == ptr) | 3682 | if (NULL == ptr) |
| 3683 | return; | 3683 | return; |
| 3684 | 3684 | ||
| 3685 | phy_c32 = kmalloc(sizeof(u16) * 20, GFP_ATOMIC); | 3685 | phy_c32 = kmalloc_array(20, sizeof(u16), GFP_ATOMIC); |
| 3686 | if (NULL == phy_c32) { | 3686 | if (NULL == phy_c32) { |
| 3687 | kfree(ptr); | 3687 | kfree(ptr); |
| 3688 | return; | 3688 | return; |
diff --git a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c index 7e01981bc5c8..1a187557982e 100644 --- a/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c +++ b/drivers/net/wireless/broadcom/brcm80211/brcmsmac/phy/phy_n.c | |||
| @@ -23032,7 +23032,7 @@ wlc_phy_loadsampletable_nphy(struct brcms_phy *pi, struct cordic_iq *tone_buf, | |||
| 23032 | u16 t; | 23032 | u16 t; |
| 23033 | u32 *data_buf = NULL; | 23033 | u32 *data_buf = NULL; |
| 23034 | 23034 | ||
| 23035 | data_buf = kmalloc(sizeof(u32) * num_samps, GFP_ATOMIC); | 23035 | data_buf = kmalloc_array(num_samps, sizeof(u32), GFP_ATOMIC); |
| 23036 | if (data_buf == NULL) | 23036 | if (data_buf == NULL) |
| 23037 | return; | 23037 | return; |
| 23038 | 23038 | ||
| @@ -23074,7 +23074,8 @@ wlc_phy_gen_load_samples_nphy(struct brcms_phy *pi, u32 f_kHz, u16 max_val, | |||
| 23074 | tbl_len = (phy_bw << 1); | 23074 | tbl_len = (phy_bw << 1); |
| 23075 | } | 23075 | } |
| 23076 | 23076 | ||
| 23077 | tone_buf = kmalloc(sizeof(struct cordic_iq) * tbl_len, GFP_ATOMIC); | 23077 | tone_buf = kmalloc_array(tbl_len, sizeof(struct cordic_iq), |
| 23078 | GFP_ATOMIC); | ||
| 23078 | if (tone_buf == NULL) | 23079 | if (tone_buf == NULL) |
| 23079 | return 0; | 23080 | return 0; |
| 23080 | 23081 | ||
diff --git a/drivers/net/wireless/cisco/airo.c b/drivers/net/wireless/cisco/airo.c index ce0fbf83285f..72046e182745 100644 --- a/drivers/net/wireless/cisco/airo.c +++ b/drivers/net/wireless/cisco/airo.c | |||
| @@ -7127,7 +7127,7 @@ static int airo_get_aplist(struct net_device *dev, | |||
| 7127 | int i; | 7127 | int i; |
| 7128 | int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; | 7128 | int loseSync = capable(CAP_NET_ADMIN) ? 1: -1; |
| 7129 | 7129 | ||
| 7130 | qual = kmalloc(IW_MAX_AP * sizeof(*qual), GFP_KERNEL); | 7130 | qual = kmalloc_array(IW_MAX_AP, sizeof(*qual), GFP_KERNEL); |
| 7131 | if (!qual) | 7131 | if (!qual) |
| 7132 | return -ENOMEM; | 7132 | return -ENOMEM; |
| 7133 | 7133 | ||
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2100.c b/drivers/net/wireless/intel/ipw2x00/ipw2100.c index 7c4f550a1475..b8fd3cc90634 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2100.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2100.c | |||
| @@ -3445,8 +3445,9 @@ static int ipw2100_msg_allocate(struct ipw2100_priv *priv) | |||
| 3445 | dma_addr_t p; | 3445 | dma_addr_t p; |
| 3446 | 3446 | ||
| 3447 | priv->msg_buffers = | 3447 | priv->msg_buffers = |
| 3448 | kmalloc(IPW_COMMAND_POOL_SIZE * sizeof(struct ipw2100_tx_packet), | 3448 | kmalloc_array(IPW_COMMAND_POOL_SIZE, |
| 3449 | GFP_KERNEL); | 3449 | sizeof(struct ipw2100_tx_packet), |
| 3450 | GFP_KERNEL); | ||
| 3450 | if (!priv->msg_buffers) | 3451 | if (!priv->msg_buffers) |
| 3451 | return -ENOMEM; | 3452 | return -ENOMEM; |
| 3452 | 3453 | ||
| @@ -4587,9 +4588,9 @@ static int ipw2100_rx_allocate(struct ipw2100_priv *priv) | |||
| 4587 | /* | 4588 | /* |
| 4588 | * allocate packets | 4589 | * allocate packets |
| 4589 | */ | 4590 | */ |
| 4590 | priv->rx_buffers = kmalloc(RX_QUEUE_LENGTH * | 4591 | priv->rx_buffers = kmalloc_array(RX_QUEUE_LENGTH, |
| 4591 | sizeof(struct ipw2100_rx_packet), | 4592 | sizeof(struct ipw2100_rx_packet), |
| 4592 | GFP_KERNEL); | 4593 | GFP_KERNEL); |
| 4593 | if (!priv->rx_buffers) { | 4594 | if (!priv->rx_buffers) { |
| 4594 | IPW_DEBUG_INFO("can't allocate rx packet buffer table\n"); | 4595 | IPW_DEBUG_INFO("can't allocate rx packet buffer table\n"); |
| 4595 | 4596 | ||
diff --git a/drivers/net/wireless/intel/ipw2x00/ipw2200.c b/drivers/net/wireless/intel/ipw2x00/ipw2200.c index f26beeb6c5ff..8a858f7e36f4 100644 --- a/drivers/net/wireless/intel/ipw2x00/ipw2200.c +++ b/drivers/net/wireless/intel/ipw2x00/ipw2200.c | |||
| @@ -3208,13 +3208,13 @@ static int ipw_load_firmware(struct ipw_priv *priv, u8 * data, size_t len) | |||
| 3208 | 3208 | ||
| 3209 | IPW_DEBUG_TRACE("<< :\n"); | 3209 | IPW_DEBUG_TRACE("<< :\n"); |
| 3210 | 3210 | ||
| 3211 | virts = kmalloc(sizeof(void *) * CB_NUMBER_OF_ELEMENTS_SMALL, | 3211 | virts = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(void *), |
| 3212 | GFP_KERNEL); | 3212 | GFP_KERNEL); |
| 3213 | if (!virts) | 3213 | if (!virts) |
| 3214 | return -ENOMEM; | 3214 | return -ENOMEM; |
| 3215 | 3215 | ||
| 3216 | phys = kmalloc(sizeof(dma_addr_t) * CB_NUMBER_OF_ELEMENTS_SMALL, | 3216 | phys = kmalloc_array(CB_NUMBER_OF_ELEMENTS_SMALL, sizeof(dma_addr_t), |
| 3217 | GFP_KERNEL); | 3217 | GFP_KERNEL); |
| 3218 | if (!phys) { | 3218 | if (!phys) { |
| 3219 | kfree(virts); | 3219 | kfree(virts); |
| 3220 | return -ENOMEM; | 3220 | return -ENOMEM; |
| @@ -3782,7 +3782,7 @@ static int ipw_queue_tx_init(struct ipw_priv *priv, | |||
| 3782 | { | 3782 | { |
| 3783 | struct pci_dev *dev = priv->pci_dev; | 3783 | struct pci_dev *dev = priv->pci_dev; |
| 3784 | 3784 | ||
| 3785 | q->txb = kmalloc(sizeof(q->txb[0]) * count, GFP_KERNEL); | 3785 | q->txb = kmalloc_array(count, sizeof(q->txb[0]), GFP_KERNEL); |
| 3786 | if (!q->txb) { | 3786 | if (!q->txb) { |
| 3787 | IPW_ERROR("vmalloc for auxiliary BD structures failed\n"); | 3787 | IPW_ERROR("vmalloc for auxiliary BD structures failed\n"); |
| 3788 | return -ENOMEM; | 3788 | return -ENOMEM; |
diff --git a/drivers/net/wireless/intel/iwlegacy/common.c b/drivers/net/wireless/intel/iwlegacy/common.c index 063e19ced7c8..6514baf799fe 100644 --- a/drivers/net/wireless/intel/iwlegacy/common.c +++ b/drivers/net/wireless/intel/iwlegacy/common.c | |||
| @@ -922,7 +922,7 @@ il_init_channel_map(struct il_priv *il) | |||
| 922 | D_EEPROM("Parsing data for %d channels.\n", il->channel_count); | 922 | D_EEPROM("Parsing data for %d channels.\n", il->channel_count); |
| 923 | 923 | ||
| 924 | il->channel_info = | 924 | il->channel_info = |
| 925 | kzalloc(sizeof(struct il_channel_info) * il->channel_count, | 925 | kcalloc(il->channel_count, sizeof(struct il_channel_info), |
| 926 | GFP_KERNEL); | 926 | GFP_KERNEL); |
| 927 | if (!il->channel_info) { | 927 | if (!il->channel_info) { |
| 928 | IL_ERR("Could not allocate channel_info\n"); | 928 | IL_ERR("Could not allocate channel_info\n"); |
| @@ -3041,9 +3041,9 @@ il_tx_queue_init(struct il_priv *il, u32 txq_id) | |||
| 3041 | } | 3041 | } |
| 3042 | 3042 | ||
| 3043 | txq->meta = | 3043 | txq->meta = |
| 3044 | kzalloc(sizeof(struct il_cmd_meta) * actual_slots, GFP_KERNEL); | 3044 | kcalloc(actual_slots, sizeof(struct il_cmd_meta), GFP_KERNEL); |
| 3045 | txq->cmd = | 3045 | txq->cmd = |
| 3046 | kzalloc(sizeof(struct il_device_cmd *) * actual_slots, GFP_KERNEL); | 3046 | kcalloc(actual_slots, sizeof(struct il_device_cmd *), GFP_KERNEL); |
| 3047 | 3047 | ||
| 3048 | if (!txq->meta || !txq->cmd) | 3048 | if (!txq->meta || !txq->cmd) |
| 3049 | goto out_free_arrays; | 3049 | goto out_free_arrays; |
| @@ -3455,7 +3455,7 @@ il_init_geos(struct il_priv *il) | |||
| 3455 | } | 3455 | } |
| 3456 | 3456 | ||
| 3457 | channels = | 3457 | channels = |
| 3458 | kzalloc(sizeof(struct ieee80211_channel) * il->channel_count, | 3458 | kcalloc(il->channel_count, sizeof(struct ieee80211_channel), |
| 3459 | GFP_KERNEL); | 3459 | GFP_KERNEL); |
| 3460 | if (!channels) | 3460 | if (!channels) |
| 3461 | return -ENOMEM; | 3461 | return -ENOMEM; |
| @@ -4654,8 +4654,9 @@ il_alloc_txq_mem(struct il_priv *il) | |||
| 4654 | { | 4654 | { |
| 4655 | if (!il->txq) | 4655 | if (!il->txq) |
| 4656 | il->txq = | 4656 | il->txq = |
| 4657 | kzalloc(sizeof(struct il_tx_queue) * | 4657 | kcalloc(il->cfg->num_of_queues, |
| 4658 | il->cfg->num_of_queues, GFP_KERNEL); | 4658 | sizeof(struct il_tx_queue), |
| 4659 | GFP_KERNEL); | ||
| 4659 | if (!il->txq) { | 4660 | if (!il->txq) { |
| 4660 | IL_ERR("Not enough memory for txq\n"); | 4661 | IL_ERR("Not enough memory for txq\n"); |
| 4661 | return -ENOMEM; | 4662 | return -ENOMEM; |
diff --git a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c index 4b3753d78d03..11ecdf63b732 100644 --- a/drivers/net/wireless/intel/iwlwifi/mvm/scan.c +++ b/drivers/net/wireless/intel/iwlwifi/mvm/scan.c | |||
| @@ -564,7 +564,7 @@ iwl_mvm_config_sched_scan_profiles(struct iwl_mvm *mvm, | |||
| 564 | else | 564 | else |
| 565 | blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN; | 565 | blacklist_len = IWL_SCAN_MAX_BLACKLIST_LEN; |
| 566 | 566 | ||
| 567 | blacklist = kzalloc(sizeof(*blacklist) * blacklist_len, GFP_KERNEL); | 567 | blacklist = kcalloc(blacklist_len, sizeof(*blacklist), GFP_KERNEL); |
| 568 | if (!blacklist) | 568 | if (!blacklist) |
| 569 | return -ENOMEM; | 569 | return -ENOMEM; |
| 570 | 570 | ||
diff --git a/drivers/net/wireless/intersil/hostap/hostap_info.c b/drivers/net/wireless/intersil/hostap/hostap_info.c index de8a099a9386..da8c30f10d92 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_info.c +++ b/drivers/net/wireless/intersil/hostap/hostap_info.c | |||
| @@ -271,8 +271,9 @@ static void prism2_info_scanresults(local_info_t *local, unsigned char *buf, | |||
| 271 | left -= 4; | 271 | left -= 4; |
| 272 | 272 | ||
| 273 | new_count = left / sizeof(struct hfa384x_scan_result); | 273 | new_count = left / sizeof(struct hfa384x_scan_result); |
| 274 | results = kmalloc(new_count * sizeof(struct hfa384x_hostscan_result), | 274 | results = kmalloc_array(new_count, |
| 275 | GFP_ATOMIC); | 275 | sizeof(struct hfa384x_hostscan_result), |
| 276 | GFP_ATOMIC); | ||
| 276 | if (results == NULL) | 277 | if (results == NULL) |
| 277 | return; | 278 | return; |
| 278 | 279 | ||
diff --git a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c index c1bc0a6ef300..1ca9731d9b14 100644 --- a/drivers/net/wireless/intersil/hostap/hostap_ioctl.c +++ b/drivers/net/wireless/intersil/hostap/hostap_ioctl.c | |||
| @@ -513,8 +513,8 @@ static int prism2_ioctl_giwaplist(struct net_device *dev, | |||
| 513 | return -EOPNOTSUPP; | 513 | return -EOPNOTSUPP; |
| 514 | } | 514 | } |
| 515 | 515 | ||
| 516 | addr = kmalloc(sizeof(struct sockaddr) * IW_MAX_AP, GFP_KERNEL); | 516 | addr = kmalloc_array(IW_MAX_AP, sizeof(struct sockaddr), GFP_KERNEL); |
| 517 | qual = kmalloc(sizeof(struct iw_quality) * IW_MAX_AP, GFP_KERNEL); | 517 | qual = kmalloc_array(IW_MAX_AP, sizeof(struct iw_quality), GFP_KERNEL); |
| 518 | if (addr == NULL || qual == NULL) { | 518 | if (addr == NULL || qual == NULL) { |
| 519 | kfree(addr); | 519 | kfree(addr); |
| 520 | kfree(qual); | 520 | kfree(qual); |
diff --git a/drivers/net/wireless/intersil/p54/eeprom.c b/drivers/net/wireless/intersil/p54/eeprom.c index d4c73d39336f..de2ef95c386c 100644 --- a/drivers/net/wireless/intersil/p54/eeprom.c +++ b/drivers/net/wireless/intersil/p54/eeprom.c | |||
| @@ -161,8 +161,9 @@ static int p54_generate_band(struct ieee80211_hw *dev, | |||
| 161 | if (!tmp) | 161 | if (!tmp) |
| 162 | goto err_out; | 162 | goto err_out; |
| 163 | 163 | ||
| 164 | tmp->channels = kzalloc(sizeof(struct ieee80211_channel) * | 164 | tmp->channels = kcalloc(list->band_channel_num[band], |
| 165 | list->band_channel_num[band], GFP_KERNEL); | 165 | sizeof(struct ieee80211_channel), |
| 166 | GFP_KERNEL); | ||
| 166 | if (!tmp->channels) | 167 | if (!tmp->channels) |
| 167 | goto err_out; | 168 | goto err_out; |
| 168 | 169 | ||
| @@ -344,7 +345,7 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
| 344 | goto free; | 345 | goto free; |
| 345 | } | 346 | } |
| 346 | priv->chan_num = max_channel_num; | 347 | priv->chan_num = max_channel_num; |
| 347 | priv->survey = kzalloc(sizeof(struct survey_info) * max_channel_num, | 348 | priv->survey = kcalloc(max_channel_num, sizeof(struct survey_info), |
| 348 | GFP_KERNEL); | 349 | GFP_KERNEL); |
| 349 | if (!priv->survey) { | 350 | if (!priv->survey) { |
| 350 | ret = -ENOMEM; | 351 | ret = -ENOMEM; |
| @@ -352,8 +353,9 @@ static int p54_generate_channel_lists(struct ieee80211_hw *dev) | |||
| 352 | } | 353 | } |
| 353 | 354 | ||
| 354 | list->max_entries = max_channel_num; | 355 | list->max_entries = max_channel_num; |
| 355 | list->channels = kzalloc(sizeof(struct p54_channel_entry) * | 356 | list->channels = kcalloc(max_channel_num, |
| 356 | max_channel_num, GFP_KERNEL); | 357 | sizeof(struct p54_channel_entry), |
| 358 | GFP_KERNEL); | ||
| 357 | if (!list->channels) { | 359 | if (!list->channels) { |
| 358 | ret = -ENOMEM; | 360 | ret = -ENOMEM; |
| 359 | goto free; | 361 | goto free; |
diff --git a/drivers/net/wireless/intersil/prism54/oid_mgt.c b/drivers/net/wireless/intersil/prism54/oid_mgt.c index 6528ed5b9b1d..6d57e1cbcc07 100644 --- a/drivers/net/wireless/intersil/prism54/oid_mgt.c +++ b/drivers/net/wireless/intersil/prism54/oid_mgt.c | |||
| @@ -244,7 +244,7 @@ mgt_init(islpci_private *priv) | |||
| 244 | /* Alloc the cache */ | 244 | /* Alloc the cache */ |
| 245 | for (i = 0; i < OID_NUM_LAST; i++) { | 245 | for (i = 0; i < OID_NUM_LAST; i++) { |
| 246 | if (isl_oid[i].flags & OID_FLAG_CACHED) { | 246 | if (isl_oid[i].flags & OID_FLAG_CACHED) { |
| 247 | priv->mib[i] = kzalloc(isl_oid[i].size * | 247 | priv->mib[i] = kcalloc(isl_oid[i].size, |
| 248 | (isl_oid[i].range + 1), | 248 | (isl_oid[i].range + 1), |
| 249 | GFP_KERNEL); | 249 | GFP_KERNEL); |
| 250 | if (!priv->mib[i]) | 250 | if (!priv->mib[i]) |
diff --git a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c index 1edcddaf7b4b..7ab44cd32a9d 100644 --- a/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c +++ b/drivers/net/wireless/marvell/mwifiex/11n_rxreorder.c | |||
| @@ -399,8 +399,8 @@ mwifiex_11n_create_rx_reorder_tbl(struct mwifiex_private *priv, u8 *ta, | |||
| 399 | 399 | ||
| 400 | new_node->win_size = win_size; | 400 | new_node->win_size = win_size; |
| 401 | 401 | ||
| 402 | new_node->rx_reorder_ptr = kzalloc(sizeof(void *) * win_size, | 402 | new_node->rx_reorder_ptr = kcalloc(win_size, sizeof(void *), |
| 403 | GFP_KERNEL); | 403 | GFP_KERNEL); |
| 404 | if (!new_node->rx_reorder_ptr) { | 404 | if (!new_node->rx_reorder_ptr) { |
| 405 | kfree((u8 *) new_node); | 405 | kfree((u8 *) new_node); |
| 406 | mwifiex_dbg(priv->adapter, ERROR, | 406 | mwifiex_dbg(priv->adapter, ERROR, |
diff --git a/drivers/net/wireless/marvell/mwifiex/cfg80211.c b/drivers/net/wireless/marvell/mwifiex/cfg80211.c index a67e2d66ac9d..4b5ae9098504 100644 --- a/drivers/net/wireless/marvell/mwifiex/cfg80211.c +++ b/drivers/net/wireless/marvell/mwifiex/cfg80211.c | |||
| @@ -4242,8 +4242,8 @@ int mwifiex_init_channel_scan_gap(struct mwifiex_adapter *adapter) | |||
| 4242 | * additional active scan request for hidden SSIDs on passive channels. | 4242 | * additional active scan request for hidden SSIDs on passive channels. |
| 4243 | */ | 4243 | */ |
| 4244 | adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); | 4244 | adapter->num_in_chan_stats = 2 * (n_channels_bg + n_channels_a); |
| 4245 | adapter->chan_stats = vmalloc(sizeof(*adapter->chan_stats) * | 4245 | adapter->chan_stats = vmalloc(array_size(sizeof(*adapter->chan_stats), |
| 4246 | adapter->num_in_chan_stats); | 4246 | adapter->num_in_chan_stats)); |
| 4247 | 4247 | ||
| 4248 | if (!adapter->chan_stats) | 4248 | if (!adapter->chan_stats) |
| 4249 | return -ENOMEM; | 4249 | return -ENOMEM; |
diff --git a/drivers/net/wireless/marvell/mwifiex/sdio.c b/drivers/net/wireless/marvell/mwifiex/sdio.c index 47d2dcc3f28f..dfdcbc4f141a 100644 --- a/drivers/net/wireless/marvell/mwifiex/sdio.c +++ b/drivers/net/wireless/marvell/mwifiex/sdio.c | |||
| @@ -2106,15 +2106,16 @@ static int mwifiex_init_sdio(struct mwifiex_adapter *adapter) | |||
| 2106 | return -ENOMEM; | 2106 | return -ENOMEM; |
| 2107 | 2107 | ||
| 2108 | /* Allocate skb pointer buffers */ | 2108 | /* Allocate skb pointer buffers */ |
| 2109 | card->mpa_rx.skb_arr = kzalloc((sizeof(void *)) * | 2109 | card->mpa_rx.skb_arr = kcalloc(card->mp_agg_pkt_limit, sizeof(void *), |
| 2110 | card->mp_agg_pkt_limit, GFP_KERNEL); | 2110 | GFP_KERNEL); |
| 2111 | if (!card->mpa_rx.skb_arr) { | 2111 | if (!card->mpa_rx.skb_arr) { |
| 2112 | kfree(card->mp_regs); | 2112 | kfree(card->mp_regs); |
| 2113 | return -ENOMEM; | 2113 | return -ENOMEM; |
| 2114 | } | 2114 | } |
| 2115 | 2115 | ||
| 2116 | card->mpa_rx.len_arr = kzalloc(sizeof(*card->mpa_rx.len_arr) * | 2116 | card->mpa_rx.len_arr = kcalloc(card->mp_agg_pkt_limit, |
| 2117 | card->mp_agg_pkt_limit, GFP_KERNEL); | 2117 | sizeof(*card->mpa_rx.len_arr), |
| 2118 | GFP_KERNEL); | ||
| 2118 | if (!card->mpa_rx.len_arr) { | 2119 | if (!card->mpa_rx.len_arr) { |
| 2119 | kfree(card->mp_regs); | 2120 | kfree(card->mp_regs); |
| 2120 | kfree(card->mpa_rx.skb_arr); | 2121 | kfree(card->mpa_rx.skb_arr); |
diff --git a/drivers/net/wireless/mediatek/mt76/mac80211.c b/drivers/net/wireless/mediatek/mt76/mac80211.c index fcd079a96782..d62e34e7eadf 100644 --- a/drivers/net/wireless/mediatek/mt76/mac80211.c +++ b/drivers/net/wireless/mediatek/mt76/mac80211.c | |||
| @@ -181,7 +181,7 @@ mt76_init_sband(struct mt76_dev *dev, struct mt76_sband *msband, | |||
| 181 | if (!chanlist) | 181 | if (!chanlist) |
| 182 | return -ENOMEM; | 182 | return -ENOMEM; |
| 183 | 183 | ||
| 184 | msband->chan = devm_kzalloc(dev->dev, n_chan * sizeof(*msband->chan), | 184 | msband->chan = devm_kcalloc(dev->dev, n_chan, sizeof(*msband->chan), |
| 185 | GFP_KERNEL); | 185 | GFP_KERNEL); |
| 186 | if (!msband->chan) | 186 | if (!msband->chan) |
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
diff --git a/drivers/net/wireless/quantenna/qtnfmac/commands.c b/drivers/net/wireless/quantenna/qtnfmac/commands.c index 5eb143667539..c5d94a95e21a 100644 --- a/drivers/net/wireless/quantenna/qtnfmac/commands.c +++ b/drivers/net/wireless/quantenna/qtnfmac/commands.c | |||
| @@ -1216,7 +1216,7 @@ static int qtnf_parse_variable_mac_info(struct qtnf_wmac *mac, | |||
| 1216 | return -EINVAL; | 1216 | return -EINVAL; |
| 1217 | } | 1217 | } |
| 1218 | 1218 | ||
| 1219 | limits = kzalloc(sizeof(*limits) * rec->n_limits, | 1219 | limits = kcalloc(rec->n_limits, sizeof(*limits), |
| 1220 | GFP_KERNEL); | 1220 | GFP_KERNEL); |
| 1221 | if (!limits) | 1221 | if (!limits) |
| 1222 | return -ENOMEM; | 1222 | return -ENOMEM; |
diff --git a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c index 0eee479583b8..acc399b5574e 100644 --- a/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c +++ b/drivers/net/wireless/ralink/rt2x00/rt2x00debug.c | |||
| @@ -397,7 +397,7 @@ static ssize_t rt2x00debug_read_crypto_stats(struct file *file, | |||
| 397 | if (*offset) | 397 | if (*offset) |
| 398 | return 0; | 398 | return 0; |
| 399 | 399 | ||
| 400 | data = kzalloc((1 + CIPHER_MAX) * MAX_LINE_LENGTH, GFP_KERNEL); | 400 | data = kcalloc(1 + CIPHER_MAX, MAX_LINE_LENGTH, GFP_KERNEL); |
| 401 | if (!data) | 401 | if (!data) |
| 402 | return -ENOMEM; | 402 | return -ENOMEM; |
| 403 | 403 | ||
diff --git a/drivers/net/wireless/realtek/rtlwifi/efuse.c b/drivers/net/wireless/realtek/rtlwifi/efuse.c index fd13d4ef53b8..9729e51fce38 100644 --- a/drivers/net/wireless/realtek/rtlwifi/efuse.c +++ b/drivers/net/wireless/realtek/rtlwifi/efuse.c | |||
| @@ -258,8 +258,8 @@ void read_efuse(struct ieee80211_hw *hw, u16 _offset, u16 _size_byte, u8 *pbuf) | |||
| 258 | } | 258 | } |
| 259 | 259 | ||
| 260 | /* allocate memory for efuse_tbl and efuse_word */ | 260 | /* allocate memory for efuse_tbl and efuse_word */ |
| 261 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE] * | 261 | efuse_tbl = kzalloc(rtlpriv->cfg->maps[EFUSE_HWSET_MAX_SIZE], |
| 262 | sizeof(u8), GFP_ATOMIC); | 262 | GFP_ATOMIC); |
| 263 | if (!efuse_tbl) | 263 | if (!efuse_tbl) |
| 264 | return; | 264 | return; |
| 265 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); | 265 | efuse_word = kcalloc(EFUSE_MAX_WORD_UNIT, sizeof(u16 *), GFP_ATOMIC); |
diff --git a/drivers/net/wireless/realtek/rtlwifi/usb.c b/drivers/net/wireless/realtek/rtlwifi/usb.c index ce3103bb8ebb..f9faffc498bc 100644 --- a/drivers/net/wireless/realtek/rtlwifi/usb.c +++ b/drivers/net/wireless/realtek/rtlwifi/usb.c | |||
| @@ -1048,7 +1048,7 @@ int rtl_usb_probe(struct usb_interface *intf, | |||
| 1048 | } | 1048 | } |
| 1049 | rtlpriv = hw->priv; | 1049 | rtlpriv = hw->priv; |
| 1050 | rtlpriv->hw = hw; | 1050 | rtlpriv->hw = hw; |
| 1051 | rtlpriv->usb_data = kzalloc(RTL_USB_MAX_RX_COUNT * sizeof(u32), | 1051 | rtlpriv->usb_data = kcalloc(RTL_USB_MAX_RX_COUNT, sizeof(u32), |
| 1052 | GFP_KERNEL); | 1052 | GFP_KERNEL); |
| 1053 | if (!rtlpriv->usb_data) | 1053 | if (!rtlpriv->usb_data) |
| 1054 | return -ENOMEM; | 1054 | return -ENOMEM; |
diff --git a/drivers/net/wireless/st/cw1200/queue.c b/drivers/net/wireless/st/cw1200/queue.c index 5153d2cfd991..7c31b63b8258 100644 --- a/drivers/net/wireless/st/cw1200/queue.c +++ b/drivers/net/wireless/st/cw1200/queue.c | |||
| @@ -154,7 +154,7 @@ int cw1200_queue_stats_init(struct cw1200_queue_stats *stats, | |||
| 154 | spin_lock_init(&stats->lock); | 154 | spin_lock_init(&stats->lock); |
| 155 | init_waitqueue_head(&stats->wait_link_id_empty); | 155 | init_waitqueue_head(&stats->wait_link_id_empty); |
| 156 | 156 | ||
| 157 | stats->link_map_cache = kzalloc(sizeof(int) * map_capacity, | 157 | stats->link_map_cache = kcalloc(map_capacity, sizeof(int), |
| 158 | GFP_KERNEL); | 158 | GFP_KERNEL); |
| 159 | if (!stats->link_map_cache) | 159 | if (!stats->link_map_cache) |
| 160 | return -ENOMEM; | 160 | return -ENOMEM; |
| @@ -181,13 +181,13 @@ int cw1200_queue_init(struct cw1200_queue *queue, | |||
| 181 | spin_lock_init(&queue->lock); | 181 | spin_lock_init(&queue->lock); |
| 182 | timer_setup(&queue->gc, cw1200_queue_gc, 0); | 182 | timer_setup(&queue->gc, cw1200_queue_gc, 0); |
| 183 | 183 | ||
| 184 | queue->pool = kzalloc(sizeof(struct cw1200_queue_item) * capacity, | 184 | queue->pool = kcalloc(capacity, sizeof(struct cw1200_queue_item), |
| 185 | GFP_KERNEL); | 185 | GFP_KERNEL); |
| 186 | if (!queue->pool) | 186 | if (!queue->pool) |
| 187 | return -ENOMEM; | 187 | return -ENOMEM; |
| 188 | 188 | ||
| 189 | queue->link_map_cache = kzalloc(sizeof(int) * stats->map_capacity, | 189 | queue->link_map_cache = kcalloc(stats->map_capacity, sizeof(int), |
| 190 | GFP_KERNEL); | 190 | GFP_KERNEL); |
| 191 | if (!queue->link_map_cache) { | 191 | if (!queue->link_map_cache) { |
| 192 | kfree(queue->pool); | 192 | kfree(queue->pool); |
| 193 | queue->pool = NULL; | 193 | queue->pool = NULL; |
diff --git a/drivers/net/wireless/st/cw1200/scan.c b/drivers/net/wireless/st/cw1200/scan.c index cc2ce60f4f09..67213f11acbd 100644 --- a/drivers/net/wireless/st/cw1200/scan.c +++ b/drivers/net/wireless/st/cw1200/scan.c | |||
| @@ -230,9 +230,9 @@ void cw1200_scan_work(struct work_struct *work) | |||
| 230 | scan.type = WSM_SCAN_TYPE_BACKGROUND; | 230 | scan.type = WSM_SCAN_TYPE_BACKGROUND; |
| 231 | scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND; | 231 | scan.flags = WSM_SCAN_FLAG_FORCE_BACKGROUND; |
| 232 | } | 232 | } |
| 233 | scan.ch = kzalloc( | 233 | scan.ch = kcalloc(it - priv->scan.curr, |
| 234 | sizeof(struct wsm_scan_ch) * (it - priv->scan.curr), | 234 | sizeof(struct wsm_scan_ch), |
| 235 | GFP_KERNEL); | 235 | GFP_KERNEL); |
| 236 | if (!scan.ch) { | 236 | if (!scan.ch) { |
| 237 | priv->scan.status = -ENOMEM; | 237 | priv->scan.status = -ENOMEM; |
| 238 | goto fail; | 238 | goto fail; |
diff --git a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c index b01b44a5d16e..1f6d9f357e57 100644 --- a/drivers/net/wireless/zydas/zd1211rw/zd_mac.c +++ b/drivers/net/wireless/zydas/zd1211rw/zd_mac.c | |||
| @@ -732,7 +732,8 @@ static int zd_mac_config_beacon(struct ieee80211_hw *hw, struct sk_buff *beacon, | |||
| 732 | 732 | ||
| 733 | /* Alloc memory for full beacon write at once. */ | 733 | /* Alloc memory for full beacon write at once. */ |
| 734 | num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len; | 734 | num_cmds = 1 + zd_chip_is_zd1211b(&mac->chip) + full_len; |
| 735 | ioreqs = kmalloc(num_cmds * sizeof(struct zd_ioreq32), GFP_KERNEL); | 735 | ioreqs = kmalloc_array(num_cmds, sizeof(struct zd_ioreq32), |
| 736 | GFP_KERNEL); | ||
| 736 | if (!ioreqs) { | 737 | if (!ioreqs) { |
| 737 | r = -ENOMEM; | 738 | r = -ENOMEM; |
| 738 | goto out_nofree; | 739 | goto out_nofree; |
diff --git a/drivers/net/xen-netback/xenbus.c b/drivers/net/xen-netback/xenbus.c index e1aef253601e..cd51492ae6c2 100644 --- a/drivers/net/xen-netback/xenbus.c +++ b/drivers/net/xen-netback/xenbus.c | |||
| @@ -977,8 +977,8 @@ static void connect(struct backend_info *be) | |||
| 977 | } | 977 | } |
| 978 | 978 | ||
| 979 | /* Use the number of queues requested by the frontend */ | 979 | /* Use the number of queues requested by the frontend */ |
| 980 | be->vif->queues = vzalloc(requested_num_queues * | 980 | be->vif->queues = vzalloc(array_size(requested_num_queues, |
| 981 | sizeof(struct xenvif_queue)); | 981 | sizeof(struct xenvif_queue))); |
| 982 | if (!be->vif->queues) { | 982 | if (!be->vif->queues) { |
| 983 | xenbus_dev_fatal(dev, -ENOMEM, | 983 | xenbus_dev_fatal(dev, -ENOMEM, |
| 984 | "allocating queues"); | 984 | "allocating queues"); |
