From f974f3355fce39338c5ea943a9809ec06d023e73 Mon Sep 17 00:00:00 2001 From: Ashish Kumar Dhanotiya Date: Thu, 19 Apr 2018 16:03:15 +0530 Subject: [PATCH] qcacld-3.0: Avoid duplicate MAC configuration Currently if the MAC is changed dynamically for any interface, driver is allowing to configure a MAC which is already in use by some other interface and it will allow different interfaces to come up on same MAC address. To address this issue add a check to configfure only different MAC address. Change-Id: Iece3bb063be30d5d983f4bec710d6d16b22bd2f9 CRs-Fixed: 2227656 --- core/hdd/src/wlan_hdd_hostapd.c | 6 ++++++ core/hdd/src/wlan_hdd_main.c | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/core/hdd/src/wlan_hdd_hostapd.c b/core/hdd/src/wlan_hdd_hostapd.c index 8b03901fbb72..f35c0e5cec40 100644 --- a/core/hdd/src/wlan_hdd_hostapd.c +++ b/core/hdd/src/wlan_hdd_hostapd.c @@ -680,6 +680,12 @@ static int __hdd_hostapd_set_mac_address(struct net_device *dev, void *addr) qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); + if (hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes)) { + hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, + MAC_ADDR_ARRAY(mac_addr.bytes)); + return -EINVAL; + } + if (qdf_is_macaddr_zero(&mac_addr)) { hdd_err("MAC is all zero"); return -EINVAL; diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c index 213d21da8141..bf71ab4b1120 100644 --- a/core/hdd/src/wlan_hdd_main.c +++ b/core/hdd/src/wlan_hdd_main.c @@ -3260,6 +3260,12 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr) qdf_mem_copy(&mac_addr, psta_mac_addr->sa_data, sizeof(mac_addr)); + if (hdd_get_adapter_by_macaddr(hdd_ctx, mac_addr.bytes)) { + hdd_err("adapter exist with same mac address " MAC_ADDRESS_STR, + MAC_ADDR_ARRAY(mac_addr.bytes)); + return -EINVAL; + } + if (qdf_is_macaddr_zero(&mac_addr)) { hdd_err("MAC is all zero"); return -EINVAL;