mac80211: check return value of dev_alloc_skb() in ieee80211_sta_join_ibss().
This patch add a check on the return value of dev_alloc_skb() in ieee80211_sta_join_ibss() in net/mac80211/mlme.c. Signed-off-by: Rami Rosen <ramirose@gmail.com> Signed-off-by: John W. Linville <linville@tuxdriver.com>
This commit is contained in:
parent
7211801527
commit
e2ef12d3fd
|
@ -1379,6 +1379,13 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
|
||||||
struct ieee80211_supported_band *sband;
|
struct ieee80211_supported_band *sband;
|
||||||
union iwreq_data wrqu;
|
union iwreq_data wrqu;
|
||||||
|
|
||||||
|
skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
|
||||||
|
if (!skb) {
|
||||||
|
printk(KERN_DEBUG "%s: failed to allocate buffer for probe "
|
||||||
|
"response\n", sdata->dev->name);
|
||||||
|
return -ENOMEM;
|
||||||
|
}
|
||||||
|
|
||||||
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
||||||
|
|
||||||
/* Remove possible STA entries from other IBSS networks. */
|
/* Remove possible STA entries from other IBSS networks. */
|
||||||
|
@ -1404,63 +1411,62 @@ static int ieee80211_sta_join_ibss(struct ieee80211_sub_if_data *sdata,
|
||||||
return res;
|
return res;
|
||||||
|
|
||||||
/* Build IBSS probe response */
|
/* Build IBSS probe response */
|
||||||
skb = dev_alloc_skb(local->hw.extra_tx_headroom + 400);
|
|
||||||
if (skb) {
|
|
||||||
skb_reserve(skb, local->hw.extra_tx_headroom);
|
|
||||||
|
|
||||||
mgmt = (struct ieee80211_mgmt *)
|
skb_reserve(skb, local->hw.extra_tx_headroom);
|
||||||
skb_put(skb, 24 + sizeof(mgmt->u.beacon));
|
|
||||||
memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
|
|
||||||
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
|
||||||
IEEE80211_STYPE_PROBE_RESP);
|
|
||||||
memset(mgmt->da, 0xff, ETH_ALEN);
|
|
||||||
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
|
||||||
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
|
|
||||||
mgmt->u.beacon.beacon_int =
|
|
||||||
cpu_to_le16(local->hw.conf.beacon_int);
|
|
||||||
mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
|
|
||||||
mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
|
|
||||||
|
|
||||||
pos = skb_put(skb, 2 + ifsta->ssid_len);
|
mgmt = (struct ieee80211_mgmt *)
|
||||||
*pos++ = WLAN_EID_SSID;
|
skb_put(skb, 24 + sizeof(mgmt->u.beacon));
|
||||||
*pos++ = ifsta->ssid_len;
|
memset(mgmt, 0, 24 + sizeof(mgmt->u.beacon));
|
||||||
memcpy(pos, ifsta->ssid, ifsta->ssid_len);
|
mgmt->frame_control = cpu_to_le16(IEEE80211_FTYPE_MGMT |
|
||||||
|
IEEE80211_STYPE_PROBE_RESP);
|
||||||
|
memset(mgmt->da, 0xff, ETH_ALEN);
|
||||||
|
memcpy(mgmt->sa, sdata->dev->dev_addr, ETH_ALEN);
|
||||||
|
memcpy(mgmt->bssid, ifsta->bssid, ETH_ALEN);
|
||||||
|
mgmt->u.beacon.beacon_int =
|
||||||
|
cpu_to_le16(local->hw.conf.beacon_int);
|
||||||
|
mgmt->u.beacon.timestamp = cpu_to_le64(bss->timestamp);
|
||||||
|
mgmt->u.beacon.capab_info = cpu_to_le16(bss->capability);
|
||||||
|
|
||||||
rates = bss->supp_rates_len;
|
pos = skb_put(skb, 2 + ifsta->ssid_len);
|
||||||
if (rates > 8)
|
*pos++ = WLAN_EID_SSID;
|
||||||
rates = 8;
|
*pos++ = ifsta->ssid_len;
|
||||||
pos = skb_put(skb, 2 + rates);
|
memcpy(pos, ifsta->ssid, ifsta->ssid_len);
|
||||||
*pos++ = WLAN_EID_SUPP_RATES;
|
|
||||||
*pos++ = rates;
|
|
||||||
memcpy(pos, bss->supp_rates, rates);
|
|
||||||
|
|
||||||
if (bss->band == IEEE80211_BAND_2GHZ) {
|
rates = bss->supp_rates_len;
|
||||||
pos = skb_put(skb, 2 + 1);
|
if (rates > 8)
|
||||||
*pos++ = WLAN_EID_DS_PARAMS;
|
rates = 8;
|
||||||
*pos++ = 1;
|
pos = skb_put(skb, 2 + rates);
|
||||||
*pos++ = ieee80211_frequency_to_channel(bss->freq);
|
*pos++ = WLAN_EID_SUPP_RATES;
|
||||||
}
|
*pos++ = rates;
|
||||||
|
memcpy(pos, bss->supp_rates, rates);
|
||||||
|
|
||||||
pos = skb_put(skb, 2 + 2);
|
if (bss->band == IEEE80211_BAND_2GHZ) {
|
||||||
*pos++ = WLAN_EID_IBSS_PARAMS;
|
pos = skb_put(skb, 2 + 1);
|
||||||
*pos++ = 2;
|
*pos++ = WLAN_EID_DS_PARAMS;
|
||||||
/* FIX: set ATIM window based on scan results */
|
*pos++ = 1;
|
||||||
*pos++ = 0;
|
*pos++ = ieee80211_frequency_to_channel(bss->freq);
|
||||||
*pos++ = 0;
|
|
||||||
|
|
||||||
if (bss->supp_rates_len > 8) {
|
|
||||||
rates = bss->supp_rates_len - 8;
|
|
||||||
pos = skb_put(skb, 2 + rates);
|
|
||||||
*pos++ = WLAN_EID_EXT_SUPP_RATES;
|
|
||||||
*pos++ = rates;
|
|
||||||
memcpy(pos, &bss->supp_rates[8], rates);
|
|
||||||
}
|
|
||||||
|
|
||||||
ifsta->probe_resp = skb;
|
|
||||||
|
|
||||||
ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pos = skb_put(skb, 2 + 2);
|
||||||
|
*pos++ = WLAN_EID_IBSS_PARAMS;
|
||||||
|
*pos++ = 2;
|
||||||
|
/* FIX: set ATIM window based on scan results */
|
||||||
|
*pos++ = 0;
|
||||||
|
*pos++ = 0;
|
||||||
|
|
||||||
|
if (bss->supp_rates_len > 8) {
|
||||||
|
rates = bss->supp_rates_len - 8;
|
||||||
|
pos = skb_put(skb, 2 + rates);
|
||||||
|
*pos++ = WLAN_EID_EXT_SUPP_RATES;
|
||||||
|
*pos++ = rates;
|
||||||
|
memcpy(pos, &bss->supp_rates[8], rates);
|
||||||
|
}
|
||||||
|
|
||||||
|
ifsta->probe_resp = skb;
|
||||||
|
|
||||||
|
ieee80211_if_config(sdata, IEEE80211_IFCC_BEACON);
|
||||||
|
|
||||||
|
|
||||||
rates = 0;
|
rates = 0;
|
||||||
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
sband = local->hw.wiphy->bands[local->hw.conf.channel->band];
|
||||||
for (i = 0; i < bss->supp_rates_len; i++) {
|
for (i = 0; i < bss->supp_rates_len; i++) {
|
||||||
|
|
Loading…
Reference in New Issue