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

Commit 329e0989 authored by Kees Cook's avatar Kees Cook
Browse files

treewide: Replace more open-coded allocation size multiplications



As done treewide earlier, this catches several more open-coded
allocation size calculations that were added to the kernel during the
merge window. This performs the following mechanical transformations
using Coccinelle:

	kvmalloc(a * b, ...) -> kvmalloc_array(a, b, ...)
	kvzalloc(a * b, ...) -> kvcalloc(a, b, ...)
	devm_kzalloc(..., a * b, ...) -> devm_kcalloc(..., a, b, ...)

Signed-off-by: default avatarKees Cook <keescook@chromium.org>
parent 57361846
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -1322,7 +1322,7 @@ static int qca_init_regulators(struct qca_power *qca,
{
	int i;

	qca->vreg_bulk = devm_kzalloc(qca->dev, num_vregs *
	qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs,
				      sizeof(struct regulator_bulk_data),
				      GFP_KERNEL);
	if (!qca->vreg_bulk)
+5 −3
Original line number Diff line number Diff line
@@ -1044,7 +1044,8 @@ static int safexcel_probe(struct platform_device *pdev)

	safexcel_configure(priv);

	priv->ring = devm_kzalloc(dev, priv->config.rings * sizeof(*priv->ring),
	priv->ring = devm_kcalloc(dev, priv->config.rings,
				  sizeof(*priv->ring),
				  GFP_KERNEL);
	if (!priv->ring) {
		ret = -ENOMEM;
@@ -1063,8 +1064,9 @@ static int safexcel_probe(struct platform_device *pdev)
		if (ret)
			goto err_reg_clk;

		priv->ring[i].rdr_req = devm_kzalloc(dev,
			sizeof(priv->ring[i].rdr_req) * EIP197_DEFAULT_RING_SIZE,
		priv->ring[i].rdr_req = devm_kcalloc(dev,
			EIP197_DEFAULT_RING_SIZE,
			sizeof(priv->ring[i].rdr_req),
			GFP_KERNEL);
		if (!priv->ring[i].rdr_req) {
			ret = -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -600,7 +600,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
	}

	mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]);
	mtk_crtc->planes = devm_kzalloc(dev, mtk_crtc->layer_nr *
	mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr,
					sizeof(struct drm_plane),
					GFP_KERNEL);

+2 −2
Original line number Diff line number Diff line
@@ -153,8 +153,8 @@ int msm_dss_parse_clock(struct platform_device *pdev,
		return 0;
	}

	mp->clk_config = devm_kzalloc(&pdev->dev,
				      sizeof(struct dss_clk) * num_clk,
	mp->clk_config = devm_kcalloc(&pdev->dev,
				      num_clk, sizeof(struct dss_clk),
				      GFP_KERNEL);
	if (!mp->clk_config)
		return -ENOMEM;
+1 −1
Original line number Diff line number Diff line
@@ -908,7 +908,7 @@ static int npcm7xx_en_pwm_fan(struct device *dev,
	if (fan_cnt < 1)
		return -EINVAL;

	fan_ch = devm_kzalloc(dev, sizeof(*fan_ch) * fan_cnt, GFP_KERNEL);
	fan_ch = devm_kcalloc(dev, fan_cnt, sizeof(*fan_ch), GFP_KERNEL);
	if (!fan_ch)
		return -ENOMEM;

Loading