Intel-Wired-Lan Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Lennert Buytenhek <buytenh@wantstofly.org>
To: intel-wired-lan@osuosl.org
Subject: [Intel-wired-lan] [PATCH 3/3 net-next v5] igb/igc: RX queues: fix DMA leak in error case
Date: Tue, 18 Jan 2022 08:01:30 +0200	[thread overview]
Message-ID: <YeZXuoRa/39zzoEY@wantstofly.org> (raw)
In-Reply-To: <20220117182915.1283151-4-vinschen@redhat.com>

On Mon, Jan 17, 2022 at 07:29:15PM +0100, Corinna Vinschen wrote:

> When setting up the rx queues, igb and igc neglect to free DMA memory
> in error case.  Add matching dma_free_coherent calls.
> 
> Signed-off-by: Corinna Vinschen <vinschen@redhat.com>
> ---
>  drivers/net/ethernet/intel/igb/igb_main.c | 1 +
>  drivers/net/ethernet/intel/igc/igc_main.c | 1 +
>  2 files changed, 2 insertions(+)
> 
> diff --git a/drivers/net/ethernet/intel/igb/igb_main.c b/drivers/net/ethernet/intel/igb/igb_main.c
> index cea89d301bfd..343568d4ff7f 100644
> --- a/drivers/net/ethernet/intel/igb/igb_main.c
> +++ b/drivers/net/ethernet/intel/igb/igb_main.c
> @@ -4389,6 +4389,7 @@ int igb_setup_rx_resources(struct igb_ring *rx_ring)
>  	return 0;
>  
>  err:
> +	dma_free_coherent(dev, rx_ring->size, rx_ring->desc, rx_ring->dma);
>  	vfree(rx_ring->rx_buffer_info);
>  	rx_ring->rx_buffer_info = NULL;
>  	dev_err(dev, "Unable to allocate memory for the Rx descriptor ring\n");
> diff --git a/drivers/net/ethernet/intel/igc/igc_main.c b/drivers/net/ethernet/intel/igc/igc_main.c
> index 56ed0f1463e5..f323cec0b74f 100644
> --- a/drivers/net/ethernet/intel/igc/igc_main.c
> +++ b/drivers/net/ethernet/intel/igc/igc_main.c
> @@ -540,6 +540,7 @@ int igc_setup_rx_resources(struct igc_ring *rx_ring)
>  	return 0;
>  
>  err:
> +	dma_free_coherent(dev, rx_ring->size, rx_ring->desc, rx_ring->dma);
>  	vfree(rx_ring->rx_buffer_info);
>  	rx_ring->rx_buffer_info = NULL;
>  	netdev_err(ndev, "Unable to allocate memory for Rx descriptor ring\n");

If the vzalloc() call in igc_setup_rx_resources() fails, and we jump
to 'err' before dma_alloc_coherent() was reached, won't dma_free_coherent()
be called inadvertently here?

  reply	other threads:[~2022-01-18  6:01 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-01-17 18:29 [Intel-wired-lan] [PATCH 0/3 net-next v5] igb/igc: fix XDP registration Corinna Vinschen
2022-01-17 18:29 ` [Intel-wired-lan] [PATCH 1/3 net-next v5] igc: avoid kernel warning when changing RX ring parameters Corinna Vinschen
2022-01-17 18:29 ` [Intel-wired-lan] [PATCH 2/3 net-next v5] igb: refactor XDP registration Corinna Vinschen
2022-01-18 15:05   ` Alexander Lobakin
2022-01-19  6:08     ` Corinna Vinschen
2022-01-17 18:29 ` [Intel-wired-lan] [PATCH 3/3 net-next v5] igb/igc: RX queues: fix DMA leak in error case Corinna Vinschen
2022-01-18  6:01   ` Lennert Buytenhek [this message]
2022-01-18  8:26     ` Corinna Vinschen

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=YeZXuoRa/39zzoEY@wantstofly.org \
    --to=buytenh@wantstofly.org \
    --cc=intel-wired-lan@osuosl.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