From c244dd2ec0b0ce94d96d79a9d5e7a7630422aff4 Mon Sep 17 00:00:00 2001 From: Jouni Malinen Date: Mon, 24 Sep 2012 00:56:57 +0300 Subject: [PATCH] P2P: Fix PSK configuration for GO network Setting just ssid->passphrase is not enough to complete the network block for the GO entry. Also the PSK needs to be derived so that the network is considered enabled by wpas_network_disabled(). The previous version worked as long as something else allowed the scan request to be performed (this is needed even though the actual scan is skipped when starting GO). The first GO start was allowed because wpa_s->scan_req is initialized to 1 in wpa_supplicant_alloc(). However, other attempts may fail if wpa_s->scan_req is cleared. This failure shows up as "No enabled networkas - do not scan" in debug log followed by state change to INACTIVE when trying to start GO. Fix this by deriving PSK from the passphrase for GO mode. Signed-hostap: Jouni Malinen --- wpa_supplicant/p2p_supplicant.c | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/wpa_supplicant/p2p_supplicant.c b/wpa_supplicant/p2p_supplicant.c index b581f3265..4463eb6c8 100644 --- a/wpa_supplicant/p2p_supplicant.c +++ b/wpa_supplicant/p2p_supplicant.c @@ -875,6 +875,13 @@ static void wpas_start_wps_go(struct wpa_supplicant *wpa_s, ssid->proto = WPA_PROTO_RSN; ssid->pairwise_cipher = WPA_CIPHER_CCMP; ssid->passphrase = os_strdup(params->passphrase); + if (ssid->passphrase == NULL) { + wpa_msg(wpa_s, MSG_ERROR, "P2P: Failed to copy passphrase for " + "GO"); + wpa_config_remove_network(wpa_s->conf, ssid->id); + return; + } + wpa_config_update_psk(ssid); ssid->ap_max_inactivity = wpa_s->parent->conf->p2p_go_max_inactivity; wpa_s->ap_configured_cb = p2p_go_configured; -- 2.39.2