Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit baeb2ffa authored by Joe Perches's avatar Joe Perches Committed by David S. Miller
Browse files

drivers/net: Convert unbounded kzalloc calls to kcalloc



These changes may be slightly safer in some instances.

There are other kzalloc calls with a multiply, but those
calls are typically "small fixed #" * sizeof(some pointer)"
and those are not converted.

Signed-off-by: default avatarJoe Perches <joe@perches.com>
Acked-by: default avatarGertjan van Wingerde <gwingerde@gmail.com>
Acked-by: default avatarLuciano Coelho <luciano.coelho@nokia.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 5a68d5ee
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1022,7 +1022,7 @@ static int cnic_alloc_bnx2x_context(struct cnic_dev *dev)
	if (blks > cp->ethdev->ctx_tbl_len)
		return -ENOMEM;

	cp->ctx_arr = kzalloc(blks * sizeof(struct cnic_ctx), GFP_KERNEL);
	cp->ctx_arr = kcalloc(blks, sizeof(struct cnic_ctx), GFP_KERNEL);
	if (cp->ctx_arr == NULL)
		return -ENOMEM;

+2 −2
Original line number Diff line number Diff line
@@ -180,7 +180,7 @@ static void ehea_update_firmware_handles(void)
			 num_portres * EHEA_NUM_PORTRES_FW_HANDLES;

	if (num_fw_handles) {
		arr = kzalloc(num_fw_handles * sizeof(*arr), GFP_KERNEL);
		arr = kcalloc(num_fw_handles, sizeof(*arr), GFP_KERNEL);
		if (!arr)
			goto out;  /* Keep the existing array */
	} else
@@ -265,7 +265,7 @@ static void ehea_update_bcmc_registrations(void)
		}

	if (num_registrations) {
		arr = kzalloc(num_registrations * sizeof(*arr), GFP_ATOMIC);
		arr = kcalloc(num_registrations, sizeof(*arr), GFP_ATOMIC);
		if (!arr)
			goto out;  /* Keep the existing array */
	} else
+1 −1
Original line number Diff line number Diff line
@@ -188,7 +188,7 @@ int mlx4_buf_alloc(struct mlx4_dev *dev, int size, int max_direct,
		buf->nbufs       = (size + PAGE_SIZE - 1) / PAGE_SIZE;
		buf->npages      = buf->nbufs;
		buf->page_shift  = PAGE_SHIFT;
		buf->page_list   = kzalloc(buf->nbufs * sizeof *buf->page_list,
		buf->page_list   = kcalloc(buf->nbufs, sizeof(*buf->page_list),
					   GFP_KERNEL);
		if (!buf->page_list)
			return -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -322,7 +322,7 @@ int mlx4_en_create_rx_ring(struct mlx4_en_priv *priv,
	ring->lro.ip_summed_aggr = CHECKSUM_UNNECESSARY;
	ring->lro.max_desc = mdev->profile.num_lro;
	ring->lro.max_aggr = MAX_SKB_FRAGS;
	ring->lro.lro_arr = kzalloc(mdev->profile.num_lro *
	ring->lro.lro_arr = kcalloc(mdev->profile.num_lro,
				    sizeof(struct net_lro_desc),
				    GFP_KERNEL);
	if (!ring->lro.lro_arr) {
+1 −1
Original line number Diff line number Diff line
@@ -85,7 +85,7 @@ u64 mlx4_make_profile(struct mlx4_dev *dev,
	struct mlx4_resource tmp;
	int i, j;

	profile = kzalloc(MLX4_RES_NUM * sizeof *profile, GFP_KERNEL);
	profile = kcalloc(MLX4_RES_NUM, sizeof(*profile), GFP_KERNEL);
	if (!profile)
		return -ENOMEM;

Loading