lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <20191216170302.29543-49-Jerome.Pouiller@silabs.com>
Date:   Mon, 16 Dec 2019 17:03:58 +0000
From:   Jérôme Pouiller <Jerome.Pouiller@...abs.com>
To:     "devel@...verdev.osuosl.org" <devel@...verdev.osuosl.org>,
        "linux-wireless@...r.kernel.org" <linux-wireless@...r.kernel.org>
CC:     "netdev@...r.kernel.org" <netdev@...r.kernel.org>,
        "linux-kernel@...r.kernel.org" <linux-kernel@...r.kernel.org>,
        Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
        Kalle Valo <kvalo@...eaurora.org>,
        "David S . Miller" <davem@...emloft.net>,
        Jérôme Pouiller <Jerome.Pouiller@...abs.com>
Subject: [PATCH 48/55] staging: wfx: introduce update_probe_tmpl()

From: Jérôme Pouiller <jerome.pouiller@...abs.com>

Simplify wfx_hw_scan() by splitting out the update of the probe request.

Signed-off-by: Jérôme Pouiller <jerome.pouiller@...abs.com>
---
 drivers/staging/wfx/scan.c | 57 ++++++++++++++++++++------------------
 1 file changed, 30 insertions(+), 27 deletions(-)

diff --git a/drivers/staging/wfx/scan.c b/drivers/staging/wfx/scan.c
index 122da87bbf92..8b184efad0cf 100644
--- a/drivers/staging/wfx/scan.c
+++ b/drivers/staging/wfx/scan.c
@@ -49,6 +49,27 @@ static int wfx_scan_start(struct wfx_vif *wvif,
 	return 0;
 }
 
+static int update_probe_tmpl(struct wfx_vif *wvif,
+			     struct cfg80211_scan_request *req)
+{
+	struct hif_mib_template_frame *tmpl;
+	struct sk_buff *skb;
+
+	skb = ieee80211_probereq_get(wvif->wdev->hw, wvif->vif->addr,
+				     NULL, 0, req->ie_len);
+	if (!skb)
+		return -ENOMEM;
+
+	skb_put_data(skb, req->ie, req->ie_len);
+	skb_push(skb, 4);
+	tmpl = (struct hif_mib_template_frame *)skb->data;
+	tmpl->frame_type = HIF_TMPLT_PRBREQ;
+	tmpl->frame_length = cpu_to_le16(skb->len - 4);
+	hif_set_template_frame(wvif, tmpl);
+	dev_kfree_skb(skb);
+	return 0;
+}
+
 int wfx_hw_scan(struct ieee80211_hw *hw,
 		   struct ieee80211_vif *vif,
 		   struct ieee80211_scan_request *hw_req)
@@ -56,9 +77,7 @@ int wfx_hw_scan(struct ieee80211_hw *hw,
 	struct wfx_dev *wdev = hw->priv;
 	struct wfx_vif *wvif = (struct wfx_vif *) vif->drv_priv;
 	struct cfg80211_scan_request *req = &hw_req->req;
-	struct sk_buff *skb;
 	int i, ret;
-	struct hif_mib_template_frame *p;
 
 	if (!wvif)
 		return -EINVAL;
@@ -72,29 +91,15 @@ int wfx_hw_scan(struct ieee80211_hw *hw,
 	if (req->n_ssids > HIF_API_MAX_NB_SSIDS)
 		return -EINVAL;
 
-	skb = ieee80211_probereq_get(hw, wvif->vif->addr, NULL, 0, req->ie_len);
-	if (!skb)
-		return -ENOMEM;
-
-	if (req->ie_len)
-		memcpy(skb_put(skb, req->ie_len), req->ie, req->ie_len);
-
 	mutex_lock(&wdev->conf_mutex);
 
-	p = (struct hif_mib_template_frame *)skb_push(skb, 4);
-	p->frame_type = HIF_TMPLT_PRBREQ;
-	p->frame_length = cpu_to_le16(skb->len - 4);
-	ret = hif_set_template_frame(wvif, p);
-	skb_pull(skb, 4);
+	ret = update_probe_tmpl(wvif, req);
+	if (ret)
+		goto failed;
 
-	if (!ret)
-		/* Host want to be the probe responder. */
-		ret = wfx_fwd_probe_req(wvif, true);
-	if (ret) {
-		mutex_unlock(&wdev->conf_mutex);
-		dev_kfree_skb(skb);
-		return ret;
-	}
+	ret = wfx_fwd_probe_req(wvif, true);
+	if (ret)
+		goto failed;
 
 	wfx_tx_lock_flush(wdev);
 
@@ -114,13 +119,11 @@ int wfx_hw_scan(struct ieee80211_hw *hw,
 		dst->ssid_length = req->ssids[i].ssid_len;
 		++wvif->scan.n_ssids;
 	}
+	schedule_work(&wvif->scan.work);
 
+failed:
 	mutex_unlock(&wdev->conf_mutex);
-
-	if (skb)
-		dev_kfree_skb(skb);
-	schedule_work(&wvif->scan.work);
-	return 0;
+	return ret;
 }
 
 void wfx_scan_work(struct work_struct *work)
-- 
2.20.1

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ