* [PATCH net 1/1] ice: Fix missing cleanup routine in the case of partial memory allocation
@ 2023-02-21 19:17 Tony Nguyen
2023-02-22 9:22 ` Leon Romanovsky
0 siblings, 1 reply; 2+ messages in thread
From: Tony Nguyen @ 2023-02-21 19:17 UTC (permalink / raw)
To: davem, kuba, pabeni, edumazet
Cc: Martyna Szapar-Mudlaw, netdev, anthony.l.nguyen,
maciej.fijalkowski, magnus.karlsson, ast, daniel, hawk,
john.fastabend, bpf, Chandan Kumar Rout
From: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Add missing memory free in the case of partial memory allocation
in the loop in ice_realloc_zc_buf function.
Fixes: 7e753eb675f0 ("ice: Fix DMA mappings leak")
Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
drivers/net/ethernet/intel/ice/ice_xsk.c | 10 +++++++++-
1 file changed, 9 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 374b7f10b549..9ec02f80a2cf 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -377,8 +377,16 @@ int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc)
for_each_set_bit(q, vsi->af_xdp_zc_qps,
max_t(int, vsi->alloc_txq, vsi->alloc_rxq)) {
rx_ring = vsi->rx_rings[q];
- if (ice_realloc_rx_xdp_bufs(rx_ring, zc))
+ if (ice_realloc_rx_xdp_bufs(rx_ring, zc)) {
+ unsigned long qid = q;
+
+ for_each_set_bit(q, vsi->af_xdp_zc_qps, qid) {
+ rx_ring = vsi->rx_rings[q];
+ zc ? kfree(rx_ring->xdp_buf) :
+ kfree(rx_ring->rx_buf);
+ }
return -ENOMEM;
+ }
}
return 0;
--
2.38.1
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH net 1/1] ice: Fix missing cleanup routine in the case of partial memory allocation
2023-02-21 19:17 [PATCH net 1/1] ice: Fix missing cleanup routine in the case of partial memory allocation Tony Nguyen
@ 2023-02-22 9:22 ` Leon Romanovsky
0 siblings, 0 replies; 2+ messages in thread
From: Leon Romanovsky @ 2023-02-22 9:22 UTC (permalink / raw)
To: Tony Nguyen
Cc: davem, kuba, pabeni, edumazet, Martyna Szapar-Mudlaw, netdev,
maciej.fijalkowski, magnus.karlsson, ast, daniel, hawk,
john.fastabend, bpf, Chandan Kumar Rout
On Tue, Feb 21, 2023 at 11:17:50AM -0800, Tony Nguyen wrote:
> From: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
>
> Add missing memory free in the case of partial memory allocation
> in the loop in ice_realloc_zc_buf function.
I don't think that this is correct behaviour for realloc function to
free memory of caller just because target allocation failed.
It should be done in upper level.
Thanks
>
> Fixes: 7e753eb675f0 ("ice: Fix DMA mappings leak")
> Signed-off-by: Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>
> Reviewed-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
> Tested-by: Chandan Kumar Rout <chandanx.rout@intel.com> (A Contingent Worker at Intel)
> Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
> ---
> drivers/net/ethernet/intel/ice/ice_xsk.c | 10 +++++++++-
> 1 file changed, 9 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
> index 374b7f10b549..9ec02f80a2cf 100644
> --- a/drivers/net/ethernet/intel/ice/ice_xsk.c
> +++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
> @@ -377,8 +377,16 @@ int ice_realloc_zc_buf(struct ice_vsi *vsi, bool zc)
> for_each_set_bit(q, vsi->af_xdp_zc_qps,
> max_t(int, vsi->alloc_txq, vsi->alloc_rxq)) {
> rx_ring = vsi->rx_rings[q];
> - if (ice_realloc_rx_xdp_bufs(rx_ring, zc))
> + if (ice_realloc_rx_xdp_bufs(rx_ring, zc)) {
> + unsigned long qid = q;
> +
> + for_each_set_bit(q, vsi->af_xdp_zc_qps, qid) {
> + rx_ring = vsi->rx_rings[q];
> + zc ? kfree(rx_ring->xdp_buf) :
> + kfree(rx_ring->rx_buf);
> + }
> return -ENOMEM;
> + }
> }
>
> return 0;
> --
> 2.38.1
>
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2023-02-22 9:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2023-02-21 19:17 [PATCH net 1/1] ice: Fix missing cleanup routine in the case of partial memory allocation Tony Nguyen
2023-02-22 9:22 ` Leon Romanovsky
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).