2021-10-06 18:06:19

by Gustavo A. R. Silva

[permalink] [raw]
Subject: [PATCH][next] ice: use devm_kcalloc() instead of devm_kzalloc()

Use 2-factor multiplication argument form devm_kcalloc() instead
of devm_kzalloc().

Link: https://github.com/KSPP/linux/issues/162
Signed-off-by: Gustavo A. R. Silva <[email protected]>
---
drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c | 4 ++--
drivers/net/ethernet/intel/ice/ice_txrx.c | 4 ++--
2 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c b/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c
index 16de603b280c..38960bcc384c 100644
--- a/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c
+++ b/drivers/net/ethernet/intel/ice/ice_ethtool_fdir.c
@@ -706,7 +706,7 @@ ice_create_init_fdir_rule(struct ice_pf *pf, enum ice_fltr_ptype flow)
if (!seg)
return -ENOMEM;

- tun_seg = devm_kzalloc(dev, sizeof(*seg) * ICE_FD_HW_SEG_MAX,
+ tun_seg = devm_kcalloc(dev, sizeof(*seg), ICE_FD_HW_SEG_MAX,
GFP_KERNEL);
if (!tun_seg) {
devm_kfree(dev, seg);
@@ -1068,7 +1068,7 @@ ice_cfg_fdir_xtrct_seq(struct ice_pf *pf, struct ethtool_rx_flow_spec *fsp,
if (!seg)
return -ENOMEM;

- tun_seg = devm_kzalloc(dev, sizeof(*seg) * ICE_FD_HW_SEG_MAX,
+ tun_seg = devm_kcalloc(dev, sizeof(*seg), ICE_FD_HW_SEG_MAX,
GFP_KERNEL);
if (!tun_seg) {
devm_kfree(dev, seg);
diff --git a/drivers/net/ethernet/intel/ice/ice_txrx.c b/drivers/net/ethernet/intel/ice/ice_txrx.c
index 13b2bdc25b0d..fd10f8548feb 100644
--- a/drivers/net/ethernet/intel/ice/ice_txrx.c
+++ b/drivers/net/ethernet/intel/ice/ice_txrx.c
@@ -340,7 +340,7 @@ int ice_setup_tx_ring(struct ice_ring *tx_ring)
/* warn if we are about to overwrite the pointer */
WARN_ON(tx_ring->tx_buf);
tx_ring->tx_buf =
- devm_kzalloc(dev, sizeof(*tx_ring->tx_buf) * tx_ring->count,
+ devm_kcalloc(dev, sizeof(*tx_ring->tx_buf), tx_ring->count,
GFP_KERNEL);
if (!tx_ring->tx_buf)
return -ENOMEM;
@@ -464,7 +464,7 @@ int ice_setup_rx_ring(struct ice_ring *rx_ring)
/* warn if we are about to overwrite the pointer */
WARN_ON(rx_ring->rx_buf);
rx_ring->rx_buf =
- devm_kzalloc(dev, sizeof(*rx_ring->rx_buf) * rx_ring->count,
+ devm_kcalloc(dev, sizeof(*rx_ring->rx_buf), rx_ring->count,
GFP_KERNEL);
if (!rx_ring->rx_buf)
return -ENOMEM;
--
2.27.0


2021-10-21 17:10:50

by Kees Cook

[permalink] [raw]
Subject: Re: [PATCH][next] ice: use devm_kcalloc() instead of devm_kzalloc()

On Wed, Oct 06, 2021 at 01:09:08PM -0500, Gustavo A. R. Silva wrote:
> Use 2-factor multiplication argument form devm_kcalloc() instead
> of devm_kzalloc().
>
> Link: https://github.com/KSPP/linux/issues/162
> Signed-off-by: Gustavo A. R. Silva <[email protected]>

Reviewed-by: Kees Cook <[email protected]>

Similar patch state here, it seems? Who needs to Ack this?
https://patchwork.kernel.org/project/netdevbpf/patch/20211006180908.GA913430@embeddedor/

Thanks!

--
Kees Cook

2021-10-21 17:38:34

by Tony Nguyen

[permalink] [raw]
Subject: Re: [PATCH][next] ice: use devm_kcalloc() instead of devm_kzalloc()

On Thu, 2021-10-21 at 10:05 -0700, Kees Cook wrote:
> On Wed, Oct 06, 2021 at 01:09:08PM -0500, Gustavo A. R. Silva wrote:
> > Use 2-factor multiplication argument form devm_kcalloc() instead
> > of devm_kzalloc().
> >
> > Link: https://github.com/KSPP/linux/issues/162
> > Signed-off-by: Gustavo A. R. Silva <[email protected]>
>
> Reviewed-by: Kees Cook <[email protected]>
>
> Similar patch state here, it seems? Who needs to Ack this?
> https://patchwork.kernel.org/project/netdevbpf/patch/20211006180908.GA913430@embeddedor/

It was reviewed/ack'd and recently accepted here:
https://patchwork.kernel.org/project/netdevbpf/patch/[email protected]/

Thanks,
Tony