mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures
@ 2026-07-18  7:40 Guangshuo Li
  2026-07-18  7:40 ` [PATCH v3 1/2] wifi: ath11k: release QMI handle " Guangshuo Li
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-07-18  7:40 UTC (permalink / raw)
  To: Jeff Johnson, Pradeep Kumar Chitrapu, Vasanthakumar Thiagarajan,
	Sathishkumar Muruganandam, Anilkumar Kolli, Ganesh Sesetti,
	Baochen Qiang, linux-wireless, ath11k, linux-kernel, ath12k
  Cc: Guangshuo Li

This series fixes QMI handle leaks in the late initialization failure
paths of ath11k and ath12k.

Both drivers initialize the QMI handle before allocating the QMI event
workqueue and registering the service lookup. If either of these later
steps fails, the initialized QMI handle is not released.

Patch 1 fixes the leak in ath11k.

Patch 2 fixes the leak in ath12k and sets ab->qmi.ab only after QMI
service initialization completes successfully.

v3:
  - Split the ath11k and ath12k changes into separate patches, as
    requested by Jeff Johnson.

v2:
  - Set ath12k ab->qmi.ab only after QMI service initialization succeeds,
    as suggested by Baochen Qiang.
  - Fix the same late initialization QMI handle leak in ath11k, as
    suggested by Vasanthakumar Thiagarajan.
  - Drop the Reviewed-by tag due to the code changes.

Guangshuo Li (2):
  wifi: ath11k: release QMI handle on late init failures
  wifi: ath12k: release QMI handle on late init failures

 drivers/net/wireless/ath/ath11k/qmi.c | 10 ++++++++--
 drivers/net/wireless/ath/ath12k/qmi.c | 13 ++++++++++---
 2 files changed, 18 insertions(+), 5 deletions(-)

-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 1/2] wifi: ath11k: release QMI handle on late init failures
  2026-07-18  7:40 [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures Guangshuo Li
@ 2026-07-18  7:40 ` Guangshuo Li
  2026-07-24  1:02   ` Jeff Johnson
  2026-07-18  7:40 ` [PATCH v3 2/2] wifi: ath12k: " Guangshuo Li
  2026-07-20  2:20 ` [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles " Baochen Qiang
  2 siblings, 1 reply; 5+ messages in thread
From: Guangshuo Li @ 2026-07-18  7:40 UTC (permalink / raw)
  To: Jeff Johnson, Pradeep Kumar Chitrapu, Vasanthakumar Thiagarajan,
	Sathishkumar Muruganandam, Anilkumar Kolli, Ganesh Sesetti,
	Baochen Qiang, linux-wireless, ath11k, linux-kernel, ath12k
  Cc: Guangshuo Li

ath11k_qmi_init_service() initializes the QMI handle before allocating
the QMI event workqueue and registering the service lookup.

If either of these later initialization steps fails, the function
returns without releasing the initialized QMI handle, leaking its
resources.

Release the QMI handle on the late failure paths.

Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/net/wireless/ath/ath11k/qmi.c | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
index 410a7ee076a0..6e3f82169d24 100644
--- a/drivers/net/wireless/ath/ath11k/qmi.c
+++ b/drivers/net/wireless/ath/ath11k/qmi.c
@@ -3329,7 +3329,8 @@ int ath11k_qmi_init_service(struct ath11k_base *ab)
 	ab->qmi.event_wq = alloc_ordered_workqueue("ath11k_qmi_driver_event", 0);
 	if (!ab->qmi.event_wq) {
 		ath11k_err(ab, "failed to allocate workqueue\n");
-		return -EFAULT;
+		ret = -EFAULT;
+		goto err_release_qmi_handle;
 	}
 
 	INIT_LIST_HEAD(&ab->qmi.event_list);
@@ -3342,9 +3343,14 @@ int ath11k_qmi_init_service(struct ath11k_base *ab)
 	if (ret < 0) {
 		ath11k_warn(ab, "failed to add qmi lookup: %d\n", ret);
 		destroy_workqueue(ab->qmi.event_wq);
-		return ret;
+		goto err_release_qmi_handle;
 	}
 
+	return ret;
+
+err_release_qmi_handle:
+	qmi_handle_release(&ab->qmi.handle);
+
 	return ret;
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* [PATCH v3 2/2] wifi: ath12k: release QMI handle on late init failures
  2026-07-18  7:40 [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures Guangshuo Li
  2026-07-18  7:40 ` [PATCH v3 1/2] wifi: ath11k: release QMI handle " Guangshuo Li
@ 2026-07-18  7:40 ` Guangshuo Li
  2026-07-20  2:20 ` [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles " Baochen Qiang
  2 siblings, 0 replies; 5+ messages in thread
From: Guangshuo Li @ 2026-07-18  7:40 UTC (permalink / raw)
  To: Jeff Johnson, Pradeep Kumar Chitrapu, Vasanthakumar Thiagarajan,
	Sathishkumar Muruganandam, Anilkumar Kolli, Ganesh Sesetti,
	Baochen Qiang, linux-wireless, ath11k, linux-kernel, ath12k
  Cc: Guangshuo Li

ath12k_qmi_init_service() initializes the QMI handle before allocating
the QMI event workqueue and registering the service lookup.

If either of these later initialization steps fails, the function
returns without releasing the initialized QMI handle. Since the failed
device is skipped by the hardware group rollback path, the handle is
leaked.

Release the QMI handle on the late failure paths.

ath12k_qmi_deinit_service() uses ab->qmi.ab to determine whether QMI
service initialization completed successfully. Set it only after all
initialization steps succeed.

Fixes: 088a099690e4 ("wifi: ath12k: fix error handling in creating hardware group")
Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
---
 drivers/net/wireless/ath/ath12k/qmi.c | 13 ++++++++++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/wireless/ath/ath12k/qmi.c b/drivers/net/wireless/ath/ath12k/qmi.c
index fd762b5d7bb5..692f1b2c2031 100644
--- a/drivers/net/wireless/ath/ath12k/qmi.c
+++ b/drivers/net/wireless/ath/ath12k/qmi.c
@@ -4041,7 +4041,6 @@ int ath12k_qmi_init_service(struct ath12k_base *ab)
 
 	memset(&ab->qmi.target, 0, sizeof(struct target_info));
 	memset(&ab->qmi.target_mem, 0, sizeof(struct target_mem_chunk));
-	ab->qmi.ab = ab;
 
 	ab->qmi.target_mem_mode = ab->target_mem_mode;
 	ret = qmi_handle_init(&ab->qmi.handle, ATH12K_QMI_RESP_LEN_MAX,
@@ -4054,7 +4053,8 @@ int ath12k_qmi_init_service(struct ath12k_base *ab)
 	ab->qmi.event_wq = alloc_ordered_workqueue("ath12k_qmi_driver_event", 0);
 	if (!ab->qmi.event_wq) {
 		ath12k_err(ab, "failed to allocate workqueue\n");
-		return -EFAULT;
+		ret = -EFAULT;
+		goto err_release_qmi_handle;
 	}
 
 	INIT_LIST_HEAD(&ab->qmi.event_list);
@@ -4067,9 +4067,16 @@ int ath12k_qmi_init_service(struct ath12k_base *ab)
 	if (ret < 0) {
 		ath12k_warn(ab, "failed to add qmi lookup\n");
 		destroy_workqueue(ab->qmi.event_wq);
-		return ret;
+		goto err_release_qmi_handle;
 	}
 
+	ab->qmi.ab = ab;
+
+	return ret;
+
+err_release_qmi_handle:
+	qmi_handle_release(&ab->qmi.handle);
+
 	return ret;
 }
 
-- 
2.43.0


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures
  2026-07-18  7:40 [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures Guangshuo Li
  2026-07-18  7:40 ` [PATCH v3 1/2] wifi: ath11k: release QMI handle " Guangshuo Li
  2026-07-18  7:40 ` [PATCH v3 2/2] wifi: ath12k: " Guangshuo Li
@ 2026-07-20  2:20 ` Baochen Qiang
  2 siblings, 0 replies; 5+ messages in thread
From: Baochen Qiang @ 2026-07-20  2:20 UTC (permalink / raw)
  To: Guangshuo Li, Jeff Johnson, Pradeep Kumar Chitrapu,
	Vasanthakumar Thiagarajan, Sathishkumar Muruganandam,
	Anilkumar Kolli, Ganesh Sesetti, linux-wireless, ath11k,
	linux-kernel, ath12k



On 7/18/2026 3:40 PM, Guangshuo Li wrote:
> This series fixes QMI handle leaks in the late initialization failure
> paths of ath11k and ath12k.
> 
> Both drivers initialize the QMI handle before allocating the QMI event
> workqueue and registering the service lookup. If either of these later
> steps fails, the initialized QMI handle is not released.
> 
> Patch 1 fixes the leak in ath11k.
> 
> Patch 2 fixes the leak in ath12k and sets ab->qmi.ab only after QMI
> service initialization completes successfully.
> 
> v3:
>   - Split the ath11k and ath12k changes into separate patches, as
>     requested by Jeff Johnson.
> 
> v2:
>   - Set ath12k ab->qmi.ab only after QMI service initialization succeeds,
>     as suggested by Baochen Qiang.
>   - Fix the same late initialization QMI handle leak in ath11k, as
>     suggested by Vasanthakumar Thiagarajan.
>   - Drop the Reviewed-by tag due to the code changes.
> 
> Guangshuo Li (2):
>   wifi: ath11k: release QMI handle on late init failures
>   wifi: ath12k: release QMI handle on late init failures
> 
>  drivers/net/wireless/ath/ath11k/qmi.c | 10 ++++++++--
>  drivers/net/wireless/ath/ath12k/qmi.c | 13 ++++++++++---
>  2 files changed, 18 insertions(+), 5 deletions(-)
> 

Reviewed-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com>


^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: [PATCH v3 1/2] wifi: ath11k: release QMI handle on late init failures
  2026-07-18  7:40 ` [PATCH v3 1/2] wifi: ath11k: release QMI handle " Guangshuo Li
@ 2026-07-24  1:02   ` Jeff Johnson
  0 siblings, 0 replies; 5+ messages in thread
From: Jeff Johnson @ 2026-07-24  1:02 UTC (permalink / raw)
  To: Guangshuo Li, Jeff Johnson, Baochen Qiang, linux-wireless,
	ath11k, linux-kernel, ath12k

On 7/18/2026 12:40 AM, Guangshuo Li wrote:

(dropping obsolete @quicinc.com and @codeaurora.org e-mail addresses)

> ath11k_qmi_init_service() initializes the QMI handle before allocating
> the QMI event workqueue and registering the service lookup.
> 
> If either of these later initialization steps fails, the function
> returns without releasing the initialized QMI handle, leaking its
> resources.
> 
> Release the QMI handle on the late failure paths.
> 
> Fixes: d5c65159f289 ("ath11k: driver for Qualcomm IEEE 802.11ax devices")
> Signed-off-by: Guangshuo Li <lgs201920130244@gmail.com>
> ---
>  drivers/net/wireless/ath/ath11k/qmi.c | 10 ++++++++--
>  1 file changed, 8 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/net/wireless/ath/ath11k/qmi.c b/drivers/net/wireless/ath/ath11k/qmi.c
> index 410a7ee076a0..6e3f82169d24 100644
> --- a/drivers/net/wireless/ath/ath11k/qmi.c
> +++ b/drivers/net/wireless/ath/ath11k/qmi.c
> @@ -3329,7 +3329,8 @@ int ath11k_qmi_init_service(struct ath11k_base *ab)
>  	ab->qmi.event_wq = alloc_ordered_workqueue("ath11k_qmi_driver_event", 0);
>  	if (!ab->qmi.event_wq) {
>  		ath11k_err(ab, "failed to allocate workqueue\n");
> -		return -EFAULT;
> +		ret = -EFAULT;
> +		goto err_release_qmi_handle;
>  	}
>  
>  	INIT_LIST_HEAD(&ab->qmi.event_list);
> @@ -3342,9 +3343,14 @@ int ath11k_qmi_init_service(struct ath11k_base *ab)
>  	if (ret < 0) {
>  		ath11k_warn(ab, "failed to add qmi lookup: %d\n", ret);
>  		destroy_workqueue(ab->qmi.event_wq);

Since you are adding cleanup labels, it would be more idiomatic to have a
separate err_destroy_workqueue: label to perform this cleanup

> -		return ret;
> +		goto err_release_qmi_handle;
>  	}
>  
> +	return ret;
> +

so here have
err_destroy_workqueue:
	destroy_workqueue(ab->qmi.event_wq);

> +err_release_qmi_handle:
> +	qmi_handle_release(&ab->qmi.handle);
> +
>  	return ret;
>  }
>  

same comment applies to ath12k

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2026-07-24  1:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-18  7:40 [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles on late init failures Guangshuo Li
2026-07-18  7:40 ` [PATCH v3 1/2] wifi: ath11k: release QMI handle " Guangshuo Li
2026-07-24  1:02   ` Jeff Johnson
2026-07-18  7:40 ` [PATCH v3 2/2] wifi: ath12k: " Guangshuo Li
2026-07-20  2:20 ` [PATCH v3 0/2] wifi: ath11k/ath12k: release QMI handles " Baochen Qiang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®