Linux RDMA and InfiniBand development
 help / color / mirror / Atom feed
From: Leon Romanovsky <leon@kernel.org>
To: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
Cc: Dennis Dalessandro <dennis.dalessandro@cornelisnetworks.com>,
	Jason Gunthorpe <jgg@ziepe.ca>,
	linux-rdma@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] IB/hfi1: Fix potential leaks in IPoIB TX queue initialization
Date: Sun, 15 Nov 2026 15:55:24 +0200	[thread overview]
Message-ID: <20261115135524.GE42525@unreal> (raw)
In-Reply-To: <20261111-e5624093d6-rdma-hfi1@mail.sdu.edu.cn>

On Wed, Nov 11, 2026 at 08:23:19PM +0800, Guangshuo Li wrote:
> When an SDMA header allocation fails, rollback skips the current TX
> queue. Its ring and already allocated headers are leaked. Free the
> partially initialized ring before unwinding the completed queues.

free_tx_ring already performs that, see "for (j = 0; j < tx_ring_size; j++)"
loop.

Thanks

> 
> This issue was found by our static analysis tool under development.
> 
> Fixes: c874ad879c2f ("IB/hifi1: add a null check of kzalloc_node in hfi1_ipoib_txreq_init")
> Signed-off-by: Guangshuo Li <liguangshuo@mail.sdu.edu.cn>
> ---
>  drivers/infiniband/hw/hfi1/ipoib_tx.c | 6 +++++-
>  1 file changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/infiniband/hw/hfi1/ipoib_tx.c b/drivers/infiniband/hw/hfi1/ipoib_tx.c
> index 8b9cc55db59d..2e9225b558b4 100644
> --- a/drivers/infiniband/hw/hfi1/ipoib_tx.c
> +++ b/drivers/infiniband/hw/hfi1/ipoib_tx.c
> @@ -743,7 +743,7 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv)
>  				kzalloc_node(sizeof(*tx->sdma_hdr),
>  					     GFP_KERNEL, priv->dd->node);
>  			if (!hfi1_txreq_from_idx(tx_ring, j)->sdma_hdr)
> -				goto free_txqs;
> +				goto free_tx_ring;
>  		}
>  
>  		netif_napi_add_tx(dev, &txq->napi, hfi1_ipoib_poll_tx_ring);
> @@ -751,6 +751,10 @@ int hfi1_ipoib_txreq_init(struct hfi1_ipoib_dev_priv *priv)
>  
>  	return 0;
>  
> +free_tx_ring:
> +	while (j--)
> +		kfree(hfi1_txreq_from_idx(tx_ring, j)->sdma_hdr);
> +	kvfree(tx_ring->items);
>  free_txqs:
>  	for (i--; i >= 0; i--) {
>  		struct hfi1_ipoib_txq *txq = &priv->txqs[i];
> 
> base-commit: 6628e7d4c6b25c8d18f1345e3a20d21829aae7e4
> 

      parent reply	other threads:[~2026-11-15 13:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-11-11 12:23 [PATCH] IB/hfi1: Fix potential leaks in IPoIB TX queue initialization Guangshuo Li
2026-11-11 12:35 ` sashiko-bot
2026-11-15 13:55 ` 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=20261115135524.GE42525@unreal \
    --to=leon@kernel.org \
    --cc=dennis.dalessandro@cornelisnetworks.com \
    --cc=jgg@ziepe.ca \
    --cc=liguangshuo@mail.sdu.edu.cn \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-rdma@vger.kernel.org \
    /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