diff --git a/drivers/acpi/fan.c b/drivers/acpi/fan.c index 6cf4988206f2..774b7d4a12d8 100644 --- a/drivers/acpi/fan.c +++ b/drivers/acpi/fan.c @@ -298,8 +298,8 @@ static int acpi_fan_get_fps(struct acpi_device *device) } fan->fps_count = obj->package.count - 1; /* minus revision field */ - fan->fps = devm_kzalloc(&device->dev, - fan->fps_count * sizeof(struct acpi_fan_fps), + fan->fps = devm_kcalloc(&device->dev, + fan->fps_count, sizeof(struct acpi_fan_fps), GFP_KERNEL); if (!fan->fps) { dev_err(&device->dev, "Not enough memory\n"); diff --git a/drivers/acpi/nfit/core.c b/drivers/acpi/nfit/core.c index 1872dc01be13..f8694680e5db 100644 --- a/drivers/acpi/nfit/core.c +++ b/drivers/acpi/nfit/core.c @@ -866,9 +866,10 @@ static int __nfit_mem_init(struct acpi_nfit_desc *acpi_desc, continue; nfit_mem->nfit_flush = nfit_flush; flush = nfit_flush->flush; - nfit_mem->flush_wpq = devm_kzalloc(acpi_desc->dev, - flush->hint_count - * sizeof(struct resource), GFP_KERNEL); + nfit_mem->flush_wpq = devm_kcalloc(acpi_desc->dev, + flush->hint_count, + sizeof(struct resource), + GFP_KERNEL); if (!nfit_mem->flush_wpq) return -ENOMEM; for (i = 0; i < flush->hint_count; i++) { diff --git a/drivers/ata/sata_mv.c b/drivers/ata/sata_mv.c index 3b2246dded74..8c10c3e43880 100644 --- a/drivers/ata/sata_mv.c +++ b/drivers/ata/sata_mv.c @@ -4116,13 +4116,13 @@ static int mv_platform_probe(struct platform_device *pdev) if (!host || !hpriv) return -ENOMEM; - hpriv->port_clks = devm_kzalloc(&pdev->dev, - sizeof(struct clk *) * n_ports, + hpriv->port_clks = devm_kcalloc(&pdev->dev, + n_ports, sizeof(struct clk *), GFP_KERNEL); if (!hpriv->port_clks) return -ENOMEM; - hpriv->port_phys = devm_kzalloc(&pdev->dev, - sizeof(struct phy *) * n_ports, + hpriv->port_phys = devm_kcalloc(&pdev->dev, + n_ports, sizeof(struct phy *), GFP_KERNEL); if (!hpriv->port_phys) return -ENOMEM; diff --git a/drivers/char/tpm/tpm2-cmd.c b/drivers/char/tpm/tpm2-cmd.c index dd64b3b37400..7cf613ba13bf 100644 --- a/drivers/char/tpm/tpm2-cmd.c +++ b/drivers/char/tpm/tpm2-cmd.c @@ -1027,7 +1027,7 @@ static int tpm2_get_cc_attrs_tbl(struct tpm_chip *chip) goto out; } - chip->cc_attrs_tbl = devm_kzalloc(&chip->dev, 4 * nr_commands, + chip->cc_attrs_tbl = devm_kcalloc(&chip->dev, 4, nr_commands, GFP_KERNEL); if (!chip->cc_attrs_tbl) { rc = -ENOMEM; diff --git a/drivers/clk/bcm/clk-bcm2835.c b/drivers/clk/bcm/clk-bcm2835.c index 6db4204e5d5d..5518a164bdd1 100644 --- a/drivers/clk/bcm/clk-bcm2835.c +++ b/drivers/clk/bcm/clk-bcm2835.c @@ -768,7 +768,7 @@ static int bcm2835_pll_debug_init(struct clk_hw *hw, const struct bcm2835_pll_data *data = pll->data; struct debugfs_reg32 *regs; - regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL); + regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); if (!regs) return -ENOMEM; @@ -899,7 +899,7 @@ static int bcm2835_pll_divider_debug_init(struct clk_hw *hw, const struct bcm2835_pll_divider_data *data = divider->data; struct debugfs_reg32 *regs; - regs = devm_kzalloc(cprman->dev, 7 * sizeof(*regs), GFP_KERNEL); + regs = devm_kcalloc(cprman->dev, 7, sizeof(*regs), GFP_KERNEL); if (!regs) return -ENOMEM; diff --git a/drivers/clk/msm/clock-a7.c b/drivers/clk/msm/clock-a7.c index 679ecd29c0e4..4b6a39e5fa50 100644 --- a/drivers/clk/msm/clock-a7.c +++ b/drivers/clk/msm/clock-a7.c @@ -196,23 +196,23 @@ static int of_get_fmax_vdd_class(struct platform_device *pdev, struct clk *c, } prop_len /= 2; - vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int), + vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int), GFP_KERNEL); if (!vdd->level_votes) return -ENOMEM; - vdd->vdd_uv = devm_kzalloc(&pdev->dev, prop_len * sizeof(int), + vdd->vdd_uv = devm_kcalloc(&pdev->dev, prop_len, sizeof(int), GFP_KERNEL); if (!vdd->vdd_uv) return -ENOMEM; - c->fmax = devm_kzalloc(&pdev->dev, prop_len * sizeof(unsigned long), + c->fmax = devm_kcalloc(&pdev->dev, prop_len, sizeof(unsigned long), GFP_KERNEL); if (!c->fmax) return -ENOMEM; array = devm_kzalloc(&pdev->dev, - prop_len * sizeof(u32) * 2, GFP_KERNEL); + array3_size(prop_len, sizeof(u32), 2), GFP_KERNEL); if (!array) return -ENOMEM; diff --git a/drivers/clk/msm/clock-local2.c b/drivers/clk/msm/clock-local2.c index 3721865fbc09..4aa9db362945 100644 --- a/drivers/clk/msm/clock-local2.c +++ b/drivers/clk/msm/clock-local2.c @@ -2485,7 +2485,7 @@ struct clk_src *msmclk_parse_clk_src(struct device *dev, } num_parents = prop_len / len; - clks = devm_kzalloc(dev, sizeof(*clks) * num_parents, GFP_KERNEL); + clks = devm_kcalloc(dev, num_parents, sizeof(*clks), GFP_KERNEL); if (!clks) return ERR_PTR(-ENOMEM); @@ -2538,8 +2538,8 @@ static int rcg_parse_freq_tbl(struct device *dev, num_rows = prop_len / 6; /* Array is null terminated. */ - rcg->freq_tbl = devm_kzalloc(dev, - sizeof(*rcg->freq_tbl) * (num_rows + 1), + rcg->freq_tbl = devm_kcalloc(dev, + num_rows + 1, sizeof(*rcg->freq_tbl), GFP_KERNEL); if (!rcg->freq_tbl) { @@ -2646,8 +2646,8 @@ static int parse_rec_parents(struct device *dev, if (mux->num_rec_parents <= 0) return 0; - mux->rec_parents = devm_kzalloc(dev, - sizeof(*mux->rec_parents) * mux->num_rec_parents, + mux->rec_parents = devm_kcalloc(dev, + mux->num_rec_parents, sizeof(*mux->rec_parents), GFP_KERNEL); if (!mux->rec_parents) { diff --git a/drivers/clk/msm/gdsc.c b/drivers/clk/msm/gdsc.c index 0614cd86eeea..ecf76698aa36 100644 --- a/drivers/clk/msm/gdsc.c +++ b/drivers/clk/msm/gdsc.c @@ -530,8 +530,8 @@ static int gdsc_probe(struct platform_device *pdev) return -EINVAL; } - sc->clocks = devm_kzalloc(&pdev->dev, - sizeof(struct clk *) * sc->clock_count, GFP_KERNEL); + sc->clocks = devm_kcalloc(&pdev->dev, + sc->clock_count, sizeof(struct clk *), GFP_KERNEL); if (!sc->clocks) return -ENOMEM; @@ -616,9 +616,9 @@ static int gdsc_probe(struct platform_device *pdev) return -EINVAL; } - sc->reset_clocks = devm_kzalloc(&pdev->dev, - sizeof(struct reset_control *) * + sc->reset_clocks = devm_kcalloc(&pdev->dev, sc->reset_count, + sizeof(struct reset_control *), GFP_KERNEL); if (!sc->reset_clocks) return -ENOMEM; diff --git a/drivers/clk/msm/msm-clock-controller.c b/drivers/clk/msm/msm-clock-controller.c index 88f2e0b143e7..08ad7754bf6c 100644 --- a/drivers/clk/msm/msm-clock-controller.c +++ b/drivers/clk/msm/msm-clock-controller.c @@ -75,8 +75,8 @@ static int generic_vdd_parse_regulators(struct device *dev, return -EINVAL; } - vdd->regulator = devm_kzalloc(dev, - sizeof(*vdd->regulator) * num_regulators, + vdd->regulator = devm_kcalloc(dev, + num_regulators, sizeof(*vdd->regulator), GFP_KERNEL); if (!vdd->regulator) { dt_err(np, "memory alloc failure\n"); @@ -121,10 +121,10 @@ static int generic_vdd_parse_levels(struct device *dev, } vdd->num_levels = len / vdd->num_regulators; - vdd->vdd_uv = devm_kzalloc(dev, len * sizeof(*vdd->vdd_uv), + vdd->vdd_uv = devm_kcalloc(dev, len, sizeof(*vdd->vdd_uv), GFP_KERNEL); - vdd->level_votes = devm_kzalloc(dev, - vdd->num_levels * sizeof(*vdd->level_votes), + vdd->level_votes = devm_kcalloc(dev, + vdd->num_levels, sizeof(*vdd->level_votes), GFP_KERNEL); if (!vdd->vdd_uv || !vdd->level_votes) { @@ -150,7 +150,7 @@ static int generic_vdd_parse_levels(struct device *dev, return -EINVAL; } - vdd->vdd_ua = devm_kzalloc(dev, len * sizeof(*vdd->vdd_ua), + vdd->vdd_ua = devm_kcalloc(dev, len, sizeof(*vdd->vdd_ua), GFP_KERNEL); if (!vdd->vdd_ua) return -ENOMEM; @@ -290,7 +290,8 @@ static int generic_clk_parse_fmax(struct device *dev, struct clk *c, return rc; } - c->fmax = devm_kzalloc(dev, sizeof(*c->fmax) * c->num_fmax, GFP_KERNEL); + c->fmax = devm_kcalloc(dev, c->num_fmax, sizeof(*c->fmax), + GFP_KERNEL); if (!c->fmax) return -ENOMEM; diff --git a/drivers/clk/qcom/clk-cpu-qcs405.c b/drivers/clk/qcom/clk-cpu-qcs405.c index 3623924a1dc4..c71b5f5abee2 100644 --- a/drivers/clk/qcom/clk-cpu-qcs405.c +++ b/drivers/clk/qcom/clk-cpu-qcs405.c @@ -367,23 +367,24 @@ static int cpucc_clk_get_fmax_vdd_class(struct platform_device *pdev, } prop_len /= num; - vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int), + vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int), GFP_KERNEL); if (!vdd->level_votes) return -ENOMEM; vdd->vdd_uv = devm_kzalloc(&pdev->dev, - prop_len * sizeof(int) * (num - 1), GFP_KERNEL); + array3_size(prop_len, sizeof(int), (num - 1)), + GFP_KERNEL); if (!vdd->vdd_uv) return -ENOMEM; - clk_intd->rate_max = devm_kzalloc(&pdev->dev, - prop_len * sizeof(unsigned long), GFP_KERNEL); + clk_intd->rate_max = devm_kcalloc(&pdev->dev, + prop_len, sizeof(unsigned long), GFP_KERNEL); if (!clk_intd->rate_max) return -ENOMEM; array = devm_kzalloc(&pdev->dev, - prop_len * sizeof(u32) * num, GFP_KERNEL); + array3_size(prop_len, num, sizeof(u32)), GFP_KERNEL); if (!array) return -ENOMEM; diff --git a/drivers/clk/qcom/clk-cpu-sdxprairie.c b/drivers/clk/qcom/clk-cpu-sdxprairie.c index be011b4021ee..038a14e7cbc8 100644 --- a/drivers/clk/qcom/clk-cpu-sdxprairie.c +++ b/drivers/clk/qcom/clk-cpu-sdxprairie.c @@ -326,23 +326,24 @@ static int cpucc_clk_get_fmax_vdd_class(struct platform_device *pdev, } prop_len /= num; - vdd->level_votes = devm_kzalloc(&pdev->dev, prop_len * sizeof(int), + vdd->level_votes = devm_kcalloc(&pdev->dev, prop_len, sizeof(int), GFP_KERNEL); if (!vdd->level_votes) return -ENOMEM; vdd->vdd_uv = devm_kzalloc(&pdev->dev, - prop_len * sizeof(int) * (num - 1), GFP_KERNEL); + array3_size(prop_len, sizeof(int), (num - 1)), + GFP_KERNEL); if (!vdd->vdd_uv) return -ENOMEM; - clk_intd->rate_max = devm_kzalloc(&pdev->dev, - prop_len * sizeof(unsigned long), GFP_KERNEL); + clk_intd->rate_max = devm_kcalloc(&pdev->dev, + prop_len, sizeof(unsigned long), GFP_KERNEL); if (!clk_intd->rate_max) return -ENOMEM; array = devm_kzalloc(&pdev->dev, - prop_len * sizeof(u32) * num, GFP_KERNEL); + array3_size(prop_len, num, sizeof(u32)), GFP_KERNEL); if (!array) return -ENOMEM; diff --git a/drivers/clk/qcom/clk-rcg2.c b/drivers/clk/qcom/clk-rcg2.c index 9fc98819321a..c601d002f13c 100644 --- a/drivers/clk/qcom/clk-rcg2.c +++ b/drivers/clk/qcom/clk-rcg2.c @@ -1620,8 +1620,9 @@ int clk_rcg2_get_dfs_clock_rate(struct clk_rcg2 *clk, struct device *dev, if (!(val & SE_CMD_DFS_EN)) return ret; - dfs_freq_tbl = devm_kzalloc(dev, MAX_PERF_LEVEL * - sizeof(struct freq_tbl), GFP_KERNEL); + dfs_freq_tbl = devm_kcalloc(dev, + MAX_PERF_LEVEL, sizeof(struct freq_tbl), + GFP_KERNEL); if (!dfs_freq_tbl) return -ENOMEM; diff --git a/drivers/clk/qcom/debugcc-atoll.c b/drivers/clk/qcom/debugcc-atoll.c index 81a92cc30df2..076769c53deb 100644 --- a/drivers/clk/qcom/debugcc-atoll.c +++ b/drivers/clk/qcom/debugcc-atoll.c @@ -738,8 +738,8 @@ static int clk_debug_atoll_probe(struct platform_device *pdev) return -EINVAL; } - gcc_debug_mux.regmap = devm_kzalloc(&pdev->dev, - sizeof(struct regmap *) * count, GFP_KERNEL); + gcc_debug_mux.regmap = devm_kcalloc(&pdev->dev, + count, sizeof(struct regmap *), GFP_KERNEL); if (!gcc_debug_mux.regmap) return -ENOMEM; diff --git a/drivers/clk/qcom/debugcc-sdmmagpie.c b/drivers/clk/qcom/debugcc-sdmmagpie.c index 7f9c9701138e..8c4378784485 100644 --- a/drivers/clk/qcom/debugcc-sdmmagpie.c +++ b/drivers/clk/qcom/debugcc-sdmmagpie.c @@ -789,8 +789,8 @@ static int clk_debug_sdmmagpie_probe(struct platform_device *pdev) return -EINVAL; } - gcc_debug_mux.regmap = devm_kzalloc(&pdev->dev, - sizeof(struct regmap *) * count, GFP_KERNEL); + gcc_debug_mux.regmap = devm_kcalloc(&pdev->dev, + count, sizeof(struct regmap *), GFP_KERNEL); if (!gcc_debug_mux.regmap) return -ENOMEM; diff --git a/drivers/clk/qcom/gdsc-regulator.c b/drivers/clk/qcom/gdsc-regulator.c index f689661cfc3d..dc585123dcd1 100644 --- a/drivers/clk/qcom/gdsc-regulator.c +++ b/drivers/clk/qcom/gdsc-regulator.c @@ -772,8 +772,8 @@ static int gdsc_probe(struct platform_device *pdev) return -EINVAL; } - sc->clocks = devm_kzalloc(&pdev->dev, - sizeof(struct clk *) * sc->clock_count, GFP_KERNEL); + sc->clocks = devm_kcalloc(&pdev->dev, + sc->clock_count, sizeof(struct clk *), GFP_KERNEL); if (!sc->clocks) return -ENOMEM; @@ -938,9 +938,9 @@ static int gdsc_probe(struct platform_device *pdev) goto err; } - sc->reset_clocks = devm_kzalloc(&pdev->dev, - sizeof(struct reset_control *) * sc->reset_count, - GFP_KERNEL); + sc->reset_clocks = devm_kcalloc(&pdev->dev, + sc->reset_count, sizeof(struct reset_control *), + GFP_KERNEL); if (!sc->reset_clocks) { ret = -ENOMEM; goto err; diff --git a/drivers/clk/qcom/mdss/mdss-pll-util.c b/drivers/clk/qcom/mdss/mdss-pll-util.c index 3e60d93f08f4..fa2209f47517 100644 --- a/drivers/clk/qcom/mdss/mdss-pll-util.c +++ b/drivers/clk/qcom/mdss/mdss-pll-util.c @@ -172,8 +172,9 @@ static int mdss_pll_util_parse_dt_supply(struct platform_device *pdev, } pr_debug("vreg found. count=%d\n", mp->num_vreg); - mp->vreg_config = devm_kzalloc(&pdev->dev, sizeof(struct dss_vreg) * - mp->num_vreg, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(&pdev->dev, + mp->num_vreg, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { rc = -ENOMEM; return rc; @@ -299,8 +300,8 @@ static int mdss_pll_util_parse_dt_clock(struct platform_device *pdev, goto clk_err; } - mp->clk_config = devm_kzalloc(&pdev->dev, - sizeof(struct dss_clk) * mp->num_clk, GFP_KERNEL); + mp->clk_config = devm_kcalloc(&pdev->dev, + mp->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!mp->clk_config) { rc = -ENOMEM; mp->num_clk = 0; diff --git a/drivers/clk/ti/adpll.c b/drivers/clk/ti/adpll.c index d6036c788fab..688e403333b9 100644 --- a/drivers/clk/ti/adpll.c +++ b/drivers/clk/ti/adpll.c @@ -501,8 +501,9 @@ static int ti_adpll_init_dco(struct ti_adpll_data *d) const char *postfix; int width, err; - d->outputs.clks = devm_kzalloc(d->dev, sizeof(struct clk *) * + d->outputs.clks = devm_kcalloc(d->dev, MAX_ADPLL_OUTPUTS, + sizeof(struct clk *), GFP_KERNEL); if (!d->outputs.clks) return -ENOMEM; @@ -915,8 +916,9 @@ static int ti_adpll_probe(struct platform_device *pdev) if (err) return err; - d->clocks = devm_kzalloc(d->dev, sizeof(struct ti_adpll_clock) * + d->clocks = devm_kcalloc(d->dev, TI_ADPLL_NR_CLOCKS, + sizeof(struct ti_adpll_clock), GFP_KERNEL); if (!d->clocks) return -ENOMEM; diff --git a/drivers/cpufreq/brcmstb-avs-cpufreq.c b/drivers/cpufreq/brcmstb-avs-cpufreq.c index 39c462711eae..267416966e93 100644 --- a/drivers/cpufreq/brcmstb-avs-cpufreq.c +++ b/drivers/cpufreq/brcmstb-avs-cpufreq.c @@ -494,7 +494,7 @@ brcm_avs_get_freq_table(struct device *dev, struct private_data *priv) if (ret) return ERR_PTR(ret); - table = devm_kzalloc(dev, (AVS_PSTATE_MAX + 1) * sizeof(*table), + table = devm_kcalloc(dev, AVS_PSTATE_MAX + 1, sizeof(*table), GFP_KERNEL); if (!table) return ERR_PTR(-ENOMEM); diff --git a/drivers/cpufreq/imx6q-cpufreq.c b/drivers/cpufreq/imx6q-cpufreq.c index 63d28323a29c..88ecfda4eecf 100644 --- a/drivers/cpufreq/imx6q-cpufreq.c +++ b/drivers/cpufreq/imx6q-cpufreq.c @@ -288,7 +288,8 @@ static int imx6q_cpufreq_probe(struct platform_device *pdev) } /* Make imx6_soc_volt array's size same as arm opp number */ - imx6_soc_volt = devm_kzalloc(cpu_dev, sizeof(*imx6_soc_volt) * num, GFP_KERNEL); + imx6_soc_volt = devm_kcalloc(cpu_dev, num, sizeof(*imx6_soc_volt), + GFP_KERNEL); if (imx6_soc_volt == NULL) { ret = -ENOMEM; goto free_freq_table; diff --git a/drivers/cpufreq/qcom-cpufreq.c b/drivers/cpufreq/qcom-cpufreq.c index 735db9250a16..07055cd4f9b4 100644 --- a/drivers/cpufreq/qcom-cpufreq.c +++ b/drivers/cpufreq/qcom-cpufreq.c @@ -382,7 +382,7 @@ static struct cpufreq_frequency_table *cpufreq_parse_dt(struct device *dev, if (nf == 0) return ERR_PTR(-EINVAL); - data = devm_kzalloc(dev, nf * sizeof(*data), GFP_KERNEL); + data = devm_kcalloc(dev, nf, sizeof(*data), GFP_KERNEL); if (!data) return ERR_PTR(-ENOMEM); @@ -390,7 +390,7 @@ static struct cpufreq_frequency_table *cpufreq_parse_dt(struct device *dev, if (ret) return ERR_PTR(ret); - ftbl = devm_kzalloc(dev, (nf + 1) * sizeof(*ftbl), GFP_KERNEL); + ftbl = devm_kcalloc(dev, nf + 1, sizeof(*ftbl), GFP_KERNEL); if (!ftbl) return ERR_PTR(-ENOMEM); diff --git a/drivers/cpuidle/lpm-levels-of.c b/drivers/cpuidle/lpm-levels-of.c index f2f0bd4d0023..c8bfecd8f902 100644 --- a/drivers/cpuidle/lpm-levels-of.c +++ b/drivers/cpuidle/lpm-levels-of.c @@ -157,8 +157,8 @@ static int create_lvl_avail_nodes(const char *name, goto failed; } - attr = devm_kzalloc(&lpm_pdev->dev, - sizeof(*attr) * (LPM_TYPE_NR + 1), GFP_KERNEL); + attr = devm_kcalloc(&lpm_pdev->dev, + LPM_TYPE_NR + 1, sizeof(*attr), GFP_KERNEL); if (!attr) { ret = -ENOMEM; goto failed; @@ -218,8 +218,10 @@ static int create_cpu_lvl_nodes(struct lpm_cluster *p, struct kobject *parent) int ret = 0; struct list_head *pos; - cpu_kobj = devm_kzalloc(&lpm_pdev->dev, sizeof(*cpu_kobj) * - cpumask_weight(&p->child_cpus), GFP_KERNEL); + cpu_kobj = devm_kcalloc(&lpm_pdev->dev, + cpumask_weight(&p->child_cpus), + sizeof(*cpu_kobj), + GFP_KERNEL); if (!cpu_kobj) return -ENOMEM; @@ -236,8 +238,8 @@ static int create_cpu_lvl_nodes(struct lpm_cluster *p, struct kobject *parent) goto release_kobj; } - level_list = devm_kzalloc(&lpm_pdev->dev, - lpm_cpu->nlevels * sizeof(*level_list), + level_list = devm_kcalloc(&lpm_pdev->dev, + lpm_cpu->nlevels, sizeof(*level_list), GFP_KERNEL); if (!level_list) { ret = -ENOMEM; diff --git a/drivers/crypto/marvell/cesa.c b/drivers/crypto/marvell/cesa.c index 6e7a5c77a00a..b92424e3178b 100644 --- a/drivers/crypto/marvell/cesa.c +++ b/drivers/crypto/marvell/cesa.c @@ -476,7 +476,7 @@ static int mv_cesa_probe(struct platform_device *pdev) sram_size = CESA_SA_MIN_SRAM_SIZE; cesa->sram_size = sram_size; - cesa->engines = devm_kzalloc(dev, caps->nengines * sizeof(*engines), + cesa->engines = devm_kcalloc(dev, caps->nengines, sizeof(*engines), GFP_KERNEL); if (!cesa->engines) return -ENOMEM; diff --git a/drivers/crypto/msm/ice.c b/drivers/crypto/msm/ice.c index 90238a5299bc..04698dce55bf 100644 --- a/drivers/crypto/msm/ice.c +++ b/drivers/crypto/msm/ice.c @@ -596,7 +596,7 @@ static int qcom_ice_parse_clock_info(struct platform_device *pdev, if (len != cnt) goto out; - clkfreq = devm_kzalloc(dev, len * sizeof(*clkfreq), GFP_KERNEL); + clkfreq = devm_kcalloc(dev, len, sizeof(*clkfreq), GFP_KERNEL); if (!clkfreq) { ret = -ENOMEM; goto out; diff --git a/drivers/devfreq/arm-memlat-mon.c b/drivers/devfreq/arm-memlat-mon.c index 740dc6f8d04f..d4e4a85c9de5 100644 --- a/drivers/devfreq/arm-memlat-mon.c +++ b/drivers/devfreq/arm-memlat-mon.c @@ -308,13 +308,17 @@ static int arm_memlat_mon_driver_probe(struct platform_device *pdev) } hw->num_cores = cpumask_weight(&cpu_grp->cpus); - hw->core_stats = devm_kzalloc(dev, hw->num_cores * - sizeof(*(hw->core_stats)), GFP_KERNEL); + hw->core_stats = devm_kcalloc(dev, + hw->num_cores, + sizeof(*(hw->core_stats)), + GFP_KERNEL); if (!hw->core_stats) return -ENOMEM; - cpu_grp->cpustats = devm_kzalloc(dev, hw->num_cores * - sizeof(*(cpu_grp->cpustats)), GFP_KERNEL); + cpu_grp->cpustats = devm_kcalloc(dev, + hw->num_cores, + sizeof(*(cpu_grp->cpustats)), + GFP_KERNEL); if (!cpu_grp->cpustats) return -ENOMEM; diff --git a/drivers/devfreq/bimc-bwmon.c b/drivers/devfreq/bimc-bwmon.c index 8b924abf781f..db13cc3f7f82 100644 --- a/drivers/devfreq/bimc-bwmon.c +++ b/drivers/devfreq/bimc-bwmon.c @@ -1155,7 +1155,7 @@ static int bimc_bwmon_driver_probe(struct platform_device *pdev) return -EINVAL; } - m->clks = devm_kzalloc(dev, sizeof(struct clk *) * m->nr_clks, + m->clks = devm_kcalloc(dev, m->nr_clks, sizeof(struct clk *), GFP_KERNEL); if (!m->clks) return -ENOMEM; diff --git a/drivers/devfreq/devfreq.c b/drivers/devfreq/devfreq.c index cf000d78e8e9..dc0643a6a55e 100644 --- a/drivers/devfreq/devfreq.c +++ b/drivers/devfreq/devfreq.c @@ -595,13 +595,11 @@ struct devfreq *devfreq_add_device(struct device *dev, } devfreq->trans_table = devm_kzalloc(&devfreq->dev, - sizeof(unsigned int) * - devfreq->profile->max_state * - devfreq->profile->max_state, + array3_size(sizeof(unsigned int), devfreq->profile->max_state, devfreq->profile->max_state), GFP_KERNEL); - devfreq->time_in_state = devm_kzalloc(&devfreq->dev, - sizeof(unsigned long) * + devfreq->time_in_state = devm_kcalloc(&devfreq->dev, devfreq->profile->max_state, + sizeof(unsigned long), GFP_KERNEL); devfreq->last_stat_updated = jiffies; diff --git a/drivers/devfreq/devfreq_simple_dev.c b/drivers/devfreq/devfreq_simple_dev.c index 8566e98af079..9f49184f4356 100644 --- a/drivers/devfreq/devfreq_simple_dev.c +++ b/drivers/devfreq/devfreq_simple_dev.c @@ -105,11 +105,11 @@ static int parse_freq_table(struct device *dev, struct dev_data *d) d->freq_in_khz = true; len /= sizeof(*data); - data = devm_kzalloc(dev, len * sizeof(*data), GFP_KERNEL); + data = devm_kcalloc(dev, len, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; - p->freq_table = devm_kzalloc(dev, len * sizeof(*p->freq_table), + p->freq_table = devm_kcalloc(dev, len, sizeof(*p->freq_table), GFP_KERNEL); if (!p->freq_table) return -ENOMEM; diff --git a/drivers/devfreq/event/exynos-ppmu.c b/drivers/devfreq/event/exynos-ppmu.c index d96e3dc71cf8..3cd6a184fe7c 100644 --- a/drivers/devfreq/event/exynos-ppmu.c +++ b/drivers/devfreq/event/exynos-ppmu.c @@ -518,7 +518,7 @@ static int of_get_devfreq_events(struct device_node *np, event_ops = exynos_bus_get_ops(np); count = of_get_child_count(events_np); - desc = devm_kzalloc(dev, sizeof(*desc) * count, GFP_KERNEL); + desc = devm_kcalloc(dev, count, sizeof(*desc), GFP_KERNEL); if (!desc) return -ENOMEM; info->num_events = count; diff --git a/drivers/devfreq/governor_memlat.c b/drivers/devfreq/governor_memlat.c index 3b6e6fee0c79..78c5c7718b62 100644 --- a/drivers/devfreq/governor_memlat.c +++ b/drivers/devfreq/governor_memlat.c @@ -447,8 +447,8 @@ static struct core_dev_map *init_core_dev_map(struct device *dev, return NULL; nf = len / NUM_COLS; - tbl = devm_kzalloc(dev, (nf + 1) * sizeof(struct core_dev_map), - GFP_KERNEL); + tbl = devm_kcalloc(dev, nf + 1, sizeof(struct core_dev_map), + GFP_KERNEL); if (!tbl) return NULL; diff --git a/drivers/dma/k3dma.c b/drivers/dma/k3dma.c index 803045c92f3b..6a5f0cc9c8c0 100644 --- a/drivers/dma/k3dma.c +++ b/drivers/dma/k3dma.c @@ -847,8 +847,8 @@ static int k3_dma_probe(struct platform_device *op) return -ENOMEM; /* init phy channel */ - d->phy = devm_kzalloc(&op->dev, - d->dma_channels * sizeof(struct k3_dma_phy), GFP_KERNEL); + d->phy = devm_kcalloc(&op->dev, + d->dma_channels, sizeof(struct k3_dma_phy), GFP_KERNEL); if (d->phy == NULL) return -ENOMEM; @@ -877,8 +877,8 @@ static int k3_dma_probe(struct platform_device *op) d->slave.copy_align = DMAENGINE_ALIGN_8_BYTES; /* init virtual channel */ - d->chans = devm_kzalloc(&op->dev, - d->dma_requests * sizeof(struct k3_dma_chan), GFP_KERNEL); + d->chans = devm_kcalloc(&op->dev, + d->dma_requests, sizeof(struct k3_dma_chan), GFP_KERNEL); if (d->chans == NULL) return -ENOMEM; diff --git a/drivers/dma/mv_xor_v2.c b/drivers/dma/mv_xor_v2.c index 75eef589d0ec..d349fedf4ab2 100644 --- a/drivers/dma/mv_xor_v2.c +++ b/drivers/dma/mv_xor_v2.c @@ -809,8 +809,9 @@ static int mv_xor_v2_probe(struct platform_device *pdev) } /* alloc memory for the SW descriptors */ - xor_dev->sw_desq = devm_kzalloc(&pdev->dev, sizeof(*sw_desc) * - MV_XOR_V2_DESC_NUM, GFP_KERNEL); + xor_dev->sw_desq = devm_kcalloc(&pdev->dev, + MV_XOR_V2_DESC_NUM, sizeof(*sw_desc), + GFP_KERNEL); if (!xor_dev->sw_desq) { ret = -ENOMEM; goto free_hw_desq; diff --git a/drivers/dma/qcom/gpi.c b/drivers/dma/qcom/gpi.c index c09b12fd57bf..6455e21a4d38 100644 --- a/drivers/dma/qcom/gpi.c +++ b/drivers/dma/qcom/gpi.c @@ -2985,8 +2985,8 @@ static int gpi_probe(struct platform_device *pdev) return ret; } - gpi_dev->gpiis = devm_kzalloc(gpi_dev->dev, - sizeof(*gpi_dev->gpiis) * gpi_dev->max_gpii, + gpi_dev->gpiis = devm_kcalloc(gpi_dev->dev, + gpi_dev->max_gpii, sizeof(*gpi_dev->gpiis), GFP_KERNEL); if (!gpi_dev->gpiis) return -ENOMEM; diff --git a/drivers/dma/s3c24xx-dma.c b/drivers/dma/s3c24xx-dma.c index f04c4702d98b..7bd6f6439826 100644 --- a/drivers/dma/s3c24xx-dma.c +++ b/drivers/dma/s3c24xx-dma.c @@ -1216,9 +1216,9 @@ static int s3c24xx_dma_probe(struct platform_device *pdev) if (IS_ERR(s3cdma->base)) return PTR_ERR(s3cdma->base); - s3cdma->phy_chans = devm_kzalloc(&pdev->dev, - sizeof(struct s3c24xx_dma_phy) * - pdata->num_phy_channels, + s3cdma->phy_chans = devm_kcalloc(&pdev->dev, + pdata->num_phy_channels, + sizeof(struct s3c24xx_dma_phy), GFP_KERNEL); if (!s3cdma->phy_chans) return -ENOMEM; diff --git a/drivers/dma/zx_dma.c b/drivers/dma/zx_dma.c index 2bb695315300..2571bc7693df 100644 --- a/drivers/dma/zx_dma.c +++ b/drivers/dma/zx_dma.c @@ -798,8 +798,8 @@ static int zx_dma_probe(struct platform_device *op) return -ENOMEM; /* init phy channel */ - d->phy = devm_kzalloc(&op->dev, - d->dma_channels * sizeof(struct zx_dma_phy), GFP_KERNEL); + d->phy = devm_kcalloc(&op->dev, + d->dma_channels, sizeof(struct zx_dma_phy), GFP_KERNEL); if (!d->phy) return -ENOMEM; @@ -834,8 +834,8 @@ static int zx_dma_probe(struct platform_device *op) d->slave.residue_granularity = DMA_RESIDUE_GRANULARITY_SEGMENT; /* init virtual channel */ - d->chans = devm_kzalloc(&op->dev, - d->dma_requests * sizeof(struct zx_dma_chan), GFP_KERNEL); + d->chans = devm_kcalloc(&op->dev, + d->dma_requests, sizeof(struct zx_dma_chan), GFP_KERNEL); if (!d->chans) return -ENOMEM; diff --git a/drivers/edac/qcom_llcc_edac.c b/drivers/edac/qcom_llcc_edac.c index ddf6776a2494..ba6946376088 100644 --- a/drivers/edac/qcom_llcc_edac.c +++ b/drivers/edac/qcom_llcc_edac.c @@ -427,8 +427,8 @@ static int qcom_llcc_erp_probe(struct platform_device *pdev) drv->num_banks = num_banks; drv->llcc_map = llcc_map; - drv->llcc_banks = devm_kzalloc(&pdev->dev, - sizeof(u32) * drv->num_banks, GFP_KERNEL); + drv->llcc_banks = devm_kcalloc(&pdev->dev, + drv->num_banks, sizeof(u32), GFP_KERNEL); if (!drv->llcc_banks) { dev_err(dev, "Cannot allocate memory for llcc_banks\n"); diff --git a/drivers/extcon/extcon.c b/drivers/extcon/extcon.c index 3a0089d0735a..427f6d25b3fc 100644 --- a/drivers/extcon/extcon.c +++ b/drivers/extcon/extcon.c @@ -1317,8 +1317,8 @@ int extcon_dev_register(struct extcon_dev *edev) goto err_dev; } - edev->bnh = devm_kzalloc(&edev->dev, - sizeof(*edev->bnh) * edev->max_supported, GFP_KERNEL); + edev->bnh = devm_kcalloc(&edev->dev, + edev->max_supported, sizeof(*edev->bnh), GFP_KERNEL); if (!edev->bnh) { ret = -ENOMEM; goto err_dev; diff --git a/drivers/firmware/arm_scpi.c b/drivers/firmware/arm_scpi.c index 7da9f1b83ebe..f17b895e5e32 100644 --- a/drivers/firmware/arm_scpi.c +++ b/drivers/firmware/arm_scpi.c @@ -930,7 +930,7 @@ static int scpi_alloc_xfer_list(struct device *dev, struct scpi_chan *ch) int i; struct scpi_xfer *xfers; - xfers = devm_kzalloc(dev, MAX_SCPI_XFERS * sizeof(*xfers), GFP_KERNEL); + xfers = devm_kcalloc(dev, MAX_SCPI_XFERS, sizeof(*xfers), GFP_KERNEL); if (!xfers) return -ENOMEM; diff --git a/drivers/firmware/ti_sci.c b/drivers/firmware/ti_sci.c index 1620722115cd..a7e9d4798758 100644 --- a/drivers/firmware/ti_sci.c +++ b/drivers/firmware/ti_sci.c @@ -1862,9 +1862,9 @@ static int ti_sci_probe(struct platform_device *pdev) if (!minfo->xfer_block) return -ENOMEM; - minfo->xfer_alloc_table = devm_kzalloc(dev, - BITS_TO_LONGS(desc->max_msgs) - * sizeof(unsigned long), + minfo->xfer_alloc_table = devm_kcalloc(dev, + BITS_TO_LONGS(desc->max_msgs), + sizeof(unsigned long), GFP_KERNEL); if (!minfo->xfer_alloc_table) return -ENOMEM; diff --git a/drivers/gpio/gpio-adnp.c b/drivers/gpio/gpio-adnp.c index ee923b1b820c..6c1280830b62 100644 --- a/drivers/gpio/gpio-adnp.c +++ b/drivers/gpio/gpio-adnp.c @@ -432,7 +432,7 @@ static int adnp_irq_setup(struct adnp *adnp) * is chosen to match the register layout of the hardware in that * each segment contains the corresponding bits for all interrupts. */ - adnp->irq_enable = devm_kzalloc(chip->parent, num_regs * 6, + adnp->irq_enable = devm_kcalloc(chip->parent, num_regs, 6, GFP_KERNEL); if (!adnp->irq_enable) return -ENOMEM; diff --git a/drivers/gpio/gpio-bcm-kona.c b/drivers/gpio/gpio-bcm-kona.c index dfcf56ee3c61..5e7af55a18ef 100644 --- a/drivers/gpio/gpio-bcm-kona.c +++ b/drivers/gpio/gpio-bcm-kona.c @@ -600,9 +600,10 @@ static int bcm_kona_gpio_probe(struct platform_device *pdev) GPIO_MAX_BANK_NUM); return -ENXIO; } - kona_gpio->banks = devm_kzalloc(dev, - kona_gpio->num_bank * - sizeof(*kona_gpio->banks), GFP_KERNEL); + kona_gpio->banks = devm_kcalloc(dev, + kona_gpio->num_bank, + sizeof(*kona_gpio->banks), + GFP_KERNEL); if (!kona_gpio->banks) return -ENOMEM; diff --git a/drivers/gpio/gpio-davinci.c b/drivers/gpio/gpio-davinci.c index e4b3d7db68c9..72b1847d3ce5 100644 --- a/drivers/gpio/gpio-davinci.c +++ b/drivers/gpio/gpio-davinci.c @@ -197,8 +197,8 @@ static int davinci_gpio_probe(struct platform_device *pdev) ngpio = ARCH_NR_GPIOS; nbank = DIV_ROUND_UP(ngpio, 32); - chips = devm_kzalloc(dev, - nbank * sizeof(struct davinci_gpio_controller), + chips = devm_kcalloc(dev, + nbank, sizeof(struct davinci_gpio_controller), GFP_KERNEL); if (!chips) return -ENOMEM; diff --git a/drivers/gpio/gpio-etraxfs.c b/drivers/gpio/gpio-etraxfs.c index 94db1bf4bfdb..403e7de849e7 100644 --- a/drivers/gpio/gpio-etraxfs.c +++ b/drivers/gpio/gpio-etraxfs.c @@ -380,7 +380,8 @@ static int etraxfs_gpio_probe(struct platform_device *pdev) info = match->data; - chips = devm_kzalloc(dev, sizeof(*chips) * info->num_ports, GFP_KERNEL); + chips = devm_kcalloc(dev, info->num_ports, sizeof(*chips), + GFP_KERNEL); if (!chips) return -ENOMEM; diff --git a/drivers/gpio/gpio-htc-egpio.c b/drivers/gpio/gpio-htc-egpio.c index 271356effb2e..c1e0b2170b3f 100644 --- a/drivers/gpio/gpio-htc-egpio.c +++ b/drivers/gpio/gpio-htc-egpio.c @@ -320,8 +320,8 @@ static int __init egpio_probe(struct platform_device *pdev) platform_set_drvdata(pdev, ei); ei->nchips = pdata->num_chips; - ei->chip = devm_kzalloc(&pdev->dev, - sizeof(struct egpio_chip) * ei->nchips, + ei->chip = devm_kcalloc(&pdev->dev, + ei->nchips, sizeof(struct egpio_chip), GFP_KERNEL); if (!ei->chip) { ret = -ENOMEM; diff --git a/drivers/gpio/gpio-thunderx.c b/drivers/gpio/gpio-thunderx.c index 10523ce00c38..21e4dceb2f23 100644 --- a/drivers/gpio/gpio-thunderx.c +++ b/drivers/gpio/gpio-thunderx.c @@ -517,16 +517,17 @@ static int thunderx_gpio_probe(struct pci_dev *pdev, txgpio->base_msi = (c >> 8) & 0xff; } - txgpio->msix_entries = devm_kzalloc(dev, - sizeof(struct msix_entry) * ngpio, + txgpio->msix_entries = devm_kcalloc(dev, + ngpio, sizeof(struct msix_entry), GFP_KERNEL); if (!txgpio->msix_entries) { err = -ENOMEM; goto out; } - txgpio->line_entries = devm_kzalloc(dev, - sizeof(struct thunderx_line) * ngpio, + txgpio->line_entries = devm_kcalloc(dev, + ngpio, + sizeof(struct thunderx_line), GFP_KERNEL); if (!txgpio->line_entries) { err = -ENOMEM; diff --git a/drivers/gpu/drm/bridge/lt9611.c b/drivers/gpu/drm/bridge/lt9611.c index 443a43d3b128..01072beac003 100644 --- a/drivers/gpu/drm/bridge/lt9611.c +++ b/drivers/gpu/drm/bridge/lt9611.c @@ -1343,8 +1343,10 @@ static int lt9611_get_dt_supply(struct device *dev, } pr_debug("vreg found. count=%d\n", pdata->num_vreg); - pdata->vreg_config = devm_kzalloc(dev, sizeof(struct lt9611_vreg) * - pdata->num_vreg, GFP_KERNEL); + pdata->vreg_config = devm_kcalloc(dev, + pdata->num_vreg, + sizeof(struct lt9611_vreg), + GFP_KERNEL); if (!pdata->vreg_config) return -ENOMEM; diff --git a/drivers/gpu/drm/exynos/exynos_drm_dsi.c b/drivers/gpu/drm/exynos/exynos_drm_dsi.c index 366c975cde5b..9b33809be85b 100644 --- a/drivers/gpu/drm/exynos/exynos_drm_dsi.c +++ b/drivers/gpu/drm/exynos/exynos_drm_dsi.c @@ -1744,8 +1744,8 @@ static int exynos_dsi_probe(struct platform_device *pdev) return ret; } - dsi->clks = devm_kzalloc(dev, - sizeof(*dsi->clks) * dsi->driver_data->num_clks, + dsi->clks = devm_kcalloc(dev, + dsi->driver_data->num_clks, sizeof(*dsi->clks), GFP_KERNEL); if (!dsi->clks) return -ENOMEM; diff --git a/drivers/gpu/drm/exynos/exynos_hdmi.c b/drivers/gpu/drm/exynos/exynos_hdmi.c index 0109ff40b1db..b730f1b86f05 100644 --- a/drivers/gpu/drm/exynos/exynos_hdmi.c +++ b/drivers/gpu/drm/exynos/exynos_hdmi.c @@ -1577,7 +1577,7 @@ static int hdmi_clk_init(struct hdmi_context *hdata) if (!count) return 0; - clks = devm_kzalloc(dev, sizeof(*clks) * count, GFP_KERNEL); + clks = devm_kcalloc(dev, count, sizeof(*clks), GFP_KERNEL); if (!clks) return -ENOMEM; diff --git a/drivers/gpu/drm/msm/dp/dp_parser.c b/drivers/gpu/drm/msm/dp/dp_parser.c index a89a51c5b0ff..cbcf25921d6c 100644 --- a/drivers/gpu/drm/msm/dp/dp_parser.c +++ b/drivers/gpu/drm/msm/dp/dp_parser.c @@ -43,8 +43,8 @@ static int dp_parser_reg(struct dp_parser *parser) } io->len = reg_count; - io->data = devm_kzalloc(dev, sizeof(struct dp_io_data) * reg_count, - GFP_KERNEL); + io->data = devm_kcalloc(dev, reg_count, sizeof(struct dp_io_data), + GFP_KERNEL); if (!io->data) return -ENOMEM; @@ -287,8 +287,8 @@ static int dp_parser_gpio(struct dp_parser *parser) if (of_find_property(of_node, "qcom,dp-gpio-aux-switch", NULL)) parser->gpio_aux_switch = true; - mp->gpio_config = devm_kzalloc(dev, - sizeof(struct dss_gpio) * ARRAY_SIZE(dp_gpios), GFP_KERNEL); + mp->gpio_config = devm_kcalloc(dev, + ARRAY_SIZE(dp_gpios), sizeof(struct dss_gpio), GFP_KERNEL); if (!mp->gpio_config) return -ENOMEM; @@ -354,8 +354,8 @@ static int dp_parser_get_vreg(struct dp_parser *parser, pr_debug("vreg found. count=%d\n", mp->num_vreg); } - mp->vreg_config = devm_kzalloc(&parser->pdev->dev, - sizeof(struct dss_vreg) * mp->num_vreg, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(&parser->pdev->dev, + mp->num_vreg, sizeof(struct dss_vreg), GFP_KERNEL); if (!mp->vreg_config) { rc = -ENOMEM; goto error; @@ -558,8 +558,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) } core_power->num_clk = core_clk_count; - core_power->clk_config = devm_kzalloc(dev, - sizeof(struct dss_clk) * core_power->num_clk, + core_power->clk_config = devm_kcalloc(dev, + core_power->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!core_power->clk_config) { rc = -EINVAL; @@ -571,8 +571,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) pr_debug("no strm0 clocks are defined\n"); } else { strm0_power->num_clk = strm0_clk_count; - strm0_power->clk_config = devm_kzalloc(dev, - sizeof(struct dss_clk) * strm0_power->num_clk, + strm0_power->clk_config = devm_kcalloc(dev, + strm0_power->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!strm0_power->clk_config) { strm0_power->num_clk = 0; @@ -586,8 +586,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) pr_debug("no strm1 clocks are defined\n"); } else { strm1_power->num_clk = strm1_clk_count; - strm1_power->clk_config = devm_kzalloc(dev, - sizeof(struct dss_clk) * strm1_power->num_clk, + strm1_power->clk_config = devm_kcalloc(dev, + strm1_power->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!strm1_power->clk_config) { strm1_power->num_clk = 0; @@ -604,8 +604,8 @@ static int dp_parser_init_clk_data(struct dp_parser *parser) } link_power->num_clk = link_clk_count; - link_power->clk_config = devm_kzalloc(dev, - sizeof(struct dss_clk) * link_power->num_clk, + link_power->clk_config = devm_kcalloc(dev, + link_power->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!link_power->clk_config) { link_power->num_clk = 0; diff --git a/drivers/gpu/drm/msm/dsi-staging/dsi_parser.c b/drivers/gpu/drm/msm/dsi-staging/dsi_parser.c index c66824ee2259..d6e743754da7 100644 --- a/drivers/gpu/drm/msm/dsi-staging/dsi_parser.c +++ b/drivers/gpu/drm/msm/dsi-staging/dsi_parser.c @@ -254,7 +254,7 @@ static bool dsi_parser_parse_prop(struct device *dev, if (dsi_parser_get_strings(dev, prop, buf)) goto end; - prop->items = devm_kzalloc(dev, strlen(buf) * 2, GFP_KERNEL); + prop->items = devm_kcalloc(dev, strlen(buf), 2, GFP_KERNEL); if (!prop->items) goto end; diff --git a/drivers/gpu/drm/msm/hdmi/hdmi.c b/drivers/gpu/drm/msm/hdmi/hdmi.c index f3509e723c0f..eb53bb9db219 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi.c @@ -157,8 +157,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->qfprom_mmio = NULL; } - hdmi->hpd_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_regs[0]) * - config->hpd_reg_cnt, GFP_KERNEL); + hdmi->hpd_regs = devm_kcalloc(&pdev->dev, + config->hpd_reg_cnt, + sizeof(hdmi->hpd_regs[0]), + GFP_KERNEL); if (!hdmi->hpd_regs) { ret = -ENOMEM; goto fail; @@ -178,8 +180,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->hpd_regs[i] = reg; } - hdmi->pwr_regs = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_regs[0]) * - config->pwr_reg_cnt, GFP_KERNEL); + hdmi->pwr_regs = devm_kcalloc(&pdev->dev, + config->pwr_reg_cnt, + sizeof(hdmi->pwr_regs[0]), + GFP_KERNEL); if (!hdmi->pwr_regs) { ret = -ENOMEM; goto fail; @@ -199,8 +203,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->pwr_regs[i] = reg; } - hdmi->hpd_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->hpd_clks[0]) * - config->hpd_clk_cnt, GFP_KERNEL); + hdmi->hpd_clks = devm_kcalloc(&pdev->dev, + config->hpd_clk_cnt, + sizeof(hdmi->hpd_clks[0]), + GFP_KERNEL); if (!hdmi->hpd_clks) { ret = -ENOMEM; goto fail; @@ -219,8 +225,10 @@ static struct hdmi *msm_hdmi_init(struct platform_device *pdev) hdmi->hpd_clks[i] = clk; } - hdmi->pwr_clks = devm_kzalloc(&pdev->dev, sizeof(hdmi->pwr_clks[0]) * - config->pwr_clk_cnt, GFP_KERNEL); + hdmi->pwr_clks = devm_kcalloc(&pdev->dev, + config->pwr_clk_cnt, + sizeof(hdmi->pwr_clks[0]), + GFP_KERNEL); if (!hdmi->pwr_clks) { ret = -ENOMEM; goto fail; diff --git a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c index 534ce5b49781..16987d8679e0 100644 --- a/drivers/gpu/drm/msm/hdmi/hdmi_phy.c +++ b/drivers/gpu/drm/msm/hdmi/hdmi_phy.c @@ -21,12 +21,12 @@ static int msm_hdmi_phy_resource_init(struct hdmi_phy *phy) struct device *dev = &phy->pdev->dev; int i, ret; - phy->regs = devm_kzalloc(dev, sizeof(phy->regs[0]) * cfg->num_regs, + phy->regs = devm_kcalloc(dev, cfg->num_regs, sizeof(phy->regs[0]), GFP_KERNEL); if (!phy->regs) return -ENOMEM; - phy->clks = devm_kzalloc(dev, sizeof(phy->clks[0]) * cfg->num_clks, + phy->clks = devm_kcalloc(dev, cfg->num_clks, sizeof(phy->clks[0]), GFP_KERNEL); if (!phy->clks) return -ENOMEM; diff --git a/drivers/gpu/drm/msm/sde_power_handle.c b/drivers/gpu/drm/msm/sde_power_handle.c index 2e5f4179a70e..59ead5d82bf1 100644 --- a/drivers/gpu/drm/msm/sde_power_handle.c +++ b/drivers/gpu/drm/msm/sde_power_handle.c @@ -164,8 +164,9 @@ static int sde_power_parse_dt_supply(struct platform_device *pdev, } pr_debug("vreg found. count=%d\n", mp->num_vreg); - mp->vreg_config = devm_kzalloc(&pdev->dev, sizeof(struct dss_vreg) * - mp->num_vreg, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(&pdev->dev, + mp->num_vreg, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { rc = -ENOMEM; return rc; @@ -299,8 +300,8 @@ static int sde_power_parse_dt_clock(struct platform_device *pdev, } mp->num_clk = num_clk; - mp->clk_config = devm_kzalloc(&pdev->dev, - sizeof(struct dss_clk) * num_clk, GFP_KERNEL); + mp->clk_config = devm_kcalloc(&pdev->dev, + num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!mp->clk_config) { rc = -ENOMEM; mp->num_clk = 0; diff --git a/drivers/gpu/drm/msm/shp/shp_drm.c b/drivers/gpu/drm/msm/shp/shp_drm.c index d2b3ecebf9fb..2a27d1799bb2 100644 --- a/drivers/gpu/drm/msm/shp/shp_drm.c +++ b/drivers/gpu/drm/msm/shp/shp_drm.c @@ -428,8 +428,8 @@ static int shp_parse(struct platform_device *pdev, struct shp_device *shp) system_count = priv->num_planes; total_count = dup_count + system_count; - shp->planes = devm_kzalloc(&pdev->dev, - sizeof(*shp_plane) * total_count, GFP_KERNEL); + shp->planes = devm_kcalloc(&pdev->dev, + total_count, sizeof(*shp_plane), GFP_KERNEL); if (!shp->planes) { rc = -ENOMEM; goto out; diff --git a/drivers/hid/hid-sensor-hub.c b/drivers/hid/hid-sensor-hub.c index b5bd5cb7d532..4256fdc5cd6d 100644 --- a/drivers/hid/hid-sensor-hub.c +++ b/drivers/hid/hid-sensor-hub.c @@ -653,7 +653,8 @@ static int sensor_hub_probe(struct hid_device *hdev, ret = -EINVAL; goto err_stop_hw; } - sd->hid_sensor_hub_client_devs = devm_kzalloc(&hdev->dev, dev_cnt * + sd->hid_sensor_hub_client_devs = devm_kcalloc(&hdev->dev, + dev_cnt, sizeof(struct mfd_cell), GFP_KERNEL); if (sd->hid_sensor_hub_client_devs == NULL) { diff --git a/drivers/hid/intel-ish-hid/ishtp-hid-client.c b/drivers/hid/intel-ish-hid/ishtp-hid-client.c index 157b44aacdff..295d8fdff342 100644 --- a/drivers/hid/intel-ish-hid/ishtp-hid-client.c +++ b/drivers/hid/intel-ish-hid/ishtp-hid-client.c @@ -121,9 +121,9 @@ static void process_recv(struct ishtp_cl *hid_ishtp_cl, void *recv_buf, } client_data->hid_dev_count = (unsigned int)*payload; if (!client_data->hid_devices) - client_data->hid_devices = devm_kzalloc( + client_data->hid_devices = devm_kcalloc( &client_data->cl_device->dev, - client_data->hid_dev_count * + client_data->hid_dev_count, sizeof(struct device_info), GFP_KERNEL); if (!client_data->hid_devices) { diff --git a/drivers/hid/wacom_sys.c b/drivers/hid/wacom_sys.c index bf8e727988c4..7b531f9feefd 100644 --- a/drivers/hid/wacom_sys.c +++ b/drivers/hid/wacom_sys.c @@ -1267,7 +1267,7 @@ static int wacom_led_groups_alloc_and_register_one(struct device *dev, if (!devres_open_group(dev, &wacom->led.groups[group_id], GFP_KERNEL)) return -ENOMEM; - leds = devm_kzalloc(dev, sizeof(struct wacom_led) * count, GFP_KERNEL); + leds = devm_kcalloc(dev, count, sizeof(struct wacom_led), GFP_KERNEL); if (!leds) { error = -ENOMEM; goto err; @@ -1367,7 +1367,7 @@ static int wacom_led_groups_allocate(struct wacom *wacom, int count) struct wacom_group_leds *groups; int error; - groups = devm_kzalloc(dev, sizeof(struct wacom_group_leds) * count, + groups = devm_kcalloc(dev, count, sizeof(struct wacom_group_leds), GFP_KERNEL); if (!groups) return -ENOMEM; diff --git a/drivers/hwmon/aspeed-pwm-tacho.c b/drivers/hwmon/aspeed-pwm-tacho.c index e4337e9dda44..f9b0342ef0c8 100644 --- a/drivers/hwmon/aspeed-pwm-tacho.c +++ b/drivers/hwmon/aspeed-pwm-tacho.c @@ -894,7 +894,7 @@ static int aspeed_create_fan(struct device *dev, count = of_property_count_u8_elems(child, "aspeed,fan-tach-ch"); if (count < 1) return -EINVAL; - fan_tach_ch = devm_kzalloc(dev, sizeof(*fan_tach_ch) * count, + fan_tach_ch = devm_kcalloc(dev, count, sizeof(*fan_tach_ch), GFP_KERNEL); if (!fan_tach_ch) return -ENOMEM; diff --git a/drivers/hwmon/gpio-fan.c b/drivers/hwmon/gpio-fan.c index 9c355b9d31c5..bd673ccaf4e9 100644 --- a/drivers/hwmon/gpio-fan.c +++ b/drivers/hwmon/gpio-fan.c @@ -477,7 +477,7 @@ static int gpio_fan_get_of_pdata(struct device *dev, dev_err(dev, "DT properties empty / missing"); return -ENODEV; } - ctrl = devm_kzalloc(dev, pdata->num_ctrl * sizeof(unsigned), + ctrl = devm_kcalloc(dev, pdata->num_ctrl, sizeof(unsigned), GFP_KERNEL); if (!ctrl) return -ENOMEM; @@ -509,8 +509,8 @@ static int gpio_fan_get_of_pdata(struct device *dev, * Speed map is in the form * this needs splitting into pairs to create gpio_fan_speed structs */ - speed = devm_kzalloc(dev, - pdata->num_speed * sizeof(struct gpio_fan_speed), + speed = devm_kcalloc(dev, + pdata->num_speed, sizeof(struct gpio_fan_speed), GFP_KERNEL); if (!speed) return -ENOMEM; diff --git a/drivers/hwmon/ibmpowernv.c b/drivers/hwmon/ibmpowernv.c index b38f4951c94e..f15b286bf111 100644 --- a/drivers/hwmon/ibmpowernv.c +++ b/drivers/hwmon/ibmpowernv.c @@ -322,9 +322,9 @@ static int populate_attr_groups(struct platform_device *pdev) of_node_put(opal); for (type = 0; type < MAX_SENSOR_TYPE; type++) { - sensor_groups[type].group.attrs = devm_kzalloc(&pdev->dev, - sizeof(struct attribute *) * - (sensor_groups[type].attr_count + 1), + sensor_groups[type].group.attrs = devm_kcalloc(&pdev->dev, + sensor_groups[type].attr_count + 1, + sizeof(struct attribute *), GFP_KERNEL); if (!sensor_groups[type].group.attrs) return -ENOMEM; @@ -405,7 +405,8 @@ static int create_device_attrs(struct platform_device *pdev) int err = 0; opal = of_find_node_by_path("/ibm,opal/sensors"); - sdata = devm_kzalloc(&pdev->dev, pdata->sensors_count * sizeof(*sdata), + sdata = devm_kcalloc(&pdev->dev, + pdata->sensors_count, sizeof(*sdata), GFP_KERNEL); if (!sdata) { err = -ENOMEM; diff --git a/drivers/hwmon/iio_hwmon.c b/drivers/hwmon/iio_hwmon.c index f6a76679c650..2eeb52e6fe37 100644 --- a/drivers/hwmon/iio_hwmon.c +++ b/drivers/hwmon/iio_hwmon.c @@ -91,8 +91,8 @@ static int iio_hwmon_probe(struct platform_device *pdev) while (st->channels[st->num_channels].indio_dev) st->num_channels++; - st->attrs = devm_kzalloc(dev, - sizeof(*st->attrs) * (st->num_channels + 1), + st->attrs = devm_kcalloc(dev, + st->num_channels + 1, sizeof(*st->attrs), GFP_KERNEL); if (st->attrs == NULL) { ret = -ENOMEM; diff --git a/drivers/hwmon/nct6683.c b/drivers/hwmon/nct6683.c index 8b0bc4fc06e8..43aa38933d1c 100644 --- a/drivers/hwmon/nct6683.c +++ b/drivers/hwmon/nct6683.c @@ -426,12 +426,12 @@ nct6683_create_attr_group(struct device *dev, if (group == NULL) return ERR_PTR(-ENOMEM); - attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1), + attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs), GFP_KERNEL); if (attrs == NULL) return ERR_PTR(-ENOMEM); - su = devm_kzalloc(dev, sizeof(*su) * repeat * count, + su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)), GFP_KERNEL); if (su == NULL) return ERR_PTR(-ENOMEM); diff --git a/drivers/hwmon/nct6775.c b/drivers/hwmon/nct6775.c index 7e14143ed119..42ad3bb2c427 100644 --- a/drivers/hwmon/nct6775.c +++ b/drivers/hwmon/nct6775.c @@ -1149,12 +1149,12 @@ nct6775_create_attr_group(struct device *dev, if (group == NULL) return ERR_PTR(-ENOMEM); - attrs = devm_kzalloc(dev, sizeof(*attrs) * (repeat * count + 1), + attrs = devm_kcalloc(dev, repeat * count + 1, sizeof(*attrs), GFP_KERNEL); if (attrs == NULL) return ERR_PTR(-ENOMEM); - su = devm_kzalloc(dev, sizeof(*su) * repeat * count, + su = devm_kzalloc(dev, array3_size(repeat, count, sizeof(*su)), GFP_KERNEL); if (su == NULL) return ERR_PTR(-ENOMEM); diff --git a/drivers/hwmon/pmbus/pmbus_core.c b/drivers/hwmon/pmbus/pmbus_core.c index cb9064ac4977..c8982cb07768 100644 --- a/drivers/hwmon/pmbus/pmbus_core.c +++ b/drivers/hwmon/pmbus/pmbus_core.c @@ -1992,8 +1992,8 @@ static int pmbus_init_debugfs(struct i2c_client *client, } /* Allocate the max possible entries we need. */ - entries = devm_kzalloc(data->dev, - sizeof(*entries) * (data->info->pages * 10), + entries = devm_kcalloc(data->dev, + data->info->pages * 10, sizeof(*entries), GFP_KERNEL); if (!entries) return -ENOMEM; diff --git a/drivers/hwmon/pwm-fan.c b/drivers/hwmon/pwm-fan.c index f981da686d7e..65de80bd63d8 100644 --- a/drivers/hwmon/pwm-fan.c +++ b/drivers/hwmon/pwm-fan.c @@ -180,7 +180,7 @@ static int pwm_fan_of_get_cooling_data(struct device *dev, } num = ret; - ctx->pwm_fan_cooling_levels = devm_kzalloc(dev, num * sizeof(u32), + ctx->pwm_fan_cooling_levels = devm_kcalloc(dev, num, sizeof(u32), GFP_KERNEL); if (!ctx->pwm_fan_cooling_levels) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-etb10.c b/drivers/hwtracing/coresight/coresight-etb10.c index e1132524f4c8..38f4e49022a7 100644 --- a/drivers/hwtracing/coresight/coresight-etb10.c +++ b/drivers/hwtracing/coresight/coresight-etb10.c @@ -748,8 +748,8 @@ static int etb_probe(struct amba_device *adev, const struct amba_id *id) if (drvdata->buffer_depth & 0x80000000) return -EINVAL; - drvdata->buf = devm_kzalloc(dev, - drvdata->buffer_depth * 4, GFP_KERNEL); + drvdata->buf = devm_kcalloc(dev, + drvdata->buffer_depth, 4, GFP_KERNEL); if (!drvdata->buf) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-hwevent.c b/drivers/hwtracing/coresight/coresight-hwevent.c index d06fe1d749d1..0ed6b4675bff 100644 --- a/drivers/hwtracing/coresight/coresight-hwevent.c +++ b/drivers/hwtracing/coresight/coresight-hwevent.c @@ -204,7 +204,8 @@ static int hwevent_probe(struct platform_device *pdev) drvdata->nr_hmux = 0; if (drvdata->nr_hmux > 0) { - drvdata->hmux = devm_kzalloc(dev, drvdata->nr_hmux * + drvdata->hmux = devm_kcalloc(dev, + drvdata->nr_hmux, sizeof(*drvdata->hmux), GFP_KERNEL); if (!drvdata->hmux) @@ -236,7 +237,8 @@ static int hwevent_probe(struct platform_device *pdev) "qcom,hwevent-regs"); if (drvdata->nr_hclk > 0) { - drvdata->hclk = devm_kzalloc(dev, drvdata->nr_hclk * + drvdata->hclk = devm_kcalloc(dev, + drvdata->nr_hclk, sizeof(*drvdata->hclk), GFP_KERNEL); if (!drvdata->hclk) @@ -255,7 +257,8 @@ static int hwevent_probe(struct platform_device *pdev) } } if (drvdata->nr_hreg > 0) { - drvdata->hreg = devm_kzalloc(dev, drvdata->nr_hreg * + drvdata->hreg = devm_kcalloc(dev, + drvdata->nr_hreg, sizeof(*drvdata->hreg), GFP_KERNEL); if (!drvdata->hreg) diff --git a/drivers/hwtracing/coresight/coresight-tgu.c b/drivers/hwtracing/coresight/coresight-tgu.c index 31e10b52ac1d..ca17fed4b139 100644 --- a/drivers/hwtracing/coresight/coresight-tgu.c +++ b/drivers/hwtracing/coresight/coresight-tgu.c @@ -458,34 +458,39 @@ static int tgu_probe(struct amba_device *adev, const struct amba_id *id) return -EINVAL; /* Alloc memory for Grps, Conditions and Steps */ - drvdata->grp_data = devm_kzalloc(dev, MAX_GROUP_SETS * - sizeof(*drvdata->grp_data), - GFP_KERNEL); + drvdata->grp_data = devm_kcalloc(dev, + MAX_GROUP_SETS, + sizeof(*drvdata->grp_data), + GFP_KERNEL); if (!drvdata->grp_data) return -ENOMEM; - drvdata->condition_data = devm_kzalloc(dev, MAX_CONDITION_SETS * - sizeof(*drvdata->condition_data), - GFP_KERNEL); + drvdata->condition_data = devm_kcalloc(dev, + MAX_CONDITION_SETS, + sizeof(*drvdata->condition_data), + GFP_KERNEL); if (!drvdata->condition_data) return -ENOMEM; - drvdata->select_data = devm_kzalloc(dev, MAX_CONDITION_SETS * - sizeof(*drvdata->select_data), - GFP_KERNEL); + drvdata->select_data = devm_kcalloc(dev, + MAX_CONDITION_SETS, + sizeof(*drvdata->select_data), + GFP_KERNEL); if (!drvdata->select_data) return -ENOMEM; - drvdata->timer_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS * - sizeof(*drvdata->timer_data), - GFP_KERNEL); + drvdata->timer_data = devm_kcalloc(dev, + MAX_TIMER_COUNTER_SETS, + sizeof(*drvdata->timer_data), + GFP_KERNEL); if (!drvdata->timer_data) return -ENOMEM; - drvdata->counter_data = devm_kzalloc(dev, MAX_TIMER_COUNTER_SETS * - sizeof(*drvdata->counter_data), - GFP_KERNEL); + drvdata->counter_data = devm_kcalloc(dev, + MAX_TIMER_COUNTER_SETS, + sizeof(*drvdata->counter_data), + GFP_KERNEL); if (!drvdata->counter_data) return -ENOMEM; diff --git a/drivers/hwtracing/coresight/coresight-tpdm.c b/drivers/hwtracing/coresight/coresight-tpdm.c index 18c0ce7d84fa..d14a31b00b0f 100644 --- a/drivers/hwtracing/coresight/coresight-tpdm.c +++ b/drivers/hwtracing/coresight/coresight-tpdm.c @@ -4437,7 +4437,8 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) drvdata->nr_tclk = of_property_count_strings(adev->dev.of_node, "qcom,tpdm-clks"); if (drvdata->nr_tclk > 0) { - drvdata->tclk = devm_kzalloc(dev, drvdata->nr_tclk * + drvdata->tclk = devm_kcalloc(dev, + drvdata->nr_tclk, sizeof(*drvdata->tclk), GFP_KERNEL); if (!drvdata->tclk) @@ -4459,7 +4460,8 @@ static int tpdm_probe(struct amba_device *adev, const struct amba_id *id) drvdata->nr_treg = of_property_count_strings(adev->dev.of_node, "qcom,tpdm-regs"); if (drvdata->nr_treg > 0) { - drvdata->treg = devm_kzalloc(dev, drvdata->nr_treg * + drvdata->treg = devm_kcalloc(dev, + drvdata->nr_treg, sizeof(*drvdata->treg), GFP_KERNEL); if (!drvdata->treg) diff --git a/drivers/hwtracing/coresight/of_coresight.c b/drivers/hwtracing/coresight/of_coresight.c index 3374394a4df4..d11d0c6292f6 100644 --- a/drivers/hwtracing/coresight/of_coresight.c +++ b/drivers/hwtracing/coresight/of_coresight.c @@ -85,27 +85,31 @@ static int of_coresight_alloc_memory(struct device *dev, struct coresight_platform_data *pdata) { /* List of output port on this component */ - pdata->outports = devm_kzalloc(dev, pdata->nr_outport * + pdata->outports = devm_kcalloc(dev, + pdata->nr_outport, sizeof(*pdata->outports), GFP_KERNEL); if (!pdata->outports) return -ENOMEM; - pdata->source_names = devm_kzalloc(dev, pdata->nr_outport * - sizeof(*pdata->source_names), - GFP_KERNEL); + pdata->source_names = devm_kcalloc(dev, + pdata->nr_outport, + sizeof(*pdata->source_names), + GFP_KERNEL); if (!pdata->source_names) return -ENOMEM; /* Children connected to this component via @outports */ - pdata->child_names = devm_kzalloc(dev, pdata->nr_outport * + pdata->child_names = devm_kcalloc(dev, + pdata->nr_outport, sizeof(*pdata->child_names), GFP_KERNEL); if (!pdata->child_names) return -ENOMEM; /* Port number on the child this component is connected to */ - pdata->child_ports = devm_kzalloc(dev, pdata->nr_outport * + pdata->child_ports = devm_kcalloc(dev, + pdata->nr_outport, sizeof(*pdata->child_ports), GFP_KERNEL); if (!pdata->child_ports) @@ -149,8 +153,9 @@ of_coresight_get_reg_clk(struct device *dev, const struct device_node *node) reg_clk->nr_reg = nr_reg; reg_clk->nr_clk = nr_clk; if (nr_reg > 0) { - reg_clk->reg = devm_kzalloc(dev, nr_reg * - sizeof(reg_clk->reg), GFP_KERNEL); + reg_clk->reg = devm_kcalloc(dev, + nr_reg, sizeof(reg_clk->reg), + GFP_KERNEL); if (!reg_clk->reg) return ERR_PTR(-ENOMEM); @@ -165,8 +170,9 @@ of_coresight_get_reg_clk(struct device *dev, const struct device_node *node) } } if (nr_clk > 0) { - reg_clk->clk = devm_kzalloc(dev, nr_clk * - sizeof(reg_clk->clk), GFP_KERNEL); + reg_clk->clk = devm_kcalloc(dev, + nr_clk, sizeof(reg_clk->clk), + GFP_KERNEL); if (!reg_clk->clk) return ERR_PTR(-ENOMEM); @@ -336,7 +342,8 @@ struct coresight_cti_data *of_get_coresight_cti_data( return ERR_PTR(-EINVAL); if (ctidata->nr_ctis) { - ctidata->names = devm_kzalloc(dev, ctidata->nr_ctis * + ctidata->names = devm_kcalloc(dev, + ctidata->nr_ctis, sizeof(*ctidata->names), GFP_KERNEL); if (!ctidata->names) diff --git a/drivers/i2c/busses/i2c-msm-v2.c b/drivers/i2c/busses/i2c-msm-v2.c index 69c4a71826c0..42ef4f0472c2 100644 --- a/drivers/i2c/busses/i2c-msm-v2.c +++ b/drivers/i2c/busses/i2c-msm-v2.c @@ -1598,11 +1598,11 @@ static int i2c_msm_clk_path_init_structs(struct i2c_msm_ctrl *ctrl) i2c_msm_dbg(ctrl, MSM_PROF, "initializes path clock voting structs\n"); - paths = devm_kzalloc(ctrl->dev, sizeof(*paths) * 2, GFP_KERNEL); + paths = devm_kcalloc(ctrl->dev, 2, sizeof(*paths), GFP_KERNEL); if (!paths) return -ENOMEM; - usecases = devm_kzalloc(ctrl->dev, sizeof(*usecases) * 2, GFP_KERNEL); + usecases = devm_kcalloc(ctrl->dev, 2, sizeof(*usecases), GFP_KERNEL); if (!usecases) goto path_init_err; diff --git a/drivers/i2c/busses/i2c-qup.c b/drivers/i2c/busses/i2c-qup.c index 8f6903ec7aec..fa5d8e0068e2 100644 --- a/drivers/i2c/busses/i2c-qup.c +++ b/drivers/i2c/busses/i2c-qup.c @@ -1459,8 +1459,8 @@ static int qup_i2c_probe(struct platform_device *pdev) goto nodma; blocks = (MX_BLOCKS << 1) + 1; - qup->btx.sg = devm_kzalloc(&pdev->dev, - sizeof(*qup->btx.sg) * blocks, + qup->btx.sg = devm_kcalloc(&pdev->dev, + blocks, sizeof(*qup->btx.sg), GFP_KERNEL); if (!qup->btx.sg) { ret = -ENOMEM; @@ -1468,8 +1468,8 @@ static int qup_i2c_probe(struct platform_device *pdev) } sg_init_table(qup->btx.sg, blocks); - qup->brx.sg = devm_kzalloc(&pdev->dev, - sizeof(*qup->brx.sg) * blocks, + qup->brx.sg = devm_kcalloc(&pdev->dev, + blocks, sizeof(*qup->brx.sg), GFP_KERNEL); if (!qup->brx.sg) { ret = -ENOMEM; diff --git a/drivers/i2c/muxes/i2c-mux-gpio.c b/drivers/i2c/muxes/i2c-mux-gpio.c index 1a9973ede443..ddc4bd4ca13b 100644 --- a/drivers/i2c/muxes/i2c-mux-gpio.c +++ b/drivers/i2c/muxes/i2c-mux-gpio.c @@ -88,8 +88,8 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, mux->data.n_values = of_get_child_count(np); - values = devm_kzalloc(&pdev->dev, - sizeof(*mux->data.values) * mux->data.n_values, + values = devm_kcalloc(&pdev->dev, + mux->data.n_values, sizeof(*mux->data.values), GFP_KERNEL); if (!values) { dev_err(&pdev->dev, "Cannot allocate values array"); @@ -111,8 +111,9 @@ static int i2c_mux_gpio_probe_dt(struct gpiomux *mux, return -EINVAL; } - gpios = devm_kzalloc(&pdev->dev, - sizeof(*mux->data.gpios) * mux->data.n_gpios, GFP_KERNEL); + gpios = devm_kcalloc(&pdev->dev, + mux->data.n_gpios, sizeof(*mux->data.gpios), + GFP_KERNEL); if (!gpios) { dev_err(&pdev->dev, "Cannot allocate gpios array"); return -ENOMEM; diff --git a/drivers/i2c/muxes/i2c-mux-reg.c b/drivers/i2c/muxes/i2c-mux-reg.c index d97031804de8..92af78769600 100644 --- a/drivers/i2c/muxes/i2c-mux-reg.c +++ b/drivers/i2c/muxes/i2c-mux-reg.c @@ -127,8 +127,8 @@ static int i2c_mux_reg_probe_dt(struct regmux *mux, else mux->data.write_only = false; - values = devm_kzalloc(&pdev->dev, - sizeof(*mux->data.values) * mux->data.n_values, + values = devm_kcalloc(&pdev->dev, + mux->data.n_values, sizeof(*mux->data.values), GFP_KERNEL); if (!values) { dev_err(&pdev->dev, "Cannot allocate values array"); diff --git a/drivers/iio/adc/at91_adc.c b/drivers/iio/adc/at91_adc.c index 492f6c8ba735..465b7b065ac8 100644 --- a/drivers/iio/adc/at91_adc.c +++ b/drivers/iio/adc/at91_adc.c @@ -629,8 +629,8 @@ static int at91_adc_trigger_init(struct iio_dev *idev) struct at91_adc_state *st = iio_priv(idev); int i, ret; - st->trig = devm_kzalloc(&idev->dev, - st->trigger_number * sizeof(*st->trig), + st->trig = devm_kcalloc(&idev->dev, + st->trigger_number, sizeof(*st->trig), GFP_KERNEL); if (st->trig == NULL) { @@ -919,7 +919,8 @@ static int at91_adc_probe_dt(struct at91_adc_state *st, st->registers = &st->caps->registers; st->num_channels = st->caps->num_channels; st->trigger_number = of_get_child_count(node); - st->trigger_list = devm_kzalloc(&idev->dev, st->trigger_number * + st->trigger_list = devm_kcalloc(&idev->dev, + st->trigger_number, sizeof(struct at91_adc_trigger), GFP_KERNEL); if (!st->trigger_list) { diff --git a/drivers/iio/adc/max1363.c b/drivers/iio/adc/max1363.c index 80eada4886b3..7f255486bff0 100644 --- a/drivers/iio/adc/max1363.c +++ b/drivers/iio/adc/max1363.c @@ -1455,8 +1455,8 @@ static int max1363_alloc_scan_masks(struct iio_dev *indio_dev) int i; masks = devm_kzalloc(&indio_dev->dev, - BITS_TO_LONGS(MAX1363_MAX_CHANNELS) * sizeof(long) * - (st->chip_info->num_modes + 1), GFP_KERNEL); + array3_size(BITS_TO_LONGS(MAX1363_MAX_CHANNELS), sizeof(long), (st->chip_info->num_modes + 1)), + GFP_KERNEL); if (!masks) return -ENOMEM; diff --git a/drivers/iio/adc/twl6030-gpadc.c b/drivers/iio/adc/twl6030-gpadc.c index bc0e60b9da45..b74a1f410ff8 100644 --- a/drivers/iio/adc/twl6030-gpadc.c +++ b/drivers/iio/adc/twl6030-gpadc.c @@ -899,9 +899,10 @@ static int twl6030_gpadc_probe(struct platform_device *pdev) gpadc = iio_priv(indio_dev); - gpadc->twl6030_cal_tbl = devm_kzalloc(dev, - sizeof(*gpadc->twl6030_cal_tbl) * - pdata->nchannels, GFP_KERNEL); + gpadc->twl6030_cal_tbl = devm_kcalloc(dev, + pdata->nchannels, + sizeof(*gpadc->twl6030_cal_tbl), + GFP_KERNEL); if (!gpadc->twl6030_cal_tbl) return -ENOMEM; diff --git a/drivers/iio/dac/ad5592r-base.c b/drivers/iio/dac/ad5592r-base.c index 69bde5909854..93c9b461c955 100644 --- a/drivers/iio/dac/ad5592r-base.c +++ b/drivers/iio/dac/ad5592r-base.c @@ -537,8 +537,9 @@ static int ad5592r_alloc_channels(struct ad5592r_state *st) st->channel_offstate[reg] = tmp; } - channels = devm_kzalloc(st->dev, - (1 + 2 * num_channels) * sizeof(*channels), GFP_KERNEL); + channels = devm_kcalloc(st->dev, + 1 + 2 * num_channels, sizeof(*channels), + GFP_KERNEL); if (!channels) return -ENOMEM; diff --git a/drivers/iio/multiplexer/iio-mux.c b/drivers/iio/multiplexer/iio-mux.c index 74831fcd0313..805c66517468 100644 --- a/drivers/iio/multiplexer/iio-mux.c +++ b/drivers/iio/multiplexer/iio-mux.c @@ -282,9 +282,10 @@ static int mux_configure_channel(struct device *dev, struct mux *mux, if (!page) return -ENOMEM; } - child->ext_info_cache = devm_kzalloc(dev, - sizeof(*child->ext_info_cache) * - num_ext_info, GFP_KERNEL); + child->ext_info_cache = devm_kcalloc(dev, + num_ext_info, + sizeof(*child->ext_info_cache), + GFP_KERNEL); if (!child->ext_info_cache) return -ENOMEM; diff --git a/drivers/input/keyboard/clps711x-keypad.c b/drivers/input/keyboard/clps711x-keypad.c index 997e3e97f573..e319f745771a 100644 --- a/drivers/input/keyboard/clps711x-keypad.c +++ b/drivers/input/keyboard/clps711x-keypad.c @@ -109,8 +109,8 @@ static int clps711x_keypad_probe(struct platform_device *pdev) if (priv->row_count < 1) return -EINVAL; - priv->gpio_data = devm_kzalloc(dev, - sizeof(*priv->gpio_data) * priv->row_count, + priv->gpio_data = devm_kcalloc(dev, + priv->row_count, sizeof(*priv->gpio_data), GFP_KERNEL); if (!priv->gpio_data) return -ENOMEM; diff --git a/drivers/input/keyboard/matrix_keypad.c b/drivers/input/keyboard/matrix_keypad.c index c04559a232f7..3d1cb7bf5e35 100644 --- a/drivers/input/keyboard/matrix_keypad.c +++ b/drivers/input/keyboard/matrix_keypad.c @@ -443,9 +443,9 @@ matrix_keypad_parse_dt(struct device *dev) of_property_read_u32(np, "col-scan-delay-us", &pdata->col_scan_delay_us); - gpios = devm_kzalloc(dev, - sizeof(unsigned int) * - (pdata->num_row_gpios + pdata->num_col_gpios), + gpios = devm_kcalloc(dev, + pdata->num_row_gpios + pdata->num_col_gpios, + sizeof(unsigned int), GFP_KERNEL); if (!gpios) { dev_err(dev, "could not allocate memory for gpios\n"); diff --git a/drivers/input/keyboard/samsung-keypad.c b/drivers/input/keyboard/samsung-keypad.c index 316414465c77..1fe1aa2adf85 100644 --- a/drivers/input/keyboard/samsung-keypad.c +++ b/drivers/input/keyboard/samsung-keypad.c @@ -281,7 +281,7 @@ samsung_keypad_parse_dt(struct device *dev) key_count = of_get_child_count(np); keymap_data->keymap_size = key_count; - keymap = devm_kzalloc(dev, sizeof(uint32_t) * key_count, GFP_KERNEL); + keymap = devm_kcalloc(dev, key_count, sizeof(uint32_t), GFP_KERNEL); if (!keymap) { dev_err(dev, "could not allocate memory for keymap\n"); return ERR_PTR(-ENOMEM); diff --git a/drivers/input/matrix-keymap.c b/drivers/input/matrix-keymap.c index 8ccefc15c7a4..8b3a5758451e 100644 --- a/drivers/input/matrix-keymap.c +++ b/drivers/input/matrix-keymap.c @@ -170,8 +170,8 @@ int matrix_keypad_build_keymap(const struct matrix_keymap_data *keymap_data, return -EINVAL; if (!keymap) { - keymap = devm_kzalloc(input_dev->dev.parent, - max_keys * sizeof(*keymap), + keymap = devm_kcalloc(input_dev->dev.parent, + max_keys, sizeof(*keymap), GFP_KERNEL); if (!keymap) { dev_err(input_dev->dev.parent, diff --git a/drivers/input/misc/rotary_encoder.c b/drivers/input/misc/rotary_encoder.c index 1588aecafff7..6d304381fc30 100644 --- a/drivers/input/misc/rotary_encoder.c +++ b/drivers/input/misc/rotary_encoder.c @@ -283,8 +283,8 @@ static int rotary_encoder_probe(struct platform_device *pdev) } encoder->irq = - devm_kzalloc(dev, - sizeof(*encoder->irq) * encoder->gpios->ndescs, + devm_kcalloc(dev, + encoder->gpios->ndescs, sizeof(*encoder->irq), GFP_KERNEL); if (!encoder->irq) return -ENOMEM; diff --git a/drivers/input/rmi4/rmi_driver.c b/drivers/input/rmi4/rmi_driver.c index 30a8d816c45c..e51cf50f3b22 100644 --- a/drivers/input/rmi4/rmi_driver.c +++ b/drivers/input/rmi4/rmi_driver.c @@ -636,9 +636,10 @@ int rmi_read_register_desc(struct rmi_device *d, u16 addr, rdesc->num_registers = bitmap_weight(rdesc->presense_map, RMI_REG_DESC_PRESENSE_BITS); - rdesc->registers = devm_kzalloc(&d->dev, rdesc->num_registers * - sizeof(struct rmi_register_desc_item), - GFP_KERNEL); + rdesc->registers = devm_kcalloc(&d->dev, + rdesc->num_registers, + sizeof(struct rmi_register_desc_item), + GFP_KERNEL); if (!rdesc->registers) return -ENOMEM; @@ -1057,7 +1058,7 @@ int rmi_probe_interrupts(struct rmi_driver_data *data) data->num_of_irq_regs = (data->irq_count + 7) / 8; size = BITS_TO_LONGS(data->irq_count) * sizeof(unsigned long); - data->irq_memory = devm_kzalloc(dev, size * 4, GFP_KERNEL); + data->irq_memory = devm_kcalloc(dev, size, 4, GFP_KERNEL); if (!data->irq_memory) { dev_err(dev, "Failed to allocate memory for irq masks.\n"); return -ENOMEM; diff --git a/drivers/input/rmi4/rmi_f11.c b/drivers/input/rmi4/rmi_f11.c index e8c3e5d1ea22..77a4a1b2dd4f 100644 --- a/drivers/input/rmi4/rmi_f11.c +++ b/drivers/input/rmi4/rmi_f11.c @@ -1190,14 +1190,15 @@ static int rmi_f11_initialize(struct rmi_function *fn) f11->sensor.attn_size += f11->sensor.nbr_fingers * 2; /* allocate the in-kernel tracking buffers */ - sensor->tracking_pos = devm_kzalloc(&fn->dev, - sizeof(struct input_mt_pos) * sensor->nbr_fingers, + sensor->tracking_pos = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, sizeof(struct input_mt_pos), + GFP_KERNEL); + sensor->tracking_slots = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, sizeof(int), GFP_KERNEL); + sensor->objs = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, + sizeof(struct rmi_2d_sensor_abs_object), GFP_KERNEL); - sensor->tracking_slots = devm_kzalloc(&fn->dev, - sizeof(int) * sensor->nbr_fingers, GFP_KERNEL); - sensor->objs = devm_kzalloc(&fn->dev, - sizeof(struct rmi_2d_sensor_abs_object) - * sensor->nbr_fingers, GFP_KERNEL); if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) return -ENOMEM; diff --git a/drivers/input/rmi4/rmi_f12.c b/drivers/input/rmi4/rmi_f12.c index 99dd2f512058..10847408e0f9 100644 --- a/drivers/input/rmi4/rmi_f12.c +++ b/drivers/input/rmi4/rmi_f12.c @@ -526,14 +526,15 @@ static int rmi_f12_probe(struct rmi_function *fn) } /* allocate the in-kernel tracking buffers */ - sensor->tracking_pos = devm_kzalloc(&fn->dev, - sizeof(struct input_mt_pos) * sensor->nbr_fingers, + sensor->tracking_pos = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, sizeof(struct input_mt_pos), + GFP_KERNEL); + sensor->tracking_slots = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, sizeof(int), GFP_KERNEL); + sensor->objs = devm_kcalloc(&fn->dev, + sensor->nbr_fingers, + sizeof(struct rmi_2d_sensor_abs_object), GFP_KERNEL); - sensor->tracking_slots = devm_kzalloc(&fn->dev, - sizeof(int) * sensor->nbr_fingers, GFP_KERNEL); - sensor->objs = devm_kzalloc(&fn->dev, - sizeof(struct rmi_2d_sensor_abs_object) - * sensor->nbr_fingers, GFP_KERNEL); if (!sensor->tracking_pos || !sensor->tracking_slots || !sensor->objs) return -ENOMEM; diff --git a/drivers/input/rmi4/rmi_f54.c b/drivers/input/rmi4/rmi_f54.c index 7f1959517ec0..de036cad7274 100644 --- a/drivers/input/rmi4/rmi_f54.c +++ b/drivers/input/rmi4/rmi_f54.c @@ -685,7 +685,7 @@ static int rmi_f54_probe(struct rmi_function *fn) rx = f54->num_rx_electrodes; tx = f54->num_tx_electrodes; f54->report_data = devm_kzalloc(&fn->dev, - sizeof(u16) * tx * rx, + array3_size(tx, rx, sizeof(u16)), GFP_KERNEL); if (f54->report_data == NULL) return -ENOMEM; diff --git a/drivers/input/rmi4/rmi_spi.c b/drivers/input/rmi4/rmi_spi.c index d0c3d275bf9f..9623395d9415 100644 --- a/drivers/input/rmi4/rmi_spi.c +++ b/drivers/input/rmi4/rmi_spi.c @@ -69,7 +69,7 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) buf_size = RMI_SPI_XFER_SIZE_LIMIT; tmp = rmi_spi->rx_buf; - buf = devm_kzalloc(&spi->dev, buf_size * 2, + buf = devm_kcalloc(&spi->dev, buf_size, 2, GFP_KERNEL | GFP_DMA); if (!buf) return -ENOMEM; @@ -96,9 +96,10 @@ static int rmi_spi_manage_pools(struct rmi_spi_xport *rmi_spi, int len) * per byte delays. */ tmp = rmi_spi->rx_xfers; - xfer_buf = devm_kzalloc(&spi->dev, - (rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count) - * sizeof(struct spi_transfer), GFP_KERNEL); + xfer_buf = devm_kcalloc(&spi->dev, + rmi_spi->rx_xfer_count + rmi_spi->tx_xfer_count, + sizeof(struct spi_transfer), + GFP_KERNEL); if (!xfer_buf) return -ENOMEM; diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c index 77d67eaca378..6f10c8b365b3 100644 --- a/drivers/iommu/arm-smmu.c +++ b/drivers/iommu/arm-smmu.c @@ -4584,8 +4584,8 @@ static int arm_smmu_init_clocks(struct arm_smmu_power_resources *pwr) return 0; } - pwr->clocks = devm_kzalloc( - dev, sizeof(*pwr->clocks) * pwr->num_clocks, + pwr->clocks = devm_kcalloc( + dev, pwr->num_clocks, sizeof(*pwr->clocks), GFP_KERNEL); if (!pwr->clocks) @@ -4630,8 +4630,8 @@ static int arm_smmu_init_regulators(struct arm_smmu_power_resources *pwr) return 0; } - pwr->gdscs = devm_kzalloc( - dev, sizeof(*pwr->gdscs) * pwr->num_gdscs, GFP_KERNEL); + pwr->gdscs = devm_kcalloc( + dev, pwr->num_gdscs, sizeof(*pwr->gdscs), GFP_KERNEL); if (!pwr->gdscs) return -ENOMEM; @@ -5141,7 +5141,7 @@ static int arm_smmu_device_dt_probe(struct platform_device *pdev) return -ENODEV; } - smmu->irqs = devm_kzalloc(dev, sizeof(*smmu->irqs) * num_irqs, + smmu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*smmu->irqs), GFP_KERNEL); if (!smmu->irqs) { dev_err(dev, "failed to allocate %d irqs\n", num_irqs); @@ -5933,7 +5933,7 @@ static int qsmmuv500_read_actlr_tbl(struct arm_smmu_device *smmu) if (len < 0) return 0; - actlrs = devm_kzalloc(dev, sizeof(*actlrs) * len, GFP_KERNEL); + actlrs = devm_kcalloc(dev, len, sizeof(*actlrs), GFP_KERNEL); if (!actlrs) return -ENOMEM; @@ -6632,7 +6632,7 @@ static int qsmmuv500_tbu_probe(struct platform_device *pdev) while ((res = platform_get_resource(pdev, IORESOURCE_IRQ, num_irqs))) num_irqs++; - tbu->irqs = devm_kzalloc(dev, sizeof(*tbu->irqs) * num_irqs, + tbu->irqs = devm_kcalloc(dev, num_irqs, sizeof(*tbu->irqs), GFP_KERNEL); if (!tbu->irqs) return -ENOMEM; diff --git a/drivers/iommu/rockchip-iommu.c b/drivers/iommu/rockchip-iommu.c index 9d991c2d8767..3300562dfa70 100644 --- a/drivers/iommu/rockchip-iommu.c +++ b/drivers/iommu/rockchip-iommu.c @@ -1148,7 +1148,7 @@ static int rk_iommu_probe(struct platform_device *pdev) iommu->dev = dev; iommu->num_mmu = 0; - iommu->bases = devm_kzalloc(dev, sizeof(*iommu->bases) * num_res, + iommu->bases = devm_kcalloc(dev, num_res, sizeof(*iommu->bases), GFP_KERNEL); if (!iommu->bases) return -ENOMEM; diff --git a/drivers/irqchip/irq-imgpdc.c b/drivers/irqchip/irq-imgpdc.c index 1f59998e03f8..b4a84ba16b39 100644 --- a/drivers/irqchip/irq-imgpdc.c +++ b/drivers/irqchip/irq-imgpdc.c @@ -354,7 +354,7 @@ static int pdc_intc_probe(struct platform_device *pdev) priv->nr_syswakes = val; /* Get peripheral IRQ numbers */ - priv->perip_irqs = devm_kzalloc(&pdev->dev, 4 * priv->nr_perips, + priv->perip_irqs = devm_kcalloc(&pdev->dev, 4, priv->nr_perips, GFP_KERNEL); if (!priv->perip_irqs) { dev_err(&pdev->dev, "cannot allocate perip IRQ list\n"); diff --git a/drivers/irqchip/irq-mvebu-gicp.c b/drivers/irqchip/irq-mvebu-gicp.c index 17a4a7b6cdbb..cb3e6ddb075b 100644 --- a/drivers/irqchip/irq-mvebu-gicp.c +++ b/drivers/irqchip/irq-mvebu-gicp.c @@ -207,8 +207,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) gicp->spi_ranges_cnt = ret / 2; gicp->spi_ranges = - devm_kzalloc(&pdev->dev, - gicp->spi_ranges_cnt * + devm_kcalloc(&pdev->dev, + gicp->spi_ranges_cnt, sizeof(struct mvebu_gicp_spi_range), GFP_KERNEL); if (!gicp->spi_ranges) @@ -226,8 +226,8 @@ static int mvebu_gicp_probe(struct platform_device *pdev) gicp->spi_cnt += gicp->spi_ranges[i].count; } - gicp->spi_bitmap = devm_kzalloc(&pdev->dev, - BITS_TO_LONGS(gicp->spi_cnt) * sizeof(long), + gicp->spi_bitmap = devm_kcalloc(&pdev->dev, + BITS_TO_LONGS(gicp->spi_cnt), sizeof(long), GFP_KERNEL); if (!gicp->spi_bitmap) return -ENOMEM; diff --git a/drivers/leds/leds-adp5520.c b/drivers/leds/leds-adp5520.c index 853b2d3bdb17..7ecf080f73ad 100644 --- a/drivers/leds/leds-adp5520.c +++ b/drivers/leds/leds-adp5520.c @@ -108,7 +108,7 @@ static int adp5520_led_probe(struct platform_device *pdev) return -EFAULT; } - led = devm_kzalloc(&pdev->dev, sizeof(*led) * pdata->num_leds, + led = devm_kcalloc(&pdev->dev, pdata->num_leds, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; diff --git a/drivers/leds/leds-da9052.c b/drivers/leds/leds-da9052.c index f8c7d82c2652..31d4c94e6fd8 100644 --- a/drivers/leds/leds-da9052.c +++ b/drivers/leds/leds-da9052.c @@ -113,8 +113,8 @@ static int da9052_led_probe(struct platform_device *pdev) goto err; } - led = devm_kzalloc(&pdev->dev, - sizeof(struct da9052_led) * pled->num_leds, + led = devm_kcalloc(&pdev->dev, + pled->num_leds, sizeof(struct da9052_led), GFP_KERNEL); if (!led) { error = -ENOMEM; diff --git a/drivers/leds/leds-lp5521.c b/drivers/leds/leds-lp5521.c index 55c0517fbe03..99689b51a73d 100644 --- a/drivers/leds/leds-lp5521.c +++ b/drivers/leds/leds-lp5521.c @@ -533,8 +533,8 @@ static int lp5521_probe(struct i2c_client *client, if (!chip) return -ENOMEM; - led = devm_kzalloc(&client->dev, - sizeof(*led) * pdata->num_channels, GFP_KERNEL); + led = devm_kcalloc(&client->dev, + pdata->num_channels, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; diff --git a/drivers/leds/leds-lp5523.c b/drivers/leds/leds-lp5523.c index 13838d72e297..5074a1b79563 100644 --- a/drivers/leds/leds-lp5523.c +++ b/drivers/leds/leds-lp5523.c @@ -900,8 +900,8 @@ static int lp5523_probe(struct i2c_client *client, if (!chip) return -ENOMEM; - led = devm_kzalloc(&client->dev, - sizeof(*led) * pdata->num_channels, GFP_KERNEL); + led = devm_kcalloc(&client->dev, + pdata->num_channels, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; diff --git a/drivers/leds/leds-lp5562.c b/drivers/leds/leds-lp5562.c index 9d9b673c873c..18edc8bdc9f7 100644 --- a/drivers/leds/leds-lp5562.c +++ b/drivers/leds/leds-lp5562.c @@ -538,8 +538,8 @@ static int lp5562_probe(struct i2c_client *client, if (!chip) return -ENOMEM; - led = devm_kzalloc(&client->dev, - sizeof(*led) * pdata->num_channels, GFP_KERNEL); + led = devm_kcalloc(&client->dev, + pdata->num_channels, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; diff --git a/drivers/leds/leds-lp55xx-common.c b/drivers/leds/leds-lp55xx-common.c index e2655953667c..723f2f17497a 100644 --- a/drivers/leds/leds-lp55xx-common.c +++ b/drivers/leds/leds-lp55xx-common.c @@ -560,7 +560,7 @@ struct lp55xx_platform_data *lp55xx_of_populate_pdata(struct device *dev, return ERR_PTR(-EINVAL); } - cfg = devm_kzalloc(dev, sizeof(*cfg) * num_channels, GFP_KERNEL); + cfg = devm_kcalloc(dev, num_channels, sizeof(*cfg), GFP_KERNEL); if (!cfg) return ERR_PTR(-ENOMEM); diff --git a/drivers/leds/leds-lp8501.c b/drivers/leds/leds-lp8501.c index 3adb113cf02e..4c800b5989a9 100644 --- a/drivers/leds/leds-lp8501.c +++ b/drivers/leds/leds-lp8501.c @@ -327,8 +327,8 @@ static int lp8501_probe(struct i2c_client *client, if (!chip) return -ENOMEM; - led = devm_kzalloc(&client->dev, - sizeof(*led) * pdata->num_channels, GFP_KERNEL); + led = devm_kcalloc(&client->dev, + pdata->num_channels, sizeof(*led), GFP_KERNEL); if (!led) return -ENOMEM; diff --git a/drivers/leds/leds-lt3593.c b/drivers/leds/leds-lt3593.c index a7ff510cbdd0..5ec730a31b65 100644 --- a/drivers/leds/leds-lt3593.c +++ b/drivers/leds/leds-lt3593.c @@ -128,8 +128,8 @@ static int lt3593_led_probe(struct platform_device *pdev) if (!pdata) return -EBUSY; - leds_data = devm_kzalloc(&pdev->dev, - sizeof(struct lt3593_led_data) * pdata->num_leds, + leds_data = devm_kcalloc(&pdev->dev, + pdata->num_leds, sizeof(struct lt3593_led_data), GFP_KERNEL); if (!leds_data) return -ENOMEM; diff --git a/drivers/leds/leds-mc13783.c b/drivers/leds/leds-mc13783.c index 2421cf104991..47ad7de9553c 100644 --- a/drivers/leds/leds-mc13783.c +++ b/drivers/leds/leds-mc13783.c @@ -136,7 +136,7 @@ static struct mc13xxx_leds_platform_data __init *mc13xxx_led_probe_dt( pdata->num_leds = of_get_child_count(parent); - pdata->led = devm_kzalloc(dev, pdata->num_leds * sizeof(*pdata->led), + pdata->led = devm_kcalloc(dev, pdata->num_leds, sizeof(*pdata->led), GFP_KERNEL); if (!pdata->led) { ret = -ENOMEM; @@ -210,7 +210,7 @@ static int __init mc13xxx_led_probe(struct platform_device *pdev) return -EINVAL; } - leds->led = devm_kzalloc(dev, leds->num_leds * sizeof(*leds->led), + leds->led = devm_kcalloc(dev, leds->num_leds, sizeof(*leds->led), GFP_KERNEL); if (!leds->led) return -ENOMEM; diff --git a/drivers/leds/leds-mlxcpld.c b/drivers/leds/leds-mlxcpld.c index 281482e1d50f..f4721f8065f0 100644 --- a/drivers/leds/leds-mlxcpld.c +++ b/drivers/leds/leds-mlxcpld.c @@ -329,8 +329,10 @@ static int mlxcpld_led_config(struct device *dev, int i; int err; - cpld->pled = devm_kzalloc(dev, sizeof(struct mlxcpld_led_priv) * - cpld->num_led_instances, GFP_KERNEL); + cpld->pled = devm_kcalloc(dev, + cpld->num_led_instances, + sizeof(struct mlxcpld_led_priv), + GFP_KERNEL); if (!cpld->pled) return -ENOMEM; diff --git a/drivers/leds/leds-netxbig.c b/drivers/leds/leds-netxbig.c index f48b1aed9b4e..62fa0de526ee 100644 --- a/drivers/leds/leds-netxbig.c +++ b/drivers/leds/leds-netxbig.c @@ -335,7 +335,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, return ret; } num_addr = ret; - addr = devm_kzalloc(dev, num_addr * sizeof(*addr), GFP_KERNEL); + addr = devm_kcalloc(dev, num_addr, sizeof(*addr), GFP_KERNEL); if (!addr) return -ENOMEM; @@ -355,7 +355,7 @@ static int gpio_ext_get_of_pdata(struct device *dev, struct device_node *np, return ret; } num_data = ret; - data = devm_kzalloc(dev, num_data * sizeof(*data), GFP_KERNEL); + data = devm_kcalloc(dev, num_data, sizeof(*data), GFP_KERNEL); if (!data) return -ENOMEM; @@ -415,7 +415,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, if (ret % 3) return -EINVAL; num_timers = ret / 3; - timers = devm_kzalloc(dev, num_timers * sizeof(*timers), + timers = devm_kcalloc(dev, num_timers, sizeof(*timers), GFP_KERNEL); if (!timers) return -ENOMEM; @@ -444,7 +444,7 @@ static int netxbig_leds_get_of_pdata(struct device *dev, return -ENODEV; } - leds = devm_kzalloc(dev, num_leds * sizeof(*leds), GFP_KERNEL); + leds = devm_kcalloc(dev, num_leds, sizeof(*leds), GFP_KERNEL); if (!leds) return -ENOMEM; @@ -470,8 +470,8 @@ static int netxbig_leds_get_of_pdata(struct device *dev, goto err_node_put; mode_val = - devm_kzalloc(dev, - NETXBIG_LED_MODE_NUM * sizeof(*mode_val), + devm_kcalloc(dev, + NETXBIG_LED_MODE_NUM, sizeof(*mode_val), GFP_KERNEL); if (!mode_val) { ret = -ENOMEM; @@ -560,8 +560,8 @@ static int netxbig_led_probe(struct platform_device *pdev) return ret; } - leds_data = devm_kzalloc(&pdev->dev, - pdata->num_leds * sizeof(*leds_data), + leds_data = devm_kcalloc(&pdev->dev, + pdata->num_leds, sizeof(*leds_data), GFP_KERNEL); if (!leds_data) return -ENOMEM; diff --git a/drivers/leds/leds-ns2.c b/drivers/leds/leds-ns2.c index 506b75b190e7..14fe5cd43232 100644 --- a/drivers/leds/leds-ns2.c +++ b/drivers/leds/leds-ns2.c @@ -264,7 +264,7 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) if (!num_leds) return -ENODEV; - leds = devm_kzalloc(dev, num_leds * sizeof(struct ns2_led), + leds = devm_kcalloc(dev, num_leds, sizeof(struct ns2_led), GFP_KERNEL); if (!leds) return -ENOMEM; @@ -298,8 +298,9 @@ ns2_leds_get_of_pdata(struct device *dev, struct ns2_led_platform_data *pdata) } num_modes = ret / 3; - modval = devm_kzalloc(dev, - num_modes * sizeof(struct ns2_led_modval), + modval = devm_kcalloc(dev, + num_modes, + sizeof(struct ns2_led_modval), GFP_KERNEL); if (!modval) return -ENOMEM; diff --git a/drivers/leds/leds-pca955x.c b/drivers/leds/leds-pca955x.c index 78183f90820e..f51b356d4426 100644 --- a/drivers/leds/leds-pca955x.c +++ b/drivers/leds/leds-pca955x.c @@ -390,8 +390,8 @@ pca955x_pdata_of_init(struct i2c_client *client, struct pca955x_chipdef *chip) if (!pdata) return ERR_PTR(-ENOMEM); - pdata->leds = devm_kzalloc(&client->dev, - sizeof(struct pca955x_led) * chip->bits, + pdata->leds = devm_kcalloc(&client->dev, + chip->bits, sizeof(struct pca955x_led), GFP_KERNEL); if (!pdata->leds) return ERR_PTR(-ENOMEM); @@ -494,8 +494,8 @@ static int pca955x_probe(struct i2c_client *client, if (!pca955x) return -ENOMEM; - pca955x->leds = devm_kzalloc(&client->dev, - sizeof(*pca955x_led) * chip->bits, GFP_KERNEL); + pca955x->leds = devm_kcalloc(&client->dev, + chip->bits, sizeof(*pca955x_led), GFP_KERNEL); if (!pca955x->leds) return -ENOMEM; diff --git a/drivers/leds/leds-pca963x.c b/drivers/leds/leds-pca963x.c index 88c7313cf869..bbcde13b77f1 100644 --- a/drivers/leds/leds-pca963x.c +++ b/drivers/leds/leds-pca963x.c @@ -302,8 +302,8 @@ pca963x_dt_init(struct i2c_client *client, struct pca963x_chipdef *chip) if (!count || count > chip->n_leds) return ERR_PTR(-ENODEV); - pca963x_leds = devm_kzalloc(&client->dev, - sizeof(struct led_info) * chip->n_leds, GFP_KERNEL); + pca963x_leds = devm_kcalloc(&client->dev, + chip->n_leds, sizeof(struct led_info), GFP_KERNEL); if (!pca963x_leds) return ERR_PTR(-ENOMEM); @@ -409,7 +409,7 @@ static int pca963x_probe(struct i2c_client *client, GFP_KERNEL); if (!pca963x_chip) return -ENOMEM; - pca963x = devm_kzalloc(&client->dev, chip->n_leds * sizeof(*pca963x), + pca963x = devm_kcalloc(&client->dev, chip->n_leds, sizeof(*pca963x), GFP_KERNEL); if (!pca963x) return -ENOMEM; diff --git a/drivers/leds/leds-pca9956b.c b/drivers/leds/leds-pca9956b.c index 0b23f21e1afb..2d0373d2c19e 100644 --- a/drivers/leds/leds-pca9956b.c +++ b/drivers/leds/leds-pca9956b.c @@ -484,8 +484,9 @@ static int pca9956b_probe(struct i2c_client *client, if (!chip) return -ENOMEM; - chip->leds = devm_kzalloc(&client->dev, sizeof(*led)*PCA9956B_LED_NUM, - GFP_KERNEL); + chip->leds = devm_kcalloc(&client->dev, + PCA9956B_LED_NUM, sizeof(*led), + GFP_KERNEL); if (!chip->leds) { devm_kfree(&client->dev, chip); return -ENOMEM; diff --git a/drivers/leds/leds-tca6507.c b/drivers/leds/leds-tca6507.c index 45222a7f4f75..6aae71362d4b 100644 --- a/drivers/leds/leds-tca6507.c +++ b/drivers/leds/leds-tca6507.c @@ -697,8 +697,8 @@ tca6507_led_dt_init(struct i2c_client *client) if (!count || count > NUM_LEDS) return ERR_PTR(-ENODEV); - tca_leds = devm_kzalloc(&client->dev, - sizeof(struct led_info) * NUM_LEDS, GFP_KERNEL); + tca_leds = devm_kcalloc(&client->dev, + NUM_LEDS, sizeof(struct led_info), GFP_KERNEL); if (!tca_leds) return ERR_PTR(-ENOMEM); diff --git a/drivers/mailbox/hi6220-mailbox.c b/drivers/mailbox/hi6220-mailbox.c index 519376d3534c..4fa9803cd204 100644 --- a/drivers/mailbox/hi6220-mailbox.c +++ b/drivers/mailbox/hi6220-mailbox.c @@ -282,13 +282,13 @@ static int hi6220_mbox_probe(struct platform_device *pdev) mbox->dev = dev; mbox->chan_num = MBOX_CHAN_MAX; - mbox->mchan = devm_kzalloc(dev, - mbox->chan_num * sizeof(*mbox->mchan), GFP_KERNEL); + mbox->mchan = devm_kcalloc(dev, + mbox->chan_num, sizeof(*mbox->mchan), GFP_KERNEL); if (!mbox->mchan) return -ENOMEM; - mbox->chan = devm_kzalloc(dev, - mbox->chan_num * sizeof(*mbox->chan), GFP_KERNEL); + mbox->chan = devm_kcalloc(dev, + mbox->chan_num, sizeof(*mbox->chan), GFP_KERNEL); if (!mbox->chan) return -ENOMEM; diff --git a/drivers/mailbox/mailbox-sti.c b/drivers/mailbox/mailbox-sti.c index 41bcd339b68a..779d41262ef0 100644 --- a/drivers/mailbox/mailbox-sti.c +++ b/drivers/mailbox/mailbox-sti.c @@ -442,8 +442,8 @@ static int sti_mbox_probe(struct platform_device *pdev) if (!mbox) return -ENOMEM; - chans = devm_kzalloc(&pdev->dev, - sizeof(*chans) * STI_MBOX_CHAN_MAX, GFP_KERNEL); + chans = devm_kcalloc(&pdev->dev, + STI_MBOX_CHAN_MAX, sizeof(*chans), GFP_KERNEL); if (!chans) return -ENOMEM; diff --git a/drivers/mailbox/msm_qmp.c b/drivers/mailbox/msm_qmp.c index 226d1d7f84ff..9ecae6c3cb00 100644 --- a/drivers/mailbox/msm_qmp.c +++ b/drivers/mailbox/msm_qmp.c @@ -831,7 +831,8 @@ static int qmp_mbox_init(struct device_node *n, struct qmp_device *mdev) mbox->desc = mdev->msgram + desc_of; num_chans = get_mbox_num_chans(n); mbox->rx_disabled = (num_chans > 1) ? true : false; - chans = devm_kzalloc(mdev->dev, sizeof(*chans) * num_chans, GFP_KERNEL); + chans = devm_kcalloc(mdev->dev, num_chans, sizeof(*chans), + GFP_KERNEL); if (!chans) return -ENOMEM; diff --git a/drivers/mailbox/omap-mailbox.c b/drivers/mailbox/omap-mailbox.c index c5e8b9cb170d..b943619a79e9 100644 --- a/drivers/mailbox/omap-mailbox.c +++ b/drivers/mailbox/omap-mailbox.c @@ -729,7 +729,7 @@ static int omap_mbox_probe(struct platform_device *pdev) return -ENODEV; } - finfoblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*finfoblk), + finfoblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*finfoblk), GFP_KERNEL); if (!finfoblk) return -ENOMEM; @@ -773,23 +773,23 @@ static int omap_mbox_probe(struct platform_device *pdev) if (IS_ERR(mdev->mbox_base)) return PTR_ERR(mdev->mbox_base); - mdev->irq_ctx = devm_kzalloc(&pdev->dev, num_users * sizeof(u32), + mdev->irq_ctx = devm_kcalloc(&pdev->dev, num_users, sizeof(u32), GFP_KERNEL); if (!mdev->irq_ctx) return -ENOMEM; /* allocate one extra for marking end of list */ - list = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*list), + list = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*list), GFP_KERNEL); if (!list) return -ENOMEM; - chnls = devm_kzalloc(&pdev->dev, (info_count + 1) * sizeof(*chnls), + chnls = devm_kcalloc(&pdev->dev, info_count + 1, sizeof(*chnls), GFP_KERNEL); if (!chnls) return -ENOMEM; - mboxblk = devm_kzalloc(&pdev->dev, info_count * sizeof(*mbox), + mboxblk = devm_kcalloc(&pdev->dev, info_count, sizeof(*mbox), GFP_KERNEL); if (!mboxblk) return -ENOMEM; diff --git a/drivers/mailbox/qcom-rpmh-mailbox.c b/drivers/mailbox/qcom-rpmh-mailbox.c index 45d2887aaaa5..a62c296f5f06 100644 --- a/drivers/mailbox/qcom-rpmh-mailbox.c +++ b/drivers/mailbox/qcom-rpmh-mailbox.c @@ -1224,8 +1224,9 @@ static int rsc_drv_probe(struct platform_device *pdev) tcs->tcs_offset = st; st += tcs->num_tcs; - tcs->cmd_addr = devm_kzalloc(&pdev->dev, sizeof(u32) * - tcs->num_tcs * tcs->ncpt, GFP_KERNEL); + tcs->cmd_addr = devm_kzalloc(&pdev->dev, + array3_size(sizeof(u32), tcs->num_tcs, tcs->ncpt), + GFP_KERNEL); if (!tcs->cmd_addr) return -ENOMEM; @@ -1253,7 +1254,7 @@ static int rsc_drv_probe(struct platform_device *pdev) return -ENODEV; } - chans = devm_kzalloc(&pdev->dev, num_chans * sizeof(*chans), + chans = devm_kcalloc(&pdev->dev, num_chans, sizeof(*chans), GFP_KERNEL); if (!chans) return -ENOMEM; diff --git a/drivers/mailbox/ti-msgmgr.c b/drivers/mailbox/ti-msgmgr.c index 54b9e4cb4cfa..ae050f79a27b 100644 --- a/drivers/mailbox/ti-msgmgr.c +++ b/drivers/mailbox/ti-msgmgr.c @@ -576,12 +576,12 @@ static int ti_msgmgr_probe(struct platform_device *pdev) } inst->num_valid_queues = queue_count; - qinst = devm_kzalloc(dev, sizeof(*qinst) * queue_count, GFP_KERNEL); + qinst = devm_kcalloc(dev, queue_count, sizeof(*qinst), GFP_KERNEL); if (!qinst) return -ENOMEM; inst->qinsts = qinst; - chans = devm_kzalloc(dev, sizeof(*chans) * queue_count, GFP_KERNEL); + chans = devm_kcalloc(dev, queue_count, sizeof(*chans), GFP_KERNEL); if (!chans) return -ENOMEM; inst->chans = chans; diff --git a/drivers/media/i2c/s5k5baf.c b/drivers/media/i2c/s5k5baf.c index ff46d2c96cea..5007c9659342 100644 --- a/drivers/media/i2c/s5k5baf.c +++ b/drivers/media/i2c/s5k5baf.c @@ -373,7 +373,7 @@ static int s5k5baf_fw_parse(struct device *dev, struct s5k5baf_fw **fw, data += S5K5BAG_FW_TAG_LEN; count -= S5K5BAG_FW_TAG_LEN; - d = devm_kzalloc(dev, count * sizeof(u16), GFP_KERNEL); + d = devm_kcalloc(dev, count, sizeof(u16), GFP_KERNEL); if (!d) return -ENOMEM; diff --git a/drivers/media/platform/am437x/am437x-vpfe.c b/drivers/media/platform/am437x/am437x-vpfe.c index e92c5b56be42..643a728e2257 100644 --- a/drivers/media/platform/am437x/am437x-vpfe.c +++ b/drivers/media/platform/am437x/am437x-vpfe.c @@ -2585,8 +2585,10 @@ static int vpfe_probe(struct platform_device *pdev) pm_runtime_put_sync(&pdev->dev); - vpfe->sd = devm_kzalloc(&pdev->dev, sizeof(struct v4l2_subdev *) * - ARRAY_SIZE(vpfe->cfg->asd), GFP_KERNEL); + vpfe->sd = devm_kcalloc(&pdev->dev, + ARRAY_SIZE(vpfe->cfg->asd), + sizeof(struct v4l2_subdev *), + GFP_KERNEL); if (!vpfe->sd) { ret = -ENOMEM; goto probe_out_v4l2_unregister; diff --git a/drivers/media/platform/davinci/vpif_capture.c b/drivers/media/platform/davinci/vpif_capture.c index dc8fc2120b63..ace58725c087 100644 --- a/drivers/media/platform/davinci/vpif_capture.c +++ b/drivers/media/platform/davinci/vpif_capture.c @@ -1523,8 +1523,10 @@ vpif_capture_get_pdata(struct platform_device *pdev) if (!pdata) return NULL; pdata->subdev_info = - devm_kzalloc(&pdev->dev, sizeof(*pdata->subdev_info) * - VPIF_CAPTURE_NUM_CHANNELS, GFP_KERNEL); + devm_kcalloc(&pdev->dev, + VPIF_CAPTURE_NUM_CHANNELS, + sizeof(*pdata->subdev_info), + GFP_KERNEL); if (!pdata->subdev_info) return NULL; @@ -1541,9 +1543,9 @@ vpif_capture_get_pdata(struct platform_device *pdev) sdinfo = &pdata->subdev_info[i]; chan = &pdata->chan_config[i]; - chan->inputs = devm_kzalloc(&pdev->dev, - sizeof(*chan->inputs) * + chan->inputs = devm_kcalloc(&pdev->dev, VPIF_CAPTURE_NUM_CHANNELS, + sizeof(*chan->inputs), GFP_KERNEL); if (!chan->inputs) return NULL; diff --git a/drivers/media/platform/msm/ais/cam_smmu/cam_smmu_api.c b/drivers/media/platform/msm/ais/cam_smmu/cam_smmu_api.c index e00b1f4ec0a7..1bc5a8ec640e 100644 --- a/drivers/media/platform/msm/ais/cam_smmu/cam_smmu_api.c +++ b/drivers/media/platform/msm/ais/cam_smmu/cam_smmu_api.c @@ -3312,8 +3312,8 @@ static int cam_alloc_smmu_context_banks(struct device *dev) } /* allocate memory for the context banks */ - iommu_cb_set.cb_info = devm_kzalloc(dev, - iommu_cb_set.cb_num * sizeof(struct cam_context_bank_info), + iommu_cb_set.cb_info = devm_kcalloc(dev, + iommu_cb_set.cb_num, sizeof(struct cam_context_bank_info), GFP_KERNEL); if (!iommu_cb_set.cb_info) { diff --git a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c index 6964f641188a..5dabde4184d9 100644 --- a/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c +++ b/drivers/media/platform/msm/camera/cam_smmu/cam_smmu_api.c @@ -3315,8 +3315,8 @@ static int cam_alloc_smmu_context_banks(struct device *dev) } /* allocate memory for the context banks */ - iommu_cb_set.cb_info = devm_kzalloc(dev, - iommu_cb_set.cb_num * sizeof(struct cam_context_bank_info), + iommu_cb_set.cb_info = devm_kcalloc(dev, + iommu_cb_set.cb_num, sizeof(struct cam_context_bank_info), GFP_KERNEL); if (!iommu_cb_set.cb_info) { diff --git a/drivers/media/platform/msm/camera_v2/common/cam_hw_ops.c b/drivers/media/platform/msm/camera_v2/common/cam_hw_ops.c index a3b41d02963f..4ceb38eb3eaf 100644 --- a/drivers/media/platform/msm/camera_v2/common/cam_hw_ops.c +++ b/drivers/media/platform/msm/camera_v2/common/cam_hw_ops.c @@ -94,8 +94,8 @@ int cam_ahb_clk_init(struct platform_device *pdev) CDBG("number of bus vectors: %d\n", data.cnt); - data.vectors = devm_kzalloc(&pdev->dev, - sizeof(struct cam_bus_vector) * cnt, + data.vectors = devm_kcalloc(&pdev->dev, + cnt, sizeof(struct cam_bus_vector), GFP_KERNEL); if (!data.vectors) return -ENOMEM; @@ -111,16 +111,16 @@ int cam_ahb_clk_init(struct platform_device *pdev) } } - data.paths = devm_kzalloc(&pdev->dev, - sizeof(struct msm_bus_vectors) * cnt, + data.paths = devm_kcalloc(&pdev->dev, + cnt, sizeof(struct msm_bus_vectors), GFP_KERNEL); if (!data.paths) { rc = -ENOMEM; goto err1; } - data.usecases = devm_kzalloc(&pdev->dev, - sizeof(struct msm_bus_paths) * cnt, + data.usecases = devm_kcalloc(&pdev->dev, + cnt, sizeof(struct msm_bus_paths), GFP_KERNEL); if (!data.usecases) { rc = -ENOMEM; @@ -135,8 +135,8 @@ int cam_ahb_clk_init(struct platform_device *pdev) goto err3; } - data.votes = devm_kzalloc(&pdev->dev, sizeof(u32) * cnt, - GFP_KERNEL); + data.votes = devm_kcalloc(&pdev->dev, cnt, sizeof(u32), + GFP_KERNEL); if (!data.votes) { rc = -ENOMEM; goto err4; diff --git a/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c b/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c index 8ae6f4d35d68..6cd1ec986668 100644 --- a/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c +++ b/drivers/media/platform/msm/camera_v2/common/cam_smmu_api.c @@ -2151,8 +2151,8 @@ static int cam_alloc_smmu_context_banks(struct device *dev) } /* allocate memory for the context banks */ - iommu_cb_set.cb_info = devm_kzalloc(dev, - iommu_cb_set.cb_num * sizeof(struct cam_context_bank_info), + iommu_cb_set.cb_info = devm_kcalloc(dev, + iommu_cb_set.cb_num, sizeof(struct cam_context_bank_info), GFP_KERNEL); if (!iommu_cb_set.cb_info) { diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c index e3ab6643c313..087ef77e0439 100644 --- a/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c +++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_core.c @@ -2294,8 +2294,8 @@ static int sde_rotator_open_session(struct sde_rot_mgr *mgr, if (!perf) return -ENOMEM; - perf->work_distribution = devm_kzalloc(&mgr->pdev->dev, - sizeof(u32) * mgr->queue_count, GFP_KERNEL); + perf->work_distribution = devm_kcalloc(&mgr->pdev->dev, + mgr->queue_count, sizeof(u32), GFP_KERNEL); if (!perf->work_distribution) { ret = -ENOMEM; goto alloc_err; @@ -2865,8 +2865,9 @@ static int sde_rotator_get_dt_vreg_data(struct device *dev, return 0; } mp->num_vreg = dt_vreg_total; - mp->vreg_config = devm_kzalloc(dev, sizeof(struct sde_vreg) * - dt_vreg_total, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + dt_vreg_total, sizeof(struct sde_vreg), + GFP_KERNEL); if (!mp->vreg_config) return -ENOMEM; @@ -2989,8 +2990,8 @@ static int sde_rotator_parse_dt_clk(struct platform_device *pdev, } mgr->num_rot_clk = SDE_ROTATOR_CLK_MAX; - mgr->rot_clk = devm_kzalloc(&pdev->dev, - sizeof(struct sde_rot_clk) * mgr->num_rot_clk, + mgr->rot_clk = devm_kcalloc(&pdev->dev, + mgr->num_rot_clk, sizeof(struct sde_rot_clk), GFP_KERNEL); if (!mgr->rot_clk) { rc = -ENOMEM; diff --git a/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c b/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c index 4658f2918898..4a169ae589f5 100644 --- a/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c +++ b/drivers/media/platform/msm/sde/rotator/sde_rotator_smmu.c @@ -117,8 +117,8 @@ static int sde_smmu_util_parse_dt_clock(struct platform_device *pdev, } mp->num_clk = num_clk; - mp->clk_config = devm_kzalloc(&pdev->dev, - sizeof(struct sde_clk) * mp->num_clk, GFP_KERNEL); + mp->clk_config = devm_kcalloc(&pdev->dev, + mp->num_clk, sizeof(struct sde_clk), GFP_KERNEL); if (num_clk && !mp->clk_config) { rc = -ENOMEM; mp->num_clk = 0; diff --git a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c index cf2e849b4b98..8ca1edfdc27b 100644 --- a/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c +++ b/drivers/media/platform/msm/vidc/msm_vidc_res_parse.c @@ -169,8 +169,10 @@ static int msm_vidc_load_reg_table(struct msm_vidc_platform_resources *res) return rc; } - reg_set->reg_tbl = devm_kzalloc(&pdev->dev, reg_set->count * - sizeof(*(reg_set->reg_tbl)), GFP_KERNEL); + reg_set->reg_tbl = devm_kcalloc(&pdev->dev, + reg_set->count, + sizeof(*(reg_set->reg_tbl)), + GFP_KERNEL); if (!reg_set->reg_tbl) { dprintk(VIDC_ERR, "%s Failed to alloc register table\n", __func__); @@ -218,8 +220,9 @@ static int msm_vidc_load_qdss_table(struct msm_vidc_platform_resources *res) return rc; } - qdss_addr_set->addr_tbl = devm_kzalloc(&pdev->dev, - qdss_addr_set->count * sizeof(*qdss_addr_set->addr_tbl), + qdss_addr_set->addr_tbl = devm_kcalloc(&pdev->dev, + qdss_addr_set->count, + sizeof(*qdss_addr_set->addr_tbl), GFP_KERNEL); if (!qdss_addr_set->addr_tbl) { dprintk(VIDC_ERR, "%s Failed to alloc register table\n", @@ -259,8 +262,8 @@ static int msm_vidc_load_subcache_info(struct msm_vidc_platform_resources *res) goto err_load_subcache_table_fail; } - subcaches->subcache_tbl = devm_kzalloc(&pdev->dev, - sizeof(*subcaches->subcache_tbl) * num_subcaches, GFP_KERNEL); + subcaches->subcache_tbl = devm_kcalloc(&pdev->dev, + num_subcaches, sizeof(*subcaches->subcache_tbl), GFP_KERNEL); if (!subcaches->subcache_tbl) { dprintk(VIDC_ERR, "Failed to allocate memory for subcache tbl\n"); @@ -326,7 +329,7 @@ int msm_vidc_load_u32_table(struct platform_device *pdev, } num_elemts /= struct_size / sizeof(u32); - ptbl = devm_kzalloc(&pdev->dev, num_elemts * struct_size, GFP_KERNEL); + ptbl = devm_kcalloc(&pdev->dev, struct_size, num_elemts, GFP_KERNEL); if (!ptbl) { dprintk(VIDC_ERR, "Failed to alloc table %s\n", table_name); return -ENOMEM; @@ -498,8 +501,8 @@ static int msm_vidc_load_buffer_usage_table( return 0; } - buffer_usage_set->buffer_usage_tbl = devm_kzalloc(&pdev->dev, - buffer_usage_set->count * + buffer_usage_set->buffer_usage_tbl = devm_kcalloc(&pdev->dev, + buffer_usage_set->count, sizeof(*buffer_usage_set->buffer_usage_tbl), GFP_KERNEL); if (!buffer_usage_set->buffer_usage_tbl) { @@ -554,9 +557,9 @@ static int msm_vidc_load_regulator_table( reg_count++; } - regulators->regulator_tbl = devm_kzalloc(&pdev->dev, - sizeof(*regulators->regulator_tbl) * - reg_count, GFP_KERNEL); + regulators->regulator_tbl = devm_kcalloc(&pdev->dev, + reg_count, sizeof(*regulators->regulator_tbl), + GFP_KERNEL); if (!regulators->regulator_tbl) { rc = -ENOMEM; @@ -638,8 +641,9 @@ static int msm_vidc_load_clock_table( goto err_load_clk_table_fail; } - clock_props = devm_kzalloc(&pdev->dev, num_clocks * - sizeof(*clock_props), GFP_KERNEL); + clock_props = devm_kcalloc(&pdev->dev, + num_clocks, sizeof(*clock_props), + GFP_KERNEL); if (!clock_props) { dprintk(VIDC_ERR, "No memory to read clock properties\n"); rc = -ENOMEM; @@ -654,8 +658,10 @@ static int msm_vidc_load_clock_table( goto err_load_clk_prop_fail; } - clocks->clock_tbl = devm_kzalloc(&pdev->dev, sizeof(*clocks->clock_tbl) - * num_clocks, GFP_KERNEL); + clocks->clock_tbl = devm_kcalloc(&pdev->dev, + num_clocks, + sizeof(*clocks->clock_tbl), + GFP_KERNEL); if (!clocks->clock_tbl) { dprintk(VIDC_ERR, "Failed to allocate memory for clock tbl\n"); rc = -ENOMEM; diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csid.c b/drivers/media/platform/qcom/camss-8x16/camss-csid.c index 4882ee25bd75..2bf65805f2c1 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-csid.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-csid.c @@ -851,7 +851,7 @@ int msm_csid_subdev_init(struct csid_device *csid, while (res->clock[csid->nclocks]) csid->nclocks++; - csid->clock = devm_kzalloc(dev, csid->nclocks * sizeof(*csid->clock), + csid->clock = devm_kcalloc(dev, csid->nclocks, sizeof(*csid->clock), GFP_KERNEL); if (!csid->clock) return -ENOMEM; @@ -874,8 +874,10 @@ int msm_csid_subdev_init(struct csid_device *csid, continue; } - clock->freq = devm_kzalloc(dev, clock->nfreqs * - sizeof(*clock->freq), GFP_KERNEL); + clock->freq = devm_kcalloc(dev, + clock->nfreqs, + sizeof(*clock->freq), + GFP_KERNEL); if (!clock->freq) return -ENOMEM; diff --git a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c index 072c6cf053f6..7e61caba6a2d 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-csiphy.c @@ -732,8 +732,9 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, while (res->clock[csiphy->nclocks]) csiphy->nclocks++; - csiphy->clock = devm_kzalloc(dev, csiphy->nclocks * - sizeof(*csiphy->clock), GFP_KERNEL); + csiphy->clock = devm_kcalloc(dev, + csiphy->nclocks, sizeof(*csiphy->clock), + GFP_KERNEL); if (!csiphy->clock) return -ENOMEM; @@ -755,8 +756,10 @@ int msm_csiphy_subdev_init(struct csiphy_device *csiphy, continue; } - clock->freq = devm_kzalloc(dev, clock->nfreqs * - sizeof(*clock->freq), GFP_KERNEL); + clock->freq = devm_kcalloc(dev, + clock->nfreqs, + sizeof(*clock->freq), + GFP_KERNEL); if (!clock->freq) return -ENOMEM; diff --git a/drivers/media/platform/qcom/camss-8x16/camss-ispif.c b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c index 24da529397b5..9d1af9353c1d 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-ispif.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-ispif.c @@ -948,7 +948,8 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, while (res->clock[ispif->nclocks]) ispif->nclocks++; - ispif->clock = devm_kzalloc(dev, ispif->nclocks * sizeof(*ispif->clock), + ispif->clock = devm_kcalloc(dev, + ispif->nclocks, sizeof(*ispif->clock), GFP_KERNEL); if (!ispif->clock) return -ENOMEM; @@ -968,8 +969,10 @@ int msm_ispif_subdev_init(struct ispif_device *ispif, while (res->clock_for_reset[ispif->nclocks_for_reset]) ispif->nclocks_for_reset++; - ispif->clock_for_reset = devm_kzalloc(dev, ispif->nclocks_for_reset * - sizeof(*ispif->clock_for_reset), GFP_KERNEL); + ispif->clock_for_reset = devm_kcalloc(dev, + ispif->nclocks_for_reset, + sizeof(*ispif->clock_for_reset), + GFP_KERNEL); if (!ispif->clock_for_reset) return -ENOMEM; diff --git a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c index 55232a912950..a6329a8a7c4a 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss-vfe.c +++ b/drivers/media/platform/qcom/camss-8x16/camss-vfe.c @@ -2794,7 +2794,7 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) while (res->clock[vfe->nclocks]) vfe->nclocks++; - vfe->clock = devm_kzalloc(dev, vfe->nclocks * sizeof(*vfe->clock), + vfe->clock = devm_kcalloc(dev, vfe->nclocks, sizeof(*vfe->clock), GFP_KERNEL); if (!vfe->clock) return -ENOMEM; @@ -2817,8 +2817,10 @@ int msm_vfe_subdev_init(struct vfe_device *vfe, const struct resources *res) continue; } - clock->freq = devm_kzalloc(dev, clock->nfreqs * - sizeof(*clock->freq), GFP_KERNEL); + clock->freq = devm_kcalloc(dev, + clock->nfreqs, + sizeof(*clock->freq), + GFP_KERNEL); if (!clock->freq) return -ENOMEM; diff --git a/drivers/media/platform/qcom/camss-8x16/camss.c b/drivers/media/platform/qcom/camss-8x16/camss.c index a3760b5dd1d1..adcef956cbec 100644 --- a/drivers/media/platform/qcom/camss-8x16/camss.c +++ b/drivers/media/platform/qcom/camss-8x16/camss.c @@ -271,7 +271,8 @@ static int camss_of_parse_endpoint_node(struct device *dev, lncfg->clk.pol = mipi_csi2->lane_polarities[0]; lncfg->num_data = mipi_csi2->num_data_lanes; - lncfg->data = devm_kzalloc(dev, lncfg->num_data * sizeof(*lncfg->data), + lncfg->data = devm_kcalloc(dev, + lncfg->num_data, sizeof(*lncfg->data), GFP_KERNEL); if (!lncfg->data) return -ENOMEM; diff --git a/drivers/media/platform/vsp1/vsp1_entity.c b/drivers/media/platform/vsp1/vsp1_entity.c index 54de15095709..51ff3d8f39f3 100644 --- a/drivers/media/platform/vsp1/vsp1_entity.c +++ b/drivers/media/platform/vsp1/vsp1_entity.c @@ -511,7 +511,8 @@ int vsp1_entity_init(struct vsp1_device *vsp1, struct vsp1_entity *entity, entity->source_pad = num_pads - 1; /* Allocate and initialize pads. */ - entity->pads = devm_kzalloc(vsp1->dev, num_pads * sizeof(*entity->pads), + entity->pads = devm_kcalloc(vsp1->dev, + num_pads, sizeof(*entity->pads), GFP_KERNEL); if (entity->pads == NULL) return -ENOMEM; diff --git a/drivers/media/platform/xilinx/xilinx-vipp.c b/drivers/media/platform/xilinx/xilinx-vipp.c index ebfdf334d99c..3bd3d640de59 100644 --- a/drivers/media/platform/xilinx/xilinx-vipp.c +++ b/drivers/media/platform/xilinx/xilinx-vipp.c @@ -535,7 +535,7 @@ static int xvip_graph_init(struct xvip_composite_device *xdev) /* Register the subdevices notifier. */ num_subdevs = xdev->num_subdevs; - subdevs = devm_kzalloc(xdev->dev, sizeof(*subdevs) * num_subdevs, + subdevs = devm_kcalloc(xdev->dev, num_subdevs, sizeof(*subdevs), GFP_KERNEL); if (subdevs == NULL) { ret = -ENOMEM; diff --git a/drivers/media/v4l2-core/v4l2-flash-led-class.c b/drivers/media/v4l2-core/v4l2-flash-led-class.c index 4ceef217de83..215b4804ada2 100644 --- a/drivers/media/v4l2-core/v4l2-flash-led-class.c +++ b/drivers/media/v4l2-core/v4l2-flash-led-class.c @@ -412,9 +412,10 @@ static int v4l2_flash_init_controls(struct v4l2_flash *v4l2_flash, struct v4l2_ctrl_config *ctrl_cfg; int i, ret, num_ctrls = 0; - v4l2_flash->ctrls = devm_kzalloc(v4l2_flash->sd.dev, - sizeof(*v4l2_flash->ctrls) * - (STROBE_SOURCE + 1), GFP_KERNEL); + v4l2_flash->ctrls = devm_kcalloc(v4l2_flash->sd.dev, + STROBE_SOURCE + 1, + sizeof(*v4l2_flash->ctrls), + GFP_KERNEL); if (!v4l2_flash->ctrls) return -ENOMEM; diff --git a/drivers/memory/of_memory.c b/drivers/memory/of_memory.c index 568f05ed961a..2f5ed7366eec 100644 --- a/drivers/memory/of_memory.c +++ b/drivers/memory/of_memory.c @@ -126,8 +126,8 @@ const struct lpddr2_timings *of_get_ddr_timings(struct device_node *np_ddr, arr_sz++; if (arr_sz) - timings = devm_kzalloc(dev, sizeof(*timings) * arr_sz, - GFP_KERNEL); + timings = devm_kcalloc(dev, arr_sz, sizeof(*timings), + GFP_KERNEL); if (!timings) goto default_timings; diff --git a/drivers/mfd/ab8500-debugfs.c b/drivers/mfd/ab8500-debugfs.c index 28c3ee38b081..eba2a4488823 100644 --- a/drivers/mfd/ab8500-debugfs.c +++ b/drivers/mfd/ab8500-debugfs.c @@ -2952,18 +2952,18 @@ static int ab8500_debug_probe(struct platform_device *plf) ab8500 = dev_get_drvdata(plf->dev.parent); num_irqs = ab8500->mask_size; - irq_count = devm_kzalloc(&plf->dev, - sizeof(*irq_count)*num_irqs, GFP_KERNEL); + irq_count = devm_kcalloc(&plf->dev, + num_irqs, sizeof(*irq_count), GFP_KERNEL); if (!irq_count) return -ENOMEM; - dev_attr = devm_kzalloc(&plf->dev, - sizeof(*dev_attr)*num_irqs, GFP_KERNEL); + dev_attr = devm_kcalloc(&plf->dev, + num_irqs, sizeof(*dev_attr), GFP_KERNEL); if (!dev_attr) return -ENOMEM; - event_name = devm_kzalloc(&plf->dev, - sizeof(*event_name)*num_irqs, GFP_KERNEL); + event_name = devm_kcalloc(&plf->dev, + num_irqs, sizeof(*event_name), GFP_KERNEL); if (!event_name) return -ENOMEM; diff --git a/drivers/mfd/htc-i2cpld.c b/drivers/mfd/htc-i2cpld.c index 3f9eee5f8fb9..9428326608ed 100644 --- a/drivers/mfd/htc-i2cpld.c +++ b/drivers/mfd/htc-i2cpld.c @@ -477,7 +477,9 @@ static int htcpld_setup_chips(struct platform_device *pdev) /* Setup each chip's output GPIOs */ htcpld->nchips = pdata->num_chip; - htcpld->chip = devm_kzalloc(dev, sizeof(struct htcpld_chip) * htcpld->nchips, + htcpld->chip = devm_kcalloc(dev, + htcpld->nchips, + sizeof(struct htcpld_chip), GFP_KERNEL); if (!htcpld->chip) { dev_warn(dev, "Unable to allocate memory for chips\n"); diff --git a/drivers/mfd/motorola-cpcap.c b/drivers/mfd/motorola-cpcap.c index d2cc1eabac05..8198c9c25a9e 100644 --- a/drivers/mfd/motorola-cpcap.c +++ b/drivers/mfd/motorola-cpcap.c @@ -173,9 +173,7 @@ static int cpcap_init_irq(struct cpcap_ddata *cpcap) int ret; cpcap->irqs = devm_kzalloc(&cpcap->spi->dev, - sizeof(*cpcap->irqs) * - CPCAP_NR_IRQ_REG_BANKS * - cpcap->regmap_conf->val_bits, + array3_size(sizeof(*cpcap->irqs), CPCAP_NR_IRQ_REG_BANKS, cpcap->regmap_conf->val_bits), GFP_KERNEL); if (!cpcap->irqs) return -ENOMEM; diff --git a/drivers/mfd/omap-usb-tll.c b/drivers/mfd/omap-usb-tll.c index 44a5d66314c6..f40fc8d59f13 100644 --- a/drivers/mfd/omap-usb-tll.c +++ b/drivers/mfd/omap-usb-tll.c @@ -254,7 +254,7 @@ static int usbtll_omap_probe(struct platform_device *pdev) break; } - tll->ch_clk = devm_kzalloc(dev, sizeof(struct clk *) * tll->nch, + tll->ch_clk = devm_kcalloc(dev, tll->nch, sizeof(struct clk *), GFP_KERNEL); if (!tll->ch_clk) { ret = -ENOMEM; diff --git a/drivers/mfd/twl-core.c b/drivers/mfd/twl-core.c index 8f993272901d..13315039e0a4 100644 --- a/drivers/mfd/twl-core.c +++ b/drivers/mfd/twl-core.c @@ -1139,8 +1139,9 @@ twl_probe(struct i2c_client *client, const struct i2c_device_id *id) } num_slaves = twl_get_num_slaves(); - twl_priv->twl_modules = devm_kzalloc(&client->dev, - sizeof(struct twl_client) * num_slaves, + twl_priv->twl_modules = devm_kcalloc(&client->dev, + num_slaves, + sizeof(struct twl_client), GFP_KERNEL); if (!twl_priv->twl_modules) { status = -ENOMEM; diff --git a/drivers/mfd/wm8994-core.c b/drivers/mfd/wm8994-core.c index 3259fb82d3c4..56a4c7c65c44 100644 --- a/drivers/mfd/wm8994-core.c +++ b/drivers/mfd/wm8994-core.c @@ -368,9 +368,10 @@ static int wm8994_device_init(struct wm8994 *wm8994, int irq) goto err; } - wm8994->supplies = devm_kzalloc(wm8994->dev, - sizeof(struct regulator_bulk_data) * - wm8994->num_supplies, GFP_KERNEL); + wm8994->supplies = devm_kcalloc(wm8994->dev, + wm8994->num_supplies, + sizeof(struct regulator_bulk_data), + GFP_KERNEL); if (!wm8994->supplies) { ret = -ENOMEM; goto err; diff --git a/drivers/misc/memory_state_time.c b/drivers/misc/memory_state_time.c index ba94dcf09169..ab8d5c11eaed 100644 --- a/drivers/misc/memory_state_time.c +++ b/drivers/misc/memory_state_time.c @@ -301,13 +301,13 @@ static int get_bw_buckets(struct device *dev) return -ENODATA; } - bandwidths = devm_kzalloc(dev, - sizeof(*bandwidths) * num_sources, GFP_KERNEL); + bandwidths = devm_kcalloc(dev, + num_sources, sizeof(*bandwidths), GFP_KERNEL); if (!bandwidths) return -ENOMEM; lenb /= sizeof(*bw_buckets); - bw_buckets = devm_kzalloc(dev, lenb * sizeof(*bw_buckets), - GFP_KERNEL); + bw_buckets = devm_kcalloc(dev, lenb, sizeof(*bw_buckets), + GFP_KERNEL); if (!bw_buckets) { devm_kfree(dev, bandwidths); return -ENOMEM; @@ -342,8 +342,8 @@ static int freq_buckets_init(struct device *dev) } lenf /= sizeof(*freq_buckets); - freq_buckets = devm_kzalloc(dev, lenf * sizeof(*freq_buckets), - GFP_KERNEL); + freq_buckets = devm_kcalloc(dev, lenf, sizeof(*freq_buckets), + GFP_KERNEL); if (!freq_buckets) return -ENOMEM; pr_debug("freqs found len %d\n", lenf); @@ -364,8 +364,9 @@ static int freq_buckets_init(struct device *dev) GFP_KERNEL); if (!freq_entry) return -ENOMEM; - freq_entry->buckets = devm_kzalloc(dev, sizeof(u64)*num_buckets, - GFP_KERNEL); + freq_entry->buckets = devm_kcalloc(dev, + num_buckets, sizeof(u64), + GFP_KERNEL); if (!freq_entry->buckets) { devm_kfree(dev, freq_entry); return -ENOMEM; diff --git a/drivers/misc/sram.c b/drivers/misc/sram.c index b856b7ede260..74b183baf044 100644 --- a/drivers/misc/sram.c +++ b/drivers/misc/sram.c @@ -264,8 +264,8 @@ static int sram_reserve_regions(struct sram_dev *sram, struct resource *res) list_sort(NULL, &reserve_list, sram_reserve_cmp); if (exports) { - sram->partition = devm_kzalloc(sram->dev, - exports * sizeof(*sram->partition), + sram->partition = devm_kcalloc(sram->dev, + exports, sizeof(*sram->partition), GFP_KERNEL); if (!sram->partition) { ret = -ENOMEM; diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index a6bd35e37a31..68e21a9c0ca0 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -1560,7 +1560,7 @@ static int sdhci_msm_dt_get_array(struct device *dev, const char *prop_name, goto out; } - arr = devm_kzalloc(dev, sz * sizeof(*arr), GFP_KERNEL); + arr = devm_kcalloc(dev, sz, sizeof(*arr), GFP_KERNEL); if (!arr) { ret = -ENOMEM; goto out; @@ -1745,8 +1745,10 @@ static int sdhci_msm_dt_parse_gpio_info(struct device *dev, goto out; } pin_data->gpio_data->size = cnt; - pin_data->gpio_data->gpio = devm_kzalloc(dev, cnt * - sizeof(struct sdhci_msm_gpio), GFP_KERNEL); + pin_data->gpio_data->gpio = devm_kcalloc(dev, + cnt, + sizeof(struct sdhci_msm_gpio), + GFP_KERNEL); if (!pin_data->gpio_data->gpio) { ret = -ENOMEM; diff --git a/drivers/mtd/devices/docg3.c b/drivers/mtd/devices/docg3.c index 6552696f2d45..f4a071734685 100644 --- a/drivers/mtd/devices/docg3.c +++ b/drivers/mtd/devices/docg3.c @@ -2076,7 +2076,7 @@ static int __init docg3_probe(struct platform_device *pdev) base = devm_ioremap(dev, ress->start, DOC_IOSPACE_SIZE); ret = -ENOMEM; - cascade = devm_kzalloc(dev, sizeof(*cascade) * DOC_MAX_NBFLOORS, + cascade = devm_kcalloc(dev, DOC_MAX_NBFLOORS, sizeof(*cascade), GFP_KERNEL); if (!cascade) return ret; diff --git a/drivers/mtd/nand/qcom_nandc.c b/drivers/mtd/nand/qcom_nandc.c index 65d1be2c3049..20ad11626f86 100644 --- a/drivers/mtd/nand/qcom_nandc.c +++ b/drivers/mtd/nand/qcom_nandc.c @@ -2414,8 +2414,8 @@ static int qcom_nandc_alloc(struct qcom_nand_controller *nandc) if (!nandc->regs) return -ENOMEM; - nandc->reg_read_buf = devm_kzalloc(nandc->dev, - MAX_REG_RD * sizeof(*nandc->reg_read_buf), + nandc->reg_read_buf = devm_kcalloc(nandc->dev, + MAX_REG_RD, sizeof(*nandc->reg_read_buf), GFP_KERNEL); if (!nandc->reg_read_buf) return -ENOMEM; diff --git a/drivers/mtd/nand/s3c2410.c b/drivers/mtd/nand/s3c2410.c index f60de68bfabc..87f78b6a5c16 100644 --- a/drivers/mtd/nand/s3c2410.c +++ b/drivers/mtd/nand/s3c2410.c @@ -1041,7 +1041,7 @@ static int s3c24xx_nand_probe_dt(struct platform_device *pdev) if (!pdata->nr_sets) return 0; - sets = devm_kzalloc(&pdev->dev, sizeof(*sets) * pdata->nr_sets, + sets = devm_kcalloc(&pdev->dev, pdata->nr_sets, sizeof(*sets), GFP_KERNEL); if (!sets) return -ENOMEM; diff --git a/drivers/net/dsa/b53/b53_common.c b/drivers/net/dsa/b53/b53_common.c index 274d36915110..4479bfc228cd 100644 --- a/drivers/net/dsa/b53/b53_common.c +++ b/drivers/net/dsa/b53/b53_common.c @@ -1825,14 +1825,14 @@ static int b53_switch_init(struct b53_device *dev) dev->num_ports = dev->cpu_port + 1; dev->enabled_ports |= BIT(dev->cpu_port); - dev->ports = devm_kzalloc(dev->dev, - sizeof(struct b53_port) * dev->num_ports, + dev->ports = devm_kcalloc(dev->dev, + dev->num_ports, sizeof(struct b53_port), GFP_KERNEL); if (!dev->ports) return -ENOMEM; - dev->vlans = devm_kzalloc(dev->dev, - sizeof(struct b53_vlan) * dev->num_vlans, + dev->vlans = devm_kcalloc(dev->dev, + dev->num_vlans, sizeof(struct b53_vlan), GFP_KERNEL); if (!dev->vlans) return -ENOMEM; diff --git a/drivers/net/ethernet/amazon/ena/ena_ethtool.c b/drivers/net/ethernet/amazon/ena/ena_ethtool.c index d29e256bf610..53683eb51bbd 100644 --- a/drivers/net/ethernet/amazon/ena/ena_ethtool.c +++ b/drivers/net/ethernet/amazon/ena/ena_ethtool.c @@ -877,8 +877,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) return; } - strings_buf = devm_kzalloc(&adapter->pdev->dev, - strings_num * ETH_GSTRING_LEN, + strings_buf = devm_kcalloc(&adapter->pdev->dev, + ETH_GSTRING_LEN, strings_num, GFP_ATOMIC); if (!strings_buf) { netif_err(adapter, drv, netdev, @@ -886,8 +886,8 @@ static void ena_dump_stats_ex(struct ena_adapter *adapter, u8 *buf) return; } - data_buf = devm_kzalloc(&adapter->pdev->dev, - strings_num * sizeof(u64), + data_buf = devm_kcalloc(&adapter->pdev->dev, + strings_num, sizeof(u64), GFP_ATOMIC); if (!data_buf) { netif_err(adapter, drv, netdev, diff --git a/drivers/net/ethernet/ethoc.c b/drivers/net/ethernet/ethoc.c index 8bb0db990c8f..c30565134c7b 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) dev_dbg(&pdev->dev, "ethoc: num_tx: %d num_rx: %d\n", priv->num_tx, priv->num_rx); - priv->vma = devm_kzalloc(&pdev->dev, num_bd*sizeof(void *), GFP_KERNEL); + priv->vma = devm_kcalloc(&pdev->dev, num_bd, sizeof(void *), + GFP_KERNEL); if (!priv->vma) { ret = -ENOMEM; goto free; diff --git a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c index 67246d42c3d9..49f318c1c8c3 100644 --- a/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c +++ b/drivers/net/ethernet/freescale/dpaa/dpaa_eth.c @@ -672,7 +672,7 @@ static struct dpaa_fq *dpaa_fq_alloc(struct device *dev, struct dpaa_fq *dpaa_fq; int i; - dpaa_fq = devm_kzalloc(dev, sizeof(*dpaa_fq) * count, + dpaa_fq = devm_kcalloc(dev, count, sizeof(*dpaa_fq), GFP_KERNEL); if (!dpaa_fq) return NULL; diff --git a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c index e9cff8ed5e07..06d22a9c8651 100644 --- a/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c +++ b/drivers/net/ethernet/hisilicon/hns3/hns3pf/hns3_enet.c @@ -2554,8 +2554,8 @@ static int hns3_get_ring_config(struct hns3_nic_priv *priv) struct pci_dev *pdev = h->pdev; int i, ret; - priv->ring_data = devm_kzalloc(&pdev->dev, h->kinfo.num_tqps * - sizeof(*priv->ring_data) * 2, + priv->ring_data = devm_kzalloc(&pdev->dev, + array3_size(h->kinfo.num_tqps, sizeof(*priv->ring_data), 2), GFP_KERNEL); if (!priv->ring_data) return -ENOMEM; diff --git a/drivers/net/ethernet/ti/cpsw.c b/drivers/net/ethernet/ti/cpsw.c index 3189afcd5888..a592b1e90442 100644 --- a/drivers/net/ethernet/ti/cpsw.c +++ b/drivers/net/ethernet/ti/cpsw.c @@ -2630,8 +2630,9 @@ static int cpsw_probe_dt(struct cpsw_platform_data *data, } data->active_slave = prop; - data->slave_data = devm_kzalloc(&pdev->dev, data->slaves - * sizeof(struct cpsw_slave_data), + data->slave_data = devm_kcalloc(&pdev->dev, + data->slaves, + sizeof(struct cpsw_slave_data), GFP_KERNEL); if (!data->slave_data) return -ENOMEM; @@ -2959,8 +2960,8 @@ static int cpsw_probe(struct platform_device *pdev) memcpy(ndev->dev_addr, priv->mac_addr, ETH_ALEN); - cpsw->slaves = devm_kzalloc(&pdev->dev, - sizeof(struct cpsw_slave) * data->slaves, + cpsw->slaves = devm_kcalloc(&pdev->dev, + data->slaves, sizeof(struct cpsw_slave), GFP_KERNEL); if (!cpsw->slaves) { ret = -ENOMEM; diff --git a/drivers/net/ethernet/ti/netcp_ethss.c b/drivers/net/ethernet/ti/netcp_ethss.c index ff7a71ca0b13..ba14f5dd7e04 100644 --- a/drivers/net/ethernet/ti/netcp_ethss.c +++ b/drivers/net/ethernet/ti/netcp_ethss.c @@ -3173,8 +3173,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, gbe_dev->et_stats = xgbe10_et_stats; gbe_dev->num_et_stats = ARRAY_SIZE(xgbe10_et_stats); - gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u64), + gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u64), GFP_KERNEL); if (!gbe_dev->hw_stats) { dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); @@ -3182,8 +3182,8 @@ static int set_xgbe_ethss10_priv(struct gbe_priv *gbe_dev, } gbe_dev->hw_stats_prev = - devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u32), + devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u32), GFP_KERNEL); if (!gbe_dev->hw_stats_prev) { dev_err(gbe_dev->dev, @@ -3293,8 +3293,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, gbe_dev->et_stats = gbe13_et_stats; gbe_dev->num_et_stats = ARRAY_SIZE(gbe13_et_stats); - gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u64), + gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u64), GFP_KERNEL); if (!gbe_dev->hw_stats) { dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); @@ -3302,8 +3302,8 @@ static int set_gbe_ethss14_priv(struct gbe_priv *gbe_dev, } gbe_dev->hw_stats_prev = - devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u32), + devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u32), GFP_KERNEL); if (!gbe_dev->hw_stats_prev) { dev_err(gbe_dev->dev, @@ -3365,8 +3365,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, gbe_dev->num_et_stats = GBENU_ET_STATS_HOST_SIZE + GBENU_ET_STATS_PORT_SIZE; - gbe_dev->hw_stats = devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u64), + gbe_dev->hw_stats = devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u64), GFP_KERNEL); if (!gbe_dev->hw_stats) { dev_err(gbe_dev->dev, "hw_stats memory allocation failed\n"); @@ -3374,8 +3374,8 @@ static int set_gbenu_ethss_priv(struct gbe_priv *gbe_dev, } gbe_dev->hw_stats_prev = - devm_kzalloc(gbe_dev->dev, - gbe_dev->num_et_stats * sizeof(u32), + devm_kcalloc(gbe_dev->dev, + gbe_dev->num_et_stats, sizeof(u32), GFP_KERNEL); if (!gbe_dev->hw_stats_prev) { dev_err(gbe_dev->dev, diff --git a/drivers/net/phy/phy_led_triggers.c b/drivers/net/phy/phy_led_triggers.c index 94ca42e630bb..0049dcae5f30 100644 --- a/drivers/net/phy/phy_led_triggers.c +++ b/drivers/net/phy/phy_led_triggers.c @@ -99,9 +99,9 @@ int phy_led_triggers_register(struct phy_device *phy) if (!phy->phy_num_led_triggers) return 0; - phy->phy_led_triggers = devm_kzalloc(&phy->mdio.dev, - sizeof(struct phy_led_trigger) * - phy->phy_num_led_triggers, + phy->phy_led_triggers = devm_kcalloc(&phy->mdio.dev, + phy->phy_num_led_triggers, + sizeof(struct phy_led_trigger), GFP_KERNEL); if (!phy->phy_led_triggers) { err = -ENOMEM; diff --git a/drivers/net/wireless/cnss2/pci.c b/drivers/net/wireless/cnss2/pci.c index 70f6376afd14..a3beeeb46496 100644 --- a/drivers/net/wireless/cnss2/pci.c +++ b/drivers/net/wireless/cnss2/pci.c @@ -726,9 +726,10 @@ static void cnss_pci_dump_shadow_reg(struct cnss_pci_data *pci_priv) gfp = GFP_ATOMIC; if (!pci_priv->debug_reg) { - pci_priv->debug_reg = devm_kzalloc(&pci_priv->pci_dev->dev, - sizeof(*pci_priv->debug_reg) - * array_size, gfp); + pci_priv->debug_reg = devm_kcalloc(&pci_priv->pci_dev->dev, + array_size, + sizeof(*pci_priv->debug_reg), + gfp); if (!pci_priv->debug_reg) return; } @@ -2604,9 +2605,10 @@ static void cnss_pci_dump_qdss_reg(struct cnss_pci_data *pci_priv) gfp = GFP_ATOMIC; if (!plat_priv->qdss_reg) { - plat_priv->qdss_reg = devm_kzalloc(&pci_priv->pci_dev->dev, - sizeof(*plat_priv->qdss_reg) - * array_size, gfp); + plat_priv->qdss_reg = devm_kcalloc(&pci_priv->pci_dev->dev, + array_size, + sizeof(*plat_priv->qdss_reg), + gfp); if (!plat_priv->qdss_reg) return; } diff --git a/drivers/pci/dwc/pci-dra7xx.c b/drivers/pci/dwc/pci-dra7xx.c index 2e0d0b29cdcb..7bfb14a8c49c 100644 --- a/drivers/pci/dwc/pci-dra7xx.c +++ b/drivers/pci/dwc/pci-dra7xx.c @@ -649,11 +649,11 @@ static int __init dra7xx_pcie_probe(struct platform_device *pdev) return phy_count; } - phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL); + phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL); if (!phy) return -ENOMEM; - link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL); + link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL); if (!link) return -ENOMEM; diff --git a/drivers/pci/dwc/pcie-designware-ep.c b/drivers/pci/dwc/pcie-designware-ep.c index 71795db41261..aea4b15cf16f 100644 --- a/drivers/pci/dwc/pcie-designware-ep.c +++ b/drivers/pci/dwc/pcie-designware-ep.c @@ -315,19 +315,21 @@ int dw_pcie_ep_init(struct dw_pcie_ep *ep) return -EINVAL; } - ep->ib_window_map = devm_kzalloc(dev, sizeof(long) * + ep->ib_window_map = devm_kcalloc(dev, BITS_TO_LONGS(ep->num_ib_windows), + sizeof(long), GFP_KERNEL); if (!ep->ib_window_map) return -ENOMEM; - ep->ob_window_map = devm_kzalloc(dev, sizeof(long) * + ep->ob_window_map = devm_kcalloc(dev, BITS_TO_LONGS(ep->num_ob_windows), + sizeof(long), GFP_KERNEL); if (!ep->ob_window_map) return -ENOMEM; - addr = devm_kzalloc(dev, sizeof(phys_addr_t) * ep->num_ob_windows, + addr = devm_kcalloc(dev, ep->num_ob_windows, sizeof(phys_addr_t), GFP_KERNEL); if (!addr) return -ENOMEM; diff --git a/drivers/pci/host/pci-msm.c b/drivers/pci/host/pci-msm.c index 71c7833ee4d3..2a6cbe368546 100644 --- a/drivers/pci/host/pci-msm.c +++ b/drivers/pci/host/pci-msm.c @@ -3776,8 +3776,9 @@ static int msm_pcie_get_resources(struct msm_pcie_dev_t *dev, "iommu-map", (u32 *)map, size / sizeof(u32)); dev->sid_info_len = map_len; - dev->sid_info = devm_kzalloc(&pdev->dev, - dev->sid_info_len * sizeof(*dev->sid_info), GFP_KERNEL); + dev->sid_info = devm_kcalloc(&pdev->dev, + dev->sid_info_len, sizeof(*dev->sid_info), + GFP_KERNEL); if (!dev->sid_info) { devm_kfree(&pdev->dev, map); ret = -ENOMEM; diff --git a/drivers/pinctrl/berlin/berlin.c b/drivers/pinctrl/berlin/berlin.c index cc3bd2efafe3..df284e9017e4 100644 --- a/drivers/pinctrl/berlin/berlin.c +++ b/drivers/pinctrl/berlin/berlin.c @@ -219,8 +219,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) } /* we will reallocate later */ - pctrl->functions = devm_kzalloc(&pdev->dev, - max_functions * sizeof(*pctrl->functions), + pctrl->functions = devm_kcalloc(&pdev->dev, + max_functions, + sizeof(*pctrl->functions), GFP_KERNEL); if (!pctrl->functions) return -ENOMEM; @@ -264,8 +265,9 @@ static int berlin_pinctrl_build_state(struct platform_device *pdev) if (!function->groups) { function->groups = - devm_kzalloc(&pdev->dev, - function->ngroups * sizeof(char *), + devm_kcalloc(&pdev->dev, + function->ngroups, + sizeof(char *), GFP_KERNEL); if (!function->groups) diff --git a/drivers/pinctrl/freescale/pinctrl-imx.c b/drivers/pinctrl/freescale/pinctrl-imx.c index e088648b3bd4..2291cc38edcc 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx.c +++ b/drivers/pinctrl/freescale/pinctrl-imx.c @@ -477,10 +477,12 @@ static int imx_pinctrl_parse_groups(struct device_node *np, config = imx_pinconf_parse_generic_config(np, ipctl); grp->num_pins = size / pin_size; - grp->data = devm_kzalloc(info->dev, grp->num_pins * - sizeof(struct imx_pin), GFP_KERNEL); - grp->pins = devm_kzalloc(info->dev, grp->num_pins * - sizeof(unsigned int), GFP_KERNEL); + grp->data = devm_kcalloc(info->dev, + grp->num_pins, sizeof(struct imx_pin), + GFP_KERNEL); + grp->pins = devm_kcalloc(info->dev, + grp->num_pins, sizeof(unsigned int), + GFP_KERNEL); if (!grp->pins || !grp->data) return -ENOMEM; diff --git a/drivers/pinctrl/freescale/pinctrl-imx1-core.c b/drivers/pinctrl/freescale/pinctrl-imx1-core.c index e994f8916f01..e423d58d57f7 100644 --- a/drivers/pinctrl/freescale/pinctrl-imx1-core.c +++ b/drivers/pinctrl/freescale/pinctrl-imx1-core.c @@ -488,10 +488,10 @@ static int imx1_pinctrl_parse_groups(struct device_node *np, } grp->npins = size / 12; - grp->pins = devm_kzalloc(info->dev, - grp->npins * sizeof(struct imx1_pin), GFP_KERNEL); - grp->pin_ids = devm_kzalloc(info->dev, - grp->npins * sizeof(unsigned int), GFP_KERNEL); + grp->pins = devm_kcalloc(info->dev, + grp->npins, sizeof(struct imx1_pin), GFP_KERNEL); + grp->pin_ids = devm_kcalloc(info->dev, + grp->npins, sizeof(unsigned int), GFP_KERNEL); if (!grp->pins || !grp->pin_ids) return -ENOMEM; @@ -528,8 +528,8 @@ static int imx1_pinctrl_parse_functions(struct device_node *np, if (func->num_groups == 0) return -EINVAL; - func->groups = devm_kzalloc(info->dev, - func->num_groups * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(info->dev, + func->num_groups, sizeof(char *), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -571,12 +571,12 @@ static int imx1_pinctrl_parse_dt(struct platform_device *pdev, } info->nfunctions = nfuncs; - info->functions = devm_kzalloc(&pdev->dev, - nfuncs * sizeof(struct imx1_pmx_func), GFP_KERNEL); + info->functions = devm_kcalloc(&pdev->dev, + nfuncs, sizeof(struct imx1_pmx_func), GFP_KERNEL); info->ngroups = ngroups; - info->groups = devm_kzalloc(&pdev->dev, - ngroups * sizeof(struct imx1_pin_group), GFP_KERNEL); + info->groups = devm_kcalloc(&pdev->dev, + ngroups, sizeof(struct imx1_pin_group), GFP_KERNEL); if (!info->functions || !info->groups) diff --git a/drivers/pinctrl/freescale/pinctrl-mxs.c b/drivers/pinctrl/freescale/pinctrl-mxs.c index 43a6e900c20f..1286fdab8632 100644 --- a/drivers/pinctrl/freescale/pinctrl-mxs.c +++ b/drivers/pinctrl/freescale/pinctrl-mxs.c @@ -377,12 +377,12 @@ static int mxs_pinctrl_parse_group(struct platform_device *pdev, return -EINVAL; g->npins = length / sizeof(u32); - g->pins = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->pins), + g->pins = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->pins), GFP_KERNEL); if (!g->pins) return -ENOMEM; - g->muxsel = devm_kzalloc(&pdev->dev, g->npins * sizeof(*g->muxsel), + g->muxsel = devm_kcalloc(&pdev->dev, g->npins, sizeof(*g->muxsel), GFP_KERNEL); if (!g->muxsel) return -ENOMEM; @@ -433,13 +433,16 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, } } - soc->functions = devm_kzalloc(&pdev->dev, soc->nfunctions * - sizeof(*soc->functions), GFP_KERNEL); + soc->functions = devm_kcalloc(&pdev->dev, + soc->nfunctions, + sizeof(*soc->functions), + GFP_KERNEL); if (!soc->functions) return -ENOMEM; - soc->groups = devm_kzalloc(&pdev->dev, soc->ngroups * - sizeof(*soc->groups), GFP_KERNEL); + soc->groups = devm_kcalloc(&pdev->dev, + soc->ngroups, sizeof(*soc->groups), + GFP_KERNEL); if (!soc->groups) return -ENOMEM; @@ -499,7 +502,8 @@ static int mxs_pinctrl_probe_dt(struct platform_device *pdev, if (strcmp(fn, child->name)) { f = &soc->functions[idxf++]; - f->groups = devm_kzalloc(&pdev->dev, f->ngroups * + f->groups = devm_kcalloc(&pdev->dev, + f->ngroups, sizeof(*f->groups), GFP_KERNEL); if (!f->groups) diff --git a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c index 262f591ad8a6..fc00aa4cd982 100644 --- a/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c +++ b/drivers/pinctrl/mvebu/pinctrl-armada-37xx.c @@ -806,9 +806,10 @@ static int armada_37xx_fill_group(struct armada_37xx_pinctrl *info) struct armada_37xx_pin_group *grp = &info->groups[n]; int i, j, f; - grp->pins = devm_kzalloc(info->dev, - (grp->npins + grp->extra_npins) * - sizeof(*grp->pins), GFP_KERNEL); + grp->pins = devm_kcalloc(info->dev, + grp->npins + grp->extra_npins, + sizeof(*grp->pins), + GFP_KERNEL); if (!grp->pins) return -ENOMEM; @@ -858,7 +859,8 @@ static int armada_37xx_fill_func(struct armada_37xx_pinctrl *info) const char **groups; int g; - funcs[n].groups = devm_kzalloc(info->dev, funcs[n].ngroups * + funcs[n].groups = devm_kcalloc(info->dev, + funcs[n].ngroups, sizeof(*(funcs[n].groups)), GFP_KERNEL); if (!funcs[n].groups) @@ -898,8 +900,9 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &armada_37xx_pmx_ops; ctrldesc->confops = &armada_37xx_pinconf_ops; - pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * - pin_data->nr_pins, GFP_KERNEL); + pindesc = devm_kcalloc(&pdev->dev, + pin_data->nr_pins, sizeof(*pindesc), + GFP_KERNEL); if (!pindesc) return -ENOMEM; @@ -918,8 +921,10 @@ static int armada_37xx_pinctrl_register(struct platform_device *pdev, * we allocate functions for number of pins and hope there are * fewer unique functions than pins available */ - info->funcs = devm_kzalloc(&pdev->dev, pin_data->nr_pins * - sizeof(struct armada_37xx_pmx_func), GFP_KERNEL); + info->funcs = devm_kcalloc(&pdev->dev, + pin_data->nr_pins, + sizeof(struct armada_37xx_pmx_func), + GFP_KERNEL); if (!info->funcs) return -ENOMEM; diff --git a/drivers/pinctrl/mvebu/pinctrl-mvebu.c b/drivers/pinctrl/mvebu/pinctrl-mvebu.c index 163d4614b0f8..30bb9f7117bb 100644 --- a/drivers/pinctrl/mvebu/pinctrl-mvebu.c +++ b/drivers/pinctrl/mvebu/pinctrl-mvebu.c @@ -501,8 +501,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, /* we allocate functions for number of pins and hope * there are fewer unique functions than pins available */ - funcs = devm_kzalloc(&pdev->dev, funcsize * - sizeof(struct mvebu_pinctrl_function), GFP_KERNEL); + funcs = devm_kcalloc(&pdev->dev, + funcsize, sizeof(struct mvebu_pinctrl_function), + GFP_KERNEL); if (!funcs) return -ENOMEM; @@ -549,8 +550,9 @@ static int mvebu_pinctrl_build_functions(struct platform_device *pdev, /* allocate group name array if not done already */ if (!f->groups) { - f->groups = devm_kzalloc(&pdev->dev, - f->num_groups * sizeof(char *), + f->groups = devm_kcalloc(&pdev->dev, + f->num_groups, + sizeof(char *), GFP_KERNEL); if (!f->groups) return -ENOMEM; @@ -622,8 +624,10 @@ int mvebu_pinctrl_probe(struct platform_device *pdev) } } - pdesc = devm_kzalloc(&pdev->dev, pctl->desc.npins * - sizeof(struct pinctrl_pin_desc), GFP_KERNEL); + pdesc = devm_kcalloc(&pdev->dev, + pctl->desc.npins, + sizeof(struct pinctrl_pin_desc), + GFP_KERNEL); if (!pdesc) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-at91-pio4.c b/drivers/pinctrl/pinctrl-at91-pio4.c index e9d797707255..abb1c853001e 100644 --- a/drivers/pinctrl/pinctrl-at91-pio4.c +++ b/drivers/pinctrl/pinctrl-at91-pio4.c @@ -941,27 +941,30 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) return PTR_ERR(atmel_pioctrl->clk); } - atmel_pioctrl->pins = devm_kzalloc(dev, sizeof(*atmel_pioctrl->pins) - * atmel_pioctrl->npins, GFP_KERNEL); + atmel_pioctrl->pins = devm_kcalloc(dev, + atmel_pioctrl->npins, + sizeof(*atmel_pioctrl->pins), + GFP_KERNEL); if (!atmel_pioctrl->pins) return -ENOMEM; - pin_desc = devm_kzalloc(dev, sizeof(*pin_desc) - * atmel_pioctrl->npins, GFP_KERNEL); + pin_desc = devm_kcalloc(dev, atmel_pioctrl->npins, sizeof(*pin_desc), + GFP_KERNEL); if (!pin_desc) return -ENOMEM; atmel_pinctrl_desc.pins = pin_desc; atmel_pinctrl_desc.npins = atmel_pioctrl->npins; /* One pin is one group since a pin can achieve all functions. */ - group_names = devm_kzalloc(dev, sizeof(*group_names) - * atmel_pioctrl->npins, GFP_KERNEL); + group_names = devm_kcalloc(dev, + atmel_pioctrl->npins, sizeof(*group_names), + GFP_KERNEL); if (!group_names) return -ENOMEM; atmel_pioctrl->group_names = group_names; - atmel_pioctrl->groups = devm_kzalloc(&pdev->dev, - sizeof(*atmel_pioctrl->groups) * atmel_pioctrl->npins, + atmel_pioctrl->groups = devm_kcalloc(&pdev->dev, + atmel_pioctrl->npins, sizeof(*atmel_pioctrl->groups), GFP_KERNEL); if (!atmel_pioctrl->groups) return -ENOMEM; @@ -997,20 +1000,24 @@ static int atmel_pinctrl_probe(struct platform_device *pdev) atmel_pioctrl->gpio_chip->parent = dev; atmel_pioctrl->gpio_chip->names = atmel_pioctrl->group_names; - atmel_pioctrl->pm_wakeup_sources = devm_kzalloc(dev, - sizeof(*atmel_pioctrl->pm_wakeup_sources) - * atmel_pioctrl->nbanks, GFP_KERNEL); + atmel_pioctrl->pm_wakeup_sources = devm_kcalloc(dev, + atmel_pioctrl->nbanks, + sizeof(*atmel_pioctrl->pm_wakeup_sources), + GFP_KERNEL); if (!atmel_pioctrl->pm_wakeup_sources) return -ENOMEM; - atmel_pioctrl->pm_suspend_backup = devm_kzalloc(dev, - sizeof(*atmel_pioctrl->pm_suspend_backup) - * atmel_pioctrl->nbanks, GFP_KERNEL); + atmel_pioctrl->pm_suspend_backup = devm_kcalloc(dev, + atmel_pioctrl->nbanks, + sizeof(*atmel_pioctrl->pm_suspend_backup), + GFP_KERNEL); if (!atmel_pioctrl->pm_suspend_backup) return -ENOMEM; - atmel_pioctrl->irqs = devm_kzalloc(dev, sizeof(*atmel_pioctrl->irqs) - * atmel_pioctrl->nbanks, GFP_KERNEL); + atmel_pioctrl->irqs = devm_kcalloc(dev, + atmel_pioctrl->nbanks, + sizeof(*atmel_pioctrl->irqs), + GFP_KERNEL); if (!atmel_pioctrl->irqs) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-at91.c b/drivers/pinctrl/pinctrl-at91.c index 404711f0985a..2311eb8ce8c7 100644 --- a/drivers/pinctrl/pinctrl-at91.c +++ b/drivers/pinctrl/pinctrl-at91.c @@ -269,7 +269,8 @@ static int at91_dt_node_to_map(struct pinctrl_dev *pctldev, } map_num += grp->npins; - new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, GFP_KERNEL); + new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), + GFP_KERNEL); if (!new_map) return -ENOMEM; @@ -1049,7 +1050,8 @@ static int at91_pinctrl_mux_mask(struct at91_pinctrl *info, } info->nmux = size / gpio_banks; - info->mux_mask = devm_kzalloc(info->dev, sizeof(u32) * size, GFP_KERNEL); + info->mux_mask = devm_kcalloc(info->dev, size, sizeof(u32), + GFP_KERNEL); if (!info->mux_mask) { dev_err(info->dev, "could not alloc mux_mask\n"); return -ENOMEM; @@ -1089,10 +1091,12 @@ static int at91_pinctrl_parse_groups(struct device_node *np, } grp->npins = size / 4; - pin = grp->pins_conf = devm_kzalloc(info->dev, grp->npins * sizeof(struct at91_pmx_pin), - GFP_KERNEL); - grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int), - GFP_KERNEL); + pin = grp->pins_conf = devm_kcalloc(info->dev, + grp->npins, + sizeof(struct at91_pmx_pin), + GFP_KERNEL); + grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), + GFP_KERNEL); if (!grp->pins_conf || !grp->pins) return -ENOMEM; @@ -1131,8 +1135,8 @@ static int at91_pinctrl_parse_functions(struct device_node *np, dev_err(info->dev, "no groups defined\n"); return -EINVAL; } - func->groups = devm_kzalloc(info->dev, - func->ngroups * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(info->dev, + func->ngroups, sizeof(char *), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -1194,12 +1198,16 @@ static int at91_pinctrl_probe_dt(struct platform_device *pdev, dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kzalloc(&pdev->dev, info->nfunctions * sizeof(struct at91_pmx_func), + info->functions = devm_kcalloc(&pdev->dev, + info->nfunctions, + sizeof(struct at91_pmx_func), GFP_KERNEL); if (!info->functions) return -ENOMEM; - info->groups = devm_kzalloc(&pdev->dev, info->ngroups * sizeof(struct at91_pin_group), + info->groups = devm_kcalloc(&pdev->dev, + info->ngroups, + sizeof(struct at91_pin_group), GFP_KERNEL); if (!info->groups) return -ENOMEM; @@ -1258,7 +1266,9 @@ static int at91_pinctrl_probe(struct platform_device *pdev) at91_pinctrl_desc.name = dev_name(&pdev->dev); at91_pinctrl_desc.npins = gpio_banks * MAX_NB_GPIO_PER_BANK; at91_pinctrl_desc.pins = pdesc = - devm_kzalloc(&pdev->dev, sizeof(*pdesc) * at91_pinctrl_desc.npins, GFP_KERNEL); + devm_kcalloc(&pdev->dev, + at91_pinctrl_desc.npins, sizeof(*pdesc), + GFP_KERNEL); if (!at91_pinctrl_desc.pins) return -ENOMEM; @@ -1765,7 +1775,7 @@ static int at91_gpio_probe(struct platform_device *pdev) chip->ngpio = ngpio; } - names = devm_kzalloc(&pdev->dev, sizeof(char *) * chip->ngpio, + names = devm_kcalloc(&pdev->dev, chip->ngpio, sizeof(char *), GFP_KERNEL); if (!names) { diff --git a/drivers/pinctrl/pinctrl-digicolor.c b/drivers/pinctrl/pinctrl-digicolor.c index ce269ced4d49..5353b23f775c 100644 --- a/drivers/pinctrl/pinctrl-digicolor.c +++ b/drivers/pinctrl/pinctrl-digicolor.c @@ -291,10 +291,11 @@ static int dc_pinctrl_probe(struct platform_device *pdev) if (IS_ERR(pmap->regs)) return PTR_ERR(pmap->regs); - pins = devm_kzalloc(&pdev->dev, sizeof(*pins)*PINS_COUNT, GFP_KERNEL); + pins = devm_kcalloc(&pdev->dev, PINS_COUNT, sizeof(*pins), + GFP_KERNEL); if (!pins) return -ENOMEM; - pin_names = devm_kzalloc(&pdev->dev, name_len * PINS_COUNT, + pin_names = devm_kcalloc(&pdev->dev, PINS_COUNT, name_len, GFP_KERNEL); if (!pin_names) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-ingenic.c b/drivers/pinctrl/pinctrl-ingenic.c index 1541f8cba556..47b1d65f9867 100644 --- a/drivers/pinctrl/pinctrl-ingenic.c +++ b/drivers/pinctrl/pinctrl-ingenic.c @@ -772,8 +772,8 @@ int ingenic_pinctrl_probe(struct platform_device *pdev) pctl_desc->pmxops = &ingenic_pmxops; pctl_desc->confops = &ingenic_confops; pctl_desc->npins = chip_info->num_chips * PINS_PER_GPIO_CHIP; - pctl_desc->pins = jzpc->pdesc = devm_kzalloc(&pdev->dev, - sizeof(*jzpc->pdesc) * pctl_desc->npins, GFP_KERNEL); + pctl_desc->pins = jzpc->pdesc = devm_kcalloc(&pdev->dev, + pctl_desc->npins, sizeof(*jzpc->pdesc), GFP_KERNEL); if (!jzpc->pdesc) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-lpc18xx.c b/drivers/pinctrl/pinctrl-lpc18xx.c index 8b4e3582af6e..1d3b88e6ab86 100644 --- a/drivers/pinctrl/pinctrl-lpc18xx.c +++ b/drivers/pinctrl/pinctrl-lpc18xx.c @@ -1302,8 +1302,9 @@ static int lpc18xx_create_group_func_map(struct device *dev, } scu->func[func].ngroups = ngroups; - scu->func[func].groups = devm_kzalloc(dev, ngroups * - sizeof(char *), GFP_KERNEL); + scu->func[func].groups = devm_kcalloc(dev, + ngroups, sizeof(char *), + GFP_KERNEL); if (!scu->func[func].groups) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-rockchip.c b/drivers/pinctrl/pinctrl-rockchip.c index 5d6cf024ee9c..53cb6c579266 100644 --- a/drivers/pinctrl/pinctrl-rockchip.c +++ b/drivers/pinctrl/pinctrl-rockchip.c @@ -506,7 +506,7 @@ static int rockchip_dt_node_to_map(struct pinctrl_dev *pctldev, } map_num += grp->npins; - new_map = devm_kzalloc(pctldev->dev, sizeof(*new_map) * map_num, + new_map = devm_kcalloc(pctldev->dev, map_num, sizeof(*new_map), GFP_KERNEL); if (!new_map) return -ENOMEM; @@ -2293,10 +2293,11 @@ static int rockchip_pinctrl_parse_groups(struct device_node *np, grp->npins = size / 4; - grp->pins = devm_kzalloc(info->dev, grp->npins * sizeof(unsigned int), + grp->pins = devm_kcalloc(info->dev, grp->npins, sizeof(unsigned int), GFP_KERNEL); - grp->data = devm_kzalloc(info->dev, grp->npins * - sizeof(struct rockchip_pin_config), + grp->data = devm_kcalloc(info->dev, + grp->npins, + sizeof(struct rockchip_pin_config), GFP_KERNEL); if (!grp->pins || !grp->data) return -ENOMEM; @@ -2348,8 +2349,8 @@ static int rockchip_pinctrl_parse_functions(struct device_node *np, if (func->ngroups <= 0) return 0; - func->groups = devm_kzalloc(info->dev, - func->ngroups * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(info->dev, + func->ngroups, sizeof(char *), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -2380,7 +2381,8 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, dev_dbg(&pdev->dev, "nfunctions = %d\n", info->nfunctions); dev_dbg(&pdev->dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kzalloc(dev, info->nfunctions * + info->functions = devm_kcalloc(dev, + info->nfunctions, sizeof(struct rockchip_pmx_func), GFP_KERNEL); if (!info->functions) { @@ -2388,7 +2390,8 @@ static int rockchip_pinctrl_parse_dt(struct platform_device *pdev, return -EINVAL; } - info->groups = devm_kzalloc(dev, info->ngroups * + info->groups = devm_kcalloc(dev, + info->ngroups, sizeof(struct rockchip_pin_group), GFP_KERNEL); if (!info->groups) { @@ -2428,8 +2431,9 @@ static int rockchip_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &rockchip_pmx_ops; ctrldesc->confops = &rockchip_pinconf_ops; - pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * - info->ctrl->nr_pins, GFP_KERNEL); + pindesc = devm_kcalloc(&pdev->dev, + info->ctrl->nr_pins, sizeof(*pindesc), + GFP_KERNEL); if (!pindesc) { dev_err(&pdev->dev, "mem alloc for pin descriptors failed\n"); return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-single.c b/drivers/pinctrl/pinctrl-single.c index b8b3d932cd73..7c00775af758 100644 --- a/drivers/pinctrl/pinctrl-single.c +++ b/drivers/pinctrl/pinctrl-single.c @@ -690,8 +690,8 @@ static int pcs_allocate_pin_table(struct pcs_device *pcs) } dev_dbg(pcs->dev, "allocating %i pins\n", nr_pins); - pcs->pins.pa = devm_kzalloc(pcs->dev, - sizeof(*pcs->pins.pa) * nr_pins, + pcs->pins.pa = devm_kcalloc(pcs->dev, + nr_pins, sizeof(*pcs->pins.pa), GFP_KERNEL); if (!pcs->pins.pa) return -ENOMEM; @@ -902,15 +902,15 @@ static int pcs_parse_pinconf(struct pcs_device *pcs, struct device_node *np, if (!nconfs) return 0; - func->conf = devm_kzalloc(pcs->dev, - sizeof(struct pcs_conf_vals) * nconfs, + func->conf = devm_kcalloc(pcs->dev, + nconfs, sizeof(struct pcs_conf_vals), GFP_KERNEL); if (!func->conf) return -ENOMEM; func->nconfs = nconfs; conf = &(func->conf[0]); m++; - settings = devm_kzalloc(pcs->dev, sizeof(unsigned long) * nconfs, + settings = devm_kcalloc(pcs->dev, nconfs, sizeof(unsigned long), GFP_KERNEL); if (!settings) return -ENOMEM; @@ -966,11 +966,11 @@ static int pcs_parse_one_pinctrl_entry(struct pcs_device *pcs, return -EINVAL; } - vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows, GFP_KERNEL); + vals = devm_kcalloc(pcs->dev, rows, sizeof(*vals), GFP_KERNEL); if (!vals) return -ENOMEM; - pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows, GFP_KERNEL); + pins = devm_kcalloc(pcs->dev, rows, sizeof(*pins), GFP_KERNEL); if (!pins) goto free_vals; @@ -1067,13 +1067,15 @@ static int pcs_parse_bits_in_pinctrl_entry(struct pcs_device *pcs, npins_in_row = pcs->width / pcs->bits_per_pin; - vals = devm_kzalloc(pcs->dev, sizeof(*vals) * rows * npins_in_row, - GFP_KERNEL); + vals = devm_kzalloc(pcs->dev, + array3_size(rows, npins_in_row, sizeof(*vals)), + GFP_KERNEL); if (!vals) return -ENOMEM; - pins = devm_kzalloc(pcs->dev, sizeof(*pins) * rows * npins_in_row, - GFP_KERNEL); + pins = devm_kzalloc(pcs->dev, + array3_size(rows, npins_in_row, sizeof(*pins)), + GFP_KERNEL); if (!pins) goto free_vals; @@ -1195,7 +1197,7 @@ static int pcs_dt_node_to_map(struct pinctrl_dev *pctldev, pcs = pinctrl_dev_get_drvdata(pctldev); /* create 2 maps. One is for pinmux, and the other is for pinconf. */ - *map = devm_kzalloc(pcs->dev, sizeof(**map) * 2, GFP_KERNEL); + *map = devm_kcalloc(pcs->dev, 2, sizeof(**map), GFP_KERNEL); if (!*map) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-st.c b/drivers/pinctrl/pinctrl-st.c index a5205b94b2e6..6988935e8ded 100644 --- a/drivers/pinctrl/pinctrl-st.c +++ b/drivers/pinctrl/pinctrl-st.c @@ -823,8 +823,8 @@ static int st_pctl_dt_node_to_map(struct pinctrl_dev *pctldev, } map_num = grp->npins + 1; - new_map = devm_kzalloc(pctldev->dev, - sizeof(*new_map) * map_num, GFP_KERNEL); + new_map = devm_kcalloc(pctldev->dev, + map_num, sizeof(*new_map), GFP_KERNEL); if (!new_map) return -ENOMEM; @@ -1191,9 +1191,9 @@ static int st_pctl_dt_parse_groups(struct device_node *np, grp->npins = npins; grp->name = np->name; - grp->pins = devm_kzalloc(info->dev, npins * sizeof(u32), GFP_KERNEL); - grp->pin_conf = devm_kzalloc(info->dev, - npins * sizeof(*conf), GFP_KERNEL); + grp->pins = devm_kcalloc(info->dev, npins, sizeof(u32), GFP_KERNEL); + grp->pin_conf = devm_kcalloc(info->dev, + npins, sizeof(*conf), GFP_KERNEL); if (!grp->pins || !grp->pin_conf) return -ENOMEM; @@ -1249,8 +1249,8 @@ static int st_pctl_parse_functions(struct device_node *np, dev_err(info->dev, "No groups defined\n"); return -EINVAL; } - func->groups = devm_kzalloc(info->dev, - func->ngroups * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(info->dev, + func->ngroups, sizeof(char *), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -1573,14 +1573,15 @@ static int st_pctl_probe_dt(struct platform_device *pdev, dev_info(&pdev->dev, "nfunctions = %d\n", info->nfunctions); dev_info(&pdev->dev, "ngroups = %d\n", info->ngroups); - info->functions = devm_kzalloc(&pdev->dev, - info->nfunctions * sizeof(*info->functions), GFP_KERNEL); + info->functions = devm_kcalloc(&pdev->dev, + info->nfunctions, sizeof(*info->functions), GFP_KERNEL); - info->groups = devm_kzalloc(&pdev->dev, - info->ngroups * sizeof(*info->groups) , GFP_KERNEL); + info->groups = devm_kcalloc(&pdev->dev, + info->ngroups, sizeof(*info->groups), + GFP_KERNEL); - info->banks = devm_kzalloc(&pdev->dev, - info->nbanks * sizeof(*info->banks), GFP_KERNEL); + info->banks = devm_kcalloc(&pdev->dev, + info->nbanks, sizeof(*info->banks), GFP_KERNEL); if (!info->functions || !info->groups || !info->banks) return -ENOMEM; @@ -1608,8 +1609,8 @@ static int st_pctl_probe_dt(struct platform_device *pdev, } pctl_desc->npins = info->nbanks * ST_GPIO_PINS_PER_BANK; - pdesc = devm_kzalloc(&pdev->dev, - sizeof(*pdesc) * pctl_desc->npins, GFP_KERNEL); + pdesc = devm_kcalloc(&pdev->dev, + pctl_desc->npins, sizeof(*pdesc), GFP_KERNEL); if (!pdesc) return -ENOMEM; diff --git a/drivers/pinctrl/pinctrl-xway.c b/drivers/pinctrl/pinctrl-xway.c index 1b0c5958c56a..ea65b0041f7e 100644 --- a/drivers/pinctrl/pinctrl-xway.c +++ b/drivers/pinctrl/pinctrl-xway.c @@ -1727,8 +1727,8 @@ static int pinmux_xway_probe(struct platform_device *pdev) xway_chip.ngpio = xway_soc->pin_count; /* load our pad descriptors */ - xway_info.pads = devm_kzalloc(&pdev->dev, - sizeof(struct pinctrl_pin_desc) * xway_chip.ngpio, + xway_info.pads = devm_kcalloc(&pdev->dev, + xway_chip.ngpio, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); if (!xway_info.pads) { dev_err(&pdev->dev, "Failed to allocate pads\n"); diff --git a/drivers/pinctrl/qcom/pinctrl-sm6150.c b/drivers/pinctrl/qcom/pinctrl-sm6150.c index ba2237ed1e1d..b0d685dbd6f2 100644 --- a/drivers/pinctrl/qcom/pinctrl-sm6150.c +++ b/drivers/pinctrl/qcom/pinctrl-sm6150.c @@ -1684,8 +1684,9 @@ static int sm6150_pinctrl_dir_conn_probe(struct platform_device *pdev) dir_conn_length = length / sizeof(u32); - dir_conn_entries = devm_kzalloc(&pdev->dev, - dir_conn_length*sizeof(uint32_t), GFP_KERNEL); + dir_conn_entries = devm_kcalloc(&pdev->dev, + dir_conn_length, sizeof(uint32_t), + GFP_KERNEL); if (!dir_conn_entries) return -ENOMEM; @@ -1700,8 +1701,8 @@ static int sm6150_pinctrl_dir_conn_probe(struct platform_device *pdev) num_dir_conns = (dir_conn_length / 3); - dir_conn_list = devm_kzalloc(&pdev->dev, - num_dir_conns * sizeof(*dir_conn_list), GFP_KERNEL); + dir_conn_list = devm_kcalloc(&pdev->dev, + num_dir_conns, sizeof(*dir_conn_list), GFP_KERNEL); if (!dir_conn_list) return -ENOMEM; diff --git a/drivers/pinctrl/qcom/pinctrl-sm8150.c b/drivers/pinctrl/qcom/pinctrl-sm8150.c index b25777617a30..b1baff68e334 100644 --- a/drivers/pinctrl/qcom/pinctrl-sm8150.c +++ b/drivers/pinctrl/qcom/pinctrl-sm8150.c @@ -1985,8 +1985,9 @@ static int sm8150_pinctrl_dir_conn_probe(struct platform_device *pdev) dir_conn_length = length / sizeof(u32); - dir_conn_entries = devm_kzalloc(&pdev->dev, - dir_conn_length*sizeof(uint32_t), GFP_KERNEL); + dir_conn_entries = devm_kcalloc(&pdev->dev, + dir_conn_length, sizeof(uint32_t), + GFP_KERNEL); if (!dir_conn_entries) return -ENOMEM; @@ -1995,8 +1996,8 @@ static int sm8150_pinctrl_dir_conn_probe(struct platform_device *pdev) num_dir_conns = (dir_conn_length / 3); - dir_conn_list = devm_kzalloc(&pdev->dev, - num_dir_conns * sizeof(*dir_conn_list), GFP_KERNEL); + dir_conn_list = devm_kcalloc(&pdev->dev, + num_dir_conns, sizeof(*dir_conn_list), GFP_KERNEL); if (!dir_conn_list) return -ENOMEM; diff --git a/drivers/pinctrl/samsung/pinctrl-exynos.c b/drivers/pinctrl/samsung/pinctrl-exynos.c index 6925a3d969e2..6e93478027e4 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos.c @@ -499,8 +499,9 @@ int exynos_eint_wkup_init(struct samsung_pinctrl_drv_data *d) continue; } - weint_data = devm_kzalloc(dev, bank->nr_pins - * sizeof(*weint_data), GFP_KERNEL); + weint_data = devm_kcalloc(dev, + bank->nr_pins, sizeof(*weint_data), + GFP_KERNEL); if (!weint_data) return -ENOMEM; diff --git a/drivers/pinctrl/samsung/pinctrl-exynos5440.c b/drivers/pinctrl/samsung/pinctrl-exynos5440.c index f8073ccd449f..cf5e066008a4 100644 --- a/drivers/pinctrl/samsung/pinctrl-exynos5440.c +++ b/drivers/pinctrl/samsung/pinctrl-exynos5440.c @@ -642,7 +642,7 @@ static int exynos5440_pinctrl_parse_dt_pins(struct platform_device *pdev, return -EINVAL; } - *pin_list = devm_kzalloc(dev, *npins * sizeof(**pin_list), GFP_KERNEL); + *pin_list = devm_kcalloc(dev, *npins, sizeof(**pin_list), GFP_KERNEL); if (!*pin_list) return -ENOMEM; @@ -671,13 +671,14 @@ static int exynos5440_pinctrl_parse_dt(struct platform_device *pdev, if (!grp_cnt) return -EINVAL; - groups = devm_kzalloc(dev, grp_cnt * sizeof(*groups), GFP_KERNEL); + groups = devm_kcalloc(dev, grp_cnt, sizeof(*groups), GFP_KERNEL); if (!groups) return -EINVAL; grp = groups; - functions = devm_kzalloc(dev, grp_cnt * sizeof(*functions), GFP_KERNEL); + functions = devm_kcalloc(dev, grp_cnt, sizeof(*functions), + GFP_KERNEL); if (!functions) return -EINVAL; @@ -759,8 +760,9 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &exynos5440_pinmux_ops; ctrldesc->confops = &exynos5440_pinconf_ops; - pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * - EXYNOS5440_MAX_PINS, GFP_KERNEL); + pindesc = devm_kcalloc(&pdev->dev, + EXYNOS5440_MAX_PINS, sizeof(*pindesc), + GFP_KERNEL); if (!pindesc) return -ENOMEM; ctrldesc->pins = pindesc; @@ -774,8 +776,9 @@ static int exynos5440_pinctrl_register(struct platform_device *pdev, * allocate space for storing the dynamically generated names for all * the pins which belong to this pin-controller. */ - pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH * - ctrldesc->npins, GFP_KERNEL); + pin_names = devm_kzalloc(&pdev->dev, + array3_size(sizeof(char), PIN_NAME_LENGTH, ctrldesc->npins), + GFP_KERNEL); if (!pin_names) return -ENOMEM; @@ -914,7 +917,7 @@ static int exynos5440_gpio_irq_init(struct platform_device *pdev, struct exynos5440_gpio_intr_data *intd; int i, irq, ret; - intd = devm_kzalloc(dev, sizeof(*intd) * EXYNOS5440_MAX_GPIO_INT, + intd = devm_kcalloc(dev, EXYNOS5440_MAX_GPIO_INT, sizeof(*intd), GFP_KERNEL); if (!intd) return -ENOMEM; diff --git a/drivers/pinctrl/samsung/pinctrl-samsung.c b/drivers/pinctrl/samsung/pinctrl-samsung.c index 7c0f5d4e89f3..306faf2c9a70 100644 --- a/drivers/pinctrl/samsung/pinctrl-samsung.c +++ b/drivers/pinctrl/samsung/pinctrl-samsung.c @@ -651,7 +651,7 @@ static struct samsung_pin_group *samsung_pinctrl_create_groups( const struct pinctrl_pin_desc *pdesc; int i; - groups = devm_kzalloc(dev, ctrldesc->npins * sizeof(*groups), + groups = devm_kcalloc(dev, ctrldesc->npins, sizeof(*groups), GFP_KERNEL); if (!groups) return ERR_PTR(-EINVAL); @@ -688,7 +688,7 @@ static int samsung_pinctrl_create_function(struct device *dev, func->name = func_np->full_name; - func->groups = devm_kzalloc(dev, npins * sizeof(char *), GFP_KERNEL); + func->groups = devm_kcalloc(dev, npins, sizeof(char *), GFP_KERNEL); if (!func->groups) return -ENOMEM; @@ -745,7 +745,7 @@ static struct samsung_pmx_func *samsung_pinctrl_create_functions( } } - functions = devm_kzalloc(dev, func_cnt * sizeof(*functions), + functions = devm_kcalloc(dev, func_cnt, sizeof(*functions), GFP_KERNEL); if (!functions) return ERR_PTR(-ENOMEM); @@ -842,8 +842,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev, ctrldesc->pmxops = &samsung_pinmux_ops; ctrldesc->confops = &samsung_pinconf_ops; - pindesc = devm_kzalloc(&pdev->dev, sizeof(*pindesc) * - drvdata->nr_pins, GFP_KERNEL); + pindesc = devm_kcalloc(&pdev->dev, + drvdata->nr_pins, sizeof(*pindesc), + GFP_KERNEL); if (!pindesc) return -ENOMEM; ctrldesc->pins = pindesc; @@ -857,8 +858,9 @@ static int samsung_pinctrl_register(struct platform_device *pdev, * allocate space for storing the dynamically generated names for all * the pins which belong to this pin-controller. */ - pin_names = devm_kzalloc(&pdev->dev, sizeof(char) * PIN_NAME_LENGTH * - drvdata->nr_pins, GFP_KERNEL); + pin_names = devm_kzalloc(&pdev->dev, + array3_size(sizeof(char), PIN_NAME_LENGTH, drvdata->nr_pins), + GFP_KERNEL); if (!pin_names) return -ENOMEM; diff --git a/drivers/pinctrl/sh-pfc/core.c b/drivers/pinctrl/sh-pfc/core.c index 0c5e952461fd..56d5214ac5f9 100644 --- a/drivers/pinctrl/sh-pfc/core.c +++ b/drivers/pinctrl/sh-pfc/core.c @@ -56,7 +56,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, return -EINVAL; /* Allocate memory windows and IRQs arrays. */ - windows = devm_kzalloc(pfc->dev, num_windows * sizeof(*windows), + windows = devm_kcalloc(pfc->dev, num_windows, sizeof(*windows), GFP_KERNEL); if (windows == NULL) return -ENOMEM; @@ -65,7 +65,7 @@ static int sh_pfc_map_resources(struct sh_pfc *pfc, pfc->windows = windows; if (num_irqs) { - irqs = devm_kzalloc(pfc->dev, num_irqs * sizeof(*irqs), + irqs = devm_kcalloc(pfc->dev, num_irqs, sizeof(*irqs), GFP_KERNEL); if (irqs == NULL) return -ENOMEM; @@ -438,7 +438,7 @@ static int sh_pfc_init_ranges(struct sh_pfc *pfc) } pfc->nr_ranges = nr_ranges; - pfc->ranges = devm_kzalloc(pfc->dev, sizeof(*pfc->ranges) * nr_ranges, + pfc->ranges = devm_kcalloc(pfc->dev, nr_ranges, sizeof(*pfc->ranges), GFP_KERNEL); if (pfc->ranges == NULL) return -ENOMEM; diff --git a/drivers/pinctrl/sh-pfc/gpio.c b/drivers/pinctrl/sh-pfc/gpio.c index 6b5422766f13..b173148e752f 100644 --- a/drivers/pinctrl/sh-pfc/gpio.c +++ b/drivers/pinctrl/sh-pfc/gpio.c @@ -107,7 +107,7 @@ static int gpio_setup_data_regs(struct sh_pfc_chip *chip) for (i = 0; pfc->info->data_regs[i].reg_width; ++i) ; - chip->regs = devm_kzalloc(pfc->dev, i * sizeof(*chip->regs), + chip->regs = devm_kcalloc(pfc->dev, i, sizeof(*chip->regs), GFP_KERNEL); if (chip->regs == NULL) return -ENOMEM; @@ -224,8 +224,9 @@ static int gpio_pin_setup(struct sh_pfc_chip *chip) struct gpio_chip *gc = &chip->gpio_chip; int ret; - chip->pins = devm_kzalloc(pfc->dev, pfc->info->nr_pins * - sizeof(*chip->pins), GFP_KERNEL); + chip->pins = devm_kcalloc(pfc->dev, + pfc->info->nr_pins, sizeof(*chip->pins), + GFP_KERNEL); if (chip->pins == NULL) return -ENOMEM; diff --git a/drivers/pinctrl/sh-pfc/pinctrl.c b/drivers/pinctrl/sh-pfc/pinctrl.c index 5c9d79981e6d..90fb4c4083fa 100644 --- a/drivers/pinctrl/sh-pfc/pinctrl.c +++ b/drivers/pinctrl/sh-pfc/pinctrl.c @@ -770,14 +770,14 @@ static int sh_pfc_map_pins(struct sh_pfc *pfc, struct sh_pfc_pinctrl *pmx) unsigned int i; /* Allocate and initialize the pins and configs arrays. */ - pmx->pins = devm_kzalloc(pfc->dev, - sizeof(*pmx->pins) * pfc->info->nr_pins, + pmx->pins = devm_kcalloc(pfc->dev, + pfc->info->nr_pins, sizeof(*pmx->pins), GFP_KERNEL); if (unlikely(!pmx->pins)) return -ENOMEM; - pmx->configs = devm_kzalloc(pfc->dev, - sizeof(*pmx->configs) * pfc->info->nr_pins, + pmx->configs = devm_kcalloc(pfc->dev, + pfc->info->nr_pins, sizeof(*pmx->configs), GFP_KERNEL); if (unlikely(!pmx->configs)) return -ENOMEM; diff --git a/drivers/pinctrl/spear/pinctrl-plgpio.c b/drivers/pinctrl/spear/pinctrl-plgpio.c index cf6d68c7345b..bd5bea82683e 100644 --- a/drivers/pinctrl/spear/pinctrl-plgpio.c +++ b/drivers/pinctrl/spear/pinctrl-plgpio.c @@ -540,9 +540,9 @@ static int plgpio_probe(struct platform_device *pdev) dev_warn(&pdev->dev, "clk_get() failed, work without it\n"); #ifdef CONFIG_PM_SLEEP - plgpio->csave_regs = devm_kzalloc(&pdev->dev, - sizeof(*plgpio->csave_regs) * + plgpio->csave_regs = devm_kcalloc(&pdev->dev, DIV_ROUND_UP(plgpio->chip.ngpio, MAX_GPIO_PER_REG), + sizeof(*plgpio->csave_regs), GFP_KERNEL); if (!plgpio->csave_regs) { dev_err(&pdev->dev, "csave registers memory allocation fail\n"); diff --git a/drivers/pinctrl/sprd/pinctrl-sprd.c b/drivers/pinctrl/sprd/pinctrl-sprd.c index 83958bdd0f05..2c850f8059c8 100644 --- a/drivers/pinctrl/sprd/pinctrl-sprd.c +++ b/drivers/pinctrl/sprd/pinctrl-sprd.c @@ -877,8 +877,9 @@ static int sprd_pinctrl_parse_groups(struct device_node *np, grp->name = np->name; grp->npins = ret; - grp->pins = devm_kzalloc(sprd_pctl->dev, grp->npins * - sizeof(unsigned int), GFP_KERNEL); + grp->pins = devm_kcalloc(sprd_pctl->dev, + grp->npins, sizeof(unsigned int), + GFP_KERNEL); if (!grp->pins) return -ENOMEM; @@ -929,14 +930,15 @@ static int sprd_pinctrl_parse_dt(struct sprd_pinctrl *sprd_pctl) if (!info->ngroups) return 0; - info->groups = devm_kzalloc(sprd_pctl->dev, info->ngroups * + info->groups = devm_kcalloc(sprd_pctl->dev, + info->ngroups, sizeof(struct sprd_pin_group), GFP_KERNEL); if (!info->groups) return -ENOMEM; - info->grp_names = devm_kzalloc(sprd_pctl->dev, - info->ngroups * sizeof(char *), + info->grp_names = devm_kcalloc(sprd_pctl->dev, + info->ngroups, sizeof(char *), GFP_KERNEL); if (!info->grp_names) return -ENOMEM; @@ -978,8 +980,8 @@ static int sprd_pinctrl_add_pins(struct sprd_pinctrl *sprd_pctl, int i; info->npins = pins_cnt; - info->pins = devm_kzalloc(sprd_pctl->dev, - info->npins * sizeof(struct sprd_pin), + info->pins = devm_kcalloc(sprd_pctl->dev, + info->npins, sizeof(struct sprd_pin), GFP_KERNEL); if (!info->pins) return -ENOMEM; @@ -1055,7 +1057,8 @@ int sprd_pinctrl_core_probe(struct platform_device *pdev, return ret; } - pin_desc = devm_kzalloc(&pdev->dev, pinctrl_info->npins * + pin_desc = devm_kcalloc(&pdev->dev, + pinctrl_info->npins, sizeof(struct pinctrl_pin_desc), GFP_KERNEL); if (!pin_desc) diff --git a/drivers/pinctrl/sunxi/pinctrl-sunxi.c b/drivers/pinctrl/sunxi/pinctrl-sunxi.c index 8b3fd553ef55..c281ac177f72 100644 --- a/drivers/pinctrl/sunxi/pinctrl-sunxi.c +++ b/drivers/pinctrl/sunxi/pinctrl-sunxi.c @@ -1053,8 +1053,8 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) * this means that the number of pins is the maximum group * number we will ever see. */ - pctl->groups = devm_kzalloc(&pdev->dev, - pctl->desc->npins * sizeof(*pctl->groups), + pctl->groups = devm_kcalloc(&pdev->dev, + pctl->desc->npins, sizeof(*pctl->groups), GFP_KERNEL); if (!pctl->groups) return -ENOMEM; @@ -1077,8 +1077,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) * We suppose that we won't have any more functions than pins, * we'll reallocate that later anyway */ - pctl->functions = devm_kzalloc(&pdev->dev, - pctl->ngroups * sizeof(*pctl->functions), + pctl->functions = devm_kcalloc(&pdev->dev, + pctl->ngroups, + sizeof(*pctl->functions), GFP_KERNEL); if (!pctl->functions) return -ENOMEM; @@ -1137,8 +1138,9 @@ static int sunxi_pinctrl_build_state(struct platform_device *pdev) if (!func_item->groups) { func_item->groups = - devm_kzalloc(&pdev->dev, - func_item->ngroups * sizeof(*func_item->groups), + devm_kcalloc(&pdev->dev, + func_item->ngroups, + sizeof(*func_item->groups), GFP_KERNEL); if (!func_item->groups) return -ENOMEM; @@ -1281,8 +1283,8 @@ int sunxi_pinctrl_init_with_variant(struct platform_device *pdev, return ret; } - pins = devm_kzalloc(&pdev->dev, - pctl->desc->npins * sizeof(*pins), + pins = devm_kcalloc(&pdev->dev, + pctl->desc->npins, sizeof(*pins), GFP_KERNEL); if (!pins) return -ENOMEM; diff --git a/drivers/pinctrl/tegra/pinctrl-tegra.c b/drivers/pinctrl/tegra/pinctrl-tegra.c index e5c9b9c68428..c26376690b02 100644 --- a/drivers/pinctrl/tegra/pinctrl-tegra.c +++ b/drivers/pinctrl/tegra/pinctrl-tegra.c @@ -679,8 +679,8 @@ int tegra_pinctrl_probe(struct platform_device *pdev, * Each mux group will appear in 4 functions' list of groups. * This over-allocates slightly, since not all groups are mux groups. */ - pmx->group_pins = devm_kzalloc(&pdev->dev, - soc_data->ngroups * 4 * sizeof(*pmx->group_pins), + pmx->group_pins = devm_kcalloc(&pdev->dev, + soc_data->ngroups * 4, sizeof(*pmx->group_pins), GFP_KERNEL); if (!pmx->group_pins) return -ENOMEM; @@ -722,7 +722,7 @@ int tegra_pinctrl_probe(struct platform_device *pdev, } pmx->nbanks = i; - pmx->regs = devm_kzalloc(&pdev->dev, pmx->nbanks * sizeof(*pmx->regs), + pmx->regs = devm_kcalloc(&pdev->dev, pmx->nbanks, sizeof(*pmx->regs), GFP_KERNEL); if (!pmx->regs) { dev_err(&pdev->dev, "Can't alloc regs pointer\n"); diff --git a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c index 8ac1f1ce4442..61f8b8d14b2d 100644 --- a/drivers/pinctrl/ti/pinctrl-ti-iodelay.c +++ b/drivers/pinctrl/ti/pinctrl-ti-iodelay.c @@ -510,11 +510,11 @@ static int ti_iodelay_dt_node_to_map(struct pinctrl_dev *pctldev, goto free_map; } - pins = devm_kzalloc(iod->dev, sizeof(*pins) * rows, GFP_KERNEL); + pins = devm_kcalloc(iod->dev, rows, sizeof(*pins), GFP_KERNEL); if (!pins) goto free_group; - cfg = devm_kzalloc(iod->dev, sizeof(*cfg) * rows, GFP_KERNEL); + cfg = devm_kcalloc(iod->dev, rows, sizeof(*cfg), GFP_KERNEL); if (!cfg) { error = -ENOMEM; goto free_pins; @@ -753,7 +753,7 @@ static int ti_iodelay_alloc_pins(struct device *dev, nr_pins = ti_iodelay_offset_to_pin(iod, r->regmap_config->max_register); dev_dbg(dev, "Allocating %i pins\n", nr_pins); - iod->pa = devm_kzalloc(dev, sizeof(*iod->pa) * nr_pins, GFP_KERNEL); + iod->pa = devm_kcalloc(dev, nr_pins, sizeof(*iod->pa), GFP_KERNEL); if (!iod->pa) return -ENOMEM; diff --git a/drivers/pinctrl/zte/pinctrl-zx.c b/drivers/pinctrl/zte/pinctrl-zx.c index 91955e770236..3cb69309912b 100644 --- a/drivers/pinctrl/zte/pinctrl-zx.c +++ b/drivers/pinctrl/zte/pinctrl-zx.c @@ -277,7 +277,7 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) /* Every single pin composes a group */ ngroups = info->npins; - groups = devm_kzalloc(&pdev->dev, ngroups * sizeof(*groups), + groups = devm_kcalloc(&pdev->dev, ngroups, sizeof(*groups), GFP_KERNEL); if (!groups) return -ENOMEM; @@ -362,8 +362,8 @@ static int zx_pinctrl_build_state(struct platform_device *pdev) func = functions + j; if (!func->group_names) { - func->group_names = devm_kzalloc(&pdev->dev, - func->num_group_names * + func->group_names = devm_kcalloc(&pdev->dev, + func->num_group_names, sizeof(*func->group_names), GFP_KERNEL); if (!func->group_names) { diff --git a/drivers/platform/msm/gsi/gsi.c b/drivers/platform/msm/gsi/gsi.c index b13347dbac96..17fdb10c8a6c 100644 --- a/drivers/platform/msm/gsi/gsi.c +++ b/drivers/platform/msm/gsi/gsi.c @@ -2374,8 +2374,8 @@ int gsi_alloc_channel(struct gsi_chan_props *props, unsigned long dev_hdl, if (props->prot == GSI_CHAN_PROT_GCI) user_data_size += GSI_VEID_MAX; - user_data = devm_kzalloc(gsi_ctx->dev, - user_data_size * sizeof(*user_data), + user_data = devm_kcalloc(gsi_ctx->dev, + user_data_size, sizeof(*user_data), GFP_KERNEL); if (user_data == NULL) { GSIERR("context not allocated\n"); diff --git a/drivers/platform/msm/qcom-geni-se.c b/drivers/platform/msm/qcom-geni-se.c index 8d5d37809546..a3ca53d4a11a 100644 --- a/drivers/platform/msm/qcom-geni-se.c +++ b/drivers/platform/msm/qcom-geni-se.c @@ -1861,8 +1861,10 @@ static struct msm_bus_scale_pdata *ab_ib_register(struct platform_device *pdev, for (i = 0; i < pdata->num_usecases; i++) { usecase[i].num_paths = host->num_paths; - usecase[i].vectors = devm_kzalloc(dev, host->num_paths * - sizeof(struct msm_bus_vectors), GFP_KERNEL); + usecase[i].vectors = devm_kcalloc(dev, + host->num_paths, + sizeof(struct msm_bus_vectors), + GFP_KERNEL); if (!usecase[i].vectors) { mem_err = true; pr_err("Error: Mem alloc failure in vectors\n"); diff --git a/drivers/platform/msm/usb_bam.c b/drivers/platform/msm/usb_bam.c index d0079e39e84d..8bdb7e108cdc 100644 --- a/drivers/platform/msm/usb_bam.c +++ b/drivers/platform/msm/usb_bam.c @@ -2952,8 +2952,10 @@ static struct msm_usb_bam_data *usb_bam_dt_to_data( goto err; } - usb_bam_connections = devm_kzalloc(&pdev->dev, max_connections * - sizeof(struct usb_bam_pipe_connect), GFP_KERNEL); + usb_bam_connections = devm_kcalloc(&pdev->dev, + max_connections, + sizeof(struct usb_bam_pipe_connect), + GFP_KERNEL); if (!usb_bam_connections) { log_event_err("%s: devm_kzalloc failed(%d)\n", @@ -3165,8 +3167,8 @@ static int enable_usb_bam(struct platform_device *pdev) if (ret) return ret; - ctx->usb_bam_sps.sps_pipes = devm_kzalloc(&pdev->dev, - ctx->max_connections * sizeof(struct sps_pipe *), + ctx->usb_bam_sps.sps_pipes = devm_kcalloc(&pdev->dev, + ctx->max_connections, sizeof(struct sps_pipe *), GFP_KERNEL); if (!ctx->usb_bam_sps.sps_pipes) { @@ -3174,8 +3176,8 @@ static int enable_usb_bam(struct platform_device *pdev) return -ENOMEM; } - ctx->usb_bam_sps.sps_connections = devm_kzalloc(&pdev->dev, - ctx->max_connections * sizeof(struct sps_connect), + ctx->usb_bam_sps.sps_connections = devm_kcalloc(&pdev->dev, + ctx->max_connections, sizeof(struct sps_connect), GFP_KERNEL); if (!ctx->usb_bam_sps.sps_connections) { log_event_err("%s: failed to allocate sps_connections\n", diff --git a/drivers/platform/x86/mlxcpld-hotplug.c b/drivers/platform/x86/mlxcpld-hotplug.c index aff3686b3b37..c6fdd4e1d2c5 100644 --- a/drivers/platform/x86/mlxcpld-hotplug.c +++ b/drivers/platform/x86/mlxcpld-hotplug.c @@ -140,7 +140,8 @@ static int mlxcpld_hotplug_attr_init(struct mlxcpld_hotplug_priv_data *priv) priv->plat->fan_count; int i; - priv->group.attrs = devm_kzalloc(&priv->pdev->dev, num_attrs * + priv->group.attrs = devm_kcalloc(&priv->pdev->dev, + num_attrs, sizeof(struct attribute *), GFP_KERNEL); if (!priv->group.attrs) diff --git a/drivers/power/supply/charger-manager.c b/drivers/power/supply/charger-manager.c index f60dfc213257..d0ad8229133b 100644 --- a/drivers/power/supply/charger-manager.c +++ b/drivers/power/supply/charger-manager.c @@ -1379,7 +1379,7 @@ static int charger_manager_register_sysfs(struct charger_manager *cm) snprintf(buf, 10, "charger.%d", i); str = devm_kzalloc(cm->dev, - sizeof(char) * (strlen(buf) + 1), GFP_KERNEL); + strlen(buf) + 1, GFP_KERNEL); if (!str) return -ENOMEM; @@ -1521,8 +1521,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) of_property_read_u32(np, "cm-num-chargers", &num_chgs); if (num_chgs) { /* Allocate empty bin at the tail of array */ - desc->psy_charger_stat = devm_kzalloc(dev, sizeof(char *) - * (num_chgs + 1), GFP_KERNEL); + desc->psy_charger_stat = devm_kcalloc(dev, + num_chgs + 1, + sizeof(char *), + GFP_KERNEL); if (desc->psy_charger_stat) { int i; for (i = 0; i < num_chgs; i++) @@ -1554,8 +1556,9 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) struct charger_regulator *chg_regs; struct device_node *child; - chg_regs = devm_kzalloc(dev, sizeof(*chg_regs) - * desc->num_charger_regulators, + chg_regs = devm_kcalloc(dev, + desc->num_charger_regulators, + sizeof(*chg_regs), GFP_KERNEL); if (!chg_regs) return ERR_PTR(-ENOMEM); @@ -1572,9 +1575,10 @@ static struct charger_desc *of_cm_parse_desc(struct device *dev) /* charger cables */ chg_regs->num_cables = of_get_child_count(child); if (chg_regs->num_cables) { - cables = devm_kzalloc(dev, sizeof(*cables) - * chg_regs->num_cables, - GFP_KERNEL); + cables = devm_kcalloc(dev, + chg_regs->num_cables, + sizeof(*cables), + GFP_KERNEL); if (!cables) { of_node_put(child); return ERR_PTR(-ENOMEM); @@ -1723,10 +1727,10 @@ static int charger_manager_probe(struct platform_device *pdev) cm->charger_psy_desc.name = cm->psy_name_buf; /* Allocate for psy properties because they may vary */ - cm->charger_psy_desc.properties = devm_kzalloc(&pdev->dev, - sizeof(enum power_supply_property) - * (ARRAY_SIZE(default_charger_props) + - NUM_CHARGER_PSY_OPTIONAL), GFP_KERNEL); + cm->charger_psy_desc.properties = devm_kcalloc(&pdev->dev, + ARRAY_SIZE(default_charger_props) + NUM_CHARGER_PSY_OPTIONAL, + sizeof(enum power_supply_property), + GFP_KERNEL); if (!cm->charger_psy_desc.properties) return -ENOMEM; diff --git a/drivers/power/supply/power_supply_core.c b/drivers/power/supply/power_supply_core.c index 4bcfcf67dcf6..ec0e1a26fc77 100644 --- a/drivers/power/supply/power_supply_core.c +++ b/drivers/power/supply/power_supply_core.c @@ -272,8 +272,8 @@ static int power_supply_check_supplies(struct power_supply *psy) if (!psy->supplied_from) return -ENOMEM; - *psy->supplied_from = devm_kzalloc(&psy->dev, - sizeof(char *) * (cnt - 1), + *psy->supplied_from = devm_kcalloc(&psy->dev, + cnt - 1, sizeof(char *), GFP_KERNEL); if (!*psy->supplied_from) return -ENOMEM; diff --git a/drivers/pwm/pwm-lp3943.c b/drivers/pwm/pwm-lp3943.c index 52584e9962ed..15b40a8bc4fb 100644 --- a/drivers/pwm/pwm-lp3943.c +++ b/drivers/pwm/pwm-lp3943.c @@ -225,7 +225,7 @@ static int lp3943_pwm_parse_dt(struct device *dev, if (num_outputs == 0) continue; - output = devm_kzalloc(dev, sizeof(*output) * num_outputs, + output = devm_kcalloc(dev, num_outputs, sizeof(*output), GFP_KERNEL); if (!output) return -ENOMEM; diff --git a/drivers/regulator/act8865-regulator.c b/drivers/regulator/act8865-regulator.c index 39e8d60df060..e0239cf3f56d 100644 --- a/drivers/regulator/act8865-regulator.c +++ b/drivers/regulator/act8865-regulator.c @@ -425,9 +425,10 @@ static int act8865_pdata_from_dt(struct device *dev, if (matched <= 0) return matched; - pdata->regulators = devm_kzalloc(dev, - sizeof(struct act8865_regulator_data) * - num_matches, GFP_KERNEL); + pdata->regulators = devm_kcalloc(dev, + num_matches, + sizeof(struct act8865_regulator_data), + GFP_KERNEL); if (!pdata->regulators) return -ENOMEM; diff --git a/drivers/regulator/as3711-regulator.c b/drivers/regulator/as3711-regulator.c index 874d415d6b4f..565a71343a8e 100644 --- a/drivers/regulator/as3711-regulator.c +++ b/drivers/regulator/as3711-regulator.c @@ -239,8 +239,10 @@ static int as3711_regulator_probe(struct platform_device *pdev) } } - regs = devm_kzalloc(&pdev->dev, AS3711_REGULATOR_NUM * - sizeof(struct as3711_regulator), GFP_KERNEL); + regs = devm_kcalloc(&pdev->dev, + AS3711_REGULATOR_NUM, + sizeof(struct as3711_regulator), + GFP_KERNEL); if (!regs) return -ENOMEM; diff --git a/drivers/regulator/bcm590xx-regulator.c b/drivers/regulator/bcm590xx-regulator.c index 9dd715407b39..92d6d7b10cf7 100644 --- a/drivers/regulator/bcm590xx-regulator.c +++ b/drivers/regulator/bcm590xx-regulator.c @@ -383,8 +383,10 @@ static int bcm590xx_probe(struct platform_device *pdev) platform_set_drvdata(pdev, pmu); - pmu->desc = devm_kzalloc(&pdev->dev, BCM590XX_NUM_REGS * - sizeof(struct regulator_desc), GFP_KERNEL); + pmu->desc = devm_kcalloc(&pdev->dev, + BCM590XX_NUM_REGS, + sizeof(struct regulator_desc), + GFP_KERNEL); if (!pmu->desc) return -ENOMEM; diff --git a/drivers/regulator/cpr-regulator.c b/drivers/regulator/cpr-regulator.c index 7c103991214d..210439c0a85e 100644 --- a/drivers/regulator/cpr-regulator.c +++ b/drivers/regulator/cpr-regulator.c @@ -1751,8 +1751,8 @@ static int cpr_config(struct cpr_regulator *cpr_vreg, struct device *dev) cpr_vreg->flags |= FLAGS_IGNORE_1ST_IRQ_STATUS; size = cpr_vreg->num_corners + 1; - cpr_vreg->save_ctl = devm_kzalloc(dev, sizeof(int) * size, GFP_KERNEL); - cpr_vreg->save_irq = devm_kzalloc(dev, sizeof(int) * size, GFP_KERNEL); + cpr_vreg->save_ctl = devm_kcalloc(dev, size, sizeof(int), GFP_KERNEL); + cpr_vreg->save_irq = devm_kcalloc(dev, size, sizeof(int), GFP_KERNEL); if (!cpr_vreg->save_ctl || !cpr_vreg->save_irq) return -ENOMEM; @@ -2118,9 +2118,9 @@ static int cpr_parse_vdd_mx_parameters(struct platform_device *pdev, return -EINVAL; } - cpr_vreg->vdd_mx_corner_map = devm_kzalloc(&pdev->dev, - (corner_map_len + 1) * sizeof(*cpr_vreg->vdd_mx_corner_map), - GFP_KERNEL); + cpr_vreg->vdd_mx_corner_map = devm_kcalloc(&pdev->dev, + corner_map_len + 1, sizeof(*cpr_vreg->vdd_mx_corner_map), + GFP_KERNEL); if (!cpr_vreg->vdd_mx_corner_map) return -ENOMEM; @@ -2369,8 +2369,8 @@ static int cpr_get_open_loop_voltage(struct cpr_regulator *cpr_vreg, u64 volt_high, volt_low, freq_high, freq_low, freq, temp, temp_limit; u32 *max_factor = NULL; - cpr_vreg->open_loop_volt = devm_kzalloc(dev, - sizeof(int) * (cpr_vreg->num_corners + 1), GFP_KERNEL); + cpr_vreg->open_loop_volt = devm_kcalloc(dev, + cpr_vreg->num_corners + 1, sizeof(int), GFP_KERNEL); if (!cpr_vreg->open_loop_volt) return -ENOMEM; @@ -2619,8 +2619,8 @@ static int cpr_get_fuse_quot_offset(struct cpr_regulator *cpr_vreg, return rc; } - cpr_vreg->fuse_quot_offset = devm_kzalloc(dev, - sizeof(u32) * (cpr_vreg->num_fuse_corners + 1), + cpr_vreg->fuse_quot_offset = devm_kcalloc(dev, + cpr_vreg->num_fuse_corners + 1, sizeof(u32), GFP_KERNEL); if (!cpr_vreg->fuse_quot_offset) { kfree(fuse_sel); @@ -2824,14 +2824,14 @@ static int cpr_get_corner_quot_adjustment(struct cpr_regulator *cpr_vreg, corners_mapped = false; } - cpr_vreg->corner_map = devm_kzalloc(dev, sizeof(int) * (size + 1), - GFP_KERNEL); + cpr_vreg->corner_map = devm_kcalloc(dev, size + 1, sizeof(int), + GFP_KERNEL); if (!cpr_vreg->corner_map) return -ENOMEM; cpr_vreg->num_corners = size; - cpr_vreg->quot_adjust = devm_kzalloc(dev, - sizeof(u32) * (cpr_vreg->num_corners + 1), + cpr_vreg->quot_adjust = devm_kcalloc(dev, + cpr_vreg->num_corners + 1, sizeof(u32), GFP_KERNEL); if (!cpr_vreg->quot_adjust) return -ENOMEM; @@ -4118,7 +4118,8 @@ static int cpr_init_cpr_voltages(struct cpr_regulator *cpr_vreg, int i; int size = cpr_vreg->num_corners + 1; - cpr_vreg->last_volt = devm_kzalloc(dev, sizeof(int) * size, GFP_KERNEL); + cpr_vreg->last_volt = devm_kcalloc(dev, size, sizeof(int), + GFP_KERNEL); if (!cpr_vreg->last_volt) return -EINVAL; @@ -4227,12 +4228,12 @@ static int cpr_init_ceiling_floor_override_voltages( int rc, i; int size = cpr_vreg->num_corners + 1; - cpr_vreg->ceiling_volt = devm_kzalloc(dev, sizeof(int) * size, + cpr_vreg->ceiling_volt = devm_kcalloc(dev, size, sizeof(int), GFP_KERNEL); - cpr_vreg->floor_volt = devm_kzalloc(dev, sizeof(int) * size, - GFP_KERNEL); - cpr_vreg->cpr_max_ceiling = devm_kzalloc(dev, sizeof(int) * size, + cpr_vreg->floor_volt = devm_kcalloc(dev, size, sizeof(int), GFP_KERNEL); + cpr_vreg->cpr_max_ceiling = devm_kcalloc(dev, size, sizeof(int), + GFP_KERNEL); if (!cpr_vreg->ceiling_volt || !cpr_vreg->floor_volt || !cpr_vreg->cpr_max_ceiling) return -ENOMEM; @@ -4586,9 +4587,10 @@ static int cpr_rpm_apc_init(struct platform_device *pdev, return -EINVAL; } - cpr_vreg->rpm_apc_corner_map = devm_kzalloc(&pdev->dev, - (cpr_vreg->num_corners + 1) * - sizeof(*cpr_vreg->rpm_apc_corner_map), GFP_KERNEL); + cpr_vreg->rpm_apc_corner_map = devm_kcalloc(&pdev->dev, + cpr_vreg->num_corners + 1, + sizeof(*cpr_vreg->rpm_apc_corner_map), + GFP_KERNEL); if (!cpr_vreg->rpm_apc_corner_map) return -ENOMEM; @@ -4845,8 +4847,8 @@ static int cpr_remap_efuse_data(struct platform_device *pdev, bits += temp[i * 4 + 2]; cpr_vreg->num_remapped_rows = DIV_ROUND_UP(bits, 64); - cpr_vreg->remapped_row = devm_kzalloc(&pdev->dev, - sizeof(*cpr_vreg->remapped_row) * cpr_vreg->num_remapped_rows, + cpr_vreg->remapped_row = devm_kcalloc(&pdev->dev, + cpr_vreg->num_remapped_rows, sizeof(*cpr_vreg->remapped_row), GFP_KERNEL); if (!cpr_vreg->remapped_row) { rc = -ENOMEM; @@ -5025,18 +5027,18 @@ static int cpr_fuse_corner_array_alloc(struct device *dev, */ len = cpr_vreg->num_fuse_corners + 1; - cpr_vreg->pvs_corner_v = devm_kzalloc(dev, - len * sizeof(*cpr_vreg->pvs_corner_v), GFP_KERNEL); - cpr_vreg->cpr_fuse_target_quot = devm_kzalloc(dev, - len * sizeof(*cpr_vreg->cpr_fuse_target_quot), GFP_KERNEL); - cpr_vreg->cpr_fuse_ro_sel = devm_kzalloc(dev, - len * sizeof(*cpr_vreg->cpr_fuse_ro_sel), GFP_KERNEL); - cpr_vreg->fuse_ceiling_volt = devm_kzalloc(dev, - len * (sizeof(*cpr_vreg->fuse_ceiling_volt)), GFP_KERNEL); - cpr_vreg->fuse_floor_volt = devm_kzalloc(dev, - len * (sizeof(*cpr_vreg->fuse_floor_volt)), GFP_KERNEL); - cpr_vreg->step_quotient = devm_kzalloc(dev, - len * sizeof(*cpr_vreg->step_quotient), GFP_KERNEL); + cpr_vreg->pvs_corner_v = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->pvs_corner_v), GFP_KERNEL); + cpr_vreg->cpr_fuse_target_quot = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->cpr_fuse_target_quot), GFP_KERNEL); + cpr_vreg->cpr_fuse_ro_sel = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->cpr_fuse_ro_sel), GFP_KERNEL); + cpr_vreg->fuse_ceiling_volt = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->fuse_ceiling_volt), GFP_KERNEL); + cpr_vreg->fuse_floor_volt = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->fuse_floor_volt), GFP_KERNEL); + cpr_vreg->step_quotient = devm_kcalloc(dev, + len, sizeof(*cpr_vreg->step_quotient), GFP_KERNEL); if (cpr_vreg->pvs_corner_v == NULL || cpr_vreg->cpr_fuse_ro_sel == NULL || cpr_vreg->fuse_ceiling_volt == NULL @@ -5127,8 +5129,8 @@ static int cpr_mem_acc_init(struct platform_device *pdev, } size = prop->length / sizeof(u32); - cpr_vreg->mem_acc_corner_map = devm_kzalloc(&pdev->dev, - sizeof(int) * (size + 1), + cpr_vreg->mem_acc_corner_map = devm_kcalloc(&pdev->dev, + size + 1, sizeof(int), GFP_KERNEL); rc = of_property_read_u32_array(pdev->dev.of_node, corner_map_str, diff --git a/drivers/regulator/da9063-regulator.c b/drivers/regulator/da9063-regulator.c index 6a8f9cd69f52..2df26f36c687 100644 --- a/drivers/regulator/da9063-regulator.c +++ b/drivers/regulator/da9063-regulator.c @@ -681,8 +681,8 @@ static struct da9063_regulators_pdata *da9063_parse_regulators_dt( if (!pdata) return ERR_PTR(-ENOMEM); - pdata->regulator_data = devm_kzalloc(&pdev->dev, - num * sizeof(*pdata->regulator_data), + pdata->regulator_data = devm_kcalloc(&pdev->dev, + num, sizeof(*pdata->regulator_data), GFP_KERNEL); if (!pdata->regulator_data) return ERR_PTR(-ENOMEM); diff --git a/drivers/regulator/gpio-regulator.c b/drivers/regulator/gpio-regulator.c index a2eb50719c7b..953966f5e84d 100644 --- a/drivers/regulator/gpio-regulator.c +++ b/drivers/regulator/gpio-regulator.c @@ -172,8 +172,8 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, if (ret > 0) { config->nr_gpios = ret; - config->gpios = devm_kzalloc(dev, - sizeof(struct gpio) * config->nr_gpios, + config->gpios = devm_kcalloc(dev, + config->nr_gpios, sizeof(struct gpio), GFP_KERNEL); if (!config->gpios) return ERR_PTR(-ENOMEM); @@ -213,9 +213,9 @@ of_get_gpio_regulator_config(struct device *dev, struct device_node *np, return ERR_PTR(-EINVAL); } - config->states = devm_kzalloc(dev, - sizeof(struct gpio_regulator_state) - * (proplen / 2), + config->states = devm_kcalloc(dev, + proplen / 2, + sizeof(struct gpio_regulator_state), GFP_KERNEL); if (!config->states) return ERR_PTR(-ENOMEM); diff --git a/drivers/regulator/max1586.c b/drivers/regulator/max1586.c index 66bbaa999433..cc52779b53f7 100644 --- a/drivers/regulator/max1586.c +++ b/drivers/regulator/max1586.c @@ -194,8 +194,10 @@ static int of_get_max1586_platform_data(struct device *dev, if (matched <= 0) return matched; - pdata->subdevs = devm_kzalloc(dev, sizeof(struct max1586_subdev_data) * - matched, GFP_KERNEL); + pdata->subdevs = devm_kcalloc(dev, + matched, + sizeof(struct max1586_subdev_data), + GFP_KERNEL); if (!pdata->subdevs) return -ENOMEM; diff --git a/drivers/regulator/max8660.c b/drivers/regulator/max8660.c index a6183425f27d..4cf6897a401f 100644 --- a/drivers/regulator/max8660.c +++ b/drivers/regulator/max8660.c @@ -351,8 +351,10 @@ static int max8660_pdata_from_dt(struct device *dev, if (matched <= 0) return matched; - pdata->subdevs = devm_kzalloc(dev, sizeof(struct max8660_subdev_data) * - matched, GFP_KERNEL); + pdata->subdevs = devm_kcalloc(dev, + matched, + sizeof(struct max8660_subdev_data), + GFP_KERNEL); if (!pdata->subdevs) return -ENOMEM; diff --git a/drivers/regulator/max8997-regulator.c b/drivers/regulator/max8997-regulator.c index 559b9ac45404..a8ea30ee18a6 100644 --- a/drivers/regulator/max8997-regulator.c +++ b/drivers/regulator/max8997-regulator.c @@ -929,8 +929,9 @@ static int max8997_pmic_dt_parse_pdata(struct platform_device *pdev, /* count the number of regulators to be supported in pmic */ pdata->num_regulators = of_get_child_count(regulators_np); - rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); + rdata = devm_kcalloc(&pdev->dev, + pdata->num_regulators, sizeof(*rdata), + GFP_KERNEL); if (!rdata) { of_node_put(regulators_np); return -ENOMEM; diff --git a/drivers/regulator/max8998.c b/drivers/regulator/max8998.c index 3027e7ce100b..050082230ad0 100644 --- a/drivers/regulator/max8998.c +++ b/drivers/regulator/max8998.c @@ -671,8 +671,9 @@ static int max8998_pmic_dt_parse_pdata(struct max8998_dev *iodev, /* count the number of regulators to be supported in pmic */ pdata->num_regulators = of_get_child_count(regulators_np); - rdata = devm_kzalloc(iodev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); + rdata = devm_kcalloc(iodev->dev, + pdata->num_regulators, sizeof(*rdata), + GFP_KERNEL); if (!rdata) { of_node_put(regulators_np); return -ENOMEM; diff --git a/drivers/regulator/mc13xxx-regulator-core.c b/drivers/regulator/mc13xxx-regulator-core.c index 0281c31ae2ed..eb63b11330f0 100644 --- a/drivers/regulator/mc13xxx-regulator-core.c +++ b/drivers/regulator/mc13xxx-regulator-core.c @@ -175,7 +175,7 @@ struct mc13xxx_regulator_init_data *mc13xxx_parse_regulators_dt( if (!parent) return NULL; - data = devm_kzalloc(&pdev->dev, sizeof(*data) * priv->num_regulators, + data = devm_kcalloc(&pdev->dev, priv->num_regulators, sizeof(*data), GFP_KERNEL); if (!data) { of_node_put(parent); diff --git a/drivers/regulator/mem-acc-regulator.c b/drivers/regulator/mem-acc-regulator.c index ebe50c185481..30cff9373c26 100644 --- a/drivers/regulator/mem-acc-regulator.c +++ b/drivers/regulator/mem-acc-regulator.c @@ -334,8 +334,8 @@ static int __mem_acc_sel_init(struct mem_acc_regulator *mem_acc_vreg, int i; u32 bit, mask; - mem_acc_vreg->acc_sel_mask[mem_type] = devm_kzalloc(mem_acc_vreg->dev, - mem_acc_vreg->num_acc_sel[mem_type] * sizeof(u32), GFP_KERNEL); + mem_acc_vreg->acc_sel_mask[mem_type] = devm_kcalloc(mem_acc_vreg->dev, + mem_acc_vreg->num_acc_sel[mem_type], sizeof(u32), GFP_KERNEL); if (!mem_acc_vreg->acc_sel_mask[mem_type]) return -ENOMEM; @@ -396,7 +396,7 @@ static int populate_acc_data(struct mem_acc_regulator *mem_acc_vreg, return -EINVAL; } - *value = devm_kzalloc(mem_acc_vreg->dev, (*len) * sizeof(u32), + *value = devm_kcalloc(mem_acc_vreg->dev, *len, sizeof(u32), GFP_KERNEL); if (!(*value)) { pr_err("Unable to allocate memory for %s\n", prop_name); @@ -1403,9 +1403,11 @@ static int mem_acc_init(struct platform_device *pdev, return rc; } if (acc_type_present) { - mem_acc_vreg->mem_acc_type_data = devm_kzalloc( - mem_acc_vreg->dev, mem_acc_vreg->num_corners * - MEM_ACC_TYPE_MAX * sizeof(u32), GFP_KERNEL); + mem_acc_vreg->mem_acc_type_data = devm_kcalloc( + mem_acc_vreg->dev, + mem_acc_vreg->num_corners * MEM_ACC_TYPE_MAX, + sizeof(u32), + GFP_KERNEL); if (!mem_acc_vreg->mem_acc_type_data) { pr_err("Unable to allocate memory for mem_acc_type\n"); diff --git a/drivers/regulator/pbias-regulator.c b/drivers/regulator/pbias-regulator.c index 0cb76ba29e84..6fca1968869a 100644 --- a/drivers/regulator/pbias-regulator.c +++ b/drivers/regulator/pbias-regulator.c @@ -158,8 +158,9 @@ static int pbias_regulator_probe(struct platform_device *pdev) if (count < 0) return count; - drvdata = devm_kzalloc(&pdev->dev, sizeof(struct pbias_regulator_data) - * count, GFP_KERNEL); + drvdata = devm_kcalloc(&pdev->dev, + count, sizeof(struct pbias_regulator_data), + GFP_KERNEL); if (!drvdata) return -ENOMEM; diff --git a/drivers/regulator/rc5t583-regulator.c b/drivers/regulator/rc5t583-regulator.c index d0f1340168b1..2ec51af43673 100644 --- a/drivers/regulator/rc5t583-regulator.c +++ b/drivers/regulator/rc5t583-regulator.c @@ -132,8 +132,10 @@ static int rc5t583_regulator_probe(struct platform_device *pdev) return -ENODEV; } - regs = devm_kzalloc(&pdev->dev, RC5T583_REGULATOR_MAX * - sizeof(struct rc5t583_regulator), GFP_KERNEL); + regs = devm_kcalloc(&pdev->dev, + RC5T583_REGULATOR_MAX, + sizeof(struct rc5t583_regulator), + GFP_KERNEL); if (!regs) return -ENOMEM; diff --git a/drivers/regulator/s5m8767.c b/drivers/regulator/s5m8767.c index 4836947e1521..ad94489aaf23 100644 --- a/drivers/regulator/s5m8767.c +++ b/drivers/regulator/s5m8767.c @@ -553,13 +553,15 @@ static int s5m8767_pmic_dt_parse_pdata(struct platform_device *pdev, /* count the number of regulators to be supported in pmic */ pdata->num_regulators = of_get_child_count(regulators_np); - rdata = devm_kzalloc(&pdev->dev, sizeof(*rdata) * - pdata->num_regulators, GFP_KERNEL); + rdata = devm_kcalloc(&pdev->dev, + pdata->num_regulators, sizeof(*rdata), + GFP_KERNEL); if (!rdata) return -ENOMEM; - rmode = devm_kzalloc(&pdev->dev, sizeof(*rmode) * - pdata->num_regulators, GFP_KERNEL); + rmode = devm_kcalloc(&pdev->dev, + pdata->num_regulators, sizeof(*rmode), + GFP_KERNEL); if (!rmode) return -ENOMEM; diff --git a/drivers/regulator/ti-abb-regulator.c b/drivers/regulator/ti-abb-regulator.c index 6d17357b3a24..89b9314d64c9 100644 --- a/drivers/regulator/ti-abb-regulator.c +++ b/drivers/regulator/ti-abb-regulator.c @@ -522,13 +522,13 @@ static int ti_abb_init_table(struct device *dev, struct ti_abb *abb, } num_entries /= num_values; - info = devm_kzalloc(dev, sizeof(*info) * num_entries, GFP_KERNEL); + info = devm_kcalloc(dev, num_entries, sizeof(*info), GFP_KERNEL); if (!info) return -ENOMEM; abb->info = info; - volt_table = devm_kzalloc(dev, sizeof(unsigned int) * num_entries, + volt_table = devm_kcalloc(dev, num_entries, sizeof(unsigned int), GFP_KERNEL); if (!volt_table) return -ENOMEM; diff --git a/drivers/regulator/tps65090-regulator.c b/drivers/regulator/tps65090-regulator.c index 395f35dc8cdb..42a6cea64104 100644 --- a/drivers/regulator/tps65090-regulator.c +++ b/drivers/regulator/tps65090-regulator.c @@ -351,8 +351,9 @@ static struct tps65090_platform_data *tps65090_parse_dt_reg_data( if (!tps65090_pdata) return ERR_PTR(-ENOMEM); - reg_pdata = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * - sizeof(*reg_pdata), GFP_KERNEL); + reg_pdata = devm_kcalloc(&pdev->dev, + TPS65090_REGULATOR_MAX, sizeof(*reg_pdata), + GFP_KERNEL); if (!reg_pdata) return ERR_PTR(-ENOMEM); @@ -432,8 +433,9 @@ static int tps65090_regulator_probe(struct platform_device *pdev) return tps65090_pdata ? PTR_ERR(tps65090_pdata) : -EINVAL; } - pmic = devm_kzalloc(&pdev->dev, TPS65090_REGULATOR_MAX * sizeof(*pmic), - GFP_KERNEL); + pmic = devm_kcalloc(&pdev->dev, + TPS65090_REGULATOR_MAX, sizeof(*pmic), + GFP_KERNEL); if (!pmic) return -ENOMEM; diff --git a/drivers/regulator/tps65217-regulator.c b/drivers/regulator/tps65217-regulator.c index 5324dc9e6d6e..77247e4d52b3 100644 --- a/drivers/regulator/tps65217-regulator.c +++ b/drivers/regulator/tps65217-regulator.c @@ -234,8 +234,9 @@ static int tps65217_regulator_probe(struct platform_device *pdev) } /* Allocate memory for strobes */ - tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) * - TPS65217_NUM_REGULATOR, GFP_KERNEL); + tps->strobes = devm_kcalloc(&pdev->dev, + TPS65217_NUM_REGULATOR, sizeof(u8), + GFP_KERNEL); platform_set_drvdata(pdev, tps); diff --git a/drivers/regulator/tps65218-regulator.c b/drivers/regulator/tps65218-regulator.c index 9aafbb03482d..e5917ad4e5e3 100644 --- a/drivers/regulator/tps65218-regulator.c +++ b/drivers/regulator/tps65218-regulator.c @@ -327,8 +327,9 @@ static int tps65218_regulator_probe(struct platform_device *pdev) config.regmap = tps->regmap; /* Allocate memory for strobes */ - tps->strobes = devm_kzalloc(&pdev->dev, sizeof(u8) * - TPS65218_NUM_REGULATOR, GFP_KERNEL); + tps->strobes = devm_kcalloc(&pdev->dev, + TPS65218_NUM_REGULATOR, sizeof(u8), + GFP_KERNEL); for (i = 0; i < ARRAY_SIZE(regulators); i++) { rdev = devm_regulator_register(&pdev->dev, ®ulators[i], diff --git a/drivers/regulator/tps65910-regulator.c b/drivers/regulator/tps65910-regulator.c index 194fa0cbbc04..5ebb6ee73f07 100644 --- a/drivers/regulator/tps65910-regulator.c +++ b/drivers/regulator/tps65910-regulator.c @@ -1133,18 +1133,24 @@ static int tps65910_probe(struct platform_device *pdev) return -ENODEV; } - pmic->desc = devm_kzalloc(&pdev->dev, pmic->num_regulators * - sizeof(struct regulator_desc), GFP_KERNEL); + pmic->desc = devm_kcalloc(&pdev->dev, + pmic->num_regulators, + sizeof(struct regulator_desc), + GFP_KERNEL); if (!pmic->desc) return -ENOMEM; - pmic->info = devm_kzalloc(&pdev->dev, pmic->num_regulators * - sizeof(struct tps_info *), GFP_KERNEL); + pmic->info = devm_kcalloc(&pdev->dev, + pmic->num_regulators, + sizeof(struct tps_info *), + GFP_KERNEL); if (!pmic->info) return -ENOMEM; - pmic->rdev = devm_kzalloc(&pdev->dev, pmic->num_regulators * - sizeof(struct regulator_dev *), GFP_KERNEL); + pmic->rdev = devm_kcalloc(&pdev->dev, + pmic->num_regulators, + sizeof(struct regulator_dev *), + GFP_KERNEL); if (!pmic->rdev) return -ENOMEM; diff --git a/drivers/regulator/tps80031-regulator.c b/drivers/regulator/tps80031-regulator.c index d4cc60ad18ae..1001147404c3 100644 --- a/drivers/regulator/tps80031-regulator.c +++ b/drivers/regulator/tps80031-regulator.c @@ -691,8 +691,8 @@ static int tps80031_regulator_probe(struct platform_device *pdev) return -EINVAL; } - pmic = devm_kzalloc(&pdev->dev, - TPS80031_REGULATOR_MAX * sizeof(*pmic), GFP_KERNEL); + pmic = devm_kcalloc(&pdev->dev, + TPS80031_REGULATOR_MAX, sizeof(*pmic), GFP_KERNEL); if (!pmic) return -ENOMEM; diff --git a/drivers/reset/reset-ti-syscon.c b/drivers/reset/reset-ti-syscon.c index 99520b0a1329..a2635c21db7f 100644 --- a/drivers/reset/reset-ti-syscon.c +++ b/drivers/reset/reset-ti-syscon.c @@ -189,7 +189,8 @@ static int ti_syscon_reset_probe(struct platform_device *pdev) } nr_controls = (size / sizeof(*list)) / 7; - controls = devm_kzalloc(dev, nr_controls * sizeof(*controls), GFP_KERNEL); + controls = devm_kcalloc(dev, nr_controls, sizeof(*controls), + GFP_KERNEL); if (!controls) return -ENOMEM; diff --git a/drivers/scsi/isci/init.c b/drivers/scsi/isci/init.c index c71e0f3b146a..c1bdcac3fea6 100644 --- a/drivers/scsi/isci/init.c +++ b/drivers/scsi/isci/init.c @@ -232,14 +232,14 @@ static int isci_register_sas_ha(struct isci_host *isci_host) struct asd_sas_phy **sas_phys; struct asd_sas_port **sas_ports; - sas_phys = devm_kzalloc(&isci_host->pdev->dev, - SCI_MAX_PHYS * sizeof(void *), + sas_phys = devm_kcalloc(&isci_host->pdev->dev, + SCI_MAX_PHYS, sizeof(void *), GFP_KERNEL); if (!sas_phys) return -ENOMEM; - sas_ports = devm_kzalloc(&isci_host->pdev->dev, - SCI_MAX_PORTS * sizeof(void *), + sas_ports = devm_kcalloc(&isci_host->pdev->dev, + SCI_MAX_PORTS, sizeof(void *), GFP_KERNEL); if (!sas_ports) return -ENOMEM; diff --git a/drivers/scsi/ufs/ufshcd-pltfrm.c b/drivers/scsi/ufs/ufshcd-pltfrm.c index 63c5c7b8cd78..e7b6fd0df2c1 100644 --- a/drivers/scsi/ufs/ufshcd-pltfrm.c +++ b/drivers/scsi/ufs/ufshcd-pltfrm.c @@ -102,8 +102,8 @@ static int ufshcd_parse_clock_info(struct ufs_hba *hba) goto out; } - clkfreq = devm_kzalloc(dev, sz * sizeof(*clkfreq), - GFP_KERNEL); + clkfreq = devm_kcalloc(dev, sz, sizeof(*clkfreq), + GFP_KERNEL); if (!clkfreq) { ret = -ENOMEM; goto out; diff --git a/drivers/scsi/ufs/ufshcd.c b/drivers/scsi/ufs/ufshcd.c index bce6a4175eab..d587fcd7e3a2 100644 --- a/drivers/scsi/ufs/ufshcd.c +++ b/drivers/scsi/ufs/ufshcd.c @@ -4883,8 +4883,8 @@ static int ufshcd_memory_alloc(struct ufs_hba *hba) } /* Allocate memory for local reference block */ - hba->lrb = devm_kzalloc(hba->dev, - hba->nutrs * sizeof(struct ufshcd_lrb), + hba->lrb = devm_kcalloc(hba->dev, + hba->nutrs, sizeof(struct ufshcd_lrb), GFP_KERNEL); if (!hba->lrb) { dev_err(hba->dev, "LRB Memory allocation failed\n"); diff --git a/drivers/soc/bcm/raspberrypi-power.c b/drivers/soc/bcm/raspberrypi-power.c index f7ed1187518b..a78dfe0a2b50 100644 --- a/drivers/soc/bcm/raspberrypi-power.c +++ b/drivers/soc/bcm/raspberrypi-power.c @@ -165,8 +165,10 @@ static int rpi_power_probe(struct platform_device *pdev) return -ENOMEM; rpi_domains->xlate.domains = - devm_kzalloc(dev, sizeof(*rpi_domains->xlate.domains) * - RPI_POWER_DOMAIN_COUNT, GFP_KERNEL); + devm_kcalloc(dev, + RPI_POWER_DOMAIN_COUNT, + sizeof(*rpi_domains->xlate.domains), + GFP_KERNEL); if (!rpi_domains->xlate.domains) return -ENOMEM; diff --git a/drivers/soc/mediatek/mtk-scpsys.c b/drivers/soc/mediatek/mtk-scpsys.c index fb2a8b1e7979..b0cb5214f659 100644 --- a/drivers/soc/mediatek/mtk-scpsys.c +++ b/drivers/soc/mediatek/mtk-scpsys.c @@ -404,15 +404,15 @@ static struct scp *init_scp(struct platform_device *pdev, if (IS_ERR(scp->base)) return ERR_CAST(scp->base); - scp->domains = devm_kzalloc(&pdev->dev, - sizeof(*scp->domains) * num, GFP_KERNEL); + scp->domains = devm_kcalloc(&pdev->dev, + num, sizeof(*scp->domains), GFP_KERNEL); if (!scp->domains) return ERR_PTR(-ENOMEM); pd_data = &scp->pd_data; - pd_data->domains = devm_kzalloc(&pdev->dev, - sizeof(*pd_data->domains) * num, GFP_KERNEL); + pd_data->domains = devm_kcalloc(&pdev->dev, + num, sizeof(*pd_data->domains), GFP_KERNEL); if (!pd_data->domains) return ERR_PTR(-ENOMEM); diff --git a/drivers/soc/qcom/gladiator_hang_detect.c b/drivers/soc/qcom/gladiator_hang_detect.c index 4d1f601f204c..4b9bc793ecf1 100644 --- a/drivers/soc/qcom/gladiator_hang_detect.c +++ b/drivers/soc/qcom/gladiator_hang_detect.c @@ -517,15 +517,15 @@ static int msm_gladiator_hang_detect_probe(struct platform_device *pdev) hang_attr_group.attrs = hang_attrs_v3; } - hang_det->threshold = devm_kzalloc(&pdev->dev, - sizeof(phys_addr_t)*NR_GLA_REG, GFP_KERNEL); + hang_det->threshold = devm_kcalloc(&pdev->dev, + NR_GLA_REG, sizeof(phys_addr_t), GFP_KERNEL); if (!hang_det->threshold) { pr_err("Can't allocate hang_detect threshold memory\n"); return -ENOMEM; } - treg = devm_kzalloc(&pdev->dev, sizeof(u32)*NR_GLA_REG, GFP_KERNEL); + treg = devm_kcalloc(&pdev->dev, NR_GLA_REG, sizeof(u32), GFP_KERNEL); if (!treg) return -ENOMEM; diff --git a/drivers/soc/qcom/glink_pkt.c b/drivers/soc/qcom/glink_pkt.c index 376ff9f62efd..2378a5a3c9f9 100644 --- a/drivers/soc/qcom/glink_pkt.c +++ b/drivers/soc/qcom/glink_pkt.c @@ -680,7 +680,7 @@ static int glink_pkt_init_rpmsg(struct glink_pkt_device *gpdev) char *drv_name; /* zalloc array of two to NULL terminate the match list */ - match = devm_kzalloc(dev, 2 * sizeof(*match), GFP_KERNEL); + match = devm_kcalloc(dev, 2, sizeof(*match), GFP_KERNEL); if (!match) return -ENOMEM; snprintf(match->name, RPMSG_NAME_SIZE, "%s", gpdev->ch_name); diff --git a/drivers/soc/qcom/jtagv8-etm.c b/drivers/soc/qcom/jtagv8-etm.c index a3080251aaf8..d16a776076d4 100644 --- a/drivers/soc/qcom/jtagv8-etm.c +++ b/drivers/soc/qcom/jtagv8-etm.c @@ -1619,8 +1619,8 @@ static int jtag_mm_etm_probe(struct platform_device *pdev, uint32_t cpu) etmdata->save_restore_disabled = 1; /* Allocate etm state save space per core */ - etmdata->state = devm_kzalloc(dev, - MAX_ETM_STATE_SIZE * sizeof(uint64_t), + etmdata->state = devm_kcalloc(dev, + MAX_ETM_STATE_SIZE, sizeof(uint64_t), GFP_KERNEL); if (!etmdata->state) return -ENOMEM; diff --git a/drivers/soc/qcom/msm_bus/msm_bus_arb_adhoc.c b/drivers/soc/qcom/msm_bus/msm_bus_arb_adhoc.c index 731fa98d9ee8..3e4ce8efc515 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_arb_adhoc.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_arb_adhoc.c @@ -127,9 +127,9 @@ static int gen_lnode(struct device *dev, } if (!cur_dev->num_lnodes) { - cur_dev->lnode_list = devm_kzalloc(dev, - sizeof(struct link_node) * NUM_LNODES, - GFP_KERNEL); + cur_dev->lnode_list = devm_kcalloc(dev, + NUM_LNODES, sizeof(struct link_node), + GFP_KERNEL); if (!cur_dev->lnode_list) goto exit_gen_lnode; diff --git a/drivers/soc/qcom/msm_bus/msm_bus_arb_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_arb_rpmh.c index a64a294e0e8c..ed62bf25d145 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_arb_rpmh.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_arb_rpmh.c @@ -140,9 +140,9 @@ static void bcm_add_bus_req(struct device *dev) bcm_dev = to_msm_bus_node(cur_dev->node_info->bcm_devs[i]); max_num_lnodes = bcm_dev->bcmdev->num_bus_devs; if (!bcm_dev->num_lnodes) { - bcm_dev->lnode_list = devm_kzalloc(dev, - sizeof(struct link_node) * max_num_lnodes, - GFP_KERNEL); + bcm_dev->lnode_list = devm_kcalloc(dev, + max_num_lnodes, sizeof(struct link_node), + GFP_KERNEL); if (!bcm_dev->lnode_list) goto exit_bcm_add_bus_req; @@ -211,9 +211,9 @@ static int gen_lnode(struct device *dev, } if (!cur_dev->num_lnodes) { - cur_dev->lnode_list = devm_kzalloc(dev, - sizeof(struct link_node) * NUM_LNODES, - GFP_KERNEL); + cur_dev->lnode_list = devm_kcalloc(dev, + NUM_LNODES, sizeof(struct link_node), + GFP_KERNEL); if (!cur_dev->lnode_list) goto exit_gen_lnode; diff --git a/drivers/soc/qcom/msm_bus/msm_bus_fabric_adhoc.c b/drivers/soc/qcom/msm_bus/msm_bus_fabric_adhoc.c index c214e384f53c..6ba06875c869 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_fabric_adhoc.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_fabric_adhoc.c @@ -919,9 +919,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->agg_params.num_aggports; node_info->agg_params.num_util_levels = pdata_node_info->agg_params.num_util_levels; - node_info->agg_params.util_levels = devm_kzalloc(bus_dev, - sizeof(struct node_util_levels_type) * + node_info->agg_params.util_levels = devm_kcalloc(bus_dev, node_info->agg_params.num_util_levels, + sizeof(struct node_util_levels_type), GFP_KERNEL); if (!node_info->agg_params.util_levels) { MSM_BUS_ERR("%s: Agg util level alloc failed\n", __func__); @@ -933,9 +933,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, sizeof(struct node_util_levels_type) * pdata_node_info->agg_params.num_util_levels); - node_info->dev_connections = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_connections, + node_info->dev_connections = devm_kcalloc(bus_dev, + pdata_node_info->num_connections, + sizeof(struct device *), GFP_KERNEL); if (!node_info->dev_connections) { MSM_BUS_ERR("%s:Bus dev connections alloc failed\n", __func__); @@ -943,8 +943,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->connections = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_connections, + node_info->connections = devm_kcalloc(bus_dev, + pdata_node_info->num_connections, sizeof(int), GFP_KERNEL); if (!node_info->connections) { MSM_BUS_ERR("%s:Bus connections alloc failed\n", __func__); @@ -957,9 +957,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->connections, sizeof(int) * pdata_node_info->num_connections); - node_info->black_connections = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_blist, + node_info->black_connections = devm_kcalloc(bus_dev, + pdata_node_info->num_blist, sizeof(struct device *), GFP_KERNEL); if (!node_info->black_connections) { MSM_BUS_ERR("%s: Bus black connections alloc failed\n", @@ -970,8 +969,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->bl_cons = devm_kzalloc(bus_dev, - pdata_node_info->num_blist * sizeof(int), + node_info->bl_cons = devm_kcalloc(bus_dev, + pdata_node_info->num_blist, sizeof(int), GFP_KERNEL); if (!node_info->bl_cons) { MSM_BUS_ERR("%s:Bus black list connections alloc failed\n", @@ -987,8 +986,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->bl_cons, sizeof(int) * pdata_node_info->num_blist); - node_info->qport = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_qports, + node_info->qport = devm_kcalloc(bus_dev, + pdata_node_info->num_qports, sizeof(int), GFP_KERNEL); if (!node_info->qport) { MSM_BUS_ERR("%s:Bus qport allocation failed\n", __func__); diff --git a/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c index 708713f92762..2bbe261c89e3 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_fabric_rpmh.c @@ -1384,8 +1384,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, node_info->name = pdata_node_info->name; node_info->id = pdata_node_info->id; - node_info->bcm_req_idx = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_bcm_devs, + node_info->bcm_req_idx = devm_kcalloc(bus_dev, + pdata_node_info->num_bcm_devs, sizeof(int), GFP_KERNEL); if (!node_info->bcm_req_idx) { ret = -ENOMEM; @@ -1441,9 +1441,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->agg_params.num_aggports; node_info->agg_params.num_util_levels = pdata_node_info->agg_params.num_util_levels; - node_info->agg_params.util_levels = devm_kzalloc(bus_dev, - sizeof(struct node_util_levels_type) * + node_info->agg_params.util_levels = devm_kcalloc(bus_dev, node_info->agg_params.num_util_levels, + sizeof(struct node_util_levels_type), GFP_KERNEL); if (!node_info->agg_params.util_levels) { MSM_BUS_ERR("%s: Agg util level alloc failed\n", __func__); @@ -1455,9 +1455,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, sizeof(struct node_util_levels_type) * pdata_node_info->agg_params.num_util_levels); - node_info->dev_connections = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_connections, + node_info->dev_connections = devm_kcalloc(bus_dev, + pdata_node_info->num_connections, + sizeof(struct device *), GFP_KERNEL); if (!node_info->dev_connections) { MSM_BUS_ERR("%s:Bus dev connections alloc failed\n", __func__); @@ -1465,8 +1465,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->connections = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_connections, + node_info->connections = devm_kcalloc(bus_dev, + pdata_node_info->num_connections, sizeof(int), GFP_KERNEL); if (!node_info->connections) { MSM_BUS_ERR("%s:Bus connections alloc failed\n", __func__); @@ -1479,9 +1479,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->connections, sizeof(int) * pdata_node_info->num_connections); - node_info->black_connections = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_blist, + node_info->black_connections = devm_kcalloc(bus_dev, + pdata_node_info->num_blist, sizeof(struct device *), GFP_KERNEL); if (!node_info->black_connections) { MSM_BUS_ERR("%s: Bus black connections alloc failed\n", @@ -1492,8 +1491,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->bl_cons = devm_kzalloc(bus_dev, - pdata_node_info->num_blist * sizeof(int), + node_info->bl_cons = devm_kcalloc(bus_dev, + pdata_node_info->num_blist, sizeof(int), GFP_KERNEL); if (!node_info->bl_cons) { MSM_BUS_ERR("%s:Bus black list connections alloc failed\n", @@ -1509,9 +1508,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->bl_cons, sizeof(int) * pdata_node_info->num_blist); - node_info->bcm_devs = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_bcm_devs, + node_info->bcm_devs = devm_kcalloc(bus_dev, + pdata_node_info->num_bcm_devs, + sizeof(struct device *), GFP_KERNEL); if (!node_info->bcm_devs) { MSM_BUS_ERR("%s:Bcm dev connections alloc failed\n", __func__); @@ -1519,8 +1518,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->bcm_dev_ids = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_bcm_devs, + node_info->bcm_dev_ids = devm_kcalloc(bus_dev, + pdata_node_info->num_bcm_devs, sizeof(int), GFP_KERNEL); if (!node_info->bcm_dev_ids) { MSM_BUS_ERR("%s:Bus connections alloc failed\n", __func__); @@ -1533,9 +1532,9 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->bcm_dev_ids, sizeof(int) * pdata_node_info->num_bcm_devs); - node_info->rsc_devs = devm_kzalloc(bus_dev, - sizeof(struct device *) * - pdata_node_info->num_rsc_devs, + node_info->rsc_devs = devm_kcalloc(bus_dev, + pdata_node_info->num_rsc_devs, + sizeof(struct device *), GFP_KERNEL); if (!node_info->rsc_devs) { MSM_BUS_ERR("%s:rsc dev connections alloc failed\n", __func__); @@ -1543,8 +1542,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, goto exit_copy_node_info; } - node_info->rsc_dev_ids = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_rsc_devs, + node_info->rsc_dev_ids = devm_kcalloc(bus_dev, + pdata_node_info->num_rsc_devs, sizeof(int), GFP_KERNEL); if (!node_info->rsc_dev_ids) { MSM_BUS_ERR("%s:Bus connections alloc failed\n", __func__); @@ -1557,8 +1556,8 @@ static int msm_bus_copy_node_info(struct msm_bus_node_device_type *pdata, pdata_node_info->rsc_dev_ids, sizeof(int) * pdata_node_info->num_rsc_devs); - node_info->qport = devm_kzalloc(bus_dev, - sizeof(int) * pdata_node_info->num_qports, + node_info->qport = devm_kcalloc(bus_dev, + pdata_node_info->num_qports, sizeof(int), GFP_KERNEL); if (!node_info->qport) { MSM_BUS_ERR("%s:Bus qport allocation failed\n", __func__); diff --git a/drivers/soc/qcom/msm_bus/msm_bus_of.c b/drivers/soc/qcom/msm_bus/msm_bus_of.c index f24bc92f16bf..f7ade63aca43 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_of.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_of.c @@ -149,8 +149,10 @@ static struct msm_bus_scale_pdata *get_pdata(struct device *dev, for (i = 0; i < num_usecases; i++) { usecase[i].num_paths = num_paths; - usecase[i].vectors = devm_kzalloc(dev, num_paths * - sizeof(struct msm_bus_vectors), GFP_KERNEL); + usecase[i].vectors = devm_kcalloc(dev, + num_paths, + sizeof(struct msm_bus_vectors), + GFP_KERNEL); if (!usecase[i].vectors) { mem_err = true; pr_err("Error: Mem alloc failure in vectors\n"); @@ -415,8 +417,9 @@ static struct msm_bus_node_info *get_nodes(struct device_node *of_node, pdata->len = i; info = (struct msm_bus_node_info *) - devm_kzalloc(&pdev->dev, sizeof(struct msm_bus_node_info) * - pdata->len, GFP_KERNEL); + devm_kcalloc(&pdev->dev, + pdata->len, sizeof(struct msm_bus_node_info), + GFP_KERNEL); if (ZERO_OR_NULL_PTR(info)) { pr_err("Failed to alloc memory for nodes: %d\n", pdata->len); goto err; diff --git a/drivers/soc/qcom/msm_bus/msm_bus_of_adhoc.c b/drivers/soc/qcom/msm_bus/msm_bus_of_adhoc.c index 34a0c5ce0b60..98ec7d726393 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_of_adhoc.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_of_adhoc.c @@ -714,9 +714,10 @@ struct msm_bus_device_node_registration pdata->num_devices = of_get_child_count(of_node); - pdata->info = devm_kzalloc(&pdev->dev, - sizeof(struct msm_bus_node_device_type) * - pdata->num_devices, GFP_KERNEL); + pdata->info = devm_kcalloc(&pdev->dev, + pdata->num_devices, + sizeof(struct msm_bus_node_device_type), + GFP_KERNEL); if (!pdata->info) goto node_reg_err; @@ -824,8 +825,8 @@ int msm_bus_of_get_static_rules(struct platform_device *pdev, of_node = pdev->dev.of_node; num_rules = of_get_child_count(of_node); - local_rule = devm_kzalloc(&pdev->dev, - sizeof(struct bus_rule_type) * num_rules, + local_rule = devm_kcalloc(&pdev->dev, + num_rules, sizeof(struct bus_rule_type), GFP_KERNEL); if (IS_ERR_OR_NULL(local_rule)) { diff --git a/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c b/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c index a97a44c3cd28..7568353f51ca 100644 --- a/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c +++ b/drivers/soc/qcom/msm_bus/msm_bus_of_rpmh.c @@ -754,9 +754,10 @@ struct msm_bus_device_node_registration pdata->num_devices = of_get_child_count(of_node); - pdata->info = devm_kzalloc(&pdev->dev, - sizeof(struct msm_bus_node_device_type) * - pdata->num_devices, GFP_KERNEL); + pdata->info = devm_kcalloc(&pdev->dev, + pdata->num_devices, + sizeof(struct msm_bus_node_device_type), + GFP_KERNEL); if (!pdata->info) { dev_err(&pdev->dev, @@ -869,8 +870,8 @@ int msm_bus_of_get_static_rules(struct platform_device *pdev, of_node = pdev->dev.of_node; num_rules = of_get_child_count(of_node); - local_rule = devm_kzalloc(&pdev->dev, - sizeof(struct bus_rule_type) * num_rules, + local_rule = devm_kcalloc(&pdev->dev, + num_rules, sizeof(struct bus_rule_type), GFP_KERNEL); if (IS_ERR_OR_NULL(local_rule)) { diff --git a/drivers/soc/qcom/qsee_ipc_irq.c b/drivers/soc/qcom/qsee_ipc_irq.c index 38a90e640835..f586fa0fe2bc 100644 --- a/drivers/soc/qcom/qsee_ipc_irq.c +++ b/drivers/soc/qcom/qsee_ipc_irq.c @@ -267,7 +267,7 @@ static int qsee_irq_probe(struct platform_device *pdev) return -ENODEV; irq_count = platform_irq_count(pdev); - qirq->banks = devm_kzalloc(dev, sizeof(*qirq->banks) * irq_count, + qirq->banks = devm_kcalloc(dev, irq_count, sizeof(*qirq->banks), GFP_KERNEL); if (!qirq->banks) return -ENOMEM; diff --git a/drivers/soc/qcom/rpm_master_stat.c b/drivers/soc/qcom/rpm_master_stat.c index 1cbf2a1dbc02..ccd11684dfe7 100644 --- a/drivers/soc/qcom/rpm_master_stat.c +++ b/drivers/soc/qcom/rpm_master_stat.c @@ -398,7 +398,9 @@ static struct msm_rpm_master_stats_platform_data goto err; } - pdata->masters = devm_kzalloc(dev, sizeof(char *) * pdata->num_masters, + pdata->masters = devm_kcalloc(dev, + pdata->num_masters, + sizeof(char *), GFP_KERNEL); if (!pdata->masters) goto err; diff --git a/drivers/soc/qcom/subsys-pil-tz.c b/drivers/soc/qcom/subsys-pil-tz.c index e267ceadf41a..322ad9550757 100644 --- a/drivers/soc/qcom/subsys-pil-tz.c +++ b/drivers/soc/qcom/subsys-pil-tz.c @@ -238,7 +238,7 @@ static int of_read_clocks(struct device *dev, struct clk ***clks_ref, return -EINVAL; } - clks = devm_kzalloc(dev, sizeof(struct clk *) * clk_count, + clks = devm_kcalloc(dev, clk_count, sizeof(struct clk *), GFP_KERNEL); if (!clks) return -ENOMEM; @@ -297,7 +297,7 @@ static int of_read_regs(struct device *dev, struct reg_info **regs_ref, return -EINVAL; } - regs = devm_kzalloc(dev, sizeof(struct reg_info) * reg_count, + regs = devm_kcalloc(dev, reg_count, sizeof(struct reg_info), GFP_KERNEL); if (!regs) return -ENOMEM; diff --git a/drivers/soc/qcom/subsystem_restart.c b/drivers/soc/qcom/subsystem_restart.c index d97b129b7e66..54f501820d73 100644 --- a/drivers/soc/qcom/subsystem_restart.c +++ b/drivers/soc/qcom/subsystem_restart.c @@ -1525,14 +1525,14 @@ static struct subsys_soc_restart_order *ssr_parse_restart_orders(struct if (!order) return ERR_PTR(-ENOMEM); - order->subsys_ptrs = devm_kzalloc(dev, - count * sizeof(struct subsys_device *), + order->subsys_ptrs = devm_kcalloc(dev, + count, sizeof(struct subsys_device *), GFP_KERNEL); if (!order->subsys_ptrs) return ERR_PTR(-ENOMEM); - order->device_ptrs = devm_kzalloc(dev, - count * sizeof(struct device_node *), + order->device_ptrs = devm_kcalloc(dev, + count, sizeof(struct device_node *), GFP_KERNEL); if (!order->device_ptrs) return ERR_PTR(-ENOMEM); diff --git a/drivers/soc/ti/knav_qmss_acc.c b/drivers/soc/ti/knav_qmss_acc.c index 672aebe1e378..2f7fb2dcc1d6 100644 --- a/drivers/soc/ti/knav_qmss_acc.c +++ b/drivers/soc/ti/knav_qmss_acc.c @@ -405,8 +405,8 @@ static int knav_acc_init_queue(struct knav_range_info *range, { unsigned id = kq->id - range->queue_base; - kq->descs = devm_kzalloc(range->kdev->dev, - ACC_DESCS_MAX * sizeof(u32), GFP_KERNEL); + kq->descs = devm_kcalloc(range->kdev->dev, + ACC_DESCS_MAX, sizeof(u32), GFP_KERNEL); if (!kq->descs) return -ENOMEM; @@ -552,7 +552,7 @@ int knav_init_acc_range(struct knav_device *kdev, info->list_size = list_size; mem_size = PAGE_ALIGN(list_size * 2); info->mem_size = mem_size; - range->acc = devm_kzalloc(kdev->dev, channels * sizeof(*range->acc), + range->acc = devm_kcalloc(kdev->dev, channels, sizeof(*range->acc), GFP_KERNEL); if (!range->acc) return -ENOMEM; diff --git a/drivers/spi/spi-davinci.c b/drivers/spi/spi-davinci.c index c5bbe08771a4..c2b2959f4eea 100644 --- a/drivers/spi/spi-davinci.c +++ b/drivers/spi/spi-davinci.c @@ -923,9 +923,10 @@ static int davinci_spi_probe(struct platform_device *pdev) /* pdata in dspi is now updated and point pdata to that */ pdata = &dspi->pdata; - dspi->bytes_per_word = devm_kzalloc(&pdev->dev, - sizeof(*dspi->bytes_per_word) * - pdata->num_chipselect, GFP_KERNEL); + dspi->bytes_per_word = devm_kcalloc(&pdev->dev, + pdata->num_chipselect, + sizeof(*dspi->bytes_per_word), + GFP_KERNEL); if (dspi->bytes_per_word == NULL) { ret = -ENOMEM; goto free_master; diff --git a/drivers/spi/spi-ep93xx.c b/drivers/spi/spi-ep93xx.c index ce28c910ee48..79fc3940245a 100644 --- a/drivers/spi/spi-ep93xx.c +++ b/drivers/spi/spi-ep93xx.c @@ -685,8 +685,8 @@ static int ep93xx_spi_probe(struct platform_device *pdev) master->bits_per_word_mask = SPI_BPW_RANGE_MASK(4, 16); master->num_chipselect = info->num_chipselect; - master->cs_gpios = devm_kzalloc(&master->dev, - sizeof(int) * master->num_chipselect, + master->cs_gpios = devm_kcalloc(&master->dev, + master->num_chipselect, sizeof(int), GFP_KERNEL); if (!master->cs_gpios) { error = -ENOMEM; diff --git a/drivers/spi/spi-imx.c b/drivers/spi/spi-imx.c index df18d07d544d..38d830141d0a 100644 --- a/drivers/spi/spi-imx.c +++ b/drivers/spi/spi-imx.c @@ -1415,8 +1415,8 @@ static int spi_imx_probe(struct platform_device *pdev) if (mxc_platform_info) { master->num_chipselect = mxc_platform_info->num_chipselect; - master->cs_gpios = devm_kzalloc(&master->dev, - sizeof(int) * master->num_chipselect, GFP_KERNEL); + master->cs_gpios = devm_kcalloc(&master->dev, + master->num_chipselect, sizeof(int), GFP_KERNEL); if (!master->cs_gpios) return -ENOMEM; diff --git a/drivers/spi/spi-oc-tiny.c b/drivers/spi/spi-oc-tiny.c index b5911282a611..085f580be7ec 100644 --- a/drivers/spi/spi-oc-tiny.c +++ b/drivers/spi/spi-oc-tiny.c @@ -213,8 +213,8 @@ static int tiny_spi_of_probe(struct platform_device *pdev) return 0; hw->gpio_cs_count = of_gpio_count(np); if (hw->gpio_cs_count > 0) { - hw->gpio_cs = devm_kzalloc(&pdev->dev, - hw->gpio_cs_count * sizeof(unsigned int), + hw->gpio_cs = devm_kcalloc(&pdev->dev, + hw->gpio_cs_count, sizeof(unsigned int), GFP_KERNEL); if (!hw->gpio_cs) return -ENOMEM; diff --git a/drivers/spi/spi-pl022.c b/drivers/spi/spi-pl022.c index 4797c57f4263..1af8c96b940e 100644 --- a/drivers/spi/spi-pl022.c +++ b/drivers/spi/spi-pl022.c @@ -2135,7 +2135,7 @@ static int pl022_probe(struct amba_device *adev, const struct amba_id *id) pl022->master_info = platform_info; pl022->adev = adev; pl022->vendor = id->data; - pl022->chipselects = devm_kzalloc(dev, num_cs * sizeof(int), + pl022->chipselects = devm_kcalloc(dev, num_cs, sizeof(int), GFP_KERNEL); if (!pl022->chipselects) { status = -ENOMEM; diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 49eee894f51d..237099464fec 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -2044,7 +2044,7 @@ static int of_spi_register_master(struct spi_controller *ctlr) else if (nb < 0) return nb; - cs = devm_kzalloc(&ctlr->dev, sizeof(int) * ctlr->num_chipselect, + cs = devm_kcalloc(&ctlr->dev, ctlr->num_chipselect, sizeof(int), GFP_KERNEL); ctlr->cs_gpios = cs; diff --git a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c index 8ea3920400a0..db39daef4cbe 100644 --- a/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c +++ b/drivers/staging/fsl-mc/bus/fsl-mc-allocator.c @@ -357,8 +357,8 @@ int fsl_mc_populate_irq_pool(struct fsl_mc_bus *mc_bus, if (error < 0) return error; - irq_resources = devm_kzalloc(&mc_bus_dev->dev, - sizeof(*irq_resources) * irq_count, + irq_resources = devm_kcalloc(&mc_bus_dev->dev, + irq_count, sizeof(*irq_resources), GFP_KERNEL); if (!irq_resources) { error = -ENOMEM; @@ -458,7 +458,7 @@ int __must_check fsl_mc_allocate_irqs(struct fsl_mc_device *mc_dev) return -ENOSPC; } - irqs = devm_kzalloc(&mc_dev->dev, irq_count * sizeof(irqs[0]), + irqs = devm_kcalloc(&mc_dev->dev, irq_count, sizeof(irqs[0]), GFP_KERNEL); if (!irqs) return -ENOMEM; diff --git a/drivers/staging/greybus/audio_topology.c b/drivers/staging/greybus/audio_topology.c index 07fac3948f3a..cc35037ace59 100644 --- a/drivers/staging/greybus/audio_topology.c +++ b/drivers/staging/greybus/audio_topology.c @@ -145,7 +145,7 @@ static const char **gb_generate_enum_strings(struct gbaudio_module_info *gb, __u8 *data; items = le32_to_cpu(gbenum->items); - strings = devm_kzalloc(gb->dev, sizeof(char *) * items, GFP_KERNEL); + strings = devm_kcalloc(gb->dev, items, sizeof(char *), GFP_KERNEL); data = gbenum->names; for (i = 0; i < items; i++) { diff --git a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c index 744ab6eb42a0..e5bf60601d92 100644 --- a/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c +++ b/drivers/staging/media/atomisp/pci/atomisp2/atomisp_subdev.c @@ -1414,8 +1414,10 @@ int atomisp_subdev_init(struct atomisp_device *isp) * multiple streams */ isp->num_of_streams = 2; - isp->asd = devm_kzalloc(isp->dev, sizeof(struct atomisp_sub_device) * - isp->num_of_streams, GFP_KERNEL); + isp->asd = devm_kcalloc(isp->dev, + isp->num_of_streams, + sizeof(struct atomisp_sub_device), + GFP_KERNEL); if (!isp->asd) return -ENOMEM; for (i = 0; i < isp->num_of_streams; i++) { diff --git a/drivers/thermal/tegra/soctherm.c b/drivers/thermal/tegra/soctherm.c index 7d2db23d71a3..ca313c9c3aec 100644 --- a/drivers/thermal/tegra/soctherm.c +++ b/drivers/thermal/tegra/soctherm.c @@ -1352,8 +1352,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) return PTR_ERR(tegra->clock_soctherm); } - tegra->calib = devm_kzalloc(&pdev->dev, - sizeof(u32) * soc->num_tsensors, + tegra->calib = devm_kcalloc(&pdev->dev, + soc->num_tsensors, sizeof(u32), GFP_KERNEL); if (!tegra->calib) return -ENOMEM; @@ -1372,8 +1372,8 @@ static int tegra_soctherm_probe(struct platform_device *pdev) return err; } - tegra->thermctl_tzs = devm_kzalloc(&pdev->dev, - sizeof(*z) * soc->num_ttgs, + tegra->thermctl_tzs = devm_kcalloc(&pdev->dev, + soc->num_ttgs, sizeof(*z), GFP_KERNEL); if (!tegra->thermctl_tzs) return -ENOMEM; diff --git a/drivers/thermal/thermal-generic-adc.c b/drivers/thermal/thermal-generic-adc.c index ad601e5b4175..173856665430 100644 --- a/drivers/thermal/thermal-generic-adc.c +++ b/drivers/thermal/thermal-generic-adc.c @@ -91,8 +91,9 @@ static int gadc_thermal_read_linear_lookup_table(struct device *dev, return -EINVAL; } - gti->lookup_table = devm_kzalloc(dev, sizeof(*gti->lookup_table) * - ntable, GFP_KERNEL); + gti->lookup_table = devm_kcalloc(dev, + ntable, sizeof(*gti->lookup_table), + GFP_KERNEL); if (!gti->lookup_table) return -ENOMEM; diff --git a/drivers/tty/serial/rp2.c b/drivers/tty/serial/rp2.c index 056f91b3a4ca..6dc3fee6dc61 100644 --- a/drivers/tty/serial/rp2.c +++ b/drivers/tty/serial/rp2.c @@ -777,7 +777,7 @@ static int rp2_probe(struct pci_dev *pdev, rp2_init_card(card); - ports = devm_kzalloc(&pdev->dev, sizeof(*ports) * card->n_ports, + ports = devm_kcalloc(&pdev->dev, card->n_ports, sizeof(*ports), GFP_KERNEL); if (!ports) return -ENOMEM; diff --git a/drivers/usb/dwc3/dwc3-msm.c b/drivers/usb/dwc3/dwc3-msm.c index b3366c67dcd2..1ef97d80654d 100644 --- a/drivers/usb/dwc3/dwc3-msm.c +++ b/drivers/usb/dwc3/dwc3-msm.c @@ -2088,8 +2088,8 @@ static void dwc3_msm_notify_event(struct dwc3 *dwc, unsigned int event, if (!mdwc->num_gsi_event_buffers) break; - mdwc->gsi_ev_buff = devm_kzalloc(dwc->dev, - sizeof(*dwc->ev_buf) * mdwc->num_gsi_event_buffers, + mdwc->gsi_ev_buff = devm_kcalloc(dwc->dev, + mdwc->num_gsi_event_buffers, sizeof(*dwc->ev_buf), GFP_KERNEL); if (!mdwc->gsi_ev_buff) { dev_err(dwc->dev, "can't allocate gsi_ev_buff\n"); diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 8540e52c28a9..c13edfc71fe6 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2095,7 +2095,7 @@ static struct usba_ep * atmel_udc_of_init(struct platform_device *pdev, udc->num_ep = usba_config_fifo_table(udc); } - eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * udc->num_ep, + eps = devm_kcalloc(&pdev->dev, udc->num_ep, sizeof(struct usba_ep), GFP_KERNEL); if (!eps) return ERR_PTR(-ENOMEM); @@ -2229,7 +2229,7 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, if (!pdata) return ERR_PTR(-ENXIO); - eps = devm_kzalloc(&pdev->dev, sizeof(struct usba_ep) * pdata->num_ep, + eps = devm_kcalloc(&pdev->dev, pdata->num_ep, sizeof(struct usba_ep), GFP_KERNEL); if (!eps) return ERR_PTR(-ENOMEM); diff --git a/drivers/usb/gadget/udc/renesas_usb3.c b/drivers/usb/gadget/udc/renesas_usb3.c index 189d4e01010b..d34ddc44bfdd 100644 --- a/drivers/usb/gadget/udc/renesas_usb3.c +++ b/drivers/usb/gadget/udc/renesas_usb3.c @@ -2447,7 +2447,8 @@ static int renesas_usb3_init_ep(struct renesas_usb3 *usb3, struct device *dev, if (usb3->num_usb3_eps > USB3_MAX_NUM_PIPES) usb3->num_usb3_eps = USB3_MAX_NUM_PIPES; - usb3->usb3_ep = devm_kzalloc(dev, sizeof(*usb3_ep) * usb3->num_usb3_eps, + usb3->usb3_ep = devm_kcalloc(dev, + usb3->num_usb3_eps, sizeof(*usb3_ep), GFP_KERNEL); if (!usb3->usb3_ep) return -ENOMEM; diff --git a/drivers/usb/phy/phy-msm-usb.c b/drivers/usb/phy/phy-msm-usb.c index e45cfa42e5ad..e2d6dc16c6c3 100644 --- a/drivers/usb/phy/phy-msm-usb.c +++ b/drivers/usb/phy/phy-msm-usb.c @@ -3734,8 +3734,8 @@ struct msm_otg_platform_data *msm_otg_dt_to_pdata(struct platform_device *pdev) len = of_property_count_elems_of_size(node, "qcom,hsusb-otg-phy-init-seq", sizeof(len)); if (len > 0) { - pdata->phy_init_seq = devm_kzalloc(&pdev->dev, - len * sizeof(len), GFP_KERNEL); + pdata->phy_init_seq = devm_kcalloc(&pdev->dev, + len, sizeof(len), GFP_KERNEL); if (!pdata->phy_init_seq) return NULL; of_property_read_u32_array(node, "qcom,hsusb-otg-phy-init-seq", diff --git a/drivers/video/backlight/adp8860_bl.c b/drivers/video/backlight/adp8860_bl.c index e7315bf14d60..16119bde9750 100644 --- a/drivers/video/backlight/adp8860_bl.c +++ b/drivers/video/backlight/adp8860_bl.c @@ -223,7 +223,7 @@ static int adp8860_led_probe(struct i2c_client *client) struct led_info *cur_led; int ret, i; - led = devm_kzalloc(&client->dev, sizeof(*led) * pdata->num_leds, + led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led), GFP_KERNEL); if (led == NULL) return -ENOMEM; diff --git a/drivers/video/backlight/adp8870_bl.c b/drivers/video/backlight/adp8870_bl.c index 058d1def2d1f..4fec9aa92d9b 100644 --- a/drivers/video/backlight/adp8870_bl.c +++ b/drivers/video/backlight/adp8870_bl.c @@ -246,7 +246,7 @@ static int adp8870_led_probe(struct i2c_client *client) struct led_info *cur_led; int ret, i; - led = devm_kzalloc(&client->dev, pdata->num_leds * sizeof(*led), + led = devm_kcalloc(&client->dev, pdata->num_leds, sizeof(*led), GFP_KERNEL); if (led == NULL) return -ENOMEM; diff --git a/drivers/video/backlight/lp855x_bl.c b/drivers/video/backlight/lp855x_bl.c index 4cdc7a3f6dc5..bd43d8cff389 100644 --- a/drivers/video/backlight/lp855x_bl.c +++ b/drivers/video/backlight/lp855x_bl.c @@ -374,7 +374,7 @@ static int lp855x_parse_dt(struct lp855x *lp) struct device_node *child; int i = 0; - rom = devm_kzalloc(dev, sizeof(*rom) * rom_length, GFP_KERNEL); + rom = devm_kcalloc(dev, rom_length, sizeof(*rom), GFP_KERNEL); if (!rom) return -ENOMEM; diff --git a/drivers/video/fbdev/au1100fb.c b/drivers/video/fbdev/au1100fb.c index 8de42f617d16..de2bfc6c3e2d 100644 --- a/drivers/video/fbdev/au1100fb.c +++ b/drivers/video/fbdev/au1100fb.c @@ -504,7 +504,7 @@ static int au1100fb_drv_probe(struct platform_device *dev) fbdev->info.fix = au1100fb_fix; fbdev->info.pseudo_palette = - devm_kzalloc(&dev->dev, sizeof(u32) * 16, GFP_KERNEL); + devm_kcalloc(&dev->dev, 16, sizeof(u32), GFP_KERNEL); if (!fbdev->info.pseudo_palette) return -ENOMEM; diff --git a/drivers/video/fbdev/bf537-lq035.c b/drivers/video/fbdev/bf537-lq035.c index ef29fb425122..57e3a6814e6b 100644 --- a/drivers/video/fbdev/bf537-lq035.c +++ b/drivers/video/fbdev/bf537-lq035.c @@ -737,8 +737,8 @@ static int bfin_lq035_probe(struct platform_device *pdev) bfin_lq035_fb.flags = FBINFO_DEFAULT; - bfin_lq035_fb.pseudo_palette = devm_kzalloc(&pdev->dev, - sizeof(u32) * 16, + bfin_lq035_fb.pseudo_palette = devm_kcalloc(&pdev->dev, + 16, sizeof(u32), GFP_KERNEL); if (bfin_lq035_fb.pseudo_palette == NULL) { pr_err("failed to allocate pseudo_palette\n"); diff --git a/drivers/video/fbdev/bf54x-lq043fb.c b/drivers/video/fbdev/bf54x-lq043fb.c index 8f1f97c75619..9b5d0b358279 100644 --- a/drivers/video/fbdev/bf54x-lq043fb.c +++ b/drivers/video/fbdev/bf54x-lq043fb.c @@ -602,7 +602,7 @@ static int bfin_bf54x_probe(struct platform_device *pdev) fbinfo->fbops = &bfin_bf54x_fb_ops; - fbinfo->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16, + fbinfo->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32), GFP_KERNEL); if (!fbinfo->pseudo_palette) { printk(KERN_ERR DRIVER_NAME diff --git a/drivers/video/fbdev/msm/dsi_v2.c b/drivers/video/fbdev/msm/dsi_v2.c index 60c57e45212d..5ac17eb2c383 100644 --- a/drivers/video/fbdev/msm/dsi_v2.c +++ b/drivers/video/fbdev/msm/dsi_v2.c @@ -286,8 +286,9 @@ static int mdss_dsi_get_dt_vreg_data(struct device *dev, pr_debug("%s: vreg found. count=%d\n", __func__, mp->num_vreg); } - mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) * - mp->num_vreg, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + mp->num_vreg, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { rc = -ENOMEM; goto error; diff --git a/drivers/video/fbdev/msm/mdp3_ctrl.c b/drivers/video/fbdev/msm/mdp3_ctrl.c index 9a2b739e6b5e..29276da66a23 100644 --- a/drivers/video/fbdev/msm/mdp3_ctrl.c +++ b/drivers/video/fbdev/msm/mdp3_ctrl.c @@ -2222,22 +2222,22 @@ static int mdp3_alloc_lut_buffer(struct platform_device *pdev, void **cmap) memset(map, 0, sizeof(struct fb_cmap)); - map->red = devm_kzalloc(&pdev->dev, MDP_LUT_SIZE * sizeof(u16), + map->red = devm_kcalloc(&pdev->dev, MDP_LUT_SIZE, sizeof(u16), GFP_KERNEL); if (map->red == NULL) goto exit_red; memset(map->red, 0, sizeof(u16) * MDP_LUT_SIZE); - map->green = devm_kzalloc(&pdev->dev, MDP_LUT_SIZE * sizeof(u16), - GFP_KERNEL); + map->green = devm_kcalloc(&pdev->dev, MDP_LUT_SIZE, sizeof(u16), + GFP_KERNEL); if (map->green == NULL) goto exit_green; memset(map->green, 0, sizeof(u16) * MDP_LUT_SIZE); - map->blue = devm_kzalloc(&pdev->dev, MDP_LUT_SIZE * sizeof(u16), - GFP_KERNEL); + map->blue = devm_kcalloc(&pdev->dev, MDP_LUT_SIZE, sizeof(u16), + GFP_KERNEL); if (map->blue == NULL) goto exit_blue; diff --git a/drivers/video/fbdev/msm/mdss_dsi.c b/drivers/video/fbdev/msm/mdss_dsi.c index f578c73ac394..0461f821027d 100644 --- a/drivers/video/fbdev/msm/mdss_dsi.c +++ b/drivers/video/fbdev/msm/mdss_dsi.c @@ -559,8 +559,9 @@ int mdss_dsi_get_dt_vreg_data(struct device *dev, pr_debug("%s: vreg found. count=%d\n", __func__, mp->num_vreg); } - mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) * - mp->num_vreg, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + mp->num_vreg, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { rc = -ENOMEM; goto error; diff --git a/drivers/video/fbdev/msm/mdss_fb.c b/drivers/video/fbdev/msm/mdss_fb.c index 918fe6a12f06..b8594852b5f0 100644 --- a/drivers/video/fbdev/msm/mdss_fb.c +++ b/drivers/video/fbdev/msm/mdss_fb.c @@ -1189,8 +1189,8 @@ static int mdss_fb_init_panel_modes(struct msm_fb_data_type *mfd, list_for_each(pos, &pdata->timings_list) num_timings++; - modedb = devm_kzalloc(fbi->dev, num_timings * sizeof(*modedb), - GFP_KERNEL); + modedb = devm_kcalloc(fbi->dev, num_timings, sizeof(*modedb), + GFP_KERNEL); if (!modedb) return -ENOMEM; diff --git a/drivers/video/fbdev/msm/mdss_hdmi_tx.c b/drivers/video/fbdev/msm/mdss_hdmi_tx.c index e634fffcf1e4..7cc3c49dbe5d 100644 --- a/drivers/video/fbdev/msm/mdss_hdmi_tx.c +++ b/drivers/video/fbdev/msm/mdss_hdmi_tx.c @@ -4191,8 +4191,10 @@ static int hdmi_tx_init_power_data(struct device *dev, } hpd_power_data->num_clk = hpd_clk_count; - hpd_power_data->clk_config = devm_kzalloc(dev, sizeof(struct dss_clk) * - hpd_power_data->num_clk, GFP_KERNEL); + hpd_power_data->clk_config = devm_kcalloc(dev, + hpd_power_data->num_clk, + sizeof(struct dss_clk), + GFP_KERNEL); if (!hpd_power_data->clk_config) { rc = -EINVAL; goto exit; @@ -4206,8 +4208,10 @@ static int hdmi_tx_init_power_data(struct device *dev, } core_power_data->num_clk = core_clk_count; - core_power_data->clk_config = devm_kzalloc(dev, sizeof(struct dss_clk) * - core_power_data->num_clk, GFP_KERNEL); + core_power_data->clk_config = devm_kcalloc(dev, + core_power_data->num_clk, + sizeof(struct dss_clk), + GFP_KERNEL); if (!core_power_data->clk_config) { core_power_data->num_clk = 0; rc = -EINVAL; @@ -4386,8 +4390,10 @@ static int hdmi_tx_get_dt_vreg_data(struct device *dev, if (mod_vreg_total > 0) { mp->num_vreg = mod_vreg_total; - mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) * - mod_vreg_total, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + mod_vreg_total, + sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { DEV_ERR("%s: can't alloc '%s' vreg mem\n", __func__, hdmi_tx_pm_name(module_type)); @@ -4398,7 +4404,7 @@ static int hdmi_tx_get_dt_vreg_data(struct device *dev, return 0; } - val_array = devm_kzalloc(dev, sizeof(u32) * dt_vreg_total, GFP_KERNEL); + val_array = devm_kcalloc(dev, dt_vreg_total, sizeof(u32), GFP_KERNEL); if (!val_array) { DEV_ERR("%s: can't allocate vreg scratch mem\n", __func__); rc = -ENOMEM; @@ -4570,8 +4576,9 @@ static int hdmi_tx_get_dt_gpio_data(struct device *dev, DEV_DBG("%s: mp_gpio_cnt = %d\n", __func__, mp_gpio_cnt); mp->num_gpio = mp_gpio_cnt; - mp->gpio_config = devm_kzalloc(dev, sizeof(struct dss_gpio) * - mp_gpio_cnt, GFP_KERNEL); + mp->gpio_config = devm_kcalloc(dev, + mp_gpio_cnt, sizeof(struct dss_gpio), + GFP_KERNEL); if (!mp->gpio_config) { DEV_ERR("%s: can't alloc '%s' gpio mem\n", __func__, hdmi_tx_pm_name(module_type)); diff --git a/drivers/video/fbdev/msm/mdss_mdp.c b/drivers/video/fbdev/msm/mdss_mdp.c index afd11b5eb603..e9625d0636f9 100644 --- a/drivers/video/fbdev/msm/mdss_mdp.c +++ b/drivers/video/fbdev/msm/mdss_mdp.c @@ -2432,8 +2432,9 @@ static u32 mdss_mdp_scaler_init(struct mdss_data_type *mdata, mdata->scaler_off->ndest_scalers = len/sizeof(u32); mdata->scaler_off->dest_scaler_off = - devm_kzalloc(dev, sizeof(u32) * + devm_kcalloc(&mdata->pdev->dev, mdata->scaler_off->ndest_scalers, + sizeof(u32), GFP_KERNEL); if (!mdata->scaler_off->dest_scaler_off) return -ENOMEM; @@ -2446,8 +2447,9 @@ static u32 mdss_mdp_scaler_init(struct mdss_data_type *mdata, return ret; mdata->scaler_off->dest_scaler_lut_off = - devm_kzalloc(dev, sizeof(u32) * + devm_kcalloc(&mdata->pdev->dev, mdata->scaler_off->ndest_scalers, + sizeof(u32), GFP_KERNEL); if (!mdata->scaler_off->dest_scaler_lut_off) return -ENOMEM; @@ -3344,8 +3346,10 @@ int mdss_mdp_parse_dt_hw_settings(struct platform_device *pdev) if (!(mdp_len + vbif_len + vbif_nrt_len)) return 0; - hws = devm_kzalloc(&pdev->dev, sizeof(*hws) * (vbif_len + mdp_len + - vbif_nrt_len + 1), GFP_KERNEL); + hws = devm_kcalloc(&pdev->dev, + vbif_len + mdp_len + vbif_nrt_len + 1, + sizeof(*hws), + GFP_KERNEL); if (!hws) return -ENOMEM; @@ -3909,10 +3913,9 @@ static int mdss_mdp_cdm_addr_setup(struct mdss_data_type *mdata, struct mdss_mdp_cdm *head; u32 i = 0; - head = devm_kzalloc(&mdata->pdev->dev, sizeof(struct mdss_mdp_cdm) * - len, GFP_KERNEL); - if (!head) { - pr_err("%s: no memory for CDM info\n", __func__); + head = devm_kcalloc(&mdata->pdev->dev, + len, sizeof(struct mdss_mdp_cdm), GFP_KERNEL); + if (!head) return -ENOMEM; } @@ -3978,8 +3981,8 @@ static int mdss_mdp_dsc_addr_setup(struct mdss_data_type *mdata, struct mdss_mdp_dsc *head; u32 i = 0; - head = devm_kzalloc(&mdata->pdev->dev, sizeof(struct mdss_mdp_dsc) * - len, GFP_KERNEL); + head = devm_kcalloc(&mdata->pdev->dev, + len, sizeof(struct mdss_mdp_dsc), GFP_KERNEL); if (!head) return -ENOMEM; @@ -4408,10 +4411,11 @@ static void mdss_mdp_parse_max_bandwidth(struct platform_device *pdev) max_bw_settings_cnt /= 2 * sizeof(u32); - max_bw_settings = devm_kzalloc(&pdev->dev, sizeof(*max_bw_settings) - * max_bw_settings_cnt, GFP_KERNEL); - if (!max_bw_settings) { - pr_err("Memory allocation failed for max_bw_settings\n"); + max_bw_settings = devm_kcalloc(&pdev->dev, + max_bw_settings_cnt, + sizeof(*max_bw_settings), + GFP_KERNEL); + if (!max_bw_settings) return; } @@ -4450,8 +4454,8 @@ static void mdss_mdp_parse_per_pipe_bandwidth(struct platform_device *pdev) max_bw_settings_cnt /= 2 * sizeof(u32); - max_bw_per_pipe_settings = devm_kzalloc(&pdev->dev, - sizeof(struct mdss_max_bw_settings) * max_bw_settings_cnt, + max_bw_per_pipe_settings = devm_kcalloc(&pdev->dev, + max_bw_settings_cnt, sizeof(struct mdss_max_bw_settings), GFP_KERNEL); if (!max_bw_per_pipe_settings) { pr_err("Memory allocation failed for max_bw_settings\n"); @@ -4710,8 +4714,8 @@ static int mdss_mdp_parse_dt_ppb_off(struct platform_device *pdev) arr = of_get_property(pdev->dev.of_node, "qcom,mdss-ppb-ctl-off", &len); if (arr) { mdata->nppb_ctl = len / sizeof(u32); - mdata->ppb_ctl = devm_kzalloc(&mdata->pdev->dev, - sizeof(u32) * mdata->nppb_ctl, GFP_KERNEL); + mdata->ppb_ctl = devm_kcalloc(&mdata->pdev->dev, + mdata->nppb_ctl, sizeof(u32), GFP_KERNEL); if (mdata->ppb_ctl == NULL) return -ENOMEM; @@ -4723,8 +4727,8 @@ static int mdss_mdp_parse_dt_ppb_off(struct platform_device *pdev) arr = of_get_property(pdev->dev.of_node, "qcom,mdss-ppb-cfg-off", &len); if (arr) { mdata->nppb_cfg = len / sizeof(u32); - mdata->ppb_cfg = devm_kzalloc(&mdata->pdev->dev, - sizeof(u32) * mdata->nppb_cfg, GFP_KERNEL); + mdata->ppb_cfg = devm_kcalloc(&mdata->pdev->dev, + mdata->nppb_cfg, sizeof(u32), GFP_KERNEL); if (mdata->ppb_cfg == NULL) return -ENOMEM; diff --git a/drivers/video/fbdev/msm/mdss_mdp_ctl.c b/drivers/video/fbdev/msm/mdss_mdp_ctl.c index 758f97197f84..b4962b0eb2e5 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_ctl.c +++ b/drivers/video/fbdev/msm/mdss_mdp_ctl.c @@ -5248,8 +5248,8 @@ int mdss_mdp_mixer_addr_setup(struct mdss_data_type *mdata, (mdata->wfd_mode == MDSS_MDP_WFD_SHARED)) size++; - head = devm_kzalloc(&mdata->pdev->dev, sizeof(struct mdss_mdp_mixer) * - size, GFP_KERNEL); + head = devm_kcalloc(&mdata->pdev->dev, + size, sizeof(struct mdss_mdp_mixer), GFP_KERNEL); if (!head) { pr_err("unable to setup mixer type=%d :kzalloc fail\n", @@ -5319,8 +5319,8 @@ int mdss_mdp_ctl_addr_setup(struct mdss_data_type *mdata, mutex_init(shared_lock); } - head = devm_kzalloc(&mdata->pdev->dev, sizeof(struct mdss_mdp_ctl) * - size, GFP_KERNEL); + head = devm_kcalloc(&mdata->pdev->dev, + size, sizeof(struct mdss_mdp_ctl), GFP_KERNEL); if (!head) { pr_err("unable to setup ctl and wb: kzalloc fail\n"); @@ -5355,10 +5355,10 @@ int mdss_mdp_wb_addr_setup(struct mdss_data_type *mdata, u32 total, i; total = num_block_wb + num_intf_wb; - wb = devm_kzalloc(&mdata->pdev->dev, sizeof(struct mdss_mdp_writeback) * - total, GFP_KERNEL); - if (!wb) { - pr_err("unable to setup wb: kzalloc fail\n"); + wb = devm_kcalloc(&mdata->pdev->dev, + total, sizeof(struct mdss_mdp_writeback), + GFP_KERNEL); + if (!wb) return -ENOMEM; } diff --git a/drivers/video/fbdev/msm/mdss_mdp_intf_video.c b/drivers/video/fbdev/msm/mdss_mdp_intf_video.c index 1ae6ebbf001e..e17a6ee2076e 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_intf_video.c +++ b/drivers/video/fbdev/msm/mdss_mdp_intf_video.c @@ -317,8 +317,8 @@ int mdss_mdp_video_addr_setup(struct mdss_data_type *mdata, struct mdss_mdp_video_ctx *head; u32 i; - head = devm_kzalloc(&mdata->pdev->dev, - sizeof(struct mdss_mdp_video_ctx) * count, GFP_KERNEL); + head = devm_kcalloc(&mdata->pdev->dev, + count, sizeof(struct mdss_mdp_video_ctx), GFP_KERNEL); if (!head) return -ENOMEM; diff --git a/drivers/video/fbdev/msm/mdss_mdp_pp.c b/drivers/video/fbdev/msm/mdss_mdp_pp.c index 4581d2538bb8..6f0d8fa4738d 100644 --- a/drivers/video/fbdev/msm/mdss_mdp_pp.c +++ b/drivers/video/fbdev/msm/mdss_mdp_pp.c @@ -3186,9 +3186,9 @@ int mdss_mdp_pp_init(struct device *dev) goto pp_exit; } pp_ops = pp_driver_ops.pp_ops; - hist = devm_kzalloc(dev, - sizeof(struct pp_hist_col_info) * + hist = devm_kcalloc(dev, mdata->ndspp, + sizeof(struct pp_hist_col_info), GFP_KERNEL); if (hist == NULL) { pr_err("dspp histogram allocation failed!\n"); @@ -6805,8 +6805,8 @@ int mdss_mdp_ad_addr_setup(struct mdss_data_type *mdata, u32 *ad_offsets) u32 i; int rc = 0; - mdata->ad_off = devm_kzalloc(&mdata->pdev->dev, - sizeof(struct mdss_mdp_ad) * mdata->nad_cfgs, + mdata->ad_off = devm_kcalloc(&mdata->pdev->dev, + mdata->nad_cfgs, sizeof(struct mdss_mdp_ad), GFP_KERNEL); if (!mdata->ad_off) { @@ -6814,8 +6814,8 @@ int mdss_mdp_ad_addr_setup(struct mdss_data_type *mdata, u32 *ad_offsets) return -ENOMEM; } - mdata->ad_cfgs = devm_kzalloc(&mdata->pdev->dev, - sizeof(struct mdss_ad_info) * mdata->nad_cfgs, + mdata->ad_cfgs = devm_kcalloc(&mdata->pdev->dev, + mdata->nad_cfgs, sizeof(struct mdss_ad_info), GFP_KERNEL); if (!mdata->ad_cfgs) { diff --git a/drivers/video/fbdev/msm/mdss_rotator.c b/drivers/video/fbdev/msm/mdss_rotator.c index f285d793d520..0997384531af 100644 --- a/drivers/video/fbdev/msm/mdss_rotator.c +++ b/drivers/video/fbdev/msm/mdss_rotator.c @@ -1942,8 +1942,8 @@ static int mdss_rotator_open_session(struct mdss_rot_mgr *mgr, return -ENOMEM; ATRACE_BEGIN(__func__); /* Open session votes for bw */ - perf->work_distribution = devm_kzalloc(&mgr->pdev->dev, - sizeof(u32) * mgr->queue_count, GFP_KERNEL); + perf->work_distribution = devm_kcalloc(&mgr->pdev->dev, + mgr->queue_count, sizeof(u32), GFP_KERNEL); if (!perf->work_distribution) { ret = -ENOMEM; goto alloc_err; @@ -2696,8 +2696,9 @@ static int mdss_rotator_get_dt_vreg_data(struct device *dev, return 0; } mp->num_vreg = dt_vreg_total; - mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) * - dt_vreg_total, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + dt_vreg_total, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) { DEV_ERR("%s: can't alloc vreg mem\n", __func__); return -ENOMEM; diff --git a/drivers/video/fbdev/msm/mdss_smmu.c b/drivers/video/fbdev/msm/mdss_smmu.c index 79554f9a10b0..1fd7e5f7ff1c 100644 --- a/drivers/video/fbdev/msm/mdss_smmu.c +++ b/drivers/video/fbdev/msm/mdss_smmu.c @@ -196,8 +196,8 @@ static int mdss_smmu_util_parse_dt_clock(struct platform_device *pdev, } mp->num_clk = num_clk; - mp->clk_config = devm_kzalloc(&pdev->dev, - sizeof(struct dss_clk) * mp->num_clk, GFP_KERNEL); + mp->clk_config = devm_kcalloc(&pdev->dev, + mp->num_clk, sizeof(struct dss_clk), GFP_KERNEL); if (!mp->clk_config) { pr_err("clock configuration allocation failed\n"); rc = -ENOMEM; diff --git a/drivers/video/fbdev/msm/mdss_spi_panel.c b/drivers/video/fbdev/msm/mdss_spi_panel.c index 5f4f4eab0547..b973e97c109a 100644 --- a/drivers/video/fbdev/msm/mdss_spi_panel.c +++ b/drivers/video/fbdev/msm/mdss_spi_panel.c @@ -732,10 +732,12 @@ static void mdss_spi_parse_esd_params(struct device_node *np, ctrl->status_cmds_rlen = (!rc ? tmp : 1); - ctrl->exp_status_value = devm_kzalloc(&mdss_pdev->dev, sizeof(u8) * - (ctrl->status_cmds_rlen + 1), GFP_KERNEL); - ctrl->act_status_value = devm_kzalloc(&mdss_pdev->dev, sizeof(u8) * - (ctrl->status_cmds_rlen + 1), GFP_KERNEL); + ctrl->exp_status_value = devm_kzalloc(&mdss_pdev->dev, + ctrl->status_cmds_rlen + 1, + GFP_KERNEL); + ctrl->act_status_value = devm_kzalloc(&mdss_pdev->dev, + ctrl->status_cmds_rlen + 1, + GFP_KERNEL); if (!ctrl->exp_status_value || !ctrl->act_status_value) { pinfo->esd_check_enabled = false; diff --git a/drivers/video/fbdev/msm/msm_dba/adv7533.c b/drivers/video/fbdev/msm/msm_dba/adv7533.c index 49303625c3d9..50648aa5fc69 100644 --- a/drivers/video/fbdev/msm/msm_dba/adv7533.c +++ b/drivers/video/fbdev/msm/msm_dba/adv7533.c @@ -449,12 +449,13 @@ static void adv7533_parse_vreg_dt(struct device *dev, goto end; } mp->num_vreg = dt_vreg_total; - mp->vreg_config = devm_kzalloc(dev, sizeof(struct dss_vreg) * - dt_vreg_total, GFP_KERNEL); + mp->vreg_config = devm_kcalloc(dev, + dt_vreg_total, sizeof(struct dss_vreg), + GFP_KERNEL); if (!mp->vreg_config) goto end; - val_array = devm_kzalloc(dev, sizeof(u32) * dt_vreg_total, GFP_KERNEL); + val_array = devm_kcalloc(dev, dt_vreg_total, sizeof(u32), GFP_KERNEL); if (!val_array) goto end; diff --git a/drivers/video/fbdev/mxsfb.c b/drivers/video/fbdev/mxsfb.c index 7846f0e8bbbb..f3657d093ce5 100644 --- a/drivers/video/fbdev/mxsfb.c +++ b/drivers/video/fbdev/mxsfb.c @@ -925,7 +925,7 @@ static int mxsfb_probe(struct platform_device *pdev) if (IS_ERR(host->reg_lcd)) host->reg_lcd = NULL; - fb_info->pseudo_palette = devm_kzalloc(&pdev->dev, sizeof(u32) * 16, + fb_info->pseudo_palette = devm_kcalloc(&pdev->dev, 16, sizeof(u32), GFP_KERNEL); if (!fb_info->pseudo_palette) { ret = -ENOMEM; diff --git a/drivers/video/fbdev/omap2/omapfb/vrfb.c b/drivers/video/fbdev/omap2/omapfb/vrfb.c index f346b02eee1d..f355ecfac3b1 100644 --- a/drivers/video/fbdev/omap2/omapfb/vrfb.c +++ b/drivers/video/fbdev/omap2/omapfb/vrfb.c @@ -359,8 +359,8 @@ static int __init vrfb_probe(struct platform_device *pdev) num_ctxs = pdev->num_resources - 1; - ctxs = devm_kzalloc(&pdev->dev, - sizeof(struct vrfb_ctx) * num_ctxs, + ctxs = devm_kcalloc(&pdev->dev, + num_ctxs, sizeof(struct vrfb_ctx), GFP_KERNEL); if (!ctxs) diff --git a/drivers/vservices/transport/axon.c b/drivers/vservices/transport/axon.c index 4604b2831922..a66d3f013f26 100644 --- a/drivers/vservices/transport/axon.c +++ b/drivers/vservices/transport/axon.c @@ -3056,8 +3056,8 @@ static int transport_axon_setup_descs(struct vs_transport_axon *transport) } /* Array of pointers to the source TX pool for each outgoing buffer. */ - transport->tx_pools = devm_kzalloc(transport->axon_dev, - sizeof(*transport->tx_pools) * transport->queue_size, + transport->tx_pools = devm_kcalloc(transport->axon_dev, + transport->queue_size, sizeof(*transport->tx_pools), GFP_KERNEL); if (!transport->tx_pools) { err = -ENOMEM; diff --git a/sound/soc/au1x/dbdma2.c b/sound/soc/au1x/dbdma2.c index 6a035ca0f521..42e6e6f89411 100644 --- a/sound/soc/au1x/dbdma2.c +++ b/sound/soc/au1x/dbdma2.c @@ -336,8 +336,8 @@ static int au1xpsc_pcm_drvprobe(struct platform_device *pdev) { struct au1xpsc_audio_dmadata *dmadata; - dmadata = devm_kzalloc(&pdev->dev, - 2 * sizeof(struct au1xpsc_audio_dmadata), + dmadata = devm_kcalloc(&pdev->dev, + 2, sizeof(struct au1xpsc_audio_dmadata), GFP_KERNEL); if (!dmadata) return -ENOMEM; diff --git a/sound/soc/codecs/hdmi-codec.c b/sound/soc/codecs/hdmi-codec.c index e00f5f49f21d..9195573b01a8 100644 --- a/sound/soc/codecs/hdmi-codec.c +++ b/sound/soc/codecs/hdmi-codec.c @@ -774,7 +774,7 @@ static int hdmi_codec_probe(struct platform_device *pdev) hcp->hcd = *hcd; mutex_init(&hcp->current_stream_lock); - hcp->daidrv = devm_kzalloc(dev, dai_count * sizeof(*hcp->daidrv), + hcp->daidrv = devm_kcalloc(dev, dai_count, sizeof(*hcp->daidrv), GFP_KERNEL); if (!hcp->daidrv) return -ENOMEM; diff --git a/sound/soc/codecs/rt5645.c b/sound/soc/codecs/rt5645.c index a98647ac497c..1000b50bd435 100644 --- a/sound/soc/codecs/rt5645.c +++ b/sound/soc/codecs/rt5645.c @@ -3383,8 +3383,9 @@ static int rt5645_probe(struct snd_soc_codec *codec) snd_soc_dapm_sync(dapm); } - rt5645->eq_param = devm_kzalloc(codec->dev, - RT5645_HWEQ_NUM * sizeof(struct rt5645_eq_param_s), GFP_KERNEL); + rt5645->eq_param = devm_kcalloc(codec->dev, + RT5645_HWEQ_NUM, sizeof(struct rt5645_eq_param_s), + GFP_KERNEL); return 0; } diff --git a/sound/soc/codecs/tfa98xx.c b/sound/soc/codecs/tfa98xx.c index 15e9a0c6cf5e..ed31bc4fa5a4 100644 --- a/sound/soc/codecs/tfa98xx.c +++ b/sound/soc/codecs/tfa98xx.c @@ -1428,8 +1428,8 @@ static int tfa98xx_create_controls(struct tfa98xx *tfa98xx) nr_controls++; /* Playback Volume control */ } - tfa98xx_controls = devm_kzalloc(tfa98xx->codec->dev, - nr_controls * sizeof(tfa98xx_controls[0]), GFP_KERNEL); + tfa98xx_controls = devm_kcalloc(tfa98xx->codec->dev, + nr_controls, sizeof(tfa98xx_controls[0]), GFP_KERNEL); if (!tfa98xx_controls) return -ENOMEM; diff --git a/sound/soc/codecs/wm8994.c b/sound/soc/codecs/wm8994.c index f289762cd676..fb7e77e51441 100644 --- a/sound/soc/codecs/wm8994.c +++ b/sound/soc/codecs/wm8994.c @@ -3297,8 +3297,8 @@ static void wm8994_handle_pdata(struct wm8994_priv *wm8994) }; /* We need an array of texts for the enum API */ - wm8994->drc_texts = devm_kzalloc(wm8994->hubs.codec->dev, - sizeof(char *) * pdata->num_drc_cfgs, GFP_KERNEL); + wm8994->drc_texts = devm_kcalloc(wm8994->hubs.codec->dev, + pdata->num_drc_cfgs, sizeof(char *), GFP_KERNEL); if (!wm8994->drc_texts) return; diff --git a/sound/soc/davinci/davinci-mcasp.c b/sound/soc/davinci/davinci-mcasp.c index 6991718d7c8a..08af1d925f28 100644 --- a/sound/soc/davinci/davinci-mcasp.c +++ b/sound/soc/davinci/davinci-mcasp.c @@ -1877,8 +1877,8 @@ static int davinci_mcasp_probe(struct platform_device *pdev) mcasp->num_serializer = pdata->num_serializer; #ifdef CONFIG_PM_SLEEP - mcasp->context.xrsr_regs = devm_kzalloc(&pdev->dev, - sizeof(u32) * mcasp->num_serializer, + mcasp->context.xrsr_regs = devm_kcalloc(&pdev->dev, + mcasp->num_serializer, sizeof(u32), GFP_KERNEL); if (!mcasp->context.xrsr_regs) { ret = -ENOMEM; @@ -2013,13 +2013,15 @@ static int davinci_mcasp_probe(struct platform_device *pdev) * bytes. */ mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list = - devm_kzalloc(mcasp->dev, sizeof(unsigned int) * - (32 + mcasp->num_serializer - 1), + devm_kcalloc(mcasp->dev, + 32 + mcasp->num_serializer - 1, + sizeof(unsigned int), GFP_KERNEL); mcasp->chconstr[SNDRV_PCM_STREAM_CAPTURE].list = - devm_kzalloc(mcasp->dev, sizeof(unsigned int) * - (32 + mcasp->num_serializer - 1), + devm_kcalloc(mcasp->dev, + 32 + mcasp->num_serializer - 1, + sizeof(unsigned int), GFP_KERNEL); if (!mcasp->chconstr[SNDRV_PCM_STREAM_PLAYBACK].list || diff --git a/sound/soc/generic/audio-graph-card.c b/sound/soc/generic/audio-graph-card.c index 488c52f9405f..a31bbef377e5 100644 --- a/sound/soc/generic/audio-graph-card.c +++ b/sound/soc/generic/audio-graph-card.c @@ -265,8 +265,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) if (num == 0) return -EINVAL; - dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); - dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); + dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); + dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); if (!dai_props || !dai_link) return -ENOMEM; diff --git a/sound/soc/generic/audio-graph-scu-card.c b/sound/soc/generic/audio-graph-scu-card.c index a967aa143d51..095ef6426d42 100644 --- a/sound/soc/generic/audio-graph-scu-card.c +++ b/sound/soc/generic/audio-graph-scu-card.c @@ -348,8 +348,8 @@ static int asoc_graph_card_probe(struct platform_device *pdev) if (num == 0) return -EINVAL; - dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); - dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); + dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); + dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); if (!dai_props || !dai_link) return -ENOMEM; diff --git a/sound/soc/generic/simple-card.c b/sound/soc/generic/simple-card.c index 6959a74a6f49..ca8dcda0906a 100644 --- a/sound/soc/generic/simple-card.c +++ b/sound/soc/generic/simple-card.c @@ -319,8 +319,8 @@ static int asoc_simple_card_parse_aux_devs(struct device_node *node, if (n <= 0) return -EINVAL; - card->aux_dev = devm_kzalloc(dev, - n * sizeof(*card->aux_dev), GFP_KERNEL); + card->aux_dev = devm_kcalloc(dev, + n, sizeof(*card->aux_dev), GFP_KERNEL); if (!card->aux_dev) return -ENOMEM; @@ -414,8 +414,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) if (!priv) return -ENOMEM; - dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); - dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); + dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); + dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); if (!dai_props || !dai_link) return -ENOMEM; diff --git a/sound/soc/generic/simple-scu-card.c b/sound/soc/generic/simple-scu-card.c index 48606c63562a..487716559deb 100644 --- a/sound/soc/generic/simple-scu-card.c +++ b/sound/soc/generic/simple-scu-card.c @@ -246,8 +246,8 @@ static int asoc_simple_card_probe(struct platform_device *pdev) num = of_get_child_count(np); - dai_props = devm_kzalloc(dev, sizeof(*dai_props) * num, GFP_KERNEL); - dai_link = devm_kzalloc(dev, sizeof(*dai_link) * num, GFP_KERNEL); + dai_props = devm_kcalloc(dev, num, sizeof(*dai_props), GFP_KERNEL); + dai_link = devm_kcalloc(dev, num, sizeof(*dai_link), GFP_KERNEL); if (!dai_props || !dai_link) return -ENOMEM; diff --git a/sound/soc/intel/skylake/skl-topology.c b/sound/soc/intel/skylake/skl-topology.c index b45c1ae60f94..be189a34efdd 100644 --- a/sound/soc/intel/skylake/skl-topology.c +++ b/sound/soc/intel/skylake/skl-topology.c @@ -2334,8 +2334,10 @@ static int skl_tplg_get_token(struct device *dev, case SKL_TKN_U8_DYN_IN_PIN: if (!mconfig->m_in_pin) - mconfig->m_in_pin = devm_kzalloc(dev, MAX_IN_QUEUE * - sizeof(*mconfig->m_in_pin), GFP_KERNEL); + mconfig->m_in_pin = devm_kcalloc(dev, + MAX_IN_QUEUE, + sizeof(*mconfig->m_in_pin), + GFP_KERNEL); if (!mconfig->m_in_pin) return -ENOMEM; @@ -2345,8 +2347,10 @@ static int skl_tplg_get_token(struct device *dev, case SKL_TKN_U8_DYN_OUT_PIN: if (!mconfig->m_out_pin) - mconfig->m_out_pin = devm_kzalloc(dev, MAX_IN_QUEUE * - sizeof(*mconfig->m_in_pin), GFP_KERNEL); + mconfig->m_out_pin = devm_kcalloc(dev, + MAX_IN_QUEUE, + sizeof(*mconfig->m_in_pin), + GFP_KERNEL); if (!mconfig->m_out_pin) return -ENOMEM; diff --git a/sound/soc/pxa/mmp-sspa.c b/sound/soc/pxa/mmp-sspa.c index 64b85e30c1f8..566080770889 100644 --- a/sound/soc/pxa/mmp-sspa.c +++ b/sound/soc/pxa/mmp-sspa.c @@ -426,8 +426,8 @@ static int asoc_mmp_sspa_probe(struct platform_device *pdev) if (priv->sspa == NULL) return -ENOMEM; - priv->dma_params = devm_kzalloc(&pdev->dev, - 2 * sizeof(struct snd_dmaengine_dai_dma_data), + priv->dma_params = devm_kcalloc(&pdev->dev, + 2, sizeof(struct snd_dmaengine_dai_dma_data), GFP_KERNEL); if (priv->dma_params == NULL) return -ENOMEM; diff --git a/sound/soc/sh/rcar/cmd.c b/sound/soc/sh/rcar/cmd.c index f1d4fb566892..6c65b6e295d1 100644 --- a/sound/soc/sh/rcar/cmd.c +++ b/sound/soc/sh/rcar/cmd.c @@ -156,7 +156,7 @@ int rsnd_cmd_probe(struct rsnd_priv *priv) if (!nr) return 0; - cmd = devm_kzalloc(dev, sizeof(*cmd) * nr, GFP_KERNEL); + cmd = devm_kcalloc(dev, nr, sizeof(*cmd), GFP_KERNEL); if (!cmd) return -ENOMEM; diff --git a/sound/soc/sh/rcar/core.c b/sound/soc/sh/rcar/core.c index f203c0878e69..6a4a49199b36 100644 --- a/sound/soc/sh/rcar/core.c +++ b/sound/soc/sh/rcar/core.c @@ -1094,8 +1094,8 @@ static int rsnd_dai_probe(struct rsnd_priv *priv) if (!nr) return -EINVAL; - rdrv = devm_kzalloc(dev, sizeof(*rdrv) * nr, GFP_KERNEL); - rdai = devm_kzalloc(dev, sizeof(*rdai) * nr, GFP_KERNEL); + rdrv = devm_kcalloc(dev, nr, sizeof(*rdrv), GFP_KERNEL); + rdai = devm_kcalloc(dev, nr, sizeof(*rdai), GFP_KERNEL); if (!rdrv || !rdai) return -ENOMEM; diff --git a/sound/soc/sh/rcar/ctu.c b/sound/soc/sh/rcar/ctu.c index e7f53f44165d..0fb32c49fc24 100644 --- a/sound/soc/sh/rcar/ctu.c +++ b/sound/soc/sh/rcar/ctu.c @@ -370,7 +370,7 @@ int rsnd_ctu_probe(struct rsnd_priv *priv) goto rsnd_ctu_probe_done; } - ctu = devm_kzalloc(dev, sizeof(*ctu) * nr, GFP_KERNEL); + ctu = devm_kcalloc(dev, nr, sizeof(*ctu), GFP_KERNEL); if (!ctu) { ret = -ENOMEM; goto rsnd_ctu_probe_done; diff --git a/sound/soc/sh/rcar/dvc.c b/sound/soc/sh/rcar/dvc.c index 1743ade3cc55..edec2e245245 100644 --- a/sound/soc/sh/rcar/dvc.c +++ b/sound/soc/sh/rcar/dvc.c @@ -360,7 +360,7 @@ int rsnd_dvc_probe(struct rsnd_priv *priv) goto rsnd_dvc_probe_done; } - dvc = devm_kzalloc(dev, sizeof(*dvc) * nr, GFP_KERNEL); + dvc = devm_kcalloc(dev, nr, sizeof(*dvc), GFP_KERNEL); if (!dvc) { ret = -ENOMEM; goto rsnd_dvc_probe_done; diff --git a/sound/soc/sh/rcar/mix.c b/sound/soc/sh/rcar/mix.c index 6c4826c189a4..b716207aab8e 100644 --- a/sound/soc/sh/rcar/mix.c +++ b/sound/soc/sh/rcar/mix.c @@ -148,7 +148,7 @@ int rsnd_mix_probe(struct rsnd_priv *priv) goto rsnd_mix_probe_done; } - mix = devm_kzalloc(dev, sizeof(*mix) * nr, GFP_KERNEL); + mix = devm_kcalloc(dev, nr, sizeof(*mix), GFP_KERNEL); if (!mix) { ret = -ENOMEM; goto rsnd_mix_probe_done; diff --git a/sound/soc/sh/rcar/src.c b/sound/soc/sh/rcar/src.c index 510b68a483b4..0e71e8ed08f6 100644 --- a/sound/soc/sh/rcar/src.c +++ b/sound/soc/sh/rcar/src.c @@ -557,7 +557,7 @@ int rsnd_src_probe(struct rsnd_priv *priv) goto rsnd_src_probe_done; } - src = devm_kzalloc(dev, sizeof(*src) * nr, GFP_KERNEL); + src = devm_kcalloc(dev, nr, sizeof(*src), GFP_KERNEL); if (!src) { ret = -ENOMEM; goto rsnd_src_probe_done; diff --git a/sound/soc/sh/rcar/ssi.c b/sound/soc/sh/rcar/ssi.c index cae9ed6a0cdb..3eac3bc49e94 100644 --- a/sound/soc/sh/rcar/ssi.c +++ b/sound/soc/sh/rcar/ssi.c @@ -1112,7 +1112,7 @@ int rsnd_ssi_probe(struct rsnd_priv *priv) goto rsnd_ssi_probe_done; } - ssi = devm_kzalloc(dev, sizeof(*ssi) * nr, GFP_KERNEL); + ssi = devm_kcalloc(dev, nr, sizeof(*ssi), GFP_KERNEL); if (!ssi) { ret = -ENOMEM; goto rsnd_ssi_probe_done; diff --git a/sound/soc/sh/rcar/ssiu.c b/sound/soc/sh/rcar/ssiu.c index 5e5ed5475473..5f4469b67125 100644 --- a/sound/soc/sh/rcar/ssiu.c +++ b/sound/soc/sh/rcar/ssiu.c @@ -255,7 +255,7 @@ int rsnd_ssiu_probe(struct rsnd_priv *priv) /* same number to SSI */ nr = priv->ssi_nr; - ssiu = devm_kzalloc(dev, sizeof(*ssiu) * nr, GFP_KERNEL); + ssiu = devm_kcalloc(dev, nr, sizeof(*ssiu), GFP_KERNEL); if (!ssiu) return -ENOMEM; diff --git a/sound/soc/soc-core.c b/sound/soc/soc-core.c index 9de75e5a0b3f..1c6858be01ce 100644 --- a/sound/soc/soc-core.c +++ b/sound/soc/soc-core.c @@ -4094,7 +4094,7 @@ int snd_soc_of_parse_audio_routing(struct snd_soc_card *card, return -EINVAL; } - routes = devm_kzalloc(card->dev, num_routes * sizeof(*routes), + routes = devm_kcalloc(card->dev, num_routes, sizeof(*routes), GFP_KERNEL); if (!routes) { dev_err(card->dev, @@ -4446,8 +4446,8 @@ int snd_soc_of_get_dai_link_codecs(struct device *dev, dev_err(dev, "Bad phandle in 'sound-dai'\n"); return num_codecs; } - component = devm_kzalloc(dev, - sizeof *component * num_codecs, + component = devm_kcalloc(dev, + num_codecs, sizeof(*component), GFP_KERNEL); if (!component) return -ENOMEM; diff --git a/techpack/audio/4.0/asoc/codecs/bolero/bolero-cdc.c b/techpack/audio/4.0/asoc/codecs/bolero/bolero-cdc.c index a09bbaec5f56..bfecc5651ee3 100644 --- a/techpack/audio/4.0/asoc/codecs/bolero/bolero-cdc.c +++ b/techpack/audio/4.0/asoc/codecs/bolero/bolero-cdc.c @@ -389,10 +389,9 @@ static int bolero_copy_dais_from_macro(struct bolero_priv *priv) /* memcpy into bolero_dais all macro dais */ if (!priv->bolero_dais) - priv->bolero_dais = devm_kzalloc(priv->dev, - priv->num_dais * - sizeof( - struct snd_soc_dai_driver), + priv->bolero_dais = devm_kcalloc(priv->dev, + priv->num_dais, + sizeof(struct snd_soc_dai_driver), GFP_KERNEL); if (!priv->bolero_dais) return -ENOMEM; diff --git a/techpack/audio/4.0/asoc/codecs/bolero/bolero-clk-rsc.c b/techpack/audio/4.0/asoc/codecs/bolero/bolero-clk-rsc.c index b134819e0c16..54f2ac6a6daf 100644 --- a/techpack/audio/4.0/asoc/codecs/bolero/bolero-clk-rsc.c +++ b/techpack/audio/4.0/asoc/codecs/bolero/bolero-clk-rsc.c @@ -640,7 +640,7 @@ static int bolero_clk_rsc_probe(struct platform_device *pdev) ret = -EINVAL; goto err; } - clk_name_array = devm_kzalloc(&pdev->dev, clk_cnt * sizeof(char *), + clk_name_array = devm_kcalloc(&pdev->dev, clk_cnt, sizeof(char *), GFP_KERNEL); if (!clk_name_array) { ret = -ENOMEM; diff --git a/techpack/audio/4.0/asoc/msm-dai-slim.c b/techpack/audio/4.0/asoc/msm-dai-slim.c index 545590fa3735..3bebf565c2f0 100644 --- a/techpack/audio/4.0/asoc/msm-dai-slim.c +++ b/techpack/audio/4.0/asoc/msm-dai-slim.c @@ -492,8 +492,8 @@ static int msm_dai_slim_populate_dai_data(struct device *dev, SET_DAI_STATE(dai_data_t->status, DAI_STATE_INITIALIZED); - dai_data_t->chan_h = devm_kzalloc(dev, - sizeof(u16) * num_ch, + dai_data_t->chan_h = devm_kcalloc(dev, + num_ch, sizeof(u16), GFP_KERNEL); if (!dai_data_t->chan_h) { dev_err(dev, @@ -503,8 +503,8 @@ static int msm_dai_slim_populate_dai_data(struct device *dev, goto err_mem_alloc; } - dai_data_t->sh_ch = devm_kzalloc(dev, - sizeof(u16) * num_ch, + dai_data_t->sh_ch = devm_kcalloc(dev, + num_ch, sizeof(u16), GFP_KERNEL); if (!dai_data_t->sh_ch) { dev_err(dev, diff --git a/techpack/audio/4.0/dsp/adsp-loader.c b/techpack/audio/4.0/dsp/adsp-loader.c index c0dbe3f4f438..673fbff0eb14 100644 --- a/techpack/audio/4.0/dsp/adsp-loader.c +++ b/techpack/audio/4.0/dsp/adsp-loader.c @@ -371,8 +371,8 @@ static int adsp_loader_probe(struct platform_device *pdev) goto wqueue; } - adsp_fw_bit_values = devm_kzalloc(&pdev->dev, - adsp_fw_cnt * sizeof(u32), GFP_KERNEL); + adsp_fw_bit_values = devm_kcalloc(&pdev->dev, + adsp_fw_cnt, sizeof(u32), GFP_KERNEL); if (!adsp_fw_bit_values) goto wqueue; @@ -387,8 +387,8 @@ static int adsp_loader_probe(struct platform_device *pdev) goto wqueue; } - adsp_fw_name_array = devm_kzalloc(&pdev->dev, - adsp_fw_cnt * sizeof(char *), GFP_KERNEL); + adsp_fw_name_array = devm_kcalloc(&pdev->dev, + adsp_fw_cnt, sizeof(char *), GFP_KERNEL); if (!adsp_fw_name_array) goto wqueue; diff --git a/techpack/audio/4.0/soc/pinctrl-wcd.c b/techpack/audio/4.0/soc/pinctrl-wcd.c index 437563f0a8a0..ff4c4718b8ab 100644 --- a/techpack/audio/4.0/soc/pinctrl-wcd.c +++ b/techpack/audio/4.0/soc/pinctrl-wcd.c @@ -331,7 +331,8 @@ static int wcd_pinctrl_probe(struct platform_device *pdev) goto err_name_alloc; } for (i = 0; i < npins; i++, pindesc++) { - name[i] = devm_kzalloc(dev, sizeof(char) * WCD_GPIO_STRING_LEN, + name[i] = devm_kzalloc(dev, + WCD_GPIO_STRING_LEN, GFP_KERNEL); if (!name[i]) { ret = -ENOMEM; diff --git a/techpack/audio/4.0/soc/swr-mstr-ctrl.c b/techpack/audio/4.0/soc/swr-mstr-ctrl.c index 847c90d71fb3..cfb6777cc30f 100644 --- a/techpack/audio/4.0/soc/swr-mstr-ctrl.c +++ b/techpack/audio/4.0/soc/swr-mstr-ctrl.c @@ -3204,8 +3204,8 @@ static int swrm_alloc_port_mem(struct device *dev, struct swr_mstr_ctrl *swrm, u32 uc, u32 size) { if (!swrm->port_param) { - swrm->port_param = devm_kzalloc(dev, - sizeof(swrm->port_param) * SWR_UC_MAX, + swrm->port_param = devm_kcalloc(dev, + SWR_UC_MAX, sizeof(swrm->port_param), GFP_KERNEL); if (!swrm->port_param) return -ENOMEM; diff --git a/techpack/audio/asoc/codecs/bolero/bolero-cdc.c b/techpack/audio/asoc/codecs/bolero/bolero-cdc.c index 02998fc4373a..7d5b1ccb0d58 100644 --- a/techpack/audio/asoc/codecs/bolero/bolero-cdc.c +++ b/techpack/audio/asoc/codecs/bolero/bolero-cdc.c @@ -288,10 +288,9 @@ static int bolero_copy_dais_from_macro(struct bolero_priv *priv) /* memcpy into bolero_dais all macro dais */ if (!priv->bolero_dais) - priv->bolero_dais = devm_kzalloc(priv->dev, - priv->num_dais * - sizeof( - struct snd_soc_dai_driver), + priv->bolero_dais = devm_kcalloc(priv->dev, + priv->num_dais, + sizeof(struct snd_soc_dai_driver), GFP_KERNEL); if (!priv->bolero_dais) return -ENOMEM; diff --git a/techpack/audio/asoc/codecs/sdm660_cdc/msm-analog-cdc.c b/techpack/audio/asoc/codecs/sdm660_cdc/msm-analog-cdc.c index abfa4b7e3f44..26827fb00075 100644 --- a/techpack/audio/asoc/codecs/sdm660_cdc/msm-analog-cdc.c +++ b/techpack/audio/asoc/codecs/sdm660_cdc/msm-analog-cdc.c @@ -4313,9 +4313,9 @@ static int msm_anlg_cdc_init_supplies(struct sdm660_cdc_priv *sdm660_cdc, int ret; int i; - sdm660_cdc->supplies = devm_kzalloc(sdm660_cdc->dev, - sizeof(struct regulator_bulk_data) * + sdm660_cdc->supplies = devm_kcalloc(sdm660_cdc->dev, ARRAY_SIZE(pdata->regulator), + sizeof(struct regulator_bulk_data), GFP_KERNEL); if (!sdm660_cdc->supplies) { ret = -ENOMEM; diff --git a/techpack/audio/asoc/msm-dai-slim.c b/techpack/audio/asoc/msm-dai-slim.c index e8bdf13fdc6c..906a86f6b007 100644 --- a/techpack/audio/asoc/msm-dai-slim.c +++ b/techpack/audio/asoc/msm-dai-slim.c @@ -500,8 +500,8 @@ static int msm_dai_slim_populate_dai_data(struct device *dev, SET_DAI_STATE(dai_data_t->status, DAI_STATE_INITIALIZED); - dai_data_t->chan_h = devm_kzalloc(dev, - sizeof(u16) * num_ch, + dai_data_t->chan_h = devm_kcalloc(dev, + num_ch, sizeof(u16), GFP_KERNEL); if (!dai_data_t->chan_h) { dev_err(dev, @@ -511,8 +511,8 @@ static int msm_dai_slim_populate_dai_data(struct device *dev, goto err_mem_alloc; } - dai_data_t->sh_ch = devm_kzalloc(dev, - sizeof(u16) * num_ch, + dai_data_t->sh_ch = devm_kcalloc(dev, + num_ch, sizeof(u16), GFP_KERNEL); if (!dai_data_t->sh_ch) { dev_err(dev, diff --git a/techpack/audio/soc/pinctrl-wcd.c b/techpack/audio/soc/pinctrl-wcd.c index d7695dbe77b8..18881f09d566 100644 --- a/techpack/audio/soc/pinctrl-wcd.c +++ b/techpack/audio/soc/pinctrl-wcd.c @@ -339,7 +339,8 @@ static int wcd_pinctrl_probe(struct platform_device *pdev) goto err_name_alloc; } for (i = 0; i < npins; i++, pindesc++) { - name[i] = devm_kzalloc(dev, sizeof(char) * WCD_GPIO_STRING_LEN, + name[i] = devm_kzalloc(dev, + WCD_GPIO_STRING_LEN, GFP_KERNEL); if (!name[i]) { ret = -ENOMEM;