EAP peer: Simplify EAP method registration call

Free the allocated structure in error cases to remove need for each EAP
method to handle the error cases separately. Each registration function
can simply do "return eap_peer_method_register(eap);" in the end of the
function.

Signed-off-by: Jouni Malinen <jouni@qca.qualcomm.com>
This commit is contained in:
Jouni Malinen 2016-01-13 23:25:54 +02:00 committed by Jouni Malinen
parent 7ce5603251
commit 49a26bb3e3
23 changed files with 36 additions and 127 deletions

View File

@ -1492,7 +1492,6 @@ static u8 * eap_aka_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_aka_register(void) int eap_peer_aka_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_AKA, "AKA"); EAP_VENDOR_IETF, EAP_TYPE_AKA, "AKA");
@ -1511,10 +1510,7 @@ int eap_peer_aka_register(void)
eap->get_identity = eap_aka_get_identity; eap->get_identity = eap_aka_get_identity;
eap->get_emsk = eap_aka_get_emsk; eap->get_emsk = eap_aka_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }
@ -1522,7 +1518,6 @@ int eap_peer_aka_register(void)
int eap_peer_aka_prime_register(void) int eap_peer_aka_prime_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME, EAP_VENDOR_IETF, EAP_TYPE_AKA_PRIME,
@ -1542,10 +1537,6 @@ int eap_peer_aka_prime_register(void)
eap->get_identity = eap_aka_get_identity; eap->get_identity = eap_aka_get_identity;
eap->get_emsk = eap_aka_get_emsk; eap->get_emsk = eap_aka_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }
#endif /* EAP_AKA_PRIME */ #endif /* EAP_AKA_PRIME */

View File

@ -771,7 +771,6 @@ static u8 * eap_eke_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_eke_register(void) int eap_peer_eke_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_EKE, "EKE"); EAP_VENDOR_IETF, EAP_TYPE_EKE, "EKE");
@ -786,8 +785,5 @@ int eap_peer_eke_register(void)
eap->get_emsk = eap_eke_get_emsk; eap->get_emsk = eap_eke_get_emsk;
eap->getSessionId = eap_eke_get_session_id; eap->getSessionId = eap_eke_get_session_id;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -1800,7 +1800,6 @@ static u8 * eap_fast_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_fast_register(void) int eap_peer_fast_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_FAST, "FAST"); EAP_VENDOR_IETF, EAP_TYPE_FAST, "FAST");
@ -1821,8 +1820,5 @@ int eap_peer_fast_register(void)
#endif #endif
eap->get_emsk = eap_fast_get_emsk; eap->get_emsk = eap_fast_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -771,7 +771,6 @@ static u8 * eap_gpsk_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_gpsk_register(void) int eap_peer_gpsk_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_GPSK, "GPSK"); EAP_VENDOR_IETF, EAP_TYPE_GPSK, "GPSK");
@ -786,8 +785,5 @@ int eap_peer_gpsk_register(void)
eap->get_emsk = eap_gpsk_get_emsk; eap->get_emsk = eap_gpsk_get_emsk;
eap->getSessionId = eap_gpsk_get_session_id; eap->getSessionId = eap_gpsk_get_session_id;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -127,7 +127,6 @@ static struct wpabuf * eap_gtc_process(struct eap_sm *sm, void *priv,
int eap_peer_gtc_register(void) int eap_peer_gtc_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_GTC, "GTC"); EAP_VENDOR_IETF, EAP_TYPE_GTC, "GTC");
@ -138,8 +137,5 @@ int eap_peer_gtc_register(void)
eap->deinit = eap_gtc_deinit; eap->deinit = eap_gtc_deinit;
eap->process = eap_gtc_process; eap->process = eap_gtc_process;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -513,7 +513,6 @@ static u8 * eap_ikev2_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_ikev2_register(void) int eap_peer_ikev2_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_IKEV2, EAP_VENDOR_IETF, EAP_TYPE_IKEV2,
@ -529,8 +528,5 @@ int eap_peer_ikev2_register(void)
eap->get_emsk = eap_ikev2_get_emsk; eap->get_emsk = eap_ikev2_get_emsk;
eap->getSessionId = eap_ikev2_get_session_id; eap->getSessionId = eap_ikev2_get_session_id;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -393,7 +393,6 @@ static u8 * eap_leap_getKey(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_leap_register(void) int eap_peer_leap_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_LEAP, "LEAP"); EAP_VENDOR_IETF, EAP_TYPE_LEAP, "LEAP");
@ -406,8 +405,5 @@ int eap_peer_leap_register(void)
eap->isKeyAvailable = eap_leap_isKeyAvailable; eap->isKeyAvailable = eap_leap_isKeyAvailable;
eap->getKey = eap_leap_getKey; eap->getKey = eap_leap_getKey;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -102,7 +102,6 @@ static struct wpabuf * eap_md5_process(struct eap_sm *sm, void *priv,
int eap_peer_md5_register(void) int eap_peer_md5_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_MD5, "MD5"); EAP_VENDOR_IETF, EAP_TYPE_MD5, "MD5");
@ -113,8 +112,5 @@ int eap_peer_md5_register(void)
eap->deinit = eap_md5_deinit; eap->deinit = eap_md5_deinit;
eap->process = eap_md5_process; eap->process = eap_md5_process;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -18,6 +18,8 @@
static struct eap_method *eap_methods = NULL; static struct eap_method *eap_methods = NULL;
static void eap_peer_method_free(struct eap_method *method);
/** /**
* eap_peer_get_eap_method - Get EAP method based on type number * eap_peer_get_eap_method - Get EAP method based on type number
@ -295,7 +297,7 @@ struct eap_method * eap_peer_method_alloc(int version, int vendor,
* eap_peer_method_free - Free EAP peer method structure * eap_peer_method_free - Free EAP peer method structure
* @method: Method structure allocated with eap_peer_method_alloc() * @method: Method structure allocated with eap_peer_method_alloc()
*/ */
void eap_peer_method_free(struct eap_method *method) static void eap_peer_method_free(struct eap_method *method)
{ {
os_free(method); os_free(method);
} }
@ -303,26 +305,31 @@ void eap_peer_method_free(struct eap_method *method)
/** /**
* eap_peer_method_register - Register an EAP peer method * eap_peer_method_register - Register an EAP peer method
* @method: EAP method to register * @method: EAP method to register from eap_peer_method_alloc()
* Returns: 0 on success, -1 on invalid method, or -2 if a matching EAP method * Returns: 0 on success, -1 on invalid method, or -2 if a matching EAP method
* has already been registered * has already been registered
* *
* Each EAP peer method needs to call this function to register itself as a * Each EAP peer method needs to call this function to register itself as a
* supported EAP method. * supported EAP method. The caller must not free the allocated method data
* regardless of the return value.
*/ */
int eap_peer_method_register(struct eap_method *method) int eap_peer_method_register(struct eap_method *method)
{ {
struct eap_method *m, *last = NULL; struct eap_method *m, *last = NULL;
if (method == NULL || method->name == NULL || if (method == NULL || method->name == NULL ||
method->version != EAP_PEER_METHOD_INTERFACE_VERSION) method->version != EAP_PEER_METHOD_INTERFACE_VERSION) {
eap_peer_method_free(method);
return -1; return -1;
}
for (m = eap_methods; m; m = m->next) { for (m = eap_methods; m; m = m->next) {
if ((m->vendor == method->vendor && if ((m->vendor == method->vendor &&
m->method == method->method) || m->method == method->method) ||
os_strcmp(m->name, method->name) == 0) os_strcmp(m->name, method->name) == 0) {
eap_peer_method_free(method);
return -2; return -2;
}
last = m; last = m;
} }

View File

@ -16,7 +16,6 @@ const struct eap_method * eap_peer_get_methods(size_t *count);
struct eap_method * eap_peer_method_alloc(int version, int vendor, struct eap_method * eap_peer_method_alloc(int version, int vendor,
EapType method, const char *name); EapType method, const char *name);
void eap_peer_method_free(struct eap_method *method);
int eap_peer_method_register(struct eap_method *method); int eap_peer_method_register(struct eap_method *method);

View File

@ -880,7 +880,6 @@ static u8 * eap_mschapv2_getKey(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_mschapv2_register(void) int eap_peer_mschapv2_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2, EAP_VENDOR_IETF, EAP_TYPE_MSCHAPV2,
@ -894,8 +893,5 @@ int eap_peer_mschapv2_register(void)
eap->isKeyAvailable = eap_mschapv2_isKeyAvailable; eap->isKeyAvailable = eap_mschapv2_isKeyAvailable;
eap->getKey = eap_mschapv2_getKey; eap->getKey = eap_mschapv2_getKey;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -83,7 +83,6 @@ static struct wpabuf * eap_otp_process(struct eap_sm *sm, void *priv,
int eap_peer_otp_register(void) int eap_peer_otp_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP"); EAP_VENDOR_IETF, EAP_TYPE_OTP, "OTP");
@ -94,8 +93,5 @@ int eap_peer_otp_register(void)
eap->deinit = eap_otp_deinit; eap->deinit = eap_otp_deinit;
eap->process = eap_otp_process; eap->process = eap_otp_process;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -535,7 +535,6 @@ static u8 * eap_pax_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_pax_register(void) int eap_peer_pax_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_PAX, "PAX"); EAP_VENDOR_IETF, EAP_TYPE_PAX, "PAX");
@ -550,8 +549,5 @@ int eap_peer_pax_register(void)
eap->get_emsk = eap_pax_get_emsk; eap->get_emsk = eap_pax_get_emsk;
eap->getSessionId = eap_pax_get_session_id; eap->getSessionId = eap_pax_get_session_id;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -1281,7 +1281,6 @@ static u8 * eap_peap_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_peap_register(void) int eap_peer_peap_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_PEAP, "PEAP"); EAP_VENDOR_IETF, EAP_TYPE_PEAP, "PEAP");
@ -1299,8 +1298,5 @@ int eap_peer_peap_register(void)
eap->init_for_reauth = eap_peap_init_for_reauth; eap->init_for_reauth = eap_peap_init_for_reauth;
eap->getSessionId = eap_peap_get_session_id; eap->getSessionId = eap_peap_get_session_id;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -480,7 +480,6 @@ static u8 * eap_psk_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_psk_register(void) int eap_peer_psk_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_PSK, "PSK"); EAP_VENDOR_IETF, EAP_TYPE_PSK, "PSK");
@ -495,8 +494,5 @@ int eap_peer_psk_register(void)
eap->getSessionId = eap_psk_get_session_id; eap->getSessionId = eap_psk_get_session_id;
eap->get_emsk = eap_psk_get_emsk; eap->get_emsk = eap_psk_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -1054,7 +1054,6 @@ static u8 * eap_pwd_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_pwd_register(void) int eap_peer_pwd_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_PWD, "PWD"); EAP_VENDOR_IETF, EAP_TYPE_PWD, "PWD");
@ -1069,8 +1068,5 @@ int eap_peer_pwd_register(void)
eap->getSessionId = eap_pwd_get_session_id; eap->getSessionId = eap_pwd_get_session_id;
eap->get_emsk = eap_pwd_get_emsk; eap->get_emsk = eap_pwd_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -494,7 +494,6 @@ static u8 * eap_sake_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_sake_register(void) int eap_peer_sake_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_SAKE, "SAKE"); EAP_VENDOR_IETF, EAP_TYPE_SAKE, "SAKE");
@ -509,8 +508,5 @@ int eap_peer_sake_register(void)
eap->getSessionId = eap_sake_get_session_id; eap->getSessionId = eap_sake_get_session_id;
eap->get_emsk = eap_sake_get_emsk; eap->get_emsk = eap_sake_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -1235,7 +1235,6 @@ static u8 * eap_sim_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_sim_register(void) int eap_peer_sim_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_SIM, "SIM"); EAP_VENDOR_IETF, EAP_TYPE_SIM, "SIM");
@ -1254,8 +1253,5 @@ int eap_peer_sim_register(void)
eap->get_identity = eap_sim_get_identity; eap->get_identity = eap_sim_get_identity;
eap->get_emsk = eap_sim_get_emsk; eap->get_emsk = eap_sim_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -390,7 +390,6 @@ static u8 * eap_tls_get_session_id(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_tls_register(void) int eap_peer_tls_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_TLS, "TLS"); EAP_VENDOR_IETF, EAP_TYPE_TLS, "TLS");
@ -409,10 +408,7 @@ int eap_peer_tls_register(void)
eap->init_for_reauth = eap_tls_init_for_reauth; eap->init_for_reauth = eap_tls_init_for_reauth;
eap->get_emsk = eap_tls_get_emsk; eap->get_emsk = eap_tls_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }
@ -420,7 +416,6 @@ int eap_peer_tls_register(void)
int eap_peer_unauth_tls_register(void) int eap_peer_unauth_tls_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_UNAUTH_TLS, EAP_VENDOR_UNAUTH_TLS,
@ -439,10 +434,7 @@ int eap_peer_unauth_tls_register(void)
eap->init_for_reauth = eap_tls_init_for_reauth; eap->init_for_reauth = eap_tls_init_for_reauth;
eap->get_emsk = eap_tls_get_emsk; eap->get_emsk = eap_tls_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }
#endif /* EAP_UNAUTH_TLS */ #endif /* EAP_UNAUTH_TLS */
@ -451,7 +443,6 @@ int eap_peer_unauth_tls_register(void)
int eap_peer_wfa_unauth_tls_register(void) int eap_peer_wfa_unauth_tls_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_WFA_NEW, EAP_VENDOR_WFA_NEW,
@ -471,9 +462,6 @@ int eap_peer_wfa_unauth_tls_register(void)
eap->init_for_reauth = eap_tls_init_for_reauth; eap->init_for_reauth = eap_tls_init_for_reauth;
eap->get_emsk = eap_tls_get_emsk; eap->get_emsk = eap_tls_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }
#endif /* CONFIG_HS20 */ #endif /* CONFIG_HS20 */

View File

@ -410,7 +410,6 @@ fail:
int eap_peer_tnc_register(void) int eap_peer_tnc_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_TNC, "TNC"); EAP_VENDOR_IETF, EAP_TYPE_TNC, "TNC");
@ -421,8 +420,5 @@ int eap_peer_tnc_register(void)
eap->deinit = eap_tnc_deinit; eap->deinit = eap_tnc_deinit;
eap->process = eap_tnc_process; eap->process = eap_tnc_process;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -1776,7 +1776,6 @@ static u8 * eap_ttls_get_emsk(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_ttls_register(void) int eap_peer_ttls_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_IETF, EAP_TYPE_TTLS, "TTLS"); EAP_VENDOR_IETF, EAP_TYPE_TTLS, "TTLS");
@ -1795,8 +1794,5 @@ int eap_peer_ttls_register(void)
eap->init_for_reauth = eap_ttls_init_for_reauth; eap->init_for_reauth = eap_ttls_init_for_reauth;
eap->get_emsk = eap_ttls_get_emsk; eap->get_emsk = eap_ttls_get_emsk;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -169,7 +169,6 @@ static u8 * eap_vendor_test_getKey(struct eap_sm *sm, void *priv, size_t *len)
int eap_peer_vendor_test_register(void) int eap_peer_vendor_test_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_ID, EAP_VENDOR_TYPE, EAP_VENDOR_ID, EAP_VENDOR_TYPE,
@ -183,8 +182,5 @@ int eap_peer_vendor_test_register(void)
eap->isKeyAvailable = eap_vendor_test_isKeyAvailable; eap->isKeyAvailable = eap_vendor_test_isKeyAvailable;
eap->getKey = eap_vendor_test_getKey; eap->getKey = eap_vendor_test_getKey;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }

View File

@ -575,7 +575,6 @@ send_msg:
int eap_peer_wsc_register(void) int eap_peer_wsc_register(void)
{ {
struct eap_method *eap; struct eap_method *eap;
int ret;
eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION, eap = eap_peer_method_alloc(EAP_PEER_METHOD_INTERFACE_VERSION,
EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC, EAP_VENDOR_WFA, EAP_VENDOR_TYPE_WSC,
@ -587,8 +586,5 @@ int eap_peer_wsc_register(void)
eap->deinit = eap_wsc_deinit; eap->deinit = eap_wsc_deinit;
eap->process = eap_wsc_process; eap->process = eap_wsc_process;
ret = eap_peer_method_register(eap); return eap_peer_method_register(eap);
if (ret)
eap_peer_method_free(eap);
return ret;
} }