Skip to content

Commit 834d3cd

Browse files
committed
Kees writes: "Fix open-coded multiplication arguments to allocators - Fixes several new open-coded multiplications added in the 4.19 merge window." * tag 'alloc-args-v4.19-rc8' of https://git.kernel.org/pub/scm/linux/kernel/git/kees/linux: treewide: Replace more open-coded allocation size multiplications
2 parents 9f203e2 + 329e098 commit 834d3cd

10 files changed

Lines changed: 22 additions & 19 deletions

File tree

‎drivers/bluetooth/hci_qca.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1322,7 +1322,7 @@ static int qca_init_regulators(struct qca_power *qca,
13221322
{
13231323
int i;
13241324

1325-
qca->vreg_bulk = devm_kzalloc(qca->dev, num_vregs *
1325+
qca->vreg_bulk = devm_kcalloc(qca->dev, num_vregs,
13261326
sizeof(struct regulator_bulk_data),
13271327
GFP_KERNEL);
13281328
if (!qca->vreg_bulk)

‎drivers/crypto/inside-secure/safexcel.c‎

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1044,7 +1044,8 @@ static int safexcel_probe(struct platform_device *pdev)
10441044

10451045
safexcel_configure(priv);
10461046

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

1066-
priv->ring[i].rdr_req = devm_kzalloc(dev,
1067-
sizeof(priv->ring[i].rdr_req) * EIP197_DEFAULT_RING_SIZE,
1067+
priv->ring[i].rdr_req = devm_kcalloc(dev,
1068+
EIP197_DEFAULT_RING_SIZE,
1069+
sizeof(priv->ring[i].rdr_req),
10681070
GFP_KERNEL);
10691071
if (!priv->ring[i].rdr_req) {
10701072
ret = -ENOMEM;

‎drivers/gpu/drm/mediatek/mtk_drm_crtc.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ int mtk_drm_crtc_create(struct drm_device *drm_dev,
600600
}
601601

602602
mtk_crtc->layer_nr = mtk_ddp_comp_layer_nr(mtk_crtc->ddp_comp[0]);
603-
mtk_crtc->planes = devm_kzalloc(dev, mtk_crtc->layer_nr *
603+
mtk_crtc->planes = devm_kcalloc(dev, mtk_crtc->layer_nr,
604604
sizeof(struct drm_plane),
605605
GFP_KERNEL);
606606

‎drivers/gpu/drm/msm/disp/dpu1/dpu_io_util.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,8 +153,8 @@ int msm_dss_parse_clock(struct platform_device *pdev,
153153
return 0;
154154
}
155155

156-
mp->clk_config = devm_kzalloc(&pdev->dev,
157-
sizeof(struct dss_clk) * num_clk,
156+
mp->clk_config = devm_kcalloc(&pdev->dev,
157+
num_clk, sizeof(struct dss_clk),
158158
GFP_KERNEL);
159159
if (!mp->clk_config)
160160
return -ENOMEM;

‎drivers/hwmon/npcm750-pwm-fan.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -908,7 +908,7 @@ static int npcm7xx_en_pwm_fan(struct device *dev,
908908
if (fan_cnt < 1)
909909
return -EINVAL;
910910

911-
fan_ch = devm_kzalloc(dev, sizeof(*fan_ch) * fan_cnt, GFP_KERNEL);
911+
fan_ch = devm_kcalloc(dev, fan_cnt, sizeof(*fan_ch), GFP_KERNEL);
912912
if (!fan_ch)
913913
return -ENOMEM;
914914

‎drivers/md/dm-integrity.c‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3462,7 +3462,8 @@ static int dm_integrity_ctr(struct dm_target *ti, unsigned argc, char **argv)
34623462
r = -ENOMEM;
34633463
goto bad;
34643464
}
3465-
ic->recalc_tags = kvmalloc((RECALC_SECTORS >> ic->sb->log2_sectors_per_block) * ic->tag_size, GFP_KERNEL);
3465+
ic->recalc_tags = kvmalloc_array(RECALC_SECTORS >> ic->sb->log2_sectors_per_block,
3466+
ic->tag_size, GFP_KERNEL);
34663467
if (!ic->recalc_tags) {
34673468
ti->error = "Cannot allocate tags for recalculating";
34683469
r = -ENOMEM;

‎drivers/net/wireless/mediatek/mt76/usb.c‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ int mt76u_buf_alloc(struct mt76_dev *dev, struct mt76u_buf *buf,
258258
if (!buf->urb)
259259
return -ENOMEM;
260260

261-
buf->urb->sg = devm_kzalloc(dev->dev, nsgs * sizeof(*buf->urb->sg),
261+
buf->urb->sg = devm_kcalloc(dev->dev, nsgs, sizeof(*buf->urb->sg),
262262
gfp);
263263
if (!buf->urb->sg)
264264
return -ENOMEM;
@@ -464,8 +464,8 @@ static int mt76u_alloc_rx(struct mt76_dev *dev)
464464
int i, err, nsgs;
465465

466466
spin_lock_init(&q->lock);
467-
q->entry = devm_kzalloc(dev->dev,
468-
MT_NUM_RX_ENTRIES * sizeof(*q->entry),
467+
q->entry = devm_kcalloc(dev->dev,
468+
MT_NUM_RX_ENTRIES, sizeof(*q->entry),
469469
GFP_KERNEL);
470470
if (!q->entry)
471471
return -ENOMEM;
@@ -717,8 +717,8 @@ static int mt76u_alloc_tx(struct mt76_dev *dev)
717717
INIT_LIST_HEAD(&q->swq);
718718
q->hw_idx = q2hwq(i);
719719

720-
q->entry = devm_kzalloc(dev->dev,
721-
MT_NUM_TX_ENTRIES * sizeof(*q->entry),
720+
q->entry = devm_kcalloc(dev->dev,
721+
MT_NUM_TX_ENTRIES, sizeof(*q->entry),
722722
GFP_KERNEL);
723723
if (!q->entry)
724724
return -ENOMEM;

‎drivers/pci/controller/pcie-cadence.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,11 +180,11 @@ int cdns_pcie_init_phy(struct device *dev, struct cdns_pcie *pcie)
180180
return 0;
181181
}
182182

183-
phy = devm_kzalloc(dev, sizeof(*phy) * phy_count, GFP_KERNEL);
183+
phy = devm_kcalloc(dev, phy_count, sizeof(*phy), GFP_KERNEL);
184184
if (!phy)
185185
return -ENOMEM;
186186

187-
link = devm_kzalloc(dev, sizeof(*link) * phy_count, GFP_KERNEL);
187+
link = devm_kcalloc(dev, phy_count, sizeof(*link), GFP_KERNEL);
188188
if (!link)
189189
return -ENOMEM;
190190

‎drivers/tty/serial/qcom_geni_serial.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -868,8 +868,8 @@ static int qcom_geni_serial_port_setup(struct uart_port *uport)
868868
geni_se_init(&port->se, port->rx_wm, port->rx_rfr);
869869
geni_se_select_mode(&port->se, port->xfer_mode);
870870
if (!uart_console(uport)) {
871-
port->rx_fifo = devm_kzalloc(uport->dev,
872-
port->rx_fifo_depth * sizeof(u32), GFP_KERNEL);
871+
port->rx_fifo = devm_kcalloc(uport->dev,
872+
port->rx_fifo_depth, sizeof(u32), GFP_KERNEL);
873873
if (!port->rx_fifo)
874874
return -ENOMEM;
875875
}

‎net/sched/sch_cake.c‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2644,7 +2644,7 @@ static int cake_init(struct Qdisc *sch, struct nlattr *opt,
26442644
for (i = 1; i <= CAKE_QUEUES; i++)
26452645
quantum_div[i] = 65535 / i;
26462646

2647-
q->tins = kvzalloc(CAKE_MAX_TINS * sizeof(struct cake_tin_data),
2647+
q->tins = kvcalloc(CAKE_MAX_TINS, sizeof(struct cake_tin_data),
26482648
GFP_KERNEL);
26492649
if (!q->tins)
26502650
goto nomem;

0 commit comments

Comments
 (0)