From ff62e33e2dfc50e92979f7cefa0f066fc212bc98 Mon Sep 17 00:00:00 2001 From: KonstantinKondrashov Date: Fri, 18 Nov 2022 16:16:55 +0800 Subject: [PATCH] esp_hw_support: Fix coverity warnings in mac_addr API --- components/esp_hw_support/mac_addr.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/components/esp_hw_support/mac_addr.c b/components/esp_hw_support/mac_addr.c index 953adf2b819..f2eb0180945 100644 --- a/components/esp_hw_support/mac_addr.c +++ b/components/esp_hw_support/mac_addr.c @@ -74,8 +74,11 @@ static int get_idx(esp_mac_type_t type) return -1; } -static esp_err_t get_mac_addr_from_mac_table(uint8_t *mac, unsigned idx, bool silent) +static esp_err_t get_mac_addr_from_mac_table(uint8_t *mac, int idx, bool silent) { + if (idx == -1) { + return ESP_ERR_NOT_SUPPORTED; + } if (!(s_mac_table[idx].state & STATE_SET)) { esp_mac_type_t type = s_mac_table[idx].type; if (type == ESP_MAC_BASE || type == ESP_MAC_EFUSE_FACTORY || type == ESP_MAC_EFUSE_CUSTOM) {