[PATCH] Fix memory leak on error path

Masashi Honma honma
Mon Nov 15 02:07:09 PST 2010


Hello.
I have encountered following debug messages.

----------
wlan0: RADIUS No authentication server configured
^CMEMLEAK[0x99a0320]: len 64
WPA_TRACE: memleak - START
[0]: ./hostapd(os_malloc+0x55) [0x806e3f5]
     os_malloc() ../src/utils/os_unix.c:359
[1]: ./hostapd(os_zalloc+0x17) [0x806e477]
     os_zalloc() ../src/utils/os_unix.c:418
[2]: ./hostapd(radius_msg_new+0x45) [0x8074f55]
     radius_msg_initialize() ../src/radius/radius.c:89
     radius_msg_new() ../src/radius/radius.c:117
[3]: ./hostapd() [0x806095e]
     ieee802_1x_encapsulate_radius() ../src/ap/ieee802_1x.c:439
     ieee802_1x_aaa_send() ../src/ap/ieee802_1x.c:1496
[4]: ./hostapd() [0x8071fdc]
     eapol_sm_sta_entry_alive() ../src/eapol_auth/eapol_auth_sm.c:866
     eapol_sm_step_run() ../src/eapol_auth/eapol_auth_sm.c:943
[5]: ./hostapd(eloop_run+0x1cb) [0x806caeb]
     eloop_run() ../src/utils/eloop.c:547
[6]: ./hostapd(main+0x25e) [0x8054cbe]
     hostapd_global_run() main.c:439
     main() main.c:548
[7]: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb7355c76]
[8]: ./hostapd() [0x80544e1]
     _start() (null):0
WPA_TRACE: memleak - END
MEMLEAK[0x999feb8]: len 1040
WPA_TRACE: memleak - START
[0]: ./hostapd(os_malloc+0x55) [0x806e3f5]
     os_malloc() ../src/utils/os_unix.c:359
[1]: ./hostapd(os_zalloc+0x17) [0x806e477]
     os_zalloc() ../src/utils/os_unix.c:418
[2]: ./hostapd(wpabuf_alloc+0x15) [0x806dee5]
     wpabuf_alloc() ../src/utils/wpabuf.c:124
[3]: ./hostapd(radius_msg_new+0x33) [0x8074f43]
     radius_msg_new() ../src/radius/radius.c:117
[4]: ./hostapd() [0x806095e]
     ieee802_1x_encapsulate_radius() ../src/ap/ieee802_1x.c:439
     ieee802_1x_aaa_send() ../src/ap/ieee802_1x.c:1496
[5]: ./hostapd() [0x8071fdc]
     eapol_sm_sta_entry_alive() ../src/eapol_auth/eapol_auth_sm.c:866
     eapol_sm_step_run() ../src/eapol_auth/eapol_auth_sm.c:943
[6]: ./hostapd(eloop_run+0x1cb) [0x806caeb]
     eloop_run() ../src/utils/eloop.c:547
[7]: ./hostapd(main+0x25e) [0x8054cbe]
     hostapd_global_run() main.c:439
     main() main.c:548
[8]: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb7355c76]
[9]: ./hostapd() [0x80544e1]
     _start() (null):0
WPA_TRACE: memleak - END
MEMLEAK[0x999fe48]: len 20
WPA_TRACE: memleak - START
[0]: ./hostapd(os_malloc+0x55) [0x806e3f5]
     os_malloc() ../src/utils/os_unix.c:359
[1]: ./hostapd(os_zalloc+0x17) [0x806e477]
     os_zalloc() ../src/utils/os_unix.c:418
[2]: ./hostapd(radius_msg_new+0x21) [0x8074f31]
     radius_msg_new() ../src/radius/radius.c:113
[3]: ./hostapd() [0x806095e]
     ieee802_1x_encapsulate_radius() ../src/ap/ieee802_1x.c:439
     ieee802_1x_aaa_send() ../src/ap/ieee802_1x.c:1496
[4]: ./hostapd() [0x8071fdc]
     eapol_sm_sta_entry_alive() ../src/eapol_auth/eapol_auth_sm.c:866
     eapol_sm_step_run() ../src/eapol_auth/eapol_auth_sm.c:943
[5]: ./hostapd(eloop_run+0x1cb) [0x806caeb]
     eloop_run() ../src/utils/eloop.c:547
[6]: ./hostapd(main+0x25e) [0x8054cbe]
     hostapd_global_run() main.c:439
     main() main.c:548
[7]: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb7355c76]
[8]: ./hostapd() [0x80544e1]
     _start() (null):0
WPA_TRACE: memleak - END
MEMLEAK: total 1124 bytes
----------

For example, this error occured when I used WPS hostapd without
"eap_server=1" definition in configuration file.

This patch solves this issue.


diff --git a/src/ap/ieee802_1x.c b/src/ap/ieee802_1x.c
index 3e4aa0f..cf781e7 100644
--- a/src/ap/ieee802_1x.c
+++ b/src/ap/ieee802_1x.c
@@ -549,7 +549,9 @@ static void ieee802_1x_encapsulate_radius(struct hostapd_data *hapd,
 		}
 	}
 
-	radius_client_send(hapd->radius, msg, RADIUS_AUTH, sta->addr);
+	if (radius_client_send(hapd->radius, msg, RADIUS_AUTH, sta->addr) < 0)
+		goto fail;
+
 	return;
 
  fail:


Regards,
Masashi Honma.



More information about the Hostap mailing list