From: Leon Romanovsky <leon@kernel.org>
To: Tony Nguyen <anthony.l.nguyen@intel.com>
Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com,
edumazet@google.com,
Martyna Szapar-Mudlaw <martyna.szapar-mudlaw@linux.intel.com>,
netdev@vger.kernel.org, maciej.fijalkowski@intel.com,
magnus.karlsson@intel.com, ast@kernel.org, daniel@iogearbox.net,
hawk@kernel.org, john.fastabend@gmail.com, bpf@vger.kernel.org,
Chandan Kumar Rout <chandanx.rout@intel.com>
Subject: Re: [PATCH net 1/1] ice: Fix missing cleanup routine in the case of partial memory allocation
Date: Wed, 22 Feb 2023 11:22:47 +0200 [thread overview]
Message-ID: <Y/Xe53wd27MaQe6G@unreal> (raw)
In-Reply-To: <20230221191750.1196493-1-anthony.l.nguyen@intel.com>
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
>
prev parent reply other threads:[~2023-02-22 9:23 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
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 message]
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Y/Xe53wd27MaQe6G@unreal \
--to=leon@kernel.org \
--cc=anthony.l.nguyen@intel.com \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=chandanx.rout@intel.com \
--cc=daniel@iogearbox.net \
--cc=davem@davemloft.net \
--cc=edumazet@google.com \
--cc=hawk@kernel.org \
--cc=john.fastabend@gmail.com \
--cc=kuba@kernel.org \
--cc=maciej.fijalkowski@intel.com \
--cc=magnus.karlsson@intel.com \
--cc=martyna.szapar-mudlaw@linux.intel.com \
--cc=netdev@vger.kernel.org \
--cc=pabeni@redhat.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).