Skip to content

Commit 4f93750

Browse files
Baochen Qianggregkh
authored andcommitted
wifi: ath12k: fix error handling in creating hardware group
[ Upstream commit 088a099 ] In ath12k_core_init() when ath12k_core_hw_group_create() fails, ath12k_core_hw_group_destroy() is called where for each device below path would get executed ath12k_core_soc_destroy() ath12k_qmi_deinit_service() qmi_handle_release() This results in kernel crash in case one of the device fails at qmi_handle_init() when creating hardware group: ath12k_pci 0000:10:00.0: failed to initialize qmi handle ath12k_pci 0000:10:00.0: failed to initialize qmi :-517 ath12k_pci 0000:10:00.0: failed to create soc core: -517 ath12k_pci 0000:10:00.0: unable to create hw group BUG: unable to handle page fault for address: ffffffffffffffb7 RIP: 0010:qmi_handle_release Call Trace: <TASK> ath12k_qmi_deinit_service ath12k_core_hw_group_destroy ath12k_core_init ath12k_pci_probe The detailed reason is, when qmi_handle_init() fails for a device ab->qmi.handle is not correctly initialized. Then ath12k_core_hw_group_create() returns failure, since error handing is done for all device, eventually qmi_handle_release() is called for the issue device and finally kernel crashes due to the uninitialized ab->qmi.handle. Fix this by moving error handling to ath12k_core_hw_group_create(), this way the issue device can be skipped. Tested-on: WCN7850 hw2.0 PCI WLAN.HMT.1.1.c5-00284.1-QCAHMTSWPL_V1.0_V2.0_SILICONZ-3 Fixes: 6f245ea ("wifi: ath12k: introduce device group abstraction") Link: https://lore.kernel.org/ath12k/fabc97122016d1a66a53ddedd965d134@posteo.net Reported-by: a-development <a-development@posteo.de> Closes: https://bugzilla.kernel.org/show_bug.cgi?id=220518 Tested-by: a-development <a-development@posteo.de> Signed-off-by: Baochen Qiang <baochen.qiang@oss.qualcomm.com> Reviewed-by: Vasanthakumar Thiagarajan <vasanthakumar.thiagarajan@oss.qualcomm.com> Link: https://patch.msgid.link/20251030-fix-hw-group-create-err-handling-v1-1-0659e4d15fb9@oss.qualcomm.com Signed-off-by: Jeff Johnson <jeff.johnson@oss.qualcomm.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent 36faeca commit 4f93750

File tree

1 file changed

+17
-5
lines changed
  • drivers/net/wireless/ath/ath12k

1 file changed

+17
-5
lines changed

drivers/net/wireless/ath/ath12k/core.c

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2106,14 +2106,27 @@ static int ath12k_core_hw_group_create(struct ath12k_hw_group *ag)
21062106
ret = ath12k_core_soc_create(ab);
21072107
if (ret) {
21082108
mutex_unlock(&ab->core_lock);
2109-
ath12k_err(ab, "failed to create soc core: %d\n", ret);
2110-
return ret;
2109+
ath12k_err(ab, "failed to create soc %d core: %d\n", i, ret);
2110+
goto destroy;
21112111
}
21122112

21132113
mutex_unlock(&ab->core_lock);
21142114
}
21152115

21162116
return 0;
2117+
2118+
destroy:
2119+
for (i--; i >= 0; i--) {
2120+
ab = ag->ab[i];
2121+
if (!ab)
2122+
continue;
2123+
2124+
mutex_lock(&ab->core_lock);
2125+
ath12k_core_soc_destroy(ab);
2126+
mutex_unlock(&ab->core_lock);
2127+
}
2128+
2129+
return ret;
21172130
}
21182131

21192132
void ath12k_core_hw_group_set_mlo_capable(struct ath12k_hw_group *ag)
@@ -2188,16 +2201,15 @@ int ath12k_core_init(struct ath12k_base *ab)
21882201
if (ret) {
21892202
mutex_unlock(&ag->mutex);
21902203
ath12k_warn(ab, "unable to create hw group\n");
2191-
goto err_destroy_hw_group;
2204+
goto err_unassign_hw_group;
21922205
}
21932206
}
21942207

21952208
mutex_unlock(&ag->mutex);
21962209

21972210
return 0;
21982211

2199-
err_destroy_hw_group:
2200-
ath12k_core_hw_group_destroy(ab->ag);
2212+
err_unassign_hw_group:
22012213
ath12k_core_hw_group_unassign(ab);
22022214
err_unregister_notifier:
22032215
ath12k_core_panic_notifier_unregister(ab);

0 commit comments

Comments
 (0)