From 4ad7daa9255201e5cfa7338298583ac9372ef7c7 Mon Sep 17 00:00:00 2001 From: Nate Jiang Date: Mon, 18 May 2020 15:17:47 -0700 Subject: [PATCH] IWifi: Validate dedicated NAN discovery interface. Bug: 156879576 Test: atest android.hardware.wifi@1.0-service-tests Change-Id: I9150b683ceb5631139eab6e0c6c8edb4209c9493 --- wifi/1.4/default/wifi_chip.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/wifi/1.4/default/wifi_chip.cpp b/wifi/1.4/default/wifi_chip.cpp index 61912a53e0..fa4f354e62 100644 --- a/wifi/1.4/default/wifi_chip.cpp +++ b/wifi/1.4/default/wifi_chip.cpp @@ -19,6 +19,7 @@ #include #include #include +#include #include #include @@ -885,7 +886,7 @@ std::pair> WifiChip::createNanIfaceInternal() { } bool is_dedicated_iface = true; std::string ifname = getNanIfaceName(); - if (ifname.empty()) { + if (ifname.empty() || if_nametoindex(ifname.c_str())) { // Use the first shared STA iface (wlan0) if a dedicated aware iface is // not defined. ifname = getFirstActiveWlanIfaceName();