mirror of
https://github.com/torvalds/linux.git
synced 2026-06-03 12:03:54 +02:00
wifi: ath12k: mhi: fix potential memory leak in ath12k_mhi_register()
mhi_alloc_controller() allocates a memory space for mhi_ctrl. When some errors occur, mhi_ctrl should be freed by mhi_free_controller() and set ab_pci->mhi_ctrl = NULL. We can fix it by calling mhi_free_controller() when the failure happens and set ab_pci->mhi_ctrl = NULL in all of the places where we call mhi_free_controller(). Signed-off-by: Ma Ke <make_ruc2021@163.com> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com> Link: https://lore.kernel.org/r/20230922021036.3604157-1-make_ruc2021@163.com
This commit is contained in:
parent
aa75cc029e
commit
47c27aa7de
|
|
@ -370,8 +370,7 @@ int ath12k_mhi_register(struct ath12k_pci *ab_pci)
|
|||
ret = ath12k_mhi_get_msi(ab_pci);
|
||||
if (ret) {
|
||||
ath12k_err(ab, "failed to get msi for mhi\n");
|
||||
mhi_free_controller(mhi_ctrl);
|
||||
return ret;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
mhi_ctrl->iova_start = 0;
|
||||
|
|
@ -388,11 +387,15 @@ int ath12k_mhi_register(struct ath12k_pci *ab_pci)
|
|||
ret = mhi_register_controller(mhi_ctrl, ab->hw_params->mhi_config);
|
||||
if (ret) {
|
||||
ath12k_err(ab, "failed to register to mhi bus, err = %d\n", ret);
|
||||
mhi_free_controller(mhi_ctrl);
|
||||
return ret;
|
||||
goto free_controller;
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
free_controller:
|
||||
mhi_free_controller(mhi_ctrl);
|
||||
ab_pci->mhi_ctrl = NULL;
|
||||
return ret;
|
||||
}
|
||||
|
||||
void ath12k_mhi_unregister(struct ath12k_pci *ab_pci)
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user