1
0
mirror of https://github.com/libretro/Lakka-LibreELEC.git synced 2024-11-24 23:06:18 +00:00
Lakka-LibreELEC/packages/linux-drivers/bcm_sta/patches/bcm_sta-0011-fix-kernel-warnings.patch
2018-06-16 18:28:21 +01:00

178 lines
6.1 KiB
Diff

From 6bc816ae3ef424bc52b2736aeb1eb08ab09f38a9 Mon Sep 17 00:00:00 2001
From: MilhouseVH <milhouseVH.github@nmacleod.com>
Date: Sun, 10 Jun 2018 19:32:39 +0100
Subject: [PATCH] fix kernel warnings
Credit: https://github.com/UnitedRPMs/broadcom-wl-dkms/blob/master/wl-kmod-008_fix_kernel_warnings.patch
---
x86-64/src/wl/sys/wl_cfg80211_hybrid.c | 88 +++++++++++++++++++++++-----------
1 file changed, 60 insertions(+), 28 deletions(-)
diff --git a/x86-64/src/wl/sys/wl_cfg80211_hybrid.c b/x86-64/src/wl/sys/wl_cfg80211_hybrid.c
index 2e8625d..4da9b38 100644
--- a/x86-64/src/wl/sys/wl_cfg80211_hybrid.c
+++ b/x86-64/src/wl/sys/wl_cfg80211_hybrid.c
@@ -1983,7 +1983,7 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
if (dtoh32(bi->length) > WL_BSS_INFO_MAX) {
WL_DBG(("Beacon is larger than buffer. Discarding\n"));
- return err;
+ return -E2BIG;
}
notif_bss_info = kzalloc(sizeof(*notif_bss_info) + sizeof(*mgmt) - sizeof(u8) +
WL_BSS_INFO_MAX, GFP_KERNEL);
@@ -2007,9 +2007,15 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
beacon_proberesp->capab_info = cpu_to_le16(bi->capability);
wl_rst_ie(wl);
- wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
- wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
- offsetof(struct wl_cfg80211_bss_info, frame_buf));
+ err = wl_mrg_ie(wl, ((u8 *) bi) + bi->ie_offset, bi->ie_length);
+ if (err)
+ goto inform_single_bss_out;
+
+ err = wl_cp_ie(wl, beacon_proberesp->variable, WL_BSS_INFO_MAX -
+ offsetof(struct wl_cfg80211_bss_info, frame_buf));
+ if (err)
+ goto inform_single_bss_out;
+
notif_bss_info->frame_len = offsetof(struct ieee80211_mgmt, u.beacon.variable) +
wl_get_ielen(wl);
#if LINUX_VERSION_CODE >= KERNEL_VERSION(2, 6, 39)
@@ -2021,14 +2027,14 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
#endif
if (freq == 0) {
WL_ERR(("Invalid channel, fail to chcnage channel to freq\n"));
- kfree(notif_bss_info);
- return -EINVAL;
+ err = -EINVAL;
+ goto inform_single_bss_out;
}
channel = ieee80211_get_channel(wiphy, freq);
if (unlikely(!channel)) {
WL_ERR(("ieee80211_get_channel error\n"));
- kfree(notif_bss_info);
- return -EINVAL;
+ err = -EINVAL;
+ goto inform_single_bss_out;
}
WL_DBG(("SSID : \"%s\", rssi %d, channel %d, capability : 0x04%x, bssid %pM\n",
@@ -2036,28 +2042,35 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
mgmt->u.beacon.capab_info, &bi->BSSID));
signal = notif_bss_info->rssi * 100;
- cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
- le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
- if (unlikely(!cbss)) {
- WL_ERR(("cfg80211_inform_bss_frame error\n"));
- kfree(notif_bss_info);
- return -EINVAL;
+ if (!wl->scan_request) {
+ cbss = cfg80211_inform_bss_frame(wiphy, channel, mgmt,
+ le16_to_cpu(notif_bss_info->frame_len), signal, GFP_KERNEL);
+ if (unlikely(!cbss)) {
+ WL_ERR(("cfg80211_inform_bss_frame error\n"));
+ err = -ENOMEM;
+ goto inform_single_bss_out;
+ }
}
-
- notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
- notify_ielen = le32_to_cpu(bi->ie_length);
+ else {
+ notify_ie = (u8 *)bi + le16_to_cpu(bi->ie_offset);
+ notify_ielen = le32_to_cpu(bi->ie_length);
#if LINUX_VERSION_CODE < KERNEL_VERSION(3, 18, 0)
- cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
- 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
- (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
+ cbss = cfg80211_inform_bss(wiphy, channel, (const u8 *)(bi->BSSID.octet),
+ 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
+ (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
#else
- cbss = cfg80211_inform_bss(wiphy, channel, CFG80211_BSS_FTYPE_UNKNOWN, (const u8 *)(bi->BSSID.octet),
- 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
- (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
+ cbss = cfg80211_inform_bss(wiphy, channel,
+ wl->active_scan ? CFG80211_BSS_FTYPE_PRESP : CFG80211_BSS_FTYPE_BEACON,
+ (const u8 *)(bi->BSSID.octet),
+ 0, beacon_proberesp->capab_info, beacon_proberesp->beacon_int,
+ (const u8 *)notify_ie, notify_ielen, signal, GFP_KERNEL);
#endif
-
- if (unlikely(!cbss))
- return -ENOMEM;
+ if (unlikely(!cbss)) {
+ WL_ERR(("cfg80211_inform_bss error\n"));
+ err = -ENOMEM;
+ goto inform_single_bss_out;
+ }
+ }
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
cfg80211_put_bss(wiphy, cbss);
@@ -2065,6 +2078,7 @@ static s32 wl_inform_single_bss(struct wl_cfg80211_priv *wl, struct wl_bss_info
cfg80211_put_bss(cbss);
#endif
+inform_single_bss_out:
kfree(notif_bss_info);
return err;
@@ -2331,6 +2345,9 @@ static s32 wl_update_bss_info(struct wl_cfg80211_priv *wl)
if (err)
goto update_bss_info_out;
+ bss = cfg80211_get_bss(wl_to_wiphy(wl), NULL, (s8 *)&wl->bssid,
+ ssid->SSID, ssid->SSID_len, WLAN_CAPABILITY_ESS, WLAN_CAPABILITY_ESS);
+
ie = ((u8 *)bi) + bi->ie_offset;
ie_len = bi->ie_length;
} else {
@@ -2343,12 +2360,20 @@ static s32 wl_update_bss_info(struct wl_cfg80211_priv *wl)
ie_len = bss->len_information_elements;
#endif
wl->conf->channel = *bss->channel;
+ }
+
+ if (bss) {
#if LINUX_VERSION_CODE >= KERNEL_VERSION(3, 9, 0)
cfg80211_put_bss(wiphy, bss);
#else
cfg80211_put_bss(bss);
#endif
}
+ else {
+ WL_DBG(("Could not update BSS\n"));
+ err = -EINVAL;
+ goto update_bss_info_out;
+ }
tim = bcm_parse_tlvs(ie, ie_len, WLAN_EID_TIM);
if (tim) {
@@ -2375,10 +2400,17 @@ wl_bss_roaming_done(struct wl_cfg80211_priv *wl, struct net_device *ndev,
struct wl_cfg80211_connect_info *conn_info = wl_to_conn(wl);
s32 err = 0;
- wl_get_assoc_ies(wl);
+ err = wl_get_assoc_ies(wl);
+ if (err)
+ return err;
+
memcpy(wl->profile->bssid, &e->addr, ETHER_ADDR_LEN);
memcpy(&wl->bssid, &e->addr, ETHER_ADDR_LEN);
- wl_update_bss_info(wl);
+
+ err = wl_update_bss_info(wl);
+ if (err)
+ return err;
+
#if LINUX_VERSION_CODE >= KERNEL_VERSION(4, 12, 0)
{
struct cfg80211_roam_info roam_info = {
--
2.14.1