summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPragaspathi Thilagaraj <tpragasp@codeaurora.org>2018-09-19 22:06:57 +0530
committernshrivas <nshrivas@codeaurora.org>2018-10-23 18:14:26 -0700
commitcde6463873641663c969b043cfdb61c596737e2f (patch)
treef02327e918776e4996a68591b955c9af2ad92c89
parent94852e85a84a8c4ab8844a95683541576980a13b (diff)
qcacld-3.0: Check for zero mac during hdd adapter open
When zero mac address is configured on nvram, the hdd_open_adapter accepts the value and passes this zero mac to csr_session_open where the self mac address is stored as zero value mac and peer creation is done with the same. When peer delete is sent to firmware with this mac, firmware asserts. Add check to validate mac address value is not zero. Change-Id: I077c29c98ef4e1b11e4c587224acd4405629fa83 CRs-Fixed: 2310499
-rw-r--r--core/hdd/inc/wlan_hdd_main.h13
-rw-r--r--core/hdd/src/wlan_hdd_main.c44
2 files changed, 44 insertions, 13 deletions
diff --git a/core/hdd/inc/wlan_hdd_main.h b/core/hdd/inc/wlan_hdd_main.h
index abb496e2c189..3a180b10a815 100644
--- a/core/hdd/inc/wlan_hdd_main.h
+++ b/core/hdd/inc/wlan_hdd_main.h
@@ -2402,6 +2402,19 @@ struct qdf_mac_addr *
hdd_wlan_get_ibss_mac_addr_from_staid(hdd_adapter_t *pAdapter,
uint8_t staIdx);
void hdd_checkandupdate_phymode(hdd_context_t *pHddCtx);
+
+/**
+ * wlan_hdd_validate_mac_address() - Function to validate mac address
+ * @mac_addr: input mac address
+ *
+ * Return QDF_STATUS
+ */
+#define wlan_hdd_validate_mac_address(mac_addr) \
+ __wlan_hdd_validate_mac_address(mac_addr, __func__)
+
+QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr,
+ const char *func);
+
#ifdef MSM_PLATFORM
/**
* hdd_bus_bw_compute_timer_start() - start the bandwidth timer
diff --git a/core/hdd/src/wlan_hdd_main.c b/core/hdd/src/wlan_hdd_main.c
index 63957aa89356..a335d363ab64 100644
--- a/core/hdd/src/wlan_hdd_main.c
+++ b/core/hdd/src/wlan_hdd_main.c
@@ -807,6 +807,32 @@ int hdd_validate_adapter(hdd_adapter_t *adapter)
return 0;
}
+QDF_STATUS __wlan_hdd_validate_mac_address(struct qdf_mac_addr *mac_addr,
+ const char *func)
+{
+ if (!mac_addr) {
+ hdd_err("Received NULL mac address (via %s)", func);
+ return QDF_STATUS_E_INVAL;
+ }
+
+ if (qdf_is_macaddr_zero(mac_addr)) {
+ hdd_err("MAC is all zero (via %s)", func);
+ return QDF_STATUS_E_INVAL;
+ }
+
+ if (qdf_is_macaddr_broadcast(mac_addr)) {
+ hdd_err("MAC is Broadcast (via %s)", func);
+ return QDF_STATUS_E_INVAL;
+ }
+
+ if (ETHER_IS_MULTICAST(mac_addr->bytes)) {
+ hdd_err("MAC is Multicast (via %s)", func);
+ return QDF_STATUS_E_INVAL;
+ }
+
+ return QDF_STATUS_SUCCESS;
+}
+
/**
* wlan_hdd_modules_are_enabled() - Check modules status
* @hdd_ctx: HDD context pointer
@@ -2851,20 +2877,10 @@ static int __hdd_set_mac_address(struct net_device *dev, void *addr)
return -EINVAL;
}
- if (qdf_is_macaddr_zero(&mac_addr)) {
- hdd_err("MAC is all zero");
- return -EINVAL;
- }
-
- if (qdf_is_macaddr_broadcast(&mac_addr)) {
- hdd_err("MAC is Broadcast");
+ qdf_ret_status = wlan_hdd_validate_mac_address(&mac_addr);
+ if (QDF_IS_STATUS_ERROR(qdf_ret_status))
return -EINVAL;
- }
- if (ETHER_IS_MULTICAST(psta_mac_addr->sa_data)) {
- hdd_err("MAC is Multicast");
- return -EINVAL;
- }
hdd_info("Changing MAC to " MAC_ADDRESS_STR " of the interface %s ",
MAC_ADDR_ARRAY(mac_addr.bytes), dev->name);
@@ -4399,11 +4415,13 @@ hdd_adapter_t *hdd_open_adapter(hdd_context_t *hdd_ctx, uint8_t session_type,
return NULL;
}
- if (macAddr == NULL) {
+ status = wlan_hdd_validate_mac_address((struct qdf_mac_addr *)macAddr);
+ if (QDF_IS_STATUS_ERROR(status)) {
/* Not received valid macAddr */
hdd_err("Unable to add virtual intf: Not able to get valid mac address");
return NULL;
}
+
status = hdd_check_for_existing_macaddr(hdd_ctx, macAddr);
if (QDF_STATUS_E_FAILURE == status) {
hdd_err("Duplicate MAC addr: " MAC_ADDRESS_STR