From patchwork Wed May 14 13:51:04 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Petar Koretic X-Patchwork-Id: 348788 Return-Path: X-Original-To: patchwork-incoming@ozlabs.org Delivered-To: patchwork-incoming@ozlabs.org Received: from maxx.maxx.shmoo.com (maxx.shmoo.com [205.134.188.171]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 950F2140082 for ; Wed, 14 May 2014 23:51:25 +1000 (EST) Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 054AA9C0CA; Wed, 14 May 2014 09:51:23 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id 3Xx1oi3PkwK9; Wed, 14 May 2014 09:51:22 -0400 (EDT) Received: from maxx.shmoo.com (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 422199C115; Wed, 14 May 2014 09:51:13 -0400 (EDT) X-Original-To: mailman-post+hostap@maxx.shmoo.com Delivered-To: mailman-post+hostap@maxx.shmoo.com Received: from localhost (localhost [127.0.0.1]) by maxx.maxx.shmoo.com (Postfix) with ESMTP id 4700B9C10E for ; Wed, 14 May 2014 09:51:12 -0400 (EDT) X-Virus-Scanned: amavisd-new at maxx.shmoo.com Received: from maxx.maxx.shmoo.com ([127.0.0.1]) by localhost (maxx.shmoo.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id A-BwydxZH5gO for ; Wed, 14 May 2014 09:51:05 -0400 (EDT) Received: from a8-82.smtp-out.amazonses.com (a8-82.smtp-out.amazonses.com [54.240.8.82]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (Client did not present a certificate) by maxx.maxx.shmoo.com (Postfix) with ESMTPS id 8321F9C1A0 for ; Wed, 14 May 2014 09:51:05 -0400 (EDT) From: Petar Koretic To: hostap@lists.shmoo.com Subject: [PATCH] WPS: Fix return value when context is not valid Date: Wed, 14 May 2014 13:51:04 +0000 Message-ID: <00000145fb002ea0-97fa64c8-ba8e-4289-bda6-21f6bab9637b-000000@email.amazonses.com> X-Mailer: git-send-email 1.9.2 X-SES-Outgoing: 2014.05.14-54.240.8.82 Cc: Luka Perkov X-BeenThere: hostap@lists.shmoo.com X-Mailman-Version: 2.1.11 Precedence: list List-Id: HostAP Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: hostap-bounces@lists.shmoo.com Errors-To: hostap-bounces@lists.shmoo.com Now, if wps push button isn't enabled hostapd_cli returns 'OK' even though wps doesn't get activated because wps context is not valid: $ hostapd_cli wps_pbc Selected interface 'wlan0' OK $ hostapd_cli wps_cancel Selected interface 'wlan0' OK Fix this by returning appropriate error when wps fails to activate: $ hostapd_cli wps_pbc Selected interface 'wlan0' FAIL $ hostapd_cli wps_cancel Selected interface 'wlan0' FAIL Signed-off-by: Petar Koretic CC: Luka Perkov --- src/ap/wps_hostapd.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/ap/wps_hostapd.c b/src/ap/wps_hostapd.c index f165670..6f16f50 100644 --- a/src/ap/wps_hostapd.c +++ b/src/ap/wps_hostapd.c @@ -1290,7 +1290,7 @@ static int wps_button_pushed(struct hostapd_data *hapd, void *ctx) { const u8 *p2p_dev_addr = ctx; if (hapd->wps == NULL) - return 0; + return -1; return wps_registrar_button_pushed(hapd->wps->registrar, p2p_dev_addr); } @@ -1306,7 +1306,7 @@ int hostapd_wps_button_pushed(struct hostapd_data *hapd, static int wps_cancel(struct hostapd_data *hapd, void *ctx) { if (hapd->wps == NULL) - return 0; + return -1; wps_registrar_wps_cancel(hapd->wps->registrar); ap_for_each_sta(hapd, ap_sta_wps_cancel, NULL);