|
@@ -949,6 +949,32 @@ int __wlan_hdd_validate_session_id(uint8_t session_id, const char *func)
|
|
|
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 (QDF_NET_IS_MAC_MULTICAST(mac_addr->bytes)) {
|
|
|
+ hdd_err("MAC is Multicast (via %s)", func);
|
|
|
+ return QDF_STATUS_E_INVAL;
|
|
|
+ }
|
|
|
+
|
|
|
+ return QDF_STATUS_SUCCESS;
|
|
|
+}
|
|
|
+
|
|
|
/**
|
|
|
* wlan_hdd_validate_modules_state() - Check modules status
|
|
|
* @hdd_ctx: HDD context pointer
|
|
@@ -3508,20 +3534,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);
|
|
|
|
|
@@ -4876,11 +4892,13 @@ struct hdd_adapter *hdd_open_adapter(struct hdd_context *hdd_ctx, uint8_t sessio
|
|
|
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
|