cfg80211: amend regulatory NULL dereference fix

commit 0bac71af6e66dc798bf07d0c0dd14ee5503362f9 upstream.

Johannes' patch for "cfg80211: fix regulatory NULL dereference"
broke user regulaotry hints and it did not address the fact that
last_request was left populated even if the previous regulatory
hint was stale due to the wiphy disappearing.

Fix user reguluatory hints by only bailing out if for those
regulatory hints where a request_wiphy is expected. The stale last_request
considerations are addressed through the previous fixes on last_request
where we reset the last_request to a static world regdom request upon
reset_regdomains(). In this case though we further enhance the effect
by simply restoring reguluatory settings completely.

Cc: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luis R. Rodriguez <mcgrof@qca.qualcomm.com>
Reviewed-by: Johannes Berg <johannes@sipsolutions.net>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
wireless: Protect regdomain change by mutex

Signed-off-by: Dmitry Shmidt <dimitrysh@google.com>
cfg80211/nl80211: Send AssocReq IEs to user space in AP mode

When user space SME/MLME (e.g., hostapd) is not used in AP mode, the
IEs from the (Re)Association Request frame that was processed in
firmware need to be made available for user space (e.g., RSN IE for
hostapd). Allow this to be done with cfg80211_new_sta().

Add a comment pointing out the use of enum station_info_flags for
all new struct station_info fields. In addition, memset the sinfo
buffer to zero before use on all paths in the current tree to avoid
leaving uninitialized pointers in the data.

Change-Id: Ia2220d58ee81c1b7ca905cfc8eb55b6a84779d38
Signed-off-by: Deepthi Gowri <deepthi@codeaurora.org>
cfg80211: fix a crash in nl80211_send_station

mac80211 leaves sinfo->assoc_req_ies uninitialized, causing a random
pointer memory access in nl80211_send_station.
Instead of checking if the pointer is null, use sinfo->filled, like
the rest of the fields.

Signed-off-by: Felix Fietkau <nbd@openwrt.org>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
nl80211/cfg80211: add max_sched_scan_ssids in the hw description

Some chips can scan more SSIDs with a single scheduled scan command
than with a single normal scan command (eg. wl12xx chips).

To support this, this patch creates a separate hardware description
element that describes the amount of SSIDs supported in scheduled
scans.

Change-Id: I6c5a1357a7a07b5d613b560c97885a58b1391910
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
nl80211/cfg80211: add max_sched_scan_ie_len in the hw description

Some chips may support different lengths of user-supplied IEs with a
single scheduled scan command than with a single normal scan command.

To support this, this patch creates a separate hardware description
element that describes the maximum size of user-supplied information
element data supported in scheduled scans.

Change-Id: I4146104d451de65cf7df07c732cf49802d392e8a
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
nl80211/cfg80211: add match filtering for sched_scan

Introduce filtering for scheduled scans to reduce the number of
unnecessary results (which cause useless wake-ups).

Add a new nested attribute where sets of parameters to be matched can
be passed when starting a scheduled scan.  Only scan results that
match any of the sets will be returned.

At this point, the set consists of a single parameter, an SSID.  This
can be easily extended in the future to support more complex matches.

Change-Id: I103e68b88af62729e819b3c0e734e74bf1673e36
Signed-off-by: Luciano Coelho <coelho@ti.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
net/wireless: Support to disable CCK rate for management frame

Provision to distinguish the P2P scan and the normal scan
with no_cck flag and thus disable the 11b rates for
p2p scan.

Signed-off-by: Sunil Dutt Undekari<duttus@codeaurora.org>
(cherry picked from commit 08166fc6f488afef37101a63881ec01613971952)

Change-Id: I4490982a7e6c8f99851b84081cb718b6b8541721
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
net/wireless: Check for number of sub bands

WiFi Drivers can advertize the number of bands dynamically.
A check has been added to see if the band information is
present and only then the values are extracted.
Without this check, a kernel crash shall occur as we would
extract the band information though the driver does not
advertize.

Signed-off-by: Sunil Dutt Undekari<duttus@codeaurora.org>
(cherry picked from commit ae86f14f2d4491a659472940e5e919af1b4afc94)

Change-Id: I712e43ed8865ef5f983b727ca0d3257355835b3f
Signed-off-by: Gopal G Goberu <ggober@codeaurora.org>
cfg80211: fix interface combinations check.

commit e55a4046dab28c440c96890bdddcf02dc8981f2d upstream.

Signed-off-by: Lukasz Kucharczyk <lukasz.kucharczyk@tieto.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
nl80211: ensure interface is up in various APIs

commit 2b5f8b0b44e17e625cfba1e7b88db44f4dcc0441 upstream.
[backported by Ben Greear]

The nl80211 handling code should ensure as much as
it can that the interface is in a valid state, it
can certainly ensure the interface is running.

Not doing so can cause calls through mac80211 into
the driver that result in warnings and unspecified
behaviour in the driver.

Reported-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: John W. Linville <linville@tuxdriver.com>
Signed-off-by: Ben Greear <greearb@candelatech.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
wcnss: add sysfs entry to support Thermal Mitigation

The Thermal Mitigation function in userspace needs a mechanism by
which it can notify the WCNSS driver that thermal mitigation is
required.  We introduce a sysfs entry via which Thermal Mitigation can
both read the current mitigation level as well as set a new mitigation
level.  Logic to actually act upon a new mitigation level will be
added at a later time.

Change-Id: I1b2b8328e2aa821414de0d345bd32b9bc30bd49a
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
wcnss: add driver API to support Thermal Mitigation

The wcnss driver currently supports a sysfs-based mechanism which
allows the Thermal Mitigation function in userspace to read and write
the current thermal mitigation level.  An API is added to allow other
drivers (specifically the WLAN Driver) to register a notifier to be
invoked when the thermal mitigation level is changed.

CRs-Fixed: 317376
Change-Id: Ieda320b618a0a08186db791168e586a86b54d173
Signed-off-by: Jeff Johnson <jjohnson@codeaurora.org>
wcnss : Add more arguments to Thermal Mitigation APIs

Thermal mitigation event handle functions needs device
context to handle the event properly.

CRs-fixed: 364094
Change-Id: I2afa87eba755f082018510e9bfa6962392f591fd
Acked-by: Leo Chang <schang@qca.qualcomm.com>
Signed-off-by: Sameer Thalappil <sameert@codeaurora.org>