OSDN Git Service

wifi: mac80211_hwsim: Fix possible NULL dereference
authorIlan Peer <ilan.peer@intel.com>
Sun, 4 Jun 2023 09:11:27 +0000 (12:11 +0300)
committerJohannes Berg <johannes.berg@intel.com>
Tue, 6 Jun 2023 12:17:11 +0000 (14:17 +0200)
In a call to mac80211_hwsim_select_tx_link() the sta pointer might
be NULL, thus need to check that it is not NULL before accessing it.

Signed-off-by: Ilan Peer <ilan.peer@intel.com>
Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
Link: https://lore.kernel.org/r/20230604120651.f4d889fc98c4.Iae85f527ed245a37637a874bb8b8c83d79812512@changeid
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
drivers/net/wireless/virtual/mac80211_hwsim.c

index b06a6e7..c706abb 100644 (file)
@@ -4,7 +4,7 @@
  * Copyright (c) 2008, Jouni Malinen <j@w1.fi>
  * Copyright (c) 2011, Javier Lopez <jlopex@gmail.com>
  * Copyright (c) 2016 - 2017 Intel Deutschland GmbH
- * Copyright (C) 2018 - 2022 Intel Corporation
+ * Copyright (C) 2018 - 2023 Intel Corporation
  */
 
 /*
@@ -1865,7 +1865,7 @@ mac80211_hwsim_select_tx_link(struct mac80211_hwsim_data *data,
 
        WARN_ON(is_multicast_ether_addr(hdr->addr1));
 
-       if (WARN_ON_ONCE(!sta->valid_links))
+       if (WARN_ON_ONCE(!sta || !sta->valid_links))
                return &vif->bss_conf;
 
        for (i = 0; i < ARRAY_SIZE(vif->link_conf); i++) {