wifi: ath11k: mhi: fix potential memory leak in ath11k_mhi_register()
authorJianglei Nie <niejianglei2021@163.com>
Wed, 7 Sep 2022 07:37:04 +0000 (15:37 +0800)
committerKalle Valo <quic_kvalo@quicinc.com>
Sat, 10 Sep 2022 06:27:09 +0000 (09:27 +0300)
commit43e7c3505ec70db3d3c6458824d5fa40f62e3e7b
tree0f896ba1595e50b53e52b6d4c0bd2128b7bdd20f
parent876eb84882a8b2fc4036e735a2de52141aebb6a5
wifi: ath11k: mhi: fix potential memory leak in ath11k_mhi_register()

mhi_alloc_controller() allocates a memory space for mhi_ctrl. When gets
some error, mhi_ctrl should be freed with mhi_free_controller(). But
when ath11k_mhi_read_addr_from_dt() fails, the function returns without
calling mhi_free_controller(), which will lead to a memory leak.

We can fix it by calling mhi_free_controller() when
ath11k_mhi_read_addr_from_dt() fails.

Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Reviewed-by: Jeff Johnson <quic_jjohnson@quicinc.com>
Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>
Link: https://lore.kernel.org/r/20220907073704.58806-1-niejianglei2021@163.com
drivers/net/wireless/ath/ath11k/mhi.c