diff --git a/core/hdd/src/wlan_hdd_cfg.c b/core/hdd/src/wlan_hdd_cfg.c index eec61825a1a8..3dc4d2e41d77 100644 --- a/core/hdd/src/wlan_hdd_cfg.c +++ b/core/hdd/src/wlan_hdd_cfg.c @@ -2755,14 +2755,16 @@ static int parse_hex_digit(char c) * * 00AA00BB00CC -> 0x00 0xAA 0x00 0xBB 0x00 0xCC * - * Return: None + * Return: QDF_STATUS */ -static void update_mac_from_string(struct hdd_context *hdd_ctx, - struct hdd_cfg_entry *macTable, int num) +static QDF_STATUS update_mac_from_string(struct hdd_context *hdd_ctx, + struct hdd_cfg_entry *macTable, + int num) { int i = 0, j = 0, res = 0; char *candidate = NULL; struct qdf_mac_addr macaddr[QDF_MAX_CONCURRENCY_PERSONA]; + QDF_STATUS status = QDF_STATUS_SUCCESS; memset(macaddr, 0, sizeof(macaddr)); @@ -2780,8 +2782,12 @@ static void update_mac_from_string(struct hdd_context *hdd_ctx, intfMacAddr[i].bytes[0], (uint8_t *) &macaddr[i].bytes[0], QDF_MAC_ADDR_SIZE); + } else { + status = QDF_STATUS_E_FAILURE; + break; } } + return status; } /** @@ -3346,7 +3352,7 @@ QDF_STATUS hdd_update_mac_config(struct hdd_context *hdd_ctx) buffer = line; } - if (i <= QDF_MAX_CONCURRENCY_PERSONA) { + if (i != 0 && i <= QDF_MAX_CONCURRENCY_PERSONA) { hdd_debug("%d Mac addresses provided", i); } else { hdd_err("invalid number of Mac address provided, nMac = %d", i); @@ -3354,7 +3360,11 @@ QDF_STATUS hdd_update_mac_config(struct hdd_context *hdd_ctx) goto config_exit; } - update_mac_from_string(hdd_ctx, &macTable[0], i); + qdf_status = update_mac_from_string(hdd_ctx, &macTable[0], i); + if (QDF_IS_STATUS_ERROR(qdf_status)) { + hdd_err("Invalid MAC addresses provided"); + goto config_exit; + } hdd_debug("Populating remaining %d Mac addresses", max_mac_addr - i); hdd_populate_random_mac_addr(hdd_ctx, max_mac_addr - i);