All of lore.kernel.org
 help / color / mirror / Atom feed
From: Simon Horman <horms@kernel.org>
To: Breno Leitao <leitao@debian.org>
Cc: Kalle Valo <kvalo@kernel.org>, Jeff Johnson <jjohnson@kernel.org>,
	netdev@vger.kernel.org, linux-wireless@vger.kernel.org,
	ath12k@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH wireless-next] wifi: ath12k: allocate dummy net_device dynamically
Date: Sat, 4 May 2024 15:55:23 +0100	[thread overview]
Message-ID: <20240504145523.GC2279@kernel.org> (raw)
In-Reply-To: <20240503100440.6066-1-leitao@debian.org>

On Fri, May 03, 2024 at 03:04:39AM -0700, Breno Leitao wrote:
> Embedding net_device into structures prohibits the usage of flexible
> arrays in the net_device structure. For more details, see the discussion
> at [1].
> 
> Un-embed the net_device from struct ath12k_ext_irq_grp by converting it
> into a pointer. Then use the leverage alloc_netdev_dummy() to allocate
> the net_device object at ath12k_pci_ext_irq_config().
> 
> The free of the device occurs at ath12k_pci_free_ext_irq().
> 
> [1] https://lore.kernel.org/all/20240229225910.79e224cf@kernel.org/
> 
> This is *very* similar to the same changes in ath11k commit
> bca592ead82528b ("wifi: ath11k: allocate dummy net_device dynamically")
> 
> Signed-off-by: Breno Leitao <leitao@debian.org>

...

> diff --git a/drivers/net/wireless/ath/ath12k/pci.c b/drivers/net/wireless/ath/ath12k/pci.c

...

> @@ -577,8 +578,11 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)
>  
>  		irq_grp->ab = ab;
>  		irq_grp->grp_id = i;
> -		init_dummy_netdev(&irq_grp->napi_ndev);
> -		netif_napi_add(&irq_grp->napi_ndev, &irq_grp->napi,
> +		irq_grp->napi_ndev = alloc_netdev_dummy(0);
> +		if (!irq_grp->napi_ndev)
> +			return -ENOMEM;

Hi Breno,

Will returning on error here leak resources allocated by
alloc_netdev_dummy() in previous iterations of this loop?

If so, I suggest jumping to unwind handling which
can be shared with the error path in the hunk below.

> +
> +		netif_napi_add(irq_grp->napi_ndev, &irq_grp->napi,
>  			       ath12k_pci_ext_grp_napi_poll);
>  
>  		if (ab->hw_params->ring_mask->tx[i] ||
> @@ -611,6 +615,10 @@ static int ath12k_pci_ext_irq_config(struct ath12k_base *ab)
>  			if (ret) {
>  				ath12k_err(ab, "failed request irq %d: %d\n",
>  					   vector, ret);
> +				for (n = 0; n <= i; n++) {
> +					irq_grp = &ab->ext_irq_grp[n];
> +					free_netdev(irq_grp->napi_ndev);
> +				}
>  				return ret;
>  			}
>  		}

-- 
pw-client: under-review


  reply	other threads:[~2024-05-04 14:55 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-05-03 10:04 [PATCH wireless-next] wifi: ath12k: allocate dummy net_device dynamically Breno Leitao
2024-05-04 14:55 ` Simon Horman [this message]
2024-05-07 11:47   ` Breno Leitao

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=20240504145523.GC2279@kernel.org \
    --to=horms@kernel.org \
    --cc=ath12k@lists.infradead.org \
    --cc=jjohnson@kernel.org \
    --cc=kvalo@kernel.org \
    --cc=leitao@debian.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=netdev@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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.