[PATCH] Fix memory leak on invalid interface error path

Masashi Honma honma
Thu Dec 9 18:48:04 PST 2010


Hello.

The hostapd produces following error messages when I specify
nonexistent interface name to hostapd.conf "interface=" field.

----------------
Configuration file: /home/honma/wpa-psk.conf
Could not open file /sys/class/net/wlan0/phy80211/name: No such file or directory
rfkill: initial event: idx=0 type=1 op=0 soft=0 hard=0
Could not get interface wlan0 hwaddr: No such device
nl80211: Register frame command failed (type=208): ret=-19 (No such device)
nl80211: Register frame match - hexdump(len=1): 06
nl80211: Failed to register Action frame processing - ignore for now
nl80211: Add own interface ifindex 0
Could not read interface wlan0 flags: No such device
WPA_TRACE: Freeing referenced memory - START
[2]: ./hostapd(os_free+0x47) [0x806bfe7]
     os_free() ../src/utils/os_unix.c:411
[3]: ./hostapd() [0x8083c93]
     i802_init() ../src/drivers/driver_nl80211.c:5484
[4]: ./hostapd(main+0x1d7) [0x8053597]
     hostapd_driver_init() main.c:266
     hostapd_interface_init() main.c:312
     main() main.c:541
[5]: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb74d6c76]
[6]: ./hostapd() [0x8052e41]
     _start() (null):0
WPA_TRACE: Freeing referenced memory - END
WPA_TRACE: Reference registration - START
[0]: ./hostapd(wpa_trace_add_ref_func+0x27) [0x80698a7]
     dl_list_add() ../src/utils/list.h:35
     wpa_trace_add_ref_func() ../src/utils/trace.c:313
[1]: ./hostapd() [0x806aaf2]
     eloop_trace_sock_add_ref() ../src/utils/eloop.c:94
[2]: ./hostapd(eloop_register_sock+0xca) [0x806ad0a]
     eloop_sock_table_add_sock() ../src/utils/eloop.c:158
     eloop_register_sock() ../src/utils/eloop.c:284
[3]: ./hostapd(eloop_register_read_sock+0x2e) [0x806ad4e]
     eloop_register_read_sock() ../src/utils/eloop.c:253
[4]: ./hostapd(rfkill_init+0x1b3) [0x8084ec3]
     rfkill_init() ../src/drivers/rfkill.c:170
[5]: ./hostapd() [0x80838a1]
     wpa_driver_nl80211_init() ../src/drivers/driver_nl80211.c:1779
[6]: ./hostapd() [0x8083b56]
     i802_init() ../src/drivers/driver_nl80211.c:5403
[7]: ./hostapd(main+0x1d7) [0x8053597]
     hostapd_driver_init() main.c:266
     hostapd_interface_init() main.c:312
     main() main.c:541
[8]: /lib/i686/cmov/libc.so.6(__libc_start_main+0xe6) [0xb74d6c76]
[9]: ./hostapd() [0x8052e41]
     _start() (null):0
WPA_TRACE: Reference registration - END
Aborted
----------------

This patch solves this issue.

diff --git a/src/drivers/driver_nl80211.c b/src/drivers/driver_nl80211.c
index 9bd4061..d9c9eb4 100644
--- a/src/drivers/driver_nl80211.c
+++ b/src/drivers/driver_nl80211.c
@@ -1927,7 +1927,8 @@ wpa_driver_nl80211_finish_drv_init(struct wpa_driver_nl80211_data *drv)
 			       1, IF_OPER_DORMANT);
 #endif /* HOSTAPD */
 
-	linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, drv->addr);
+	if (linux_get_ifhwaddr(drv->ioctl_sock, bss->ifname, drv->addr))
+		return -1;
 
 	if (nl80211_register_action_frames(drv) < 0) {
 		wpa_printf(MSG_DEBUG, "nl80211: Failed to register Action "

Regards,
Masashi Honma.



More information about the Hostap mailing list