From patchwork Sat Dec 18 14:59:29 2010 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jussi Kivilinna X-Patchwork-Id: 418101 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter1.kernel.org (8.14.4/8.14.3) with ESMTP id oBIExZsl006566 for ; Sat, 18 Dec 2010 14:59:35 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753895Ab0LRO7e (ORCPT ); Sat, 18 Dec 2010 09:59:34 -0500 Received: from sypressi.dnainternet.net ([83.102.40.135]:56370 "EHLO sypressi.dnainternet.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753349Ab0LRO7d (ORCPT ); Sat, 18 Dec 2010 09:59:33 -0500 Received: from localhost (localhost [127.0.0.1]) by sypressi.dnainternet.net (Postfix) with ESMTP id C4EFCC6B71; Sat, 18 Dec 2010 16:59:31 +0200 (EET) X-Virus-Scanned: DNA Postiturva at dnainternet.net X-Spam-Flag: NO X-Spam-Score: -1.44 X-Spam-Level: X-Spam-Status: No, score=-1.44 tagged_above=-9999 required=6 tests=[ALL_TRUSTED=-1.44] Received: from sypressi.dnainternet.net ([83.102.40.135]) by localhost (sypressi.dnainternet.net [127.0.0.1]) (amavisd-new, port 10041) with ESMTP id mBCgw0hWx-2p; Sat, 18 Dec 2010 16:59:31 +0200 (EET) Received: from omenapuu.dnainternet.net (omenapuu.dnainternet.net [83.102.40.212]) by sypressi.dnainternet.net (Postfix) with ESMTP id 98689C6E23; Sat, 18 Dec 2010 16:59:31 +0200 (EET) Received: from fate.lan (dyn2-85-23-163-31.psoas.suomi.net [85.23.163.31]) by omenapuu.dnainternet.net (Postfix) with ESMTP id 693997F001; Sat, 18 Dec 2010 16:59:29 +0200 (EET) Subject: [PATCH] rndis_wlan: scanning, workaround device returning incorrect bssid-list item count. To: "John W. Linville" From: Jussi Kivilinna Cc: linux-wireless@vger.kernel.org Date: Sat, 18 Dec 2010 16:59:29 +0200 Message-ID: <20101218145929.13559.78929.stgit@fate.lan> User-Agent: StGit/0.15 MIME-Version: 1.0 Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.3 (demeter1.kernel.org [140.211.167.41]); Sat, 18 Dec 2010 14:59:36 +0000 (UTC) diff --git a/drivers/net/wireless/rndis_wlan.c b/drivers/net/wireless/rndis_wlan.c index 4a4f005..8db8333 100644 --- a/drivers/net/wireless/rndis_wlan.c +++ b/drivers/net/wireless/rndis_wlan.c @@ -1967,8 +1967,8 @@ static struct cfg80211_bss *rndis_bss_info_update(struct usbnet *usbdev, int ie_len, bssid_len; u8 *ie; - netdev_dbg(usbdev->net, " found bssid: '%.32s' [%pM]\n", - bssid->ssid.essid, bssid->mac); + netdev_dbg(usbdev->net, " found bssid: '%.32s' [%pM], len: %d\n", + bssid->ssid.essid, bssid->mac, le32_to_cpu(bssid->length)); /* parse bssid structure */ bssid_len = le32_to_cpu(bssid->length); @@ -2008,10 +2008,10 @@ static int rndis_check_bssid_list(struct usbnet *usbdev, u8 *match_bssid, void *buf = NULL; struct ndis_80211_bssid_list_ex *bssid_list; struct ndis_80211_bssid_ex *bssid; - int ret = -EINVAL, len, count, bssid_len; + int ret = -EINVAL, len, count, bssid_len, real_count; bool resized = false; - netdev_dbg(usbdev->net, "check_bssid_list\n"); + netdev_dbg(usbdev->net, "%s\n", __func__); len = CONTROL_BUFFER_SIZE; resize_buf: @@ -2035,10 +2035,13 @@ resize_buf: bssid = bssid_list->bssid; bssid_len = le32_to_cpu(bssid->length); count = le32_to_cpu(bssid_list->num_items); - netdev_dbg(usbdev->net, "check_bssid_list: %d BSSIDs found (buflen: %d)\n", - count, len); + real_count = 0; + netdev_dbg(usbdev->net, "%s, buflen: %d\n", __func__, len); - while (count && ((void *)bssid + bssid_len) <= (buf + len)) { + /* Device returns incorrect 'num_items'. Workaround by ignoring the + * received 'num_items' and walking through full bssid buffer instead. + */ + while (bssid_len > 0 && ((void *)bssid + bssid_len) <= (buf + len)) { if (rndis_bss_info_update(usbdev, bssid) && match_bssid && matched) { if (compare_ether_addr(bssid->mac, match_bssid)) @@ -2047,9 +2050,12 @@ resize_buf: bssid = (void *)bssid + bssid_len; bssid_len = le32_to_cpu(bssid->length); - count--; + real_count++; } + netdev_dbg(usbdev->net, "%s, num_items from device: %d, really found: " + "%d\n", __func__, count, real_count); + out: kfree(buf); return ret;