diff --git a/net/wireless/scan.c b/net/wireless/scan.c index 21be56b..fc74091 100644 --- a/net/wireless/scan.c +++ b/net/wireless/scan.c @@ -1699,6 +1699,7 @@ static int ieee80211_scan_results(struct cfg80211_registered_device *rdev, struct iw_request_info *info, char *buf, size_t len) { + char *maybe_current_ev; char *current_ev = buf; char *end_buf = buf + len; struct cfg80211_internal_bss *bss; @@ -1709,14 +1710,20 @@ static int ieee80211_scan_results(struct cfg80211_registered_device *rdev, list_for_each_entry(bss, &rdev->bss_list, list) { if (buf + len - current_ev <= IW_EV_ADDR_LEN) { - err = -E2BIG; + // Buffer too big to hold another BSS; ignore break; } - current_ev = ieee80211_bss(&rdev->wiphy, info, bss, - current_ev, end_buf); - if (IS_ERR(current_ev)) { - err = PTR_ERR(current_ev); + maybe_current_ev = ieee80211_bss(&rdev->wiphy, info, bss, + current_ev, end_buf); + if (IS_ERR(maybe_current_ev)) { + err = PTR_ERR(maybe_current_ev); + if (err == -E2BIG) { + // Last BSS failed to copy into buffer; ignore + err = 0; + } break; + } else { + current_ev = maybe_current_ev; } } spin_unlock_bh(&rdev->bss_lock);