From 6cbdb0c537e6e4dddfef043f3bb7a2f403f2265b Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Sat, 11 Oct 2014 12:38:35 +0300 Subject: [PATCH] Set WoWLAN triggers only if driver capabilities are known Previously, wpas_set_wowlan_triggers() could have been called in uninitialized wpa_driver_capa data if the driver interface did not support reporting of capabilities. While this would not really happen with a driver wrapper that implements set_wowlan() and as such, would not cause any difference in practice, it is better to clean this up to make the code path easier to understand for static analyzers. Signed-off-by: Jouni Malinen --- wpa_supplicant/wpa_supplicant.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/wpa_supplicant/wpa_supplicant.c b/wpa_supplicant/wpa_supplicant.c index e92e3f34e..18ae24508 100644 --- a/wpa_supplicant/wpa_supplicant.c +++ b/wpa_supplicant/wpa_supplicant.c @@ -3267,7 +3267,7 @@ static int wpas_check_wowlan_trigger(const char *start, const char *trigger, static int wpas_set_wowlan_triggers(struct wpa_supplicant *wpa_s, - struct wpa_driver_capa *capa) + const struct wpa_driver_capa *capa) { struct wowlan_triggers triggers; char *start, *end, *buf; @@ -3632,6 +3632,7 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, struct wpa_interface *iface) { struct wpa_driver_capa capa; + int capa_res; wpa_printf(MSG_DEBUG, "Initializing interface '%s' conf '%s' driver " "'%s' ctrl_interface '%s' bridge '%s'", iface->ifname, @@ -3761,7 +3762,8 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, &wpa_s->hw.num_modes, &wpa_s->hw.flags); - if (wpa_drv_get_capa(wpa_s, &capa) == 0) { + capa_res = wpa_drv_get_capa(wpa_s, &capa); + if (capa_res == 0) { wpa_s->drv_capa_known = 1; wpa_s->drv_flags = capa.flags; wpa_s->drv_enc = capa.enc; @@ -3851,7 +3853,7 @@ static int wpa_supplicant_init_iface(struct wpa_supplicant *wpa_s, * Note: We don't restore/remove the triggers on shutdown (it doesn't * have effect anyway when the interface is down). */ - if (wpas_set_wowlan_triggers(wpa_s, &capa) < 0) + if (capa_res == 0 && wpas_set_wowlan_triggers(wpa_s, &capa) < 0) return -1; #ifdef CONFIG_EAP_PROXY