[OpenWrt-Devel] [PATCH] iwinfo: do not wait for scan results if scan request failed.

Dmitry Ivanov dmitrijs.ivanovs at ubnt.com
Fri Jul 31 04:53:15 EDT 2015


Do not wait for scan results if scan request failed.

Signed-off-by: Dmitry Ivanov <dima at ubnt.com>
---
 iwinfo_nl80211.c | 14 ++++++++++----
 1 file changed, 10 insertions(+), 4 deletions(-)

diff --git a/iwinfo_nl80211.c b/iwinfo_nl80211.c
index 900eef2..251ec33 100644
--- a/iwinfo_nl80211.c
+++ b/iwinfo_nl80211.c
@@ -389,11 +389,12 @@ static struct nl80211_msg_conveyor * nl80211_send(
 	while (err > 0)
 		nl_recvmsgs(nls->nl_sock, cv->cb);
 
+	if (err)
+		goto err;
+
 	return &rcv;
 
 err:
-	nl_cb_put(cv->cb);
-	nlmsg_free(cv->msg);
 
 	return NULL;
 }
@@ -2016,16 +2017,21 @@ static int nl80211_get_scanlist_cb(struct nl_msg *msg, void *arg)
 
 static int nl80211_get_scanlist_nl(const char *ifname, char *buf, int *len)
 {
-	struct nl80211_msg_conveyor *req;
+	struct nl80211_msg_conveyor *req, *scan_res = NULL;
 	struct nl80211_scanlist sl = { .e = (struct iwinfo_scanlist_entry *)buf };
 
 	req = nl80211_msg(ifname, NL80211_CMD_TRIGGER_SCAN, 0);
 	if (req)
 	{
-		nl80211_send(req, NULL, NULL);
+		scan_res = nl80211_send(req, NULL, NULL);
 		nl80211_free(req);
 	}
 
+	if (!scan_res)
+	{
+		return -1;
+	}
+
 	nl80211_wait("nl80211", "scan", NL80211_CMD_NEW_SCAN_RESULTS);
 
 	req = nl80211_msg(ifname, NL80211_CMD_GET_SCAN, NLM_F_DUMP);
-- 
2.1.4
_______________________________________________
openwrt-devel mailing list
openwrt-devel at lists.openwrt.org
https://lists.openwrt.org/cgi-bin/mailman/listinfo/openwrt-devel



More information about the openwrt-devel mailing list