--- a/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c +++ b/sys/dev/netif/ath/ath_hal/ah_eeprom_9287.c @@ -297,6 +297,7 @@ HAL_BOOL need_swap; u_int w, off, len; uint32_t sum; + HAL_STATUS ecode; HALASSERT(ee == AH_NULL); @@ -332,7 +333,8 @@ HALDEBUG(ah, HAL_DEBUG_ANY, "%s eeprom read error at offset 0x%x\n", __func__, off); - return HAL_EEREAD; + ecode = HAL_EEREAD; + goto fail; } } /* Convert to eeprom native eeprom endian format */ @@ -373,7 +375,8 @@ if (sum != 0xffff) { HALDEBUG(ah, HAL_DEBUG_ANY, "Bad EEPROM checksum 0x%x (Len=%u)\n", sum, len); - return HAL_EEBADSUM; + ecode = HAL_EEBADSUM; + goto fail; } if (need_swap) @@ -392,7 +395,8 @@ if (owl_get_eep_ver(ee) != AR5416_EEP_VER) { HALDEBUG(ah, HAL_DEBUG_ANY, "Bad EEPROM version 0x%x\n", owl_get_eep_ver(ee)); - return HAL_EEBADSUM; + ecode = HAL_EEBADSUM; + goto fail; } v9287EepromReadCTLInfo(ah, ee); /* Get CTLs */ @@ -405,5 +409,9 @@ AH_PRIVATE(ah)->ah_getSpurChan = v9287EepromGetSpurChan; AH_PRIVATE(ah)->ah_eepromDiag = v9287EepromDiag; return HAL_OK; + +fail: + ath_hal_free(ee); /* not yet installed; nothing owns it */ + return ecode; #undef NW }