From: Jouni Malinen Date: Thu, 8 Jan 2015 00:29:59 +0000 (+0200) Subject: Verify that eloop_register_read_sock() succeeds for ctrl_iface setup X-Git-Tag: hostap_2_4~504 X-Git-Url: http://www.project-moonshot.org/gitweb/?a=commitdiff_plain;h=86a7fbb2c18f5200429fea8b69a64c5dcb9673f2;p=mech_eap.git Verify that eloop_register_read_sock() succeeds for ctrl_iface setup This allows faster detection of a case where a memory allocation fails within eloop. Signed-off-by: Jouni Malinen --- diff --git a/hostapd/ctrl_iface.c b/hostapd/ctrl_iface.c index 6c81211..a7235a4 100644 --- a/hostapd/ctrl_iface.c +++ b/hostapd/ctrl_iface.c @@ -2251,8 +2251,11 @@ int hostapd_ctrl_iface_init(struct hostapd_data *hapd) os_free(fname); hapd->ctrl_sock = s; - eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd, - NULL); + if (eloop_register_read_sock(s, hostapd_ctrl_iface_receive, hapd, + NULL) < 0) { + hostapd_ctrl_iface_deinit(hapd); + return -1; + } hapd->msg_ctx = hapd; wpa_msg_register_cb(hostapd_ctrl_iface_msg_cb); @@ -2299,6 +2302,7 @@ void hostapd_ctrl_iface_deinit(struct hostapd_data *hapd) } dst = hapd->ctrl_dst; + hapd->ctrl_dst = NULL; while (dst) { prev = dst; dst = dst->next;