P2P: Fix possible NULL pointer dereference
authorAyala Beker <ayala.beker@intel.com>
Thu, 10 Dec 2015 10:56:02 +0000 (12:56 +0200)
committerJouni Malinen <j@w1.fi>
Thu, 17 Dec 2015 22:24:51 +0000 (00:24 +0200)
Fix wpas_p2p_invite() to call p2p_set_own_pref_freq_list() after the
NULL check, to avoid NULL pointer dereference if P2P initialization were
to have failed or P2P module getting deinitialized.

Signed-off-by: Ayala Beker <ayala.beker@intel.com>
wpa_supplicant/p2p_supplicant.c

index c7ddc99..45dae50 100644 (file)
@@ -6770,11 +6770,12 @@ int wpas_p2p_invite(struct wpa_supplicant *wpa_s, const u8 *peer_addr,
                                   pref_freq_list, &size);
        if (res)
                return res;
-       p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size);
 
        if (wpa_s->global->p2p_disabled || wpa_s->global->p2p == NULL)
                return -1;
 
+       p2p_set_own_pref_freq_list(wpa_s->global->p2p, pref_freq_list, size);
+
        if (wpa_s->parent->conf->p2p_ignore_shared_freq &&
            no_pref_freq_given && pref_freq > 0 &&
            wpa_s->num_multichan_concurrent > 1 &&