summaryrefslogtreecommitdiffstats
path: root/drivers/staging/wfx
diff options
context:
space:
mode:
authorJérôme Pouiller <jerome.pouiller@silabs.com>2019-10-08 09:42:58 +0000
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>2019-10-08 14:41:13 +0200
commitc54f9f0e8c81192b17e2ae2eb7af6a037fd250a5 (patch)
tree6a2ff611c9d54efcc6ac368556db0c63691667bf /drivers/staging/wfx
parente772cd8c9c9cd3d08715800aabaf50b771b395d9 (diff)
downloadlinux-stable-c54f9f0e8c81192b17e2ae2eb7af6a037fd250a5.tar.gz
linux-stable-c54f9f0e8c81192b17e2ae2eb7af6a037fd250a5.tar.bz2
linux-stable-c54f9f0e8c81192b17e2ae2eb7af6a037fd250a5.zip
staging: wfx: simplify memory allocation in wfx_update_filtering()
Original code did not handle case where kmalloc failed. By the way, it is more convenient to allocate and build HIF message in hif_set_beacon_filter_table() instead of to ask to caller function to build it. Fixes: 40115bbc40e2 ("staging: wfx: implement the rest of mac80211 API") Reported-by: kbuild test robot <lkp@intel.com> Signed-off-by: Jérôme Pouiller <jerome.pouiller@silabs.com> Link: https://lore.kernel.org/r/20191008094232.10014-2-Jerome.Pouiller@silabs.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
Diffstat (limited to 'drivers/staging/wfx')
-rw-r--r--drivers/staging/wfx/hif_tx_mib.h21
-rw-r--r--drivers/staging/wfx/sta.c17
2 files changed, 22 insertions, 16 deletions
diff --git a/drivers/staging/wfx/hif_tx_mib.h b/drivers/staging/wfx/hif_tx_mib.h
index f6624a403016..167c5dec009f 100644
--- a/drivers/staging/wfx/hif_tx_mib.h
+++ b/drivers/staging/wfx/hif_tx_mib.h
@@ -86,13 +86,22 @@ static inline int hif_set_rx_filter(struct wfx_vif *wvif, bool filter_bssid,
}
static inline int hif_set_beacon_filter_table(struct wfx_vif *wvif,
- struct hif_mib_bcn_filter_table *ft)
+ int tbl_len,
+ struct hif_ie_table_entry *tbl)
{
- size_t buf_len = struct_size(ft, ie_table, ft->num_of_info_elmts);
-
- cpu_to_le32s(&ft->num_of_info_elmts);
- return hif_write_mib(wvif->wdev, wvif->id,
- HIF_MIB_ID_BEACON_FILTER_TABLE, ft, buf_len);
+ int ret;
+ struct hif_mib_bcn_filter_table *val;
+ int buf_len = struct_size(val, ie_table, tbl_len);
+
+ val = kzalloc(buf_len, GFP_KERNEL);
+ if (!val)
+ return -ENOMEM;
+ val->num_of_info_elmts = cpu_to_le32(tbl_len);
+ memcpy(val->ie_table, tbl, tbl_len * sizeof(*tbl));
+ ret = hif_write_mib(wvif->wdev, wvif->id,
+ HIF_MIB_ID_BEACON_FILTER_TABLE, val, buf_len);
+ kfree(val);
+ return ret;
}
static inline int hif_beacon_filter_control(struct wfx_vif *wvif,
diff --git a/drivers/staging/wfx/sta.c b/drivers/staging/wfx/sta.c
index 2855d14a709c..12198b8f3685 100644
--- a/drivers/staging/wfx/sta.c
+++ b/drivers/staging/wfx/sta.c
@@ -217,14 +217,13 @@ void wfx_update_filtering(struct wfx_vif *wvif)
bool filter_bssid = wvif->filter_bssid;
bool fwd_probe_req = wvif->fwd_probe_req;
struct hif_mib_bcn_filter_enable bf_ctrl;
- struct hif_mib_bcn_filter_table *bf_tbl;
- struct hif_ie_table_entry ie_tbl[] = {
+ struct hif_ie_table_entry filter_ies[] = {
{
.ie_id = WLAN_EID_VENDOR_SPECIFIC,
.has_changed = 1,
.no_longer = 1,
.has_appeared = 1,
- .oui = { 0x50, 0x6F, 0x9A},
+ .oui = { 0x50, 0x6F, 0x9A },
}, {
.ie_id = WLAN_EID_HT_OPERATION,
.has_changed = 1,
@@ -237,36 +236,34 @@ void wfx_update_filtering(struct wfx_vif *wvif)
.has_appeared = 1,
}
};
+ int n_filter_ies;
if (wvif->state == WFX_STATE_PASSIVE)
return;
- bf_tbl = kmalloc(sizeof(struct hif_mib_bcn_filter_table) + sizeof(ie_tbl), GFP_KERNEL);
- memcpy(bf_tbl->ie_table, ie_tbl, sizeof(ie_tbl));
if (wvif->disable_beacon_filter) {
bf_ctrl.enable = 0;
bf_ctrl.bcn_count = 1;
- bf_tbl->num_of_info_elmts = 0;
+ n_filter_ies = 0;
} else if (!is_sta) {
bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE | HIF_BEACON_FILTER_AUTO_ERP;
bf_ctrl.bcn_count = 0;
- bf_tbl->num_of_info_elmts = 2;
+ n_filter_ies = 2;
} else {
bf_ctrl.enable = HIF_BEACON_FILTER_ENABLE;
bf_ctrl.bcn_count = 0;
- bf_tbl->num_of_info_elmts = 3;
+ n_filter_ies = 3;
}
ret = hif_set_rx_filter(wvif, filter_bssid, fwd_probe_req);
if (!ret)
- ret = hif_set_beacon_filter_table(wvif, bf_tbl);
+ ret = hif_set_beacon_filter_table(wvif, n_filter_ies, filter_ies);
if (!ret)
ret = hif_beacon_filter_control(wvif, bf_ctrl.enable, bf_ctrl.bcn_count);
if (!ret)
ret = wfx_set_mcast_filter(wvif, &wvif->mcast_filter);
if (ret)
dev_err(wvif->wdev->dev, "update filtering failed: %d\n", ret);
- kfree(bf_tbl);
}
void wfx_update_filtering_work(struct work_struct *work)