[PATCH] ath10k: Check return value of ath10k_get_arvif in ath10k_wmi_event_tdls_peer

Peter Kosyh posted 1 patch 3 years, 6 months ago
drivers/net/wireless/ath/ath10k/wmi-tlv.c | 5 +++++
1 file changed, 5 insertions(+)
[PATCH] ath10k: Check return value of ath10k_get_arvif in ath10k_wmi_event_tdls_peer
Posted by Peter Kosyh 3 years, 6 months ago
Return value of a function 'ath10k_get_arvif' is dereferenced without
checking for null in ath10k_wmi_event_tdls_peer, but it is usually checked
for this function.

Make ath10k_wmi_event_tdls_peer do check retval of ath10k_get_arvif.

Found by Linux Verification Center (linuxtesting.org) with SVACE.

Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
---
 drivers/net/wireless/ath/ath10k/wmi-tlv.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/drivers/net/wireless/ath/ath10k/wmi-tlv.c b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
index 876410a47d1d..1f2c37c642ff 100644
--- a/drivers/net/wireless/ath/ath10k/wmi-tlv.c
+++ b/drivers/net/wireless/ath/ath10k/wmi-tlv.c
@@ -585,6 +585,11 @@ static void ath10k_wmi_event_tdls_peer(struct ath10k *ar, struct sk_buff *skb)
 			goto exit;
 		}
 		arvif = ath10k_get_arvif(ar, __le32_to_cpu(ev->vdev_id));
+		if (!arvif) {
+			ath10k_warn(ar, "no vif for vdev_id %d found\n",
+				__le32_to_cpu(ev->vdev_id));
+			goto exit;
+		}
 		ieee80211_tdls_oper_request(
 					arvif->vif, station->addr,
 					NL80211_TDLS_TEARDOWN,
-- 
2.37.0
Re: [PATCH] ath10k: Check return value of ath10k_get_arvif in ath10k_wmi_event_tdls_peer
Posted by Kalle Valo 3 years, 5 months ago
Peter Kosyh <pkosyh@yandex.ru> wrote:

> Return value of a function ath10k_get_arvif() is dereferenced without
> checking for null in ath10k_wmi_event_tdls_peer(), but it is usually checked
> for this function.
> 
> Make ath10k_wmi_event_tdls_peer() do check retval of ath10k_get_arvif().
> 
> Found by Linux Verification Center (linuxtesting.org) with SVACE.
> 
> Signed-off-by: Peter Kosyh <pkosyh@yandex.ru>
> Signed-off-by: Kalle Valo <quic_kvalo@quicinc.com>

Patch applied to ath-next branch of ath.git, thanks.

473118917cc3 wifi: ath10k: Check return value of ath10k_get_arvif() in ath10k_wmi_event_tdls_peer()

-- 
https://patchwork.kernel.org/project/linux-wireless/patch/20221003091217.322598-1-pkosyh@yandex.ru/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches