* [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config
@ 2024-05-08 18:59 Breno Leitao
2024-05-10 11:56 ` Simon Horman
` (2 more replies)
0 siblings, 3 replies; 5+ messages in thread
From: Breno Leitao @ 2024-05-08 18:59 UTC (permalink / raw
To: horms, Kalle Valo, Jeff Johnson, David S. Miller
Cc: netdev, open list:NETWORKING DRIVERS (WIRELESS),
open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER, open list
If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(),
the previous allocated devices might leak due to returning without
deallocating the devices.
Instead of returning on the error path, deallocate all the previously
allocated net_devices and then return.
Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically")
Signed-off-by: Breno Leitao <leitao@debian.org>
---
drivers/net/wireless/ath/ath11k/pcic.c | 25 +++++++++++++++++--------
1 file changed, 17 insertions(+), 8 deletions(-)
diff --git a/drivers/net/wireless/ath/ath11k/pcic.c b/drivers/net/wireless/ath/ath11k/pcic.c
index 79eb3f9c902f..debe7c5919ef 100644
--- a/drivers/net/wireless/ath/ath11k/pcic.c
+++ b/drivers/net/wireless/ath/ath11k/pcic.c
@@ -561,6 +561,7 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab)
{
int i, j, n, ret, num_vectors = 0;
u32 user_base_data = 0, base_vector = 0;
+ struct ath11k_ext_irq_grp *irq_grp;
unsigned long irq_flags;
ret = ath11k_pcic_get_user_msi_assignment(ab, "DP", &num_vectors,
@@ -574,14 +575,16 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab)
irq_flags |= IRQF_NOBALANCING;
for (i = 0; i < ATH11K_EXT_IRQ_GRP_NUM_MAX; i++) {
- struct ath11k_ext_irq_grp *irq_grp = &ab->ext_irq_grp[i];
+ irq_grp = &ab->ext_irq_grp[i];
u32 num_irq = 0;
irq_grp->ab = ab;
irq_grp->grp_id = i;
irq_grp->napi_ndev = alloc_netdev_dummy(0);
- if (!irq_grp->napi_ndev)
- return -ENOMEM;
+ if (!irq_grp->napi_ndev) {
+ ret = -ENOMEM;
+ goto fail_allocate;
+ }
netif_napi_add(irq_grp->napi_ndev, &irq_grp->napi,
ath11k_pcic_ext_grp_napi_poll);
@@ -606,11 +609,8 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab)
int irq = ath11k_pcic_get_msi_irq(ab, vector);
if (irq < 0) {
- for (n = 0; n <= i; n++) {
- irq_grp = &ab->ext_irq_grp[n];
- free_netdev(irq_grp->napi_ndev);
- }
- return irq;
+ ret = irq;
+ goto fail_irq;
}
ab->irq_num[irq_idx] = irq;
@@ -635,6 +635,15 @@ static int ath11k_pcic_ext_irq_config(struct ath11k_base *ab)
}
return 0;
+fail_irq:
+ /* i ->napi_ndev was properly allocated. Free it also */
+ i += 1;
+fail_allocate:
+ for (n = 0; n < i; n++) {
+ irq_grp = &ab->ext_irq_grp[n];
+ free_netdev(irq_grp->napi_ndev);
+ }
+ return ret;
}
int ath11k_pcic_config_irq(struct ath11k_base *ab)
--
2.43.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config
2024-05-08 18:59 [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config Breno Leitao
@ 2024-05-10 11:56 ` Simon Horman
2024-05-14 13:24 ` Kalle Valo
2024-05-17 6:55 ` Kalle Valo
2 siblings, 0 replies; 5+ messages in thread
From: Simon Horman @ 2024-05-10 11:56 UTC (permalink / raw
To: Breno Leitao
Cc: Kalle Valo, Jeff Johnson, David S. Miller, netdev,
open list:NETWORKING DRIVERS (WIRELESS),
open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER, open list
On Wed, May 08, 2024 at 11:59:01AM -0700, Breno Leitao wrote:
> If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(),
> the previous allocated devices might leak due to returning without
> deallocating the devices.
>
> Instead of returning on the error path, deallocate all the previously
> allocated net_devices and then return.
>
> Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically")
> Signed-off-by: Breno Leitao <leitao@debian.org>
Reviewed-by: Simon Horman <horms@kernel.org>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config
2024-05-08 18:59 [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config Breno Leitao
2024-05-10 11:56 ` Simon Horman
@ 2024-05-14 13:24 ` Kalle Valo
2024-05-14 13:51 ` Jakub Kicinski
2024-05-17 6:55 ` Kalle Valo
2 siblings, 1 reply; 5+ messages in thread
From: Kalle Valo @ 2024-05-14 13:24 UTC (permalink / raw
To: Breno Leitao
Cc: horms, Jeff Johnson, David S. Miller, netdev,
open list:NETWORKING DRIVERS (WIRELESS),
open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER, open list
Breno Leitao <leitao@debian.org> wrote:
> If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(),
> the previous allocated devices might leak due to returning without
> deallocating the devices.
>
> Instead of returning on the error path, deallocate all the previously
> allocated net_devices and then return.
>
> Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Reviewed-by: Simon Horman <horms@kernel.org>
As commit bca592ead825 is in net-next I think this patch needs to go to v6.10, right?
--
https://patchwork.kernel.org/project/linux-wireless/patch/20240508185902.70975-1-leitao@debian.org/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config
2024-05-14 13:24 ` Kalle Valo
@ 2024-05-14 13:51 ` Jakub Kicinski
0 siblings, 0 replies; 5+ messages in thread
From: Jakub Kicinski @ 2024-05-14 13:51 UTC (permalink / raw
To: Kalle Valo
Cc: Breno Leitao, horms, Jeff Johnson, David S. Miller, netdev,
open list:NETWORKING DRIVERS (WIRELESS),
open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER, open list
On Tue, 14 May 2024 13:24:28 +0000 (UTC) Kalle Valo wrote:
> > If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(),
> > the previous allocated devices might leak due to returning without
> > deallocating the devices.
> >
> > Instead of returning on the error path, deallocate all the previously
> > allocated net_devices and then return.
> >
> > Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically")
> > Signed-off-by: Breno Leitao <leitao@debian.org>
> > Reviewed-by: Simon Horman <horms@kernel.org>
>
> As commit bca592ead825 is in net-next I think this patch needs to go to v6.10, right?
There's no rush, FWIW, we can pick up the conversion after the merge
window.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config
2024-05-08 18:59 [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config Breno Leitao
2024-05-10 11:56 ` Simon Horman
2024-05-14 13:24 ` Kalle Valo
@ 2024-05-17 6:55 ` Kalle Valo
2 siblings, 0 replies; 5+ messages in thread
From: Kalle Valo @ 2024-05-17 6:55 UTC (permalink / raw
To: Breno Leitao
Cc: horms, Jeff Johnson, David S. Miller, netdev,
open list:NETWORKING DRIVERS (WIRELESS),
open list:QUALCOMM ATHEROS ATH11K WIRELESS DRIVER, open list
Breno Leitao <leitao@debian.org> wrote:
> If one of the dummy allocation fails in ath11k_pcic_ext_irq_config(),
> the previous allocated devices might leak due to returning without
> deallocating the devices.
>
> Instead of returning on the error path, deallocate all the previously
> allocated net_devices and then return.
>
> Fixes: bca592ead825 ("wifi: ath11k: allocate dummy net_device dynamically")
> Signed-off-by: Breno Leitao <leitao@debian.org>
> Reviewed-by: Simon Horman <horms@kernel.org>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Patch applied to ath-current branch of ath.git, thanks.
637c435f08ea wifi: ath11k: Fix error path in ath11k_pcic_ext_irq_config
--
https://patchwork.kernel.org/project/linux-wireless/patch/20240508185902.70975-1-leitao@debian.org/
https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches
^ permalink raw reply [flat|nested] 5+ messages in thread
end of thread, other threads:[~2024-05-17 6:55 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-05-08 18:59 [PATCH wireless-next] ath11k: Fix error path in ath11k_pcic_ext_irq_config Breno Leitao
2024-05-10 11:56 ` Simon Horman
2024-05-14 13:24 ` Kalle Valo
2024-05-14 13:51 ` Jakub Kicinski
2024-05-17 6:55 ` Kalle Valo
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 read-only IMAP folder(s) and NNTP newsgroup(s).